[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-9427-gc2be6fc

weinig at apple.com weinig at apple.com
Wed Dec 22 12:18:56 UTC 2010


The following commit has been merged in the debian/experimental branch:
commit ea322fc050d911ca04acad81d8b59fc0e844076b
Author: weinig at apple.com <weinig at apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Wed Aug 18 23:46:21 2010 +0000

    Add ability to set custom userAgent for WebKit2
    https://bugs.webkit.org/show_bug.cgi?id=44215
    
    Reviewed by Jon Honeycutt.
    
    * Shared/CoreIPCSupport/WebPageMessageKinds.h:
    (WebPageMessage::):
    * UIProcess/API/C/WKPage.cpp:
    (WKPageSetCustomUserAgent):
    * UIProcess/API/C/WKPage.h:
    * UIProcess/WebPageProxy.cpp:
    (WebKit::WebPageProxy::setCustomUserAgent):
    * UIProcess/WebPageProxy.h:
    * WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp:
    (WebKit::WebFrameLoaderClient::userAgent):
    * WebProcess/WebPage/WebPage.cpp:
    (WebKit::WebPage::setCustomUserAgent):
    (WebKit::WebPage::userAgent):
    (WebKit::WebPage::didReceiveMessage):
    * WebProcess/WebPage/WebPage.h:
    
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@65644 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebKit2/ChangeLog b/WebKit2/ChangeLog
index 1cf11c6..8488080 100644
--- a/WebKit2/ChangeLog
+++ b/WebKit2/ChangeLog
@@ -1,5 +1,28 @@
 2010-08-18  Sam Weinig  <sam at webkit.org>
 
+        Reviewed by Jon Honeycutt.
+
+        Add ability to set custom userAgent for WebKit2
+        https://bugs.webkit.org/show_bug.cgi?id=44215
+
+        * Shared/CoreIPCSupport/WebPageMessageKinds.h:
+        (WebPageMessage::):
+        * UIProcess/API/C/WKPage.cpp:
+        (WKPageSetCustomUserAgent):
+        * UIProcess/API/C/WKPage.h:
+        * UIProcess/WebPageProxy.cpp:
+        (WebKit::WebPageProxy::setCustomUserAgent):
+        * UIProcess/WebPageProxy.h:
+        * WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp:
+        (WebKit::WebFrameLoaderClient::userAgent):
+        * WebProcess/WebPage/WebPage.cpp:
+        (WebKit::WebPage::setCustomUserAgent):
+        (WebKit::WebPage::userAgent):
+        (WebKit::WebPage::didReceiveMessage):
+        * WebProcess/WebPage/WebPage.h:
+
+2010-08-18  Sam Weinig  <sam at webkit.org>
+
         Rubber-stamped by John Sullivan.
 
         Make WKBundleNodeHandleRef usable from WKRetainPtr.
diff --git a/WebKit2/Shared/CoreIPCSupport/WebPageMessageKinds.h b/WebKit2/Shared/CoreIPCSupport/WebPageMessageKinds.h
index 491902c..439273c 100644
--- a/WebKit2/Shared/CoreIPCSupport/WebPageMessageKinds.h
+++ b/WebKit2/Shared/CoreIPCSupport/WebPageMessageKinds.h
@@ -46,6 +46,7 @@ enum Kind {
     Reload,
     RunJavaScriptInMainFrame,
     SetActive,
+    SetCustomUserAgent,
     SetFocused,
     SetIsInWindow,
     StopLoading,
diff --git a/WebKit2/UIProcess/API/C/WKPage.cpp b/WebKit2/UIProcess/API/C/WKPage.cpp
index 9883dfa..decb9b8 100644
--- a/WebKit2/UIProcess/API/C/WKPage.cpp
+++ b/WebKit2/UIProcess/API/C/WKPage.cpp
@@ -127,6 +127,11 @@ double WKPageGetEstimatedProgress(WKPageRef pageRef)
     return toWK(pageRef)->estimatedProgress();
 }
 
+void WKPageSetCustomUserAgent(WKPageRef pageRef, WKStringRef userAgentRef)
+{
+    toWK(pageRef)->setCustomUserAgent(toWK(userAgentRef)->string());
+}
+
 void WKPageTerminate(WKPageRef pageRef)
 {
     toWK(pageRef)->terminateProcess();
diff --git a/WebKit2/UIProcess/API/C/WKPage.h b/WebKit2/UIProcess/API/C/WKPage.h
index 072ad61..5352996 100644
--- a/WebKit2/UIProcess/API/C/WKPage.h
+++ b/WebKit2/UIProcess/API/C/WKPage.h
@@ -169,7 +169,9 @@ WK_EXPORT WKStringRef WKPageCopyTitle(WKPageRef page);
 
 WK_EXPORT WKFrameRef WKPageGetMainFrame(WKPageRef page);
 WK_EXPORT double WKPageGetEstimatedProgress(WKPageRef page);
-    
+
+WK_EXPORT void WKPageSetCustomUserAgent(WKPageRef page, WKStringRef userAgent);
+
 WK_EXPORT void WKPageTerminate(WKPageRef page);
 
 WK_EXPORT WKDataRef WKPageCopySessionState(WKPageRef page);
diff --git a/WebKit2/UIProcess/WebPageProxy.cpp b/WebKit2/UIProcess/WebPageProxy.cpp
index 5f49a92..fd5a809 100644
--- a/WebKit2/UIProcess/WebPageProxy.cpp
+++ b/WebKit2/UIProcess/WebPageProxy.cpp
@@ -340,6 +340,14 @@ void WebPageProxy::receivedPolicyDecision(WebCore::PolicyAction action, WebFrame
     process()->send(WebPageMessage::DidReceivePolicyDecision, m_pageID, CoreIPC::In(frame->frameID(), listenerID, (uint32_t)action));
 }
 
+void WebPageProxy::setCustomUserAgent(const String& userAgent)
+{
+    if (!isValid())
+        return;
+
+    process()->send(WebPageMessage::SetCustomUserAgent, m_pageID, CoreIPC::In(userAgent));
+}
+
 void WebPageProxy::terminateProcess()
 {
     if (!isValid())
diff --git a/WebKit2/UIProcess/WebPageProxy.h b/WebKit2/UIProcess/WebPageProxy.h
index 50f020b..b4eff4c 100644
--- a/WebKit2/UIProcess/WebPageProxy.h
+++ b/WebKit2/UIProcess/WebPageProxy.h
@@ -132,6 +132,8 @@ public:
 
     double estimatedProgress() const { return m_estimatedProgress; }
 
+    void setCustomUserAgent(const String&);
+
     void terminateProcess();
     
     PassRefPtr<WebData> sessionState() const;
diff --git a/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp b/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp
index acd1067..8b8a50b 100644
--- a/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp
+++ b/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp
@@ -804,8 +804,11 @@ void WebFrameLoaderClient::setTitle(const String& title, const KURL& url)
 
 String WebFrameLoaderClient::userAgent(const KURL&)
 {
-    notImplemented();
-    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";
+    WebPage* webPage = m_frame->page();
+    if (!webPage)
+        return String();
+
+    return webPage->userAgent();
 }
 
 void WebFrameLoaderClient::savePlatformDataToCachedFrame(CachedFrame*)
diff --git a/WebKit2/WebProcess/WebPage/WebPage.cpp b/WebKit2/WebProcess/WebPage/WebPage.cpp
index 95c163f..4066b44 100644
--- a/WebKit2/WebProcess/WebPage/WebPage.cpp
+++ b/WebKit2/WebProcess/WebPage/WebPage.cpp
@@ -452,6 +452,20 @@ void WebPage::show()
     WebProcess::shared().connection()->send(WebPageProxyMessage::ShowPage, m_pageID, CoreIPC::In());
 }
 
+void WebPage::setCustomUserAgent(const String& customUserAgent)
+{
+    m_customUserAgent = customUserAgent;
+}
+
+String WebPage::userAgent() const
+{
+    if (!m_customUserAgent.isNull())
+        return m_customUserAgent;
+
+    // FIXME: This should be based on an application name.
+    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";
+}
+
 void WebPage::runJavaScriptInMainFrame(const WTF::String& script, uint64_t callbackID)
 {
     // NOTE: We need to be careful when running scripts that the objects we depend on don't
@@ -646,6 +660,13 @@ void WebPage::didReceiveMessage(CoreIPC::Connection* connection, CoreIPC::Messag
             tryClose();
             return;
         }
+        case WebPageMessage::SetCustomUserAgent: {
+            String customUserAgent;
+            if (!arguments->decode(CoreIPC::Out(customUserAgent)))
+                return;
+            setCustomUserAgent(customUserAgent);
+            return;
+        }
     }
 
     ASSERT_NOT_REACHED();
diff --git a/WebKit2/WebProcess/WebPage/WebPage.h b/WebKit2/WebProcess/WebPage/WebPage.h
index 2d877ba..9d64ec3 100644
--- a/WebKit2/WebProcess/WebPage/WebPage.h
+++ b/WebKit2/WebProcess/WebPage/WebPage.h
@@ -35,11 +35,11 @@
 #include <WebCore/FrameLoaderTypes.h>
 #include <WebCore/IntRect.h>
 #include <WebCore/ZoomMode.h>
-#include <wtf/Forward.h>
 #include <wtf/HashMap.h>
 #include <wtf/OwnPtr.h>
 #include <wtf/PassRefPtr.h>
 #include <wtf/RefPtr.h>
+#include <wtf/text/WTFString.h>
 
 namespace CoreIPC {
     class ArgumentDecoder;
@@ -92,6 +92,7 @@ public:
     // -- Called from WebCore clients.
     bool handleEditingKeyboardEvent(WebCore::KeyboardEvent*);
     void show();
+    String userAgent() const;
 
     // -- Called from WebProcess.
     void didReceiveMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*);
@@ -109,7 +110,7 @@ public:
 
     WebFrame* mainFrame() const { return m_mainFrame.get(); }
 
-    WTF::String renderTreeExternalRepresentation() const;
+    String renderTreeExternalRepresentation() const;
     void executeEditingCommand(const WTF::String& commandName, const WTF::String& argument);
     bool isEditingCommandEnabled(const WTF::String& commandName);
     void clearMainFrameName();
@@ -156,11 +157,14 @@ private:
     void preferencesDidChange(const WebPreferencesStore&);
     void platformPreferencesDidChange(const WebPreferencesStore&);
     void didReceivePolicyDecision(WebFrame*, uint64_t listenerID, WebCore::PolicyAction policyAction);
+    void setCustomUserAgent(const WTF::String&);
 
     WebCore::Page* m_page;
     RefPtr<WebFrame> m_mainFrame;
     HashMap<uint64_t, WebFrame*> m_frameMap;
 
+    String m_customUserAgent;
+
     WebCore::IntSize m_viewSize;
     RefPtr<DrawingArea> m_drawingArea;
 

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list