summaryrefslogtreecommitdiffstats
path: root/src/3rdparty/webkit/WebCore/page/PageGroup.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/3rdparty/webkit/WebCore/page/PageGroup.cpp')
-rw-r--r--src/3rdparty/webkit/WebCore/page/PageGroup.cpp73
1 files changed, 73 insertions, 0 deletions
diff --git a/src/3rdparty/webkit/WebCore/page/PageGroup.cpp b/src/3rdparty/webkit/WebCore/page/PageGroup.cpp
index 5155be1..f9855a7 100644
--- a/src/3rdparty/webkit/WebCore/page/PageGroup.cpp
+++ b/src/3rdparty/webkit/WebCore/page/PageGroup.cpp
@@ -28,6 +28,7 @@
#include "ChromeClient.h"
#include "Document.h"
+#include "Frame.h"
#include "Page.h"
#include "Settings.h"
@@ -66,6 +67,11 @@ PageGroup::PageGroup(Page* page)
addPage(page);
}
+PageGroup::~PageGroup()
+{
+ removeAllUserContent();
+}
+
typedef HashMap<String, PageGroup*> PageGroupMap;
static PageGroupMap* pageGroups = 0;
@@ -193,4 +199,71 @@ StorageNamespace* PageGroup::localStorage()
}
#endif
+void PageGroup::addUserScript(const String& source, const KURL& url, const Vector<String>& patterns,
+ unsigned worldID, UserScriptInjectionTime injectionTime)
+{
+ if (worldID == UINT_MAX)
+ return;
+ OwnPtr<UserScript> userScript(new UserScript(source, url, patterns, worldID, injectionTime));
+ if (!m_userScripts)
+ m_userScripts.set(new UserScriptMap);
+ UserScriptVector*& scriptsInWorld = m_userScripts->add(worldID, 0).first->second;
+ if (!scriptsInWorld)
+ scriptsInWorld = new UserScriptVector;
+ scriptsInWorld->append(userScript.release());
+}
+
+void PageGroup::addUserStyleSheet(const String& source, const KURL& url, const Vector<String>& patterns, unsigned worldID)
+{
+ if (worldID == UINT_MAX)
+ return;
+ OwnPtr<UserStyleSheet> userStyleSheet(new UserStyleSheet(source, url, patterns, worldID));
+ if (!m_userStyleSheets)
+ m_userStyleSheets.set(new UserStyleSheetMap);
+ UserStyleSheetVector*& styleSheetsInWorld = m_userStyleSheets->add(worldID, 0).first->second;
+ if (!styleSheetsInWorld)
+ styleSheetsInWorld = new UserStyleSheetVector;
+ styleSheetsInWorld->append(userStyleSheet.release());
+
+ // Clear our cached sheets and have them just reparse.
+ HashSet<Page*>::const_iterator end = m_pages.end();
+ for (HashSet<Page*>::const_iterator it = m_pages.begin(); it != end; ++it) {
+ for (Frame* frame = (*it)->mainFrame(); frame; frame = frame->tree()->traverseNext())
+ frame->document()->clearPageGroupUserSheets();
+ }
+}
+
+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;
+ }
+ }
+
+ if (m_userStyleSheets) {
+ UserStyleSheetMap::iterator it = m_userStyleSheets->find(worldID);
+ if (it != m_userStyleSheets->end()) {
+ m_userStyleSheets->remove(it);
+ delete it->second;
+ }
+ }
+}
+
+void PageGroup::removeAllUserContent()
+{
+ if (m_userScripts) {
+ deleteAllValues(*m_userScripts);
+ m_userScripts.clear();
+ }
+
+
+ if (m_userStyleSheets) {
+ deleteAllValues(*m_userStyleSheets);
+ m_userStyleSheets.clear();
+ }
+}
+
} // namespace WebCore