[SCM] WebKit Debian packaging branch, webkit-1.1, updated. upstream/1.1.15.1-1414-gc69ee75

hyatt at apple.com hyatt at apple.com
Thu Oct 29 20:38:16 UTC 2009


The following commit has been merged in the webkit-1.1 branch:
commit 19fd591242a0b30aacfc32f4aec74b6eeb93b1c6
Author: hyatt at apple.com <hyatt at apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Fri Oct 2 19:42:39 2009 +0000

    Add support for blacklist patterns to user stylesheets and scripts in addition to whitelist patterns.
    
    Reviewed by Adam Roben.
    
    WebCore:
    
    * WebCore.base.exp:
    * dom/Document.cpp:
    (WebCore::Document::pageGroupUserSheets):
    * page/Frame.cpp:
    (WebCore::Frame::injectUserScriptsForWorld):
    * page/PageGroup.cpp:
    (WebCore::PageGroup::addUserScript):
    (WebCore::PageGroup::addUserStyleSheet):
    (WebCore::PageGroup::removeUserContentWithURLForWorld):
    (WebCore::PageGroup::removeUserContentForWorld):
    * page/PageGroup.h:
    * page/UserContentURLPattern.cpp:
    (WebCore::UserContentURLPattern::matchesPatterns):
    * page/UserContentURLPattern.h:
    * page/UserScript.h:
    (WebCore::UserScript::UserScript):
    (WebCore::UserScript::whitelist):
    (WebCore::UserScript::blacklist):
    * page/UserStyleSheet.h:
    (WebCore::UserStyleSheet::UserStyleSheet):
    (WebCore::UserStyleSheet::whitelist):
    (WebCore::UserStyleSheet::blacklist):
    
    WebKit/mac:
    
    * WebView/WebView.mm:
    (toStringVector):
    (+[WebView _addUserScriptToGroup:source:url:worldID:whitelist:blacklist:injectionTime:]):
    (+[WebView _addUserStyleSheetToGroup:source:url:worldID:whitelist:blacklist:]):
    * WebView/WebViewPrivate.h:
    
    WebKit/win:
    
    * Interfaces/IWebViewPrivate.idl:
    * WebView.cpp:
    (toStringVector):
    (WebView::addUserScriptToGroup):
    (WebView::addUserStyleSheetToGroup):
    * WebView.h:
    
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@49033 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index d8ec92c..1049f35 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,32 @@
+2009-10-02  Dave Hyatt  <hyatt at apple.com>
+
+        Reviewed by Adam Roben.
+
+        Add support for blacklist patterns to user stylesheets and scripts in addition to whitelist patterns.
+
+        * WebCore.base.exp:
+        * dom/Document.cpp:
+        (WebCore::Document::pageGroupUserSheets):
+        * page/Frame.cpp:
+        (WebCore::Frame::injectUserScriptsForWorld):
+        * page/PageGroup.cpp:
+        (WebCore::PageGroup::addUserScript):
+        (WebCore::PageGroup::addUserStyleSheet):
+        (WebCore::PageGroup::removeUserContentWithURLForWorld):
+        (WebCore::PageGroup::removeUserContentForWorld):
+        * page/PageGroup.h:
+        * page/UserContentURLPattern.cpp:
+        (WebCore::UserContentURLPattern::matchesPatterns):
+        * page/UserContentURLPattern.h:
+        * page/UserScript.h:
+        (WebCore::UserScript::UserScript):
+        (WebCore::UserScript::whitelist):
+        (WebCore::UserScript::blacklist):
+        * page/UserStyleSheet.h:
+        (WebCore::UserStyleSheet::UserStyleSheet):
+        (WebCore::UserStyleSheet::whitelist):
+        (WebCore::UserStyleSheet::blacklist):
+
 2009-10-02  Laszlo Gombos  <laszlo.1.gombos at nokia.com>
 
         Reviewed by Darin Adler.
diff --git a/WebCore/WebCore.base.exp b/WebCore/WebCore.base.exp
index 6674043..5b9c2bd 100644
--- a/WebCore/WebCore.base.exp
+++ b/WebCore/WebCore.base.exp
@@ -721,9 +721,9 @@ __ZN7WebCore9HTMLNames9iframeTagE
 __ZN7WebCore9HTMLNames9scriptTagE
 __ZN7WebCore9PageCache11setCapacityEi
 __ZN7WebCore9PageCache27releaseAutoreleasedPagesNowEv
-__ZN7WebCore9PageGroup13addUserScriptERKNS_6StringERKNS_4KURLERKN3WTF6VectorIS1_Lm0EEEjNS_23UserScriptInjectionTimeE
+__ZN7WebCore9PageGroup17addUserStyleSheetERKNS_6StringERKNS_4KURLEN3WTF10PassOwnPtrINS7_6VectorIS1_Lm0EEEEESB_j
+__ZN7WebCore9PageGroup13addUserScriptERKNS_6StringERKNS_4KURLEN3WTF10PassOwnPtrINS7_6VectorIS1_Lm0EEEEESB_jNS_23UserScriptInjectionTimeE
 __ZN7WebCore9PageGroup14addVisitedLinkEPKtm
-__ZN7WebCore9PageGroup17addUserStyleSheetERKNS_6StringERKNS_4KURLERKN3WTF6VectorIS1_Lm0EEEj
 __ZN7WebCore9PageGroup17closeLocalStorageEv
 __ZN7WebCore9PageGroup20removeAllUserContentEv
 __ZN7WebCore9PageGroup21removeAllVisitedLinksEv
diff --git a/WebCore/dom/Document.cpp b/WebCore/dom/Document.cpp
index f18801e..7925633 100644
--- a/WebCore/dom/Document.cpp
+++ b/WebCore/dom/Document.cpp
@@ -1969,7 +1969,7 @@ const Vector<RefPtr<CSSStyleSheet> >* Document::pageGroupUserSheets() const
         const UserStyleSheetVector* sheets = it->second;
         for (unsigned i = 0; i < sheets->size(); ++i) {
             const UserStyleSheet* sheet = sheets->at(i).get();
-            if (!UserContentURLPattern::matchesPatterns(url(), sheet->patterns()))
+            if (!UserContentURLPattern::matchesPatterns(url(), sheet->whitelist(), sheet->blacklist()))
                 continue;
             RefPtr<CSSStyleSheet> parsedSheet = CSSStyleSheet::create(const_cast<Document*>(this), sheet->url());
             parsedSheet->setIsUserStyleSheet(true);
diff --git a/WebCore/page/Frame.cpp b/WebCore/page/Frame.cpp
index be64393..d52a225 100644
--- a/WebCore/page/Frame.cpp
+++ b/WebCore/page/Frame.cpp
@@ -881,12 +881,11 @@ void Frame::injectUserScriptsForWorld(unsigned worldID, const UserScriptVector&
     if (!doc)
         return;
 
-    // FIXME: Need to implement pattern checking.
     Vector<ScriptSourceCode> sourceCode;
     unsigned count = userScripts.size();
     for (unsigned i = 0; i < count; ++i) {
         UserScript* script = userScripts[i].get();
-        if (script->injectionTime() == injectionTime && UserContentURLPattern::matchesPatterns(doc->url(), script->patterns()))
+        if (script->injectionTime() == injectionTime && UserContentURLPattern::matchesPatterns(doc->url(), script->whitelist(), script->blacklist()))
             sourceCode.append(ScriptSourceCode(script->source(), script->url()));
     }
     script()->evaluateInIsolatedWorld(worldID, sourceCode);
diff --git a/WebCore/page/PageGroup.cpp b/WebCore/page/PageGroup.cpp
index 210a02a..6b638f1 100644
--- a/WebCore/page/PageGroup.cpp
+++ b/WebCore/page/PageGroup.cpp
@@ -199,12 +199,12 @@ StorageNamespace* PageGroup::localStorage()
 }
 #endif
 
-void PageGroup::addUserScript(const String& source, const KURL& url, const Vector<String>& patterns, 
-                              unsigned worldID, UserScriptInjectionTime injectionTime)
+void PageGroup::addUserScript(const String& source, const KURL& url,  PassOwnPtr<Vector<String> > whitelist,
+                              PassOwnPtr<Vector<String> > blacklist, unsigned worldID, UserScriptInjectionTime injectionTime)
 {
     if (worldID == UINT_MAX)
         return;
-    OwnPtr<UserScript> userScript(new UserScript(source, url, patterns, worldID, injectionTime));
+    OwnPtr<UserScript> userScript(new UserScript(source, url, whitelist, blacklist, worldID, injectionTime));
     if (!m_userScripts)
         m_userScripts.set(new UserScriptMap);
     UserScriptVector*& scriptsInWorld = m_userScripts->add(worldID, 0).first->second;
@@ -213,11 +213,12 @@ void PageGroup::addUserScript(const String& source, const KURL& url, const Vecto
     scriptsInWorld->append(userScript.release());
 }
 
-void PageGroup::addUserStyleSheet(const String& source, const KURL& url, const Vector<String>& patterns, unsigned worldID)
+void PageGroup::addUserStyleSheet(const String& source, const KURL& url, PassOwnPtr<Vector<String> > whitelist,
+                                  PassOwnPtr<Vector<String> > blacklist, unsigned worldID)
 {
     if (worldID == UINT_MAX)
         return;
-    OwnPtr<UserStyleSheet> userStyleSheet(new UserStyleSheet(source, url, patterns, worldID));
+    OwnPtr<UserStyleSheet> userStyleSheet(new UserStyleSheet(source, url, whitelist, blacklist, worldID));
     if (!m_userStyleSheets)
         m_userStyleSheets.set(new UserStyleSheetMap);
     UserStyleSheetVector*& styleSheetsInWorld = m_userStyleSheets->add(worldID, 0).first->second;
@@ -245,8 +246,8 @@ void PageGroup::removeUserContentWithURLForWorld(const KURL& url, unsigned world
             }
             
             if (scripts->isEmpty()) {
-                m_userScripts->remove(it);
                 delete it->second;
+                m_userScripts->remove(it);
             }
         }
     }
@@ -264,8 +265,8 @@ void PageGroup::removeUserContentWithURLForWorld(const KURL& url, unsigned world
             }
             
             if (stylesheets->isEmpty()) {
-                m_userStyleSheets->remove(it);
                 delete it->second;
+                m_userStyleSheets->remove(it);
             }
         }
         
@@ -285,8 +286,8 @@ void PageGroup::removeUserContentForWorld(unsigned worldID)
     if (m_userScripts) {
         UserScriptMap::iterator it = m_userScripts->find(worldID);
         if (it != m_userScripts->end()) {
-            m_userScripts->remove(it);
             delete it->second;
+            m_userScripts->remove(it);
         }
     }
     
@@ -294,9 +295,9 @@ void PageGroup::removeUserContentForWorld(unsigned worldID)
         bool sheetsChanged = false;
         UserStyleSheetMap::iterator it = m_userStyleSheets->find(worldID);
         if (it != m_userStyleSheets->end()) {
+            delete it->second;
             m_userStyleSheets->remove(it);
             sheetsChanged = true;
-            delete it->second;
         }
     
         if (sheetsChanged) {
diff --git a/WebCore/page/PageGroup.h b/WebCore/page/PageGroup.h
index edfc131..7ea2967 100644
--- a/WebCore/page/PageGroup.h
+++ b/WebCore/page/PageGroup.h
@@ -70,11 +70,14 @@ namespace WebCore {
         bool hasLocalStorage() { return m_localStorage; }
 #endif
 
-        void addUserScript(const String& source, const KURL&, const Vector<String>& patterns,
+        void addUserScript(const String& source, const KURL&, 
+                           PassOwnPtr<Vector<String> > whitelist, PassOwnPtr<Vector<String> > blacklist,
                            unsigned worldID, UserScriptInjectionTime);
         const UserScriptMap* userScripts() const { return m_userScripts.get(); }
         
-        void addUserStyleSheet(const String& source, const KURL&, const Vector<String>& patterns, unsigned worldID);
+        void addUserStyleSheet(const String& source, const KURL&,
+                               PassOwnPtr<Vector<String> > whitelist, PassOwnPtr<Vector<String> > blacklist,
+                               unsigned worldID);
         const UserStyleSheetMap* userStyleSheets() const { return m_userStyleSheets.get(); }
         
         void removeUserContentForWorld(unsigned);
diff --git a/WebCore/page/UserContentURLPattern.cpp b/WebCore/page/UserContentURLPattern.cpp
index 1960131..5f0a311 100644
--- a/WebCore/page/UserContentURLPattern.cpp
+++ b/WebCore/page/UserContentURLPattern.cpp
@@ -30,19 +30,33 @@
 
 namespace WebCore {
 
-bool UserContentURLPattern::matchesPatterns(const KURL& url, const Vector<String>& patterns)
+bool UserContentURLPattern::matchesPatterns(const KURL& url, const Vector<String>* whitelist, const Vector<String>* blacklist)
 {
-    // Treat no patterns at all as though a pattern of * was specified.
-    if (patterns.isEmpty())
-        return true;
+    // In order for a URL to be a match it has to be present in the whitelist and not present in the blacklist.
+    // If there is no whitelist at all, then all URLs are assumed to be in the whitelist.
+    bool matchesWhitelist = !whitelist || whitelist->isEmpty();
+    if (!matchesWhitelist) {
+        for (unsigned i = 0; i < whitelist->size(); ++i) {
+            UserContentURLPattern contentPattern(whitelist->at(i));
+            if (contentPattern.matches(url)) {
+                matchesWhitelist = true;
+                break;
+            }
+        }
+    }
 
-    for (unsigned i = 0; i < patterns.size(); ++i) {
-        UserContentURLPattern contentPattern(patterns[i]);
-        if (contentPattern.matches(url))
-            return true;
+    bool matchesBlacklist = false;
+    if (blacklist) {
+        for (unsigned i = 0; i < blacklist->size(); ++i) {
+            UserContentURLPattern contentPattern(blacklist->at(i));
+            if (contentPattern.matches(url)) {
+                matchesBlacklist = true;
+                break;
+            }
+        }
     }
 
-    return false;
+    return matchesWhitelist && !matchesBlacklist;
 }
 
 bool UserContentURLPattern::parse(const String& pattern)
diff --git a/WebCore/page/UserContentURLPattern.h b/WebCore/page/UserContentURLPattern.h
index bc87f55..0b1a248 100644
--- a/WebCore/page/UserContentURLPattern.h
+++ b/WebCore/page/UserContentURLPattern.h
@@ -49,7 +49,7 @@ public:
 
     bool matchSubdomains() const { return m_matchSubdomains; }
     
-    static bool matchesPatterns(const KURL&, const Vector<String>&);
+    static bool matchesPatterns(const KURL&, const Vector<String>* whitelist, const Vector<String>* blacklist);
 
 private:
     bool parse(const String& pattern);
diff --git a/WebCore/page/UserScript.h b/WebCore/page/UserScript.h
index 51031ab..dbbb879 100644
--- a/WebCore/page/UserScript.h
+++ b/WebCore/page/UserScript.h
@@ -29,6 +29,7 @@
 #include "KURL.h"
 #include "UserScriptTypes.h"
 #include <wtf/OwnPtr.h>
+#include <wtf/PassOwnPtr.h>
 #include <wtf/Vector.h>
 
 namespace WebCore {
@@ -36,11 +37,12 @@ namespace WebCore {
 class UserScript {
 public:
     UserScript(const String& source, const KURL& url,
-               const Vector<String>& patterns, unsigned worldID,
-               UserScriptInjectionTime injectionTime)
+               PassOwnPtr<Vector<String> > whitelist, PassOwnPtr<Vector<String> > blacklist,
+               unsigned worldID, UserScriptInjectionTime injectionTime)
         : m_source(source)
         , m_url(url)
-        , m_patterns(patterns)
+        , m_whitelist(whitelist)
+        , m_blacklist(blacklist)
         , m_worldID(worldID)
         , m_injectionTime(injectionTime)
     {
@@ -48,14 +50,16 @@ public:
 
     const String& source() const { return m_source; }
     const KURL& url() const { return m_url; }
-    const Vector<String>& patterns() const { return m_patterns; }
+    const Vector<String>* whitelist() const { return m_whitelist.get(); }
+    const Vector<String>* blacklist() const { return m_blacklist.get(); }
     unsigned worldID() const { return m_worldID; }
     UserScriptInjectionTime injectionTime() const { return m_injectionTime; }
     
 private:
     String m_source;
     KURL m_url;
-    Vector<String> m_patterns;
+    OwnPtr<Vector<String> > m_whitelist;
+    OwnPtr<Vector<String> > m_blacklist;
     unsigned m_worldID;
     UserScriptInjectionTime m_injectionTime;
 };
diff --git a/WebCore/page/UserStyleSheet.h b/WebCore/page/UserStyleSheet.h
index 5ae95c3..56bec40 100644
--- a/WebCore/page/UserStyleSheet.h
+++ b/WebCore/page/UserStyleSheet.h
@@ -29,6 +29,7 @@
 #include "KURL.h"
 #include "UserStyleSheetTypes.h"
 #include <wtf/OwnPtr.h>
+#include <wtf/PassOwnPtr.h>
 #include <wtf/Vector.h>
 
 namespace WebCore {
@@ -36,23 +37,27 @@ namespace WebCore {
 class UserStyleSheet {
 public:
     UserStyleSheet(const String& source, const KURL& url,
-               const Vector<String>& patterns, unsigned worldID)
+                   PassOwnPtr<Vector<String> > whitelist, PassOwnPtr<Vector<String> > blacklist,
+                   unsigned worldID)
         : m_source(source)
         , m_url(url)
-        , m_patterns(patterns)
+        , m_whitelist(whitelist)
+        , m_blacklist(blacklist)
         , m_worldID(worldID)
     {
     }
 
     const String& source() const { return m_source; }
     const KURL& url() const { return m_url; }
-    const Vector<String>& patterns() const { return m_patterns; }
+    const Vector<String>* whitelist() const { return m_whitelist.get(); }
+    const Vector<String>* blacklist() const { return m_blacklist.get(); }
     unsigned worldID() const { return m_worldID; }
 
 private:
     String m_source;
     KURL m_url;
-    Vector<String> m_patterns;
+    OwnPtr<Vector<String> > m_whitelist;
+    OwnPtr<Vector<String> > m_blacklist;
     unsigned m_worldID;
 };
 
diff --git a/WebKit/mac/ChangeLog b/WebKit/mac/ChangeLog
index f7568d0..d00ee08 100644
--- a/WebKit/mac/ChangeLog
+++ b/WebKit/mac/ChangeLog
@@ -1,3 +1,15 @@
+2009-10-02  Dave Hyatt  <hyatt at apple.com>
+
+        Reviewed by Adam Roben.
+
+        Add support for blacklist patterns to user stylesheets and scripts in addition to whitelist patterns.
+
+        * WebView/WebView.mm:
+        (toStringVector):
+        (+[WebView _addUserScriptToGroup:source:url:worldID:whitelist:blacklist:injectionTime:]):
+        (+[WebView _addUserStyleSheetToGroup:source:url:worldID:whitelist:blacklist:]):
+        * WebView/WebViewPrivate.h:
+
 2009-10-01  Mark Rowe  <mrowe at apple.com>
 
         Fix the Tiger build.  Don't unconditionally enable 3D canvas as it is not supported on Tiger.
diff --git a/WebKit/mac/WebView/WebView.mm b/WebKit/mac/WebView/WebView.mm
index aeb6ff3..60f033d 100644
--- a/WebKit/mac/WebView/WebView.mm
+++ b/WebKit/mac/WebView/WebView.mm
@@ -2128,7 +2128,23 @@ static inline IMP getMethod(id o, SEL s)
         _private->page->focusController()->setActive([[self window] isKeyWindow]);
 }
 
-+ (void)_addUserScriptToGroup:(NSString *)groupName source:(NSString *)source url:(NSURL *)url worldID:(unsigned)worldID patterns:(NSArray *)patterns injectionTime:(WebUserScriptInjectionTime)injectionTime
+static PassOwnPtr<Vector<String> > toStringVector(NSArray* patterns)
+{
+    // Convert the patterns into Vectors.
+    NSUInteger count = [patterns count];
+    if (count == 0)
+        return 0;
+    Vector<String>* patternsVector = new Vector<String>;
+    for (NSUInteger i = 0; i < count; ++i) {
+        id entry = [patterns objectAtIndex:i];
+        if ([entry isKindOfClass:[NSString class]])
+            patternsVector->append(String((NSString*)entry));
+    }
+    return patternsVector;
+}
+
++ (void)_addUserScriptToGroup:(NSString *)groupName source:(NSString *)source url:(NSURL *)url worldID:(unsigned)worldID 
+                    whitelist:(NSArray *)whitelist blacklist:(NSArray *)blacklist injectionTime:(WebUserScriptInjectionTime)injectionTime
 {
     String group(groupName);
     if (group.isEmpty() || worldID == UINT_MAX)
@@ -2138,20 +2154,12 @@ static inline IMP getMethod(id o, SEL s)
     if (!pageGroup)
         return;
     
-    // Convert the patterns into a Vector.
-    Vector<String> patternsVector;
-    NSUInteger count = [patterns count];
-    for (NSUInteger i = 0; i < count; ++i) {
-        id entry = [patterns objectAtIndex: i];
-        if ([entry isKindOfClass:[NSString class]])
-            patternsVector.append(String((NSString*)entry));
-    }
-    
-    pageGroup->addUserScript(source, url, patternsVector, worldID, 
+    pageGroup->addUserScript(source, url, toStringVector(whitelist), toStringVector(blacklist), worldID, 
                              injectionTime == WebInjectAtDocumentStart ? InjectAtDocumentStart : InjectAtDocumentEnd);
 }
 
-+ (void)_addUserStyleSheetToGroup:(NSString *)groupName source:(NSString *)source url:(NSURL *)url worldID:(unsigned)worldID patterns:(NSArray *)patterns
++ (void)_addUserStyleSheetToGroup:(NSString *)groupName source:(NSString *)source url:(NSURL *)url worldID:(unsigned)worldID
+                        whitelist:(NSArray *)whitelist blacklist:(NSArray *)blacklist
 {
     String group(groupName);
     if (group.isEmpty() || worldID == UINT_MAX)
@@ -2160,17 +2168,8 @@ static inline IMP getMethod(id o, SEL s)
     PageGroup* pageGroup = PageGroup::pageGroup(group);
     if (!pageGroup)
         return;
-    
-    // Convert the patterns into a Vector.
-    Vector<String> patternsVector;
-    NSUInteger count = [patterns count];
-    for (NSUInteger i = 0; i < count; ++i) {
-        id entry = [patterns objectAtIndex: i];
-        if ([entry isKindOfClass:[NSString class]])
-            patternsVector.append(String((NSString*)entry));
-    }
-    
-    pageGroup->addUserStyleSheet(source, url, patternsVector, worldID);
+
+    pageGroup->addUserStyleSheet(source, url, toStringVector(whitelist), toStringVector(blacklist), worldID);
 }
 
 + (void)_removeUserContentFromGroup:(NSString *)groupName url:(NSURL *)url worldID:(unsigned)worldID
diff --git a/WebKit/mac/WebView/WebViewPrivate.h b/WebKit/mac/WebView/WebViewPrivate.h
index 9346840..730bc41 100644
--- a/WebKit/mac/WebView/WebViewPrivate.h
+++ b/WebKit/mac/WebView/WebViewPrivate.h
@@ -471,8 +471,8 @@ Could be worth adding to the API.
 // Removes all white list entries created with _whiteListAccessFromOrigin.
 + (void)_resetOriginAccessWhiteLists;
 
-+ (void)_addUserScriptToGroup:(NSString *)groupName source:(NSString *)source url:(NSURL *)url worldID:(unsigned)worldID patterns:(NSArray *)patterns injectionTime:(WebUserScriptInjectionTime)injectionTime;
-+ (void)_addUserStyleSheetToGroup:(NSString *)groupName source:(NSString *)source url:(NSURL *)url worldID:(unsigned)worldID patterns:(NSArray *)patterns;
++ (void)_addUserScriptToGroup:(NSString *)groupName source:(NSString *)source url:(NSURL *)url worldID:(unsigned)worldID whitelist:(NSArray *)whitelist blacklist:(NSArray *)blacklist injectionTime:(WebUserScriptInjectionTime)injectionTime;
++ (void)_addUserStyleSheetToGroup:(NSString *)groupName source:(NSString *)source url:(NSURL *)url worldID:(unsigned)worldID whitelist:(NSArray *)whitelist blacklist:(NSArray *)blacklist;
 + (void)_removeUserContentFromGroup:(NSString *)groupName url:(NSURL *)url worldID:(unsigned)worldID;
 + (void)_removeUserContentFromGroup:(NSString *)groupName worldID:(unsigned)worldID;
 + (void)_removeAllUserContentFromGroup:(NSString *)groupName;
diff --git a/WebKit/win/ChangeLog b/WebKit/win/ChangeLog
index c1d4b12..751ac93 100644
--- a/WebKit/win/ChangeLog
+++ b/WebKit/win/ChangeLog
@@ -1,3 +1,16 @@
+2009-10-02  Dave Hyatt  <hyatt at apple.com>
+
+        Reviewed by Adam Roben.
+
+        Add support for blacklist patterns to user stylesheets and scripts in addition to whitelist patterns.
+
+        * Interfaces/IWebViewPrivate.idl:
+        * WebView.cpp:
+        (toStringVector):
+        (WebView::addUserScriptToGroup):
+        (WebView::addUserStyleSheetToGroup):
+        * WebView.h:
+
 2009-10-02  Steve Falkenburg  <sfalken at apple.com>
 
         Reviewed by Mark Rowe.
diff --git a/WebKit/win/Interfaces/IWebViewPrivate.idl b/WebKit/win/Interfaces/IWebViewPrivate.idl
index db61de8..d90740d 100644
--- a/WebKit/win/Interfaces/IWebViewPrivate.idl
+++ b/WebKit/win/Interfaces/IWebViewPrivate.idl
@@ -181,8 +181,13 @@ interface IWebViewPrivate : IUnknown
     HRESULT MIMETypeForExtension([in] BSTR extension, [out, retval] BSTR* mimeType);
 
     // For the following functions, 0 < worldID < UINT_MAX.
-    HRESULT addUserScriptToGroup([in] BSTR groupName, [in] unsigned worldID, [in] BSTR source, [in] BSTR url, [in] unsigned patternsCount, [in, size_is(patternsCount)] BSTR* patterns, [in] WebUserScriptInjectionTime injectionTime);
-    HRESULT addUserStyleSheetToGroup([in] BSTR groupName, [in] unsigned worldID, [in] BSTR source, [in] BSTR url, [in] unsigned patternsCount, [in, size_is(patternsCount)] BSTR* patterns);
+    HRESULT addUserScriptToGroup([in] BSTR groupName, [in] unsigned worldID, [in] BSTR source, [in] BSTR url,
+                                 [in] unsigned whitelistCount, [in, size_is(whitelistCount)] BSTR* whitelist,
+                                 [in] unsigned blacklistCount, [in, size_is(blacklistCount)] BSTR* blacklist,
+                                 [in] WebUserScriptInjectionTime injectionTime);
+    HRESULT addUserStyleSheetToGroup([in] BSTR groupName, [in] unsigned worldID, [in] BSTR source, [in] BSTR url,
+                                     [in] unsigned whitelistCount, [in, size_is(whitelistCount)] BSTR* whitelist,
+                                     [in] unsigned blacklistCount, [in, size_is(blacklistCount)] BSTR* blacklist);
     HRESULT removeUserContentWithURLFromGroup([in] BSTR groupName, [in] unsigned worldID, [in] BSTR url);
     HRESULT removeUserContentFromGroup([in] BSTR groupName, [in] unsigned worldID);
     HRESULT removeAllUserContentFromGroup([in] BSTR groupName);
diff --git a/WebKit/win/WebView.cpp b/WebKit/win/WebView.cpp
index fd97e31..9f7a0cd 100644
--- a/WebKit/win/WebView.cpp
+++ b/WebKit/win/WebView.cpp
@@ -5433,7 +5433,21 @@ HRESULT WebView::setCanStartPlugins(BOOL canStartPlugins)
     return S_OK;
 }
 
-HRESULT WebView::addUserScriptToGroup(BSTR groupName, unsigned worldID, BSTR source, BSTR url, unsigned patternsCount, BSTR* patterns, WebUserScriptInjectionTime injectionTime)
+static PassOwnPtr<Vector<String> > toStringVector(unsigned patternsCount, BSTR* patterns)
+{
+    // Convert the patterns into a Vector.
+    if (patternsCount == 0)
+        return 0;
+    Vector<String>* patternsVector = new Vector<String>;
+    for (unsigned i = 0; i < patternsCount; ++i)
+        patternsVector.append(String(patterns[i], SysStringLen(patterns[i])));
+    return patternsVector;
+}
+
+HRESULT WebView::addUserScriptToGroup(BSTR groupName, unsigned worldID, BSTR source, BSTR url, 
+                                      unsigned whitelistCount, BSTR* whitelist,
+                                      unsigned blacklistCount, BSTR* blacklist,
+                                      WebUserScriptInjectionTime injectionTime)
 {
     String group(groupName, SysStringLen(groupName));
     if (group.isEmpty() || !worldID || worldID == numeric_limits<unsigned>::max())
@@ -5444,18 +5458,16 @@ HRESULT WebView::addUserScriptToGroup(BSTR groupName, unsigned worldID, BSTR sou
     if (!pageGroup)
         return E_FAIL;
 
-    // Convert the patterns into a Vector.
-    Vector<String> patternsVector;
-    for (unsigned i = 0; i < patternsCount; ++i)
-        patternsVector.append(String(patterns[i], SysStringLen(patterns[i])));
-
-    pageGroup->addUserScript(String(source, SysStringLen(source)), KURL(KURL(), String(url, SysStringLen(url))), patternsVector, worldID,
+    pageGroup->addUserScript(String(source, SysStringLen(source)), KURL(KURL(), String(url, SysStringLen(url))),
+                             toStringVector(whitelist), toStringVector(blacklist), worldID,
                              injectionTime == WebInjectAtDocumentStart ? InjectAtDocumentStart : InjectAtDocumentEnd);
 
     return S_OK;
 }
 
-HRESULT WebView::addUserStyleSheetToGroup(BSTR groupName, unsigned worldID, BSTR source, BSTR url, unsigned patternsCount, BSTR* patterns)
+HRESULT WebView::addUserStyleSheetToGroup(BSTR groupName, unsigned worldID, BSTR source, BSTR url
+                                          unsigned whitelistCount, BSTR* whitelist,
+                                          unsigned blacklistCount, BSTR* blacklist)
 {
     String group(groupName, SysStringLen(groupName));
     if (group.isEmpty() || !worldID || worldID == numeric_limits<unsigned>::max())
@@ -5466,12 +5478,8 @@ HRESULT WebView::addUserStyleSheetToGroup(BSTR groupName, unsigned worldID, BSTR
     if (!pageGroup)
         return E_FAIL;
 
-    // Convert the patterns into a Vector.
-    Vector<String> patternsVector;
-    for (unsigned i = 0; i < patternsCount; ++i)
-        patternsVector.append(String(patterns[i], SysStringLen(patterns[i])));
-
-    pageGroup->addUserStyleSheet(String(source, SysStringLen(source)), KURL(KURL(), String(url, SysStringLen(url))), patternsVector, worldID);
+    pageGroup->addUserStyleSheet(String(source, SysStringLen(source)), KURL(KURL(), String(url, SysStringLen(url))),
+                                 toStringVector(whitelist), toStringVector(blacklist), worldID);
 
     return S_OK;
 }
diff --git a/WebKit/win/WebView.h b/WebKit/win/WebView.h
index 3ba30df..f991cdd 100644
--- a/WebKit/win/WebView.h
+++ b/WebKit/win/WebView.h
@@ -740,8 +740,13 @@ public:
     virtual HRESULT STDMETHODCALLTYPE setCanStartPlugins(
         /* [in] */ BOOL canStartPlugins);
 
-    virtual HRESULT STDMETHODCALLTYPE addUserScriptToGroup(BSTR groupName, unsigned worldID, BSTR source, BSTR url, unsigned patternsCount, BSTR* patterns, WebUserScriptInjectionTime);
-    virtual HRESULT STDMETHODCALLTYPE addUserStyleSheetToGroup(BSTR groupName, unsigned worldID, BSTR source, BSTR url, unsigned patternsCount, BSTR* patterns);
+    virtual HRESULT STDMETHODCALLTYPE addUserScriptToGroup(BSTR groupName, unsigned worldID, BSTR source, BSTR url,
+                                                           unsigned whitelistCount, BSTR* whitelist, 
+                                                           unsigned blacklistCount, BSTR* blacklist,
+                                                           WebUserScriptInjectionTime);
+    virtual HRESULT STDMETHODCALLTYPE addUserStyleSheetToGroup(BSTR groupName, unsigned worldID, BSTR source, BSTR url,
+                                                               unsigned whitelistCount, BSTR* whitelist, 
+                                                               unsigned blacklistCount, BSTR* blacklist);
     virtual HRESULT STDMETHODCALLTYPE removeUserContentWithURLFromGroup(BSTR groupName, unsigned worldID, BSTR url);
     virtual HRESULT STDMETHODCALLTYPE removeUserContentFromGroup(BSTR groupName, unsigned worldID);
     virtual HRESULT STDMETHODCALLTYPE removeAllUserContentFromGroup(BSTR groupName);

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list