summaryrefslogtreecommitdiff
path: root/Source/WebKit2/UIProcess/WebPageGroup.cpp
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@digia.com>2012-10-17 16:21:14 +0200
committerSimon Hausmann <simon.hausmann@digia.com>2012-10-17 16:21:14 +0200
commit8995b83bcbfbb68245f779b64e5517627c6cc6ea (patch)
tree17985605dab9263cc2444bd4d45f189e142cca7c /Source/WebKit2/UIProcess/WebPageGroup.cpp
parentb9c9652036d5e9f1e29c574f40bc73a35c81ace6 (diff)
downloadqtwebkit-8995b83bcbfbb68245f779b64e5517627c6cc6ea.tar.gz
Imported WebKit commit cf4f8fc6f19b0629f51860cb2d4b25e139d07e00 (http://svn.webkit.org/repository/webkit/trunk@131592)
New snapshot that includes the build fixes for Mac OS X 10.6 and earlier as well as the previously cherry-picked changes
Diffstat (limited to 'Source/WebKit2/UIProcess/WebPageGroup.cpp')
-rw-r--r--Source/WebKit2/UIProcess/WebPageGroup.cpp62
1 files changed, 62 insertions, 0 deletions
diff --git a/Source/WebKit2/UIProcess/WebPageGroup.cpp b/Source/WebKit2/UIProcess/WebPageGroup.cpp
index 72588d4d7..0cdbf817d 100644
--- a/Source/WebKit2/UIProcess/WebPageGroup.cpp
+++ b/Source/WebKit2/UIProcess/WebPageGroup.cpp
@@ -26,6 +26,7 @@
#include "config.h"
#include "WebPageGroup.h"
+#include "WebPageGroupProxyMessages.h"
#include "WebPageProxy.h"
#include "WebPreferences.h"
#include <wtf/HashMap.h>
@@ -128,4 +129,65 @@ void WebPageGroup::preferencesDidChange()
}
}
+static Vector<String> toStringVector(ImmutableArray* array)
+{
+ Vector<String> patternVector;
+ if (!array)
+ return patternVector;
+
+ size_t size = array->size();
+ if (!size)
+ return patternVector;
+
+ patternVector.reserveInitialCapacity(size);
+ for (size_t i = 0; i < size; ++i) {
+ WebString* webString = array->at<WebString>(i);
+ ASSERT(webString);
+ patternVector.uncheckedAppend(webString->string());
+ }
+
+ return patternVector;
+}
+
+void WebPageGroup::addUserStyleSheet(const String& source, const String& baseURL, ImmutableArray* whitelist, ImmutableArray* blacklist, WebCore::UserContentInjectedFrames injectedFrames, WebCore::UserStyleLevel level)
+{
+ if (source.isEmpty())
+ return;
+
+ WebCore::UserStyleSheet userStyleSheet = WebCore::UserStyleSheet(source, (baseURL.isEmpty() ? WebCore::blankURL() : WebCore::KURL(WebCore::KURL(), baseURL)), toStringVector(whitelist), toStringVector(blacklist), injectedFrames, level);
+
+ m_data.userStyleSheets.append(userStyleSheet);
+ sendToAllProcessesInGroup(Messages::WebPageGroupProxy::AddUserStyleSheet(userStyleSheet), m_data.pageGroupID);
+}
+
+void WebPageGroup::addUserScript(const String& source, const String& baseURL, ImmutableArray* whitelist, ImmutableArray* blacklist, WebCore::UserContentInjectedFrames injectedFrames, WebCore::UserScriptInjectionTime injectionTime)
+{
+ if (source.isEmpty())
+ return;
+
+ WebCore::UserScript userScript = WebCore::UserScript(source, (baseURL.isEmpty() ? WebCore::blankURL() : WebCore::KURL(WebCore::KURL(), baseURL)), toStringVector(whitelist), toStringVector(blacklist), injectionTime, injectedFrames);
+
+ m_data.userScripts.append(userScript);
+ sendToAllProcessesInGroup(Messages::WebPageGroupProxy::AddUserScript(userScript), m_data.pageGroupID);
+}
+
+void WebPageGroup::removeAllUserStyleSheets()
+{
+ m_data.userStyleSheets.clear();
+ sendToAllProcessesInGroup(Messages::WebPageGroupProxy::RemoveAllUserStyleSheets(), m_data.pageGroupID);
+}
+
+void WebPageGroup::removeAllUserScripts()
+{
+ m_data.userScripts.clear();
+ sendToAllProcessesInGroup(Messages::WebPageGroupProxy::RemoveAllUserScripts(), m_data.pageGroupID);
+}
+
+void WebPageGroup::removeAllUserContent()
+{
+ m_data.userStyleSheets.clear();
+ m_data.userScripts.clear();
+ sendToAllProcessesInGroup(Messages::WebPageGroupProxy::RemoveAllUserContent(), m_data.pageGroupID);
+}
+
} // namespace WebKit