Changeset 74000 in webkit
- Timestamp:
- Dec 13, 2010 9:49:20 PM (13 years ago)
- Location:
- trunk/WebKit2
- Files:
-
- 3 added
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebKit2/ChangeLog
r73992 r74000 1 2010-12-13 Sam Weinig <sam@webkit.org> 2 3 Reviewed by Anders Carlsson. 4 5 WebKit2: Need to be able to set the application name for the user agent for a WKPage 6 https://bugs.webkit.org/show_bug.cgi?id=51011 7 8 Fixes: 9 WebKit2: Need to be able to set the application name for the user agent for a WKPage 10 <rdar://problem/8564532> 11 WebKit2: Need to be able to get the computed user agent for a WKPage 12 <rdar://problem/8637285> 13 14 Moves user agent computation to the UIProcess and just passes it to the WebProcess 15 when it has changed. 16 17 * Shared/WebPageCreationParameters.cpp: 18 (WebKit::WebPageCreationParameters::encode): 19 (WebKit::WebPageCreationParameters::decode): 20 * Shared/WebPageCreationParameters.h: 21 Add a user agent to the creation parameters. 22 23 * UIProcess/API/C/WKPage.cpp: 24 (WKPageCopyUserAgent): 25 (WKPageCopyApplicationNameForUserAgent): 26 (WKPageSetApplicationNameForUserAgent): 27 (WKPageSetCustomUserAgent): 28 * UIProcess/API/C/WKPage.h: 29 Add new API to set the application name and access the computed user agent. 30 31 * UIProcess/WebPageProxy.cpp: 32 (WebKit::WebPageProxy::WebPageProxy): 33 (WebKit::WebPageProxy::close): 34 (WebKit::WebPageProxy::setUserAgent): 35 (WebKit::WebPageProxy::setApplicationNameForUserAgent): 36 (WebKit::WebPageProxy::setCustomUserAgent): 37 (WebKit::WebPageProxy::processDidCrash): 38 (WebKit::WebPageProxy::creationParameters): 39 * UIProcess/WebPageProxy.h: 40 (WebKit::WebPageProxy::userAgent): 41 (WebKit::WebPageProxy::applicationNameForUserAgent): 42 * UIProcess/mac/WebPageProxyMac.mm: Added. 43 * WebProcess/WebPage/WebPage.cpp: 44 (WebKit::WebPage::WebPage): 45 (WebKit::WebPage::setUserAgent): 46 * WebProcess/WebPage/WebPage.h: 47 (WebKit::WebPage::userAgent): 48 * WebProcess/WebPage/WebPage.messages.in: 49 Pipe through user agent. 50 51 (WebKit::callGestalt): 52 (WebKit::macOSXVersionString): 53 (WebKit::userVisibleWebKitVersionString): 54 (WebKit::WebPageProxy::standardUserAgent): 55 * UIProcess/win/WebPageProxyWin.cpp: Added. 56 (WebKit::windowsVersion): 57 (WebKit::userVisibleWebKitVersionString): 58 (WebKit::WebPageProxy::standardUserAgent): 59 Port standardUserAgent computation from WebKit1. 60 61 * UIProcess/qt/WebPageProxyQt.cpp: Added. 62 (WebKit::WebPageProxy::standardUserAgent): 63 Stub out the user agent so there is no change in behavior. 64 65 * WebKit2.pro: 66 * WebKit2.xcodeproj/project.pbxproj: 67 * win/WebKit2.vcproj: 68 Add new file. 69 1 70 2010-12-13 Brady Eidson <beidson@apple.com> 2 71 -
trunk/WebKit2/Shared/WebPageCreationParameters.cpp
r73666 r74000 38 38 encoder->encode(drawsBackground); 39 39 encoder->encode(drawsTransparentBackground); 40 encoder->encode(userAgent); 40 41 41 42 #if PLATFORM(WIN) … … 58 59 if (!decoder->decode(parameters.drawsTransparentBackground)) 59 60 return false; 61 if (!decoder->decode(parameters.userAgent)) 62 return false; 60 63 61 64 #if PLATFORM(WIN) -
trunk/WebKit2/Shared/WebPageCreationParameters.h
r73666 r74000 31 31 #include "WebPreferencesStore.h" 32 32 #include <WebCore/IntSize.h> 33 #include <wtf/text/WTFString.h> 33 34 34 35 namespace CoreIPC { … … 51 52 bool drawsTransparentBackground; 52 53 54 String userAgent; 55 53 56 #if PLATFORM(WIN) 54 57 HWND nativeWindow; -
trunk/WebKit2/UIProcess/API/C/WKPage.cpp
r73965 r74000 165 165 } 166 166 167 WKStringRef WKPageCopyUserAgent(WKPageRef pageRef) 168 { 169 return toCopiedAPI(toImpl(pageRef)->userAgent()); 170 } 171 172 WKStringRef WKPageCopyApplicationNameForUserAgent(WKPageRef pageRef) 173 { 174 return toCopiedAPI(toImpl(pageRef)->applicationNameForUserAgent()); 175 } 176 177 void WKPageSetApplicationNameForUserAgent(WKPageRef pageRef, WKStringRef applicationNameRef) 178 { 179 toImpl(pageRef)->setApplicationNameForUserAgent(toWTFString(applicationNameRef)); 180 } 181 167 182 WKStringRef WKPageCopyCustomUserAgent(WKPageRef pageRef) 168 183 { … … 172 187 void WKPageSetCustomUserAgent(WKPageRef pageRef, WKStringRef userAgentRef) 173 188 { 174 toImpl(pageRef)->setCustomUserAgent(to Impl(userAgentRef)->string());189 toImpl(pageRef)->setCustomUserAgent(toWTFString(userAgentRef)); 175 190 } 176 191 -
trunk/WebKit2/UIProcess/API/C/WKPage.h
r73986 r74000 252 252 #endif 253 253 254 WK_EXPORT WKStringRef WKPageCopyUserAgent(WKPageRef page); 255 256 WK_EXPORT WKStringRef WKPageCopyApplicationNameForUserAgent(WKPageRef page); 257 WK_EXPORT void WKPageSetApplicationNameForUserAgent(WKPageRef page, WKStringRef applicationName); 258 254 259 WK_EXPORT WKStringRef WKPageCopyCustomUserAgent(WKPageRef page); 255 260 WK_EXPORT void WKPageSetCustomUserAgent(WKPageRef page, WKStringRef userAgent); -
trunk/WebKit2/UIProcess/WebPageProxy.cpp
r73986 r74000 91 91 , m_pageGroup(pageGroup) 92 92 , m_mainFrame(0) 93 , m_userAgent(standardUserAgent()) 93 94 , m_estimatedProgress(0.0) 94 95 , m_isInWindow(false) … … 224 225 m_mainFrame = 0; 225 226 226 m_customUserAgent = String();227 228 227 #if ENABLE(INSPECTOR) 229 228 if (m_inspector) { … … 604 603 } 605 604 606 void WebPageProxy::setCustomUserAgent(const String& userAgent) 607 { 608 if (!isValid()) 609 return; 610 611 if (m_customUserAgent == userAgent || (m_customUserAgent.isEmpty() && userAgent.isEmpty())) 612 return; 613 614 m_customUserAgent = userAgent; 615 process()->send(Messages::WebPage::SetCustomUserAgent(userAgent), m_pageID); 605 void WebPageProxy::setUserAgent(const String& userAgent) 606 { 607 if (m_userAgent == userAgent) 608 return; 609 m_userAgent = userAgent; 610 611 if (!isValid()) 612 return; 613 process()->send(Messages::WebPage::SetUserAgent(m_userAgent), m_pageID); 614 } 615 616 void WebPageProxy::setApplicationNameForUserAgent(const String& applicationName) 617 { 618 if (m_applicationNameForUserAgent == applicationName) 619 return; 620 621 m_applicationNameForUserAgent = applicationName; 622 if (!m_customUserAgent.isEmpty()) 623 return; 624 625 setUserAgent(standardUserAgent(m_applicationNameForUserAgent)); 626 } 627 628 void WebPageProxy::setCustomUserAgent(const String& customUserAgent) 629 { 630 if (m_customUserAgent == customUserAgent) 631 return; 632 633 m_customUserAgent = customUserAgent; 634 635 if (m_customUserAgent.isEmpty()) { 636 setUserAgent(standardUserAgent(m_applicationNameForUserAgent)); 637 return; 638 } 639 640 setUserAgent(m_customUserAgent); 616 641 } 617 642 … … 1583 1608 #endif 1584 1609 1585 m_customUserAgent = String();1586 1610 m_pageTitle = String(); 1587 1611 m_toolTip = String(); … … 1616 1640 parameters.drawsBackground = m_drawsBackground; 1617 1641 parameters.drawsTransparentBackground = m_drawsTransparentBackground; 1642 parameters.userAgent = userAgent(); 1618 1643 1619 1644 #if PLATFORM(WIN) -
trunk/WebKit2/UIProcess/WebPageProxy.h
r73986 r74000 196 196 const String& pageTitle() const { return m_pageTitle; } 197 197 const String& toolTip() const { return m_toolTip; } 198 199 void setUserAgent(const String&); 200 const String& userAgent() const { return m_userAgent; } 201 void setApplicationNameForUserAgent(const String&); 202 const String& applicationNameForUserAgent() const { return m_applicationNameForUserAgent; } 203 void setCustomUserAgent(const String&); 198 204 const String& customUserAgent() const { return m_customUserAgent; } 199 205 200 206 double estimatedProgress() const { return m_estimatedProgress; } 201 202 void setCustomUserAgent(const String&);203 207 204 208 void terminateProcess(); … … 398 402 #endif 399 403 404 static String standardUserAgent(const String& applicationName = String()); 405 400 406 PageClient* m_pageClient; 401 407 WebLoaderClient m_loaderClient; … … 413 419 String m_pageTitle; 414 420 421 String m_userAgent; 422 String m_applicationNameForUserAgent; 415 423 String m_customUserAgent; 416 424 -
trunk/WebKit2/WebKit2.pro
r73986 r74000 546 546 UIProcess/qt/WebContextQt.cpp \ 547 547 UIProcess/qt/WebInspectorProxyQt.cpp \ 548 UIProcess/qt/WebPageProxyQt.cpp \ 548 549 UIProcess/qt/WebPopupMenuProxyQt.cpp \ 549 550 UIProcess/qt/WebPreferencesQt.cpp \ -
trunk/WebKit2/WebKit2.xcodeproj/project.pbxproj
r73986 r74000 440 440 BC8452A81162C80900CAB9B5 /* DrawingArea.h in Headers */ = {isa = PBXBuildFile; fileRef = BC8452A61162C80900CAB9B5 /* DrawingArea.h */; }; 441 441 BC84EB1812A7100C0083F2DA /* WebPreferencesMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = BC84EB1712A7100C0083F2DA /* WebPreferencesMac.mm */; }; 442 BC857E8712B71EBB00EDEB2E /* WebPageProxyMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = BC857E8512B71EBB00EDEB2E /* WebPageProxyMac.mm */; }; 442 443 BC8699B5116AADAA002A925B /* WKView.h in Headers */ = {isa = PBXBuildFile; fileRef = BC8699B2116AADAA002A925B /* WKView.h */; settings = {ATTRIBUTES = (Public, ); }; }; 443 444 BC8699B6116AADAA002A925B /* WKView.mm in Sources */ = {isa = PBXBuildFile; fileRef = BC8699B3116AADAA002A925B /* WKView.mm */; }; … … 1086 1087 BC8452A61162C80900CAB9B5 /* DrawingArea.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DrawingArea.h; sourceTree = "<group>"; }; 1087 1088 BC84EB1712A7100C0083F2DA /* WebPreferencesMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebPreferencesMac.mm; sourceTree = "<group>"; }; 1089 BC857E8512B71EBB00EDEB2E /* WebPageProxyMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebPageProxyMac.mm; sourceTree = "<group>"; }; 1088 1090 BC8699B2116AADAA002A925B /* WKView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKView.h; sourceTree = "<group>"; }; 1089 1091 BC8699B3116AADAA002A925B /* WKView.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WKView.mm; sourceTree = "<group>"; }; … … 2250 2252 51ACBB9F127A8F2C00D203B9 /* WebContextMenuProxyMac.mm */, 2251 2253 1CA8B935127C774E00576C2B /* WebInspectorProxyMac.mm */, 2254 BC857E8512B71EBB00EDEB2E /* WebPageProxyMac.mm */, 2252 2255 BC5750951268F3C6006F0F12 /* WebPopupMenuProxyMac.h */, 2253 2256 BC5750961268F3C6006F0F12 /* WebPopupMenuProxyMac.mm */, … … 3103 3106 F62A76B612B1B25F0005F1B6 /* WebDatabaseManagerMessageReceiver.cpp in Sources */, 3104 3107 F62A76B812B1B25F0005F1B6 /* WebDatabaseManagerProxyMessageReceiver.cpp in Sources */, 3108 BC857E8712B71EBB00EDEB2E /* WebPageProxyMac.mm in Sources */, 3105 3109 ); 3106 3110 runOnlyForDeploymentPostprocessing = 0; -
trunk/WebKit2/WebProcess/WebPage/WebPage.cpp
r73803 r74000 160 160 setDrawsTransparentBackground(parameters.drawsTransparentBackground); 161 161 162 m_userAgent = parameters.userAgent; 163 162 164 #ifndef NDEBUG 163 165 webPageCounter.increment(); … … 861 863 } 862 864 863 void WebPage::setCustomUserAgent(const String& customUserAgent) 864 { 865 m_customUserAgent = customUserAgent; 866 } 867 868 String WebPage::userAgent() const 869 { 870 if (!m_customUserAgent.isEmpty()) 871 return m_customUserAgent; 872 873 // FIXME: This should be based on an application name. 874 return "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6; en-us) AppleWebKit/531.4 (KHTML, like Gecko) Version/4.0.3 Safari/531.4"; 865 void WebPage::setUserAgent(const String& userAgent) 866 { 867 m_userAgent = userAgent; 875 868 } 876 869 -
trunk/WebKit2/WebProcess/WebPage/WebPage.h
r73803 r74000 127 127 #endif 128 128 void show(); 129 String userAgent() const ;129 String userAgent() const { return m_userAgent; } 130 130 WebCore::IntRect windowResizerRect() const; 131 131 bool tabsToLinks() const { return m_tabToLinks; } … … 302 302 303 303 void didReceivePolicyDecision(uint64_t frameID, uint64_t listenerID, uint32_t policyAction, uint64_t downloadID); 304 void set CustomUserAgent(const String&);304 void setUserAgent(const String&); 305 305 306 306 #if PLATFORM(MAC) … … 333 333 RefPtr<WebPageGroupProxy> m_pageGroup; 334 334 335 String m_ customUserAgent;335 String m_userAgent; 336 336 337 337 WebCore::IntSize m_viewSize; -
trunk/WebKit2/WebProcess/WebPage/WebPage.messages.in
r73803 r74000 58 58 PreferencesDidChange(WebKit::WebPreferencesStore store) 59 59 60 Set CustomUserAgent(WTF::String customUserAgent)60 SetUserAgent(WTF::String userAgent) 61 61 62 62 #if ENABLE(TILED_BACKING_STORE) -
trunk/WebKit2/win/WebKit2.vcproj
r73986 r74000 2467 2467 </File> 2468 2468 <File 2469 RelativePath="..\UIProcess\win\WebPageProxyWin.cpp" 2470 > 2471 </File> 2472 <File 2469 2473 RelativePath="..\UIProcess\win\WebPopupMenuProxyWin.cpp" 2470 2474 >
Note: See TracChangeset
for help on using the changeset viewer.