[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:44:38 UTC 2010


The following commit has been merged in the debian/experimental branch:
commit 17cf9950bcec6689849d3e20c2b32eacd749014f
Author: weinig at apple.com <weinig at apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Sat Aug 28 02:16:40 2010 +0000

    Add UserContent API to WebKit2 InjectedBundle
    <rdar://problem/8367587>
    https://bugs.webkit.org/show_bug.cgi?id=44810
    
    Reviewed by Dan Bernstein.
    
    The new API differs from the version in WebKit1 in that the function do not take
    a group name since we currently do not expose a way to make multiple PageGroups in
    the API.
    
    * WebProcess/InjectedBundle/API/c/WKBundleAPICast.h:
    (toUserScriptInjectionTime):
    (toUserContentInjectedFrames):
    Add conversion functions for enums.
    
    * WebProcess/InjectedBundle/API/c/WKBundle.cpp:
    (WKBundleAddUserScript):
    (WKBundleAddUserStyleSheet):
    (WKBundleRemoveUserScript):
    (WKBundleRemoveUserStyleSheet):
    (WKBundleRemoveUserScripts):
    (WKBundleRemoveUserStyleSheets):
    (WKBundleRemoveAllUserContent):
    * WebProcess/InjectedBundle/API/c/WKBundlePrivate.h:
    * WebProcess/InjectedBundle/InjectedBundle.cpp:
    (WebKit::toStringVector):
    (WebKit::InjectedBundle::addUserScript):
    (WebKit::InjectedBundle::addUserStyleSheet):
    (WebKit::InjectedBundle::removeUserScript):
    (WebKit::InjectedBundle::removeUserStyleSheet):
    (WebKit::InjectedBundle::removeUserScripts):
    (WebKit::InjectedBundle::removeUserStyleSheets):
    (WebKit::InjectedBundle::removeAllUserContent):
    * WebProcess/InjectedBundle/InjectedBundle.h:
    Forward API to PageGroup.
    
    * WebProcess/WebProcess.cpp:
    (WebKit::WebProcess::sharedPageGroup):
    (WebKit::WebProcess::visitedLinkStateChanged):
    (WebKit::WebProcess::allVisitedLinkStateChanged):
    * WebProcess/WebProcess.h: Ad accessor for global PageGroup.
    
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@66292 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebKit2/ChangeLog b/WebKit2/ChangeLog
index d8006d7..d616b4a 100644
--- a/WebKit2/ChangeLog
+++ b/WebKit2/ChangeLog
@@ -1,5 +1,49 @@
 2010-08-27  Sam Weinig  <sam at webkit.org>
 
+        Reviewed by Dan Bernstein.
+
+        Add UserContent API to WebKit2 InjectedBundle
+        <rdar://problem/8367587>
+        https://bugs.webkit.org/show_bug.cgi?id=44810
+
+        The new API differs from the version in WebKit1 in that the function do not take
+        a group name since we currently do not expose a way to make multiple PageGroups in
+        the API.
+
+        * WebProcess/InjectedBundle/API/c/WKBundleAPICast.h:
+        (toUserScriptInjectionTime):
+        (toUserContentInjectedFrames):
+        Add conversion functions for enums.
+
+        * WebProcess/InjectedBundle/API/c/WKBundle.cpp:
+        (WKBundleAddUserScript):
+        (WKBundleAddUserStyleSheet):
+        (WKBundleRemoveUserScript):
+        (WKBundleRemoveUserStyleSheet):
+        (WKBundleRemoveUserScripts):
+        (WKBundleRemoveUserStyleSheets):
+        (WKBundleRemoveAllUserContent):
+        * WebProcess/InjectedBundle/API/c/WKBundlePrivate.h:
+        * WebProcess/InjectedBundle/InjectedBundle.cpp:
+        (WebKit::toStringVector):
+        (WebKit::InjectedBundle::addUserScript):
+        (WebKit::InjectedBundle::addUserStyleSheet):
+        (WebKit::InjectedBundle::removeUserScript):
+        (WebKit::InjectedBundle::removeUserStyleSheet):
+        (WebKit::InjectedBundle::removeUserScripts):
+        (WebKit::InjectedBundle::removeUserStyleSheets):
+        (WebKit::InjectedBundle::removeAllUserContent):
+        * WebProcess/InjectedBundle/InjectedBundle.h:
+        Forward API to PageGroup.
+
+        * WebProcess/WebProcess.cpp:
+        (WebKit::WebProcess::sharedPageGroup):
+        (WebKit::WebProcess::visitedLinkStateChanged):
+        (WebKit::WebProcess::allVisitedLinkStateChanged):
+        * WebProcess/WebProcess.h: Ad accessor for global PageGroup.
+
+2010-08-27  Sam Weinig  <sam at webkit.org>
+
         Reviewed by Gavin Barraclough.
 
         Move WKBundle didCreatePage callback to outside the WebPage
diff --git a/WebKit2/WebProcess/InjectedBundle/API/c/WKBundle.cpp b/WebKit2/WebProcess/InjectedBundle/API/c/WKBundle.cpp
index 4236671..81b645d 100644
--- a/WebKit2/WebProcess/InjectedBundle/API/c/WKBundle.cpp
+++ b/WebKit2/WebProcess/InjectedBundle/API/c/WKBundle.cpp
@@ -77,3 +77,38 @@ size_t WKBundleGetJavaScriptObjectsCount(WKBundleRef bundleRef)
 {
     return toWK(bundleRef)->javaScriptObjectsCount();
 }
+
+void WKBundleAddUserScript(WKBundleRef bundleRef, WKBundleScriptWorldRef scriptWorldRef, WKStringRef sourceRef, WKURLRef urlRef, WKArrayRef whitelistRef, WKArrayRef blacklistRef, WKUserScriptInjectionTime injectionTimeRef, WKUserContentInjectedFrames injectedFramesRef)
+{
+    toWK(bundleRef)->addUserScript(toWK(scriptWorldRef), toWK(sourceRef)->string(), toWK(urlRef)->string(), toWK(whitelistRef), toWK(blacklistRef), toUserScriptInjectionTime(injectionTimeRef), toUserContentInjectedFrames(injectedFramesRef));
+}
+
+void WKBundleAddUserStyleSheet(WKBundleRef bundleRef, WKBundleScriptWorldRef scriptWorldRef, WKStringRef sourceRef, WKURLRef urlRef, WKArrayRef whitelistRef, WKArrayRef blacklistRef, WKUserContentInjectedFrames injectedFramesRef)
+{
+    toWK(bundleRef)->addUserStyleSheet(toWK(scriptWorldRef), toWK(sourceRef)->string(), toWK(urlRef)->string(), toWK(whitelistRef), toWK(blacklistRef), toUserContentInjectedFrames(injectedFramesRef));
+}
+
+void WKBundleRemoveUserScript(WKBundleRef bundleRef, WKBundleScriptWorldRef scriptWorldRef, WKURLRef urlRef)
+{
+    toWK(bundleRef)->removeUserScript(toWK(scriptWorldRef), toWK(urlRef)->string());
+}
+
+void WKBundleRemoveUserStyleSheet(WKBundleRef bundleRef, WKBundleScriptWorldRef scriptWorldRef, WKURLRef urlRef)
+{
+    toWK(bundleRef)->removeUserStyleSheet(toWK(scriptWorldRef), toWK(urlRef)->string());
+}
+
+void WKBundleRemoveUserScripts(WKBundleRef bundleRef, WKBundleScriptWorldRef scriptWorldRef)
+{
+    toWK(bundleRef)->removeUserScripts(toWK(scriptWorldRef));
+}
+
+void WKBundleRemoveUserStyleSheets(WKBundleRef bundleRef, WKBundleScriptWorldRef scriptWorldRef)
+{
+    toWK(bundleRef)->removeUserStyleSheets(toWK(scriptWorldRef));
+}
+
+void WKBundleRemoveAllUserContent(WKBundleRef bundleRef)
+{
+    toWK(bundleRef)->removeAllUserContent();
+}
diff --git a/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleAPICast.h b/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleAPICast.h
index f5e3843..3922cae 100644
--- a/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleAPICast.h
+++ b/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleAPICast.h
@@ -29,8 +29,11 @@
 #include "WKBundleBase.h"
 #include "WKBundlePage.h"
 #include "WKBundlePagePrivate.h"
+#include "WKBundlePrivate.h"
 #include <WebCore/EditorInsertAction.h>
 #include <WebCore/TextAffinity.h>
+#include <WebCore/UserContentTypes.h>
+#include <WebCore/UserScriptTypes.h>
 #include <WebCore/ZoomMode.h>
 
 namespace WebCore {
@@ -127,4 +130,30 @@ inline WebCore::ZoomMode toZoomMode(WKBundlePageZoomMode wkZoomMode)
     return WebCore::ZoomTextOnly;
 }
 
+inline WebCore::UserScriptInjectionTime toUserScriptInjectionTime(WKUserScriptInjectionTime wkInjectedTime)
+{
+    switch (wkInjectedTime) {
+    case kWKInjectAtDocumentStart:
+        return WebCore::InjectAtDocumentStart;
+    case kWKInjectAtDocumentEnd:
+        return WebCore::InjectAtDocumentEnd;
+    }
+
+    ASSERT_NOT_REACHED();
+    return WebCore::InjectAtDocumentStart;
+}
+
+inline WebCore::UserContentInjectedFrames toUserContentInjectedFrames(WKUserContentInjectedFrames wkInjectedFrames)
+{
+    switch (wkInjectedFrames) {
+    case kWKInjectInAllFrames:
+        return WebCore::InjectInAllFrames;
+    case kWKInjectInTopFrameOnly:
+        return WebCore::InjectInTopFrameOnly;
+    }
+
+    ASSERT_NOT_REACHED();
+    return WebCore::InjectInAllFrames;
+}
+
 #endif // WKBundleAPICast_h
diff --git a/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePrivate.h b/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePrivate.h
index 64b97ea..e09ab86 100644
--- a/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePrivate.h
+++ b/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePrivate.h
@@ -44,6 +44,26 @@ WK_EXPORT void WKBundleGarbageCollectJavaScriptObjects(WKBundleRef bundle);
 WK_EXPORT void WKBundleGarbageCollectJavaScriptObjectsOnAlternateThreadForDebugging(WKBundleRef bundle, bool waitUntilDone);
 WK_EXPORT size_t WKBundleGetJavaScriptObjectsCount(WKBundleRef bundle);
 
+enum WKUserScriptInjectionTime {
+    kWKInjectAtDocumentStart,
+    kWKInjectAtDocumentEnd
+};
+typedef enum WKUserScriptInjectionTime WKUserScriptInjectionTime;
+
+enum WKUserContentInjectedFrames {
+    kWKInjectInAllFrames,
+    kWKInjectInTopFrameOnly
+};
+typedef enum WKUserContentInjectedFrames WKUserContentInjectedFrames;
+
+WK_EXPORT void WKBundleAddUserScript(WKBundleRef bundle, WKBundleScriptWorldRef scriptWorld, WKStringRef source, WKURLRef url, WKArrayRef whitelist, WKArrayRef blacklist, WKUserScriptInjectionTime injectionTime, WKUserContentInjectedFrames injectedFrames);
+WK_EXPORT void WKBundleAddUserStyleSheet(WKBundleRef bundle, WKBundleScriptWorldRef scriptWorld, WKStringRef source, WKURLRef url, WKArrayRef whitelist, WKArrayRef blacklist, WKUserContentInjectedFrames injectedFrames);
+WK_EXPORT void WKBundleRemoveUserScript(WKBundleRef bundle, WKBundleScriptWorldRef scriptWorld, WKURLRef url);
+WK_EXPORT void WKBundleRemoveUserStyleSheet(WKBundleRef bundle, WKBundleScriptWorldRef scriptWorld, WKURLRef url);
+WK_EXPORT void WKBundleRemoveUserScripts(WKBundleRef bundle, WKBundleScriptWorldRef scriptWorld);
+WK_EXPORT void WKBundleRemoveUserStyleSheets(WKBundleRef bundle, WKBundleScriptWorldRef scriptWorld);
+WK_EXPORT void WKBundleRemoveAllUserContent(WKBundleRef bundle);
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/WebKit2/WebProcess/InjectedBundle/InjectedBundle.cpp b/WebKit2/WebProcess/InjectedBundle/InjectedBundle.cpp
index 02eb32c..90ef4a1 100644
--- a/WebKit2/WebProcess/InjectedBundle/InjectedBundle.cpp
+++ b/WebKit2/WebProcess/InjectedBundle/InjectedBundle.cpp
@@ -28,6 +28,7 @@
 #include "Arguments.h"
 #include "ImmutableArray.h"
 #include "InjectedBundleMessageKinds.h"
+#include "InjectedBundleScriptWorld.h"
 #include "WKAPICast.h"
 #include "WKBundleAPICast.h"
 #include "WebContextMessageKinds.h"
@@ -196,6 +197,57 @@ void InjectedBundle::removeAllVisitedLinks()
     PageGroup::removeAllVisitedLinks();
 }
 
+static PassOwnPtr<Vector<String> > toStringVector(ImmutableArray* patterns)
+{
+    size_t size =  patterns->size();
+    if (!size)
+        return 0;
+
+    Vector<String>* patternsVector = new Vector<String>;
+    patternsVector->reserveInitialCapacity(size);
+    for (size_t i = 0; i < size; ++i) {
+        WebString* entry = patterns->at<WebString>(i);
+        if (entry)
+            patternsVector->uncheckedAppend(entry->string());
+    }
+    return patternsVector;
+}
+
+void InjectedBundle::addUserScript(InjectedBundleScriptWorld* scriptWorld, const String& source, const String& url, ImmutableArray* whitelist, ImmutableArray* blacklist, WebCore::UserScriptInjectionTime injectionTime, WebCore::UserContentInjectedFrames injectedFrames)
+{
+    WebProcess::sharedPageGroup()->addUserScriptToWorld(scriptWorld->coreWorld(), source, KURL(ParsedURLString, url), toStringVector(whitelist), toStringVector(blacklist), injectionTime, injectedFrames);
+}
+
+void InjectedBundle::addUserStyleSheet(InjectedBundleScriptWorld* scriptWorld, const String& source, const String& url, ImmutableArray* whitelist, ImmutableArray* blacklist, WebCore::UserContentInjectedFrames injectedFrames)
+{
+    WebProcess::sharedPageGroup()->addUserStyleSheetToWorld(scriptWorld->coreWorld(), source, KURL(ParsedURLString, url), toStringVector(whitelist), toStringVector(blacklist), injectedFrames);
+}
+
+void InjectedBundle::removeUserScript(InjectedBundleScriptWorld* scriptWorld, const String& url)
+{
+    WebProcess::sharedPageGroup()->removeUserScriptFromWorld(scriptWorld->coreWorld(), KURL(ParsedURLString, url));
+}
+
+void InjectedBundle::removeUserStyleSheet(InjectedBundleScriptWorld* scriptWorld, const String& url)
+{
+    WebProcess::sharedPageGroup()->removeUserStyleSheetFromWorld(scriptWorld->coreWorld(), KURL(ParsedURLString, url));
+}
+
+void InjectedBundle::removeUserScripts(InjectedBundleScriptWorld* scriptWorld)
+{
+    WebProcess::sharedPageGroup()->removeUserScriptsFromWorld(scriptWorld->coreWorld());
+}
+
+void InjectedBundle::removeUserStyleSheets(InjectedBundleScriptWorld* scriptWorld)
+{
+    WebProcess::sharedPageGroup()->removeUserStyleSheetsFromWorld(scriptWorld->coreWorld());
+}
+
+void InjectedBundle::removeAllUserContent()
+{
+    WebProcess::sharedPageGroup()->removeAllUserContent();
+}
+
 void InjectedBundle::garbageCollectJavaScriptObjects()
 {
     gcController().garbageCollectNow();
diff --git a/WebKit2/WebProcess/InjectedBundle/InjectedBundle.h b/WebKit2/WebProcess/InjectedBundle/InjectedBundle.h
index 504b88b..d5b9673 100644
--- a/WebKit2/WebProcess/InjectedBundle/InjectedBundle.h
+++ b/WebKit2/WebProcess/InjectedBundle/InjectedBundle.h
@@ -28,6 +28,8 @@
 
 #include "APIObject.h"
 #include "WKBundle.h"
+#include <WebCore/UserContentTypes.h>
+#include <WebCore/UserScriptTypes.h>
 #include <wtf/PassRefPtr.h>
 #include <wtf/text/WTFString.h>
 
@@ -47,6 +49,8 @@ typedef HMODULE PlatformBundle;
 typedef void* PlatformBundle;
 #endif
 
+class ImmutableArray;
+class InjectedBundleScriptWorld;
 class WebPage;
 
 class InjectedBundle : public APIObject {
@@ -72,6 +76,15 @@ public:
     void removeAllVisitedLinks();
     void activateMacFontAscentHack();
 
+    // UserContent API
+    void addUserScript(InjectedBundleScriptWorld*, const String& source, const String& url, ImmutableArray* whitelist, ImmutableArray* blacklist, WebCore::UserScriptInjectionTime, WebCore::UserContentInjectedFrames);
+    void addUserStyleSheet(InjectedBundleScriptWorld*, const String& source, const String& url, ImmutableArray* whitelist, ImmutableArray* blacklist, WebCore::UserContentInjectedFrames);
+    void removeUserScript(InjectedBundleScriptWorld*, const String& url);
+    void removeUserStyleSheet(InjectedBundleScriptWorld*, const String& url);
+    void removeUserScripts(InjectedBundleScriptWorld*);
+    void removeUserStyleSheets(InjectedBundleScriptWorld*);
+    void removeAllUserContent();
+
     // Garbage collection API
     void garbageCollectJavaScriptObjects();
     void garbageCollectJavaScriptObjectsOnAlternateThreadForDebugging(bool waitUntilDone);
diff --git a/WebKit2/WebProcess/WebProcess.cpp b/WebKit2/WebProcess/WebProcess.cpp
index d0d4211..097f88c 100644
--- a/WebKit2/WebProcess/WebProcess.cpp
+++ b/WebKit2/WebProcess/WebProcess.cpp
@@ -122,7 +122,7 @@ void WebProcess::setVisitedLinkTable(const SharedMemory::Handle& handle)
     m_visitedLinkTable.setSharedMemory(sharedMemory.release());
 }
 
-static PageGroup* webKit2PageGroup()
+PageGroup* WebProcess::sharedPageGroup()
 {
     return PageGroup::pageGroup("WebKit2Group");
 }
@@ -130,12 +130,12 @@ static PageGroup* webKit2PageGroup()
 void WebProcess::visitedLinkStateChanged(const Vector<WebCore::LinkHash>& linkHashes)
 {
     for (size_t i = 0; i < linkHashes.size(); ++i)
-        Page::visitedStateChanged(webKit2PageGroup(), linkHashes[i]);
+        Page::visitedStateChanged(sharedPageGroup(), linkHashes[i]);
 }
 
 void WebProcess::allVisitedLinkStateChanged()
 {
-    Page::allVisitedStateChanged(webKit2PageGroup());
+    Page::allVisitedStateChanged(sharedPageGroup());
 }
 
 bool WebProcess::isLinkVisited(LinkHash linkHash) const
diff --git a/WebKit2/WebProcess/WebProcess.h b/WebKit2/WebProcess/WebProcess.h
index dfad394..380bca0 100644
--- a/WebKit2/WebProcess/WebProcess.h
+++ b/WebKit2/WebProcess/WebProcess.h
@@ -36,6 +36,7 @@
 
 namespace WebCore {
     class IntSize;
+    class PageGroup;
 }
 
 namespace WebKit {
@@ -73,6 +74,8 @@ public:
     void addWebFrame(uint64_t, WebFrame*);
     void removeWebFrame(uint64_t);
 
+    static WebCore::PageGroup* sharedPageGroup();
+
 private:
     WebProcess();
     void shutdown();

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list