- Revision
- 138203
- Author
- [email protected]
- Date
- 2012-12-19 16:38:22 -0800 (Wed, 19 Dec 2012)
Log Message
Add a function to set the origin hash table
https://bugs.webkit.org/show_bug.cgi?id=105447
<rdar://problem/12910985>
Reviewed by Brian Weinstein.
Add a new API called WKContextSetPlugInAutoStartOriginHashes. It assigns the table of hashes,
keyed by main frame origin, to the WebContext. That, in turn, notifies all existing web
processes, so that each web process can update its copy of the auto-start hashes.
* UIProcess/API/C/WKContext.cpp:
(WKContextSetPlugInAutoStartOriginHashes): To clear the table, an empty dictionary must be
provided.
* UIProcess/API/C/WKContext.h:
* UIProcess/WebContext.cpp:
(WebKit::WebContext::setPlugInAutoStartOriginHashes): Forward to PlugInAutoStartProvider.
* UIProcess/WebContext.h:
* UIProcess/Plugins/PlugInAutoStartProvider.cpp:
(WebKit::PlugInAutoStartProvider::setAutoStartOriginsTable): Clear the map and set of hashes,
and convert the data from the provided dictionary. Also add it to a temporary vector, which will
be used to pass along to all of the active web processes.
* UIProcess/Plugins/PlugInAutoStartProvider.h:
* WebProcess/WebProcess.messages.in: Add plugInAutoStartOriginsChanged. Takes in a vector of
the new set of hashes.
* WebProcess/WebProcess.cpp:
(WebKit::WebProcess::plugInAutoStartOriginsChanged): Clear the existing set, and copy the new
hashes.
* WebProcess/WebProcess.h:
Modified Paths
Diff
Modified: trunk/Source/WebKit2/ChangeLog (138202 => 138203)
--- trunk/Source/WebKit2/ChangeLog 2012-12-20 00:27:40 UTC (rev 138202)
+++ trunk/Source/WebKit2/ChangeLog 2012-12-20 00:38:22 UTC (rev 138203)
@@ -1,3 +1,37 @@
+2012-12-19 Jon Lee <[email protected]>
+
+ Add a function to set the origin hash table
+ https://bugs.webkit.org/show_bug.cgi?id=105447
+ <rdar://problem/12910985>
+
+ Reviewed by Brian Weinstein.
+
+ Add a new API called WKContextSetPlugInAutoStartOriginHashes. It assigns the table of hashes,
+ keyed by main frame origin, to the WebContext. That, in turn, notifies all existing web
+ processes, so that each web process can update its copy of the auto-start hashes.
+
+ * UIProcess/API/C/WKContext.cpp:
+ (WKContextSetPlugInAutoStartOriginHashes): To clear the table, an empty dictionary must be
+ provided.
+ * UIProcess/API/C/WKContext.h:
+
+ * UIProcess/WebContext.cpp:
+ (WebKit::WebContext::setPlugInAutoStartOriginHashes): Forward to PlugInAutoStartProvider.
+ * UIProcess/WebContext.h:
+
+ * UIProcess/Plugins/PlugInAutoStartProvider.cpp:
+ (WebKit::PlugInAutoStartProvider::setAutoStartOriginsTable): Clear the map and set of hashes,
+ and convert the data from the provided dictionary. Also add it to a temporary vector, which will
+ be used to pass along to all of the active web processes.
+ * UIProcess/Plugins/PlugInAutoStartProvider.h:
+
+ * WebProcess/WebProcess.messages.in: Add plugInAutoStartOriginsChanged. Takes in a vector of
+ the new set of hashes.
+ * WebProcess/WebProcess.cpp:
+ (WebKit::WebProcess::plugInAutoStartOriginsChanged): Clear the existing set, and copy the new
+ hashes.
+ * WebProcess/WebProcess.h:
+
2012-12-18 Jon Lee <[email protected]>
Notify context client of change to table, and allow client to get a copy of it
Modified: trunk/Source/WebKit2/UIProcess/API/C/WKContext.cpp (138202 => 138203)
--- trunk/Source/WebKit2/UIProcess/API/C/WKContext.cpp 2012-12-20 00:27:40 UTC (rev 138202)
+++ trunk/Source/WebKit2/UIProcess/API/C/WKContext.cpp 2012-12-20 00:38:22 UTC (rev 138203)
@@ -342,6 +342,13 @@
return toAPI(toImpl(contextRef)->plugInAutoStartOriginHashes().leakRef());
}
+void WKContextSetPlugInAutoStartOriginHashes(WKContextRef contextRef, WKDictionaryRef dictionaryRef)
+{
+ if (!dictionaryRef)
+ return;
+ toImpl(contextRef)->setPlugInAutoStartOriginHashes(*toImpl(dictionaryRef));
+}
+
// Deprecated functions.
void _WKContextSetAdditionalPluginsDirectory(WKContextRef context, WKStringRef pluginsDirectory)
{
Modified: trunk/Source/WebKit2/UIProcess/API/C/WKContext.h (138202 => 138203)
--- trunk/Source/WebKit2/UIProcess/API/C/WKContext.h 2012-12-20 00:27:40 UTC (rev 138202)
+++ trunk/Source/WebKit2/UIProcess/API/C/WKContext.h 2012-12-20 00:38:22 UTC (rev 138203)
@@ -191,6 +191,7 @@
WK_EXPORT void WKContextSetJavaScriptGarbageCollectorTimerEnabled(WKContextRef context, bool enable);
WK_EXPORT WKDictionaryRef WKContextCopyPlugInAutoStartOriginHashes(WKContextRef context);
+WK_EXPORT void WKContextSetPlugInAutoStartOriginHashes(WKContextRef context, WKDictionaryRef dictionary);
#ifdef __cplusplus
}
Modified: trunk/Source/WebKit2/UIProcess/Plugins/PlugInAutoStartProvider.cpp (138202 => 138203)
--- trunk/Source/WebKit2/UIProcess/Plugins/PlugInAutoStartProvider.cpp 2012-12-20 00:27:40 UTC (rev 138202)
+++ trunk/Source/WebKit2/UIProcess/Plugins/PlugInAutoStartProvider.cpp 2012-12-20 00:38:22 UTC (rev 138203)
@@ -77,4 +77,28 @@
return ImmutableDictionary::adopt(map);
}
+void PlugInAutoStartProvider::setAutoStartOriginsTable(ImmutableDictionary& table)
+{
+ m_autoStartTable.clear();
+ m_autoStartHashes.clear();
+ Vector<unsigned> hashVector;
+
+ ImmutableDictionary::MapType::const_iterator end = table.map().end();
+ for (ImmutableDictionary::MapType::const_iterator it = table.map().begin(); it != end; ++it) {
+ HashSet<unsigned> hashes;
+ ImmutableArray* tableHashes = static_cast<ImmutableArray*>(it->value.get());
+ size_t hashSetSize = tableHashes->size();
+ for (size_t i = 0; i < hashSetSize; ++i) {
+ unsigned hash = static_cast<unsigned>(tableHashes->at<WebUInt64>(i)->value());
+ hashes.add(hash);
+ m_autoStartHashes.add(hash);
+ hashVector.append(hash);
+ }
+
+ m_autoStartTable.add(it->key, hashes);
+ }
+
+ m_context->sendToAllProcesses(Messages::WebProcess::PlugInAutoStartOriginsChanged(hashVector));
+}
+
} // namespace WebKit
Modified: trunk/Source/WebKit2/UIProcess/Plugins/PlugInAutoStartProvider.h (138202 => 138203)
--- trunk/Source/WebKit2/UIProcess/Plugins/PlugInAutoStartProvider.h 2012-12-20 00:27:40 UTC (rev 138202)
+++ trunk/Source/WebKit2/UIProcess/Plugins/PlugInAutoStartProvider.h 2012-12-20 00:38:22 UTC (rev 138203)
@@ -45,6 +45,7 @@
Vector<unsigned> autoStartOriginsCopy() const;
PassRefPtr<ImmutableDictionary> autoStartOriginsTableCopy() const;
+ void setAutoStartOriginsTable(ImmutableDictionary&);
private:
WebContext* m_context;
Modified: trunk/Source/WebKit2/UIProcess/WebContext.cpp (138202 => 138203)
--- trunk/Source/WebKit2/UIProcess/WebContext.cpp 2012-12-20 00:27:40 UTC (rev 138202)
+++ trunk/Source/WebKit2/UIProcess/WebContext.cpp 2012-12-20 00:38:22 UTC (rev 138203)
@@ -1156,6 +1156,11 @@
return m_plugInAutoStartProvider.autoStartOriginsTableCopy();
}
+void WebContext::setPlugInAutoStartOriginHashes(ImmutableDictionary& dictionary)
+{
+ return m_plugInAutoStartProvider.setAutoStartOriginsTable(dictionary);
+}
+
#if ENABLE(CUSTOM_PROTOCOLS)
void WebContext::registerSchemeForCustomProtocol(const WTF::String& scheme)
{
Modified: trunk/Source/WebKit2/UIProcess/WebContext.h (138202 => 138203)
--- trunk/Source/WebKit2/UIProcess/WebContext.h 2012-12-20 00:27:40 UTC (rev 138202)
+++ trunk/Source/WebKit2/UIProcess/WebContext.h 2012-12-20 00:38:22 UTC (rev 138203)
@@ -259,6 +259,7 @@
void textCheckerStateChanged();
PassRefPtr<ImmutableDictionary> plugInAutoStartOriginHashes() const;
+ void setPlugInAutoStartOriginHashes(ImmutableDictionary&);
// Network Process Management
Modified: trunk/Source/WebKit2/WebProcess/WebProcess.cpp (138202 => 138203)
--- trunk/Source/WebKit2/WebProcess/WebProcess.cpp 2012-12-20 00:27:40 UTC (rev 138202)
+++ trunk/Source/WebKit2/WebProcess/WebProcess.cpp 2012-12-20 00:38:22 UTC (rev 138203)
@@ -832,6 +832,13 @@
m_plugInAutoStartOrigins.add(plugInOriginHash);
}
+void WebProcess::plugInAutoStartOriginsChanged(const Vector<unsigned>& hashes)
+{
+ m_plugInAutoStartOrigins.clear();
+ for (size_t i = 0; i < hashes.size(); ++i)
+ didAddPlugInAutoStartOrigin(hashes[i]);
+}
+
static void fromCountedSetToHashMap(TypeCountSet* countedSet, HashMap<String, uint64_t>& map)
{
TypeCountSet::const_iterator end = countedSet->end();
Modified: trunk/Source/WebKit2/WebProcess/WebProcess.h (138202 => 138203)
--- trunk/Source/WebKit2/WebProcess/WebProcess.h 2012-12-20 00:27:40 UTC (rev 138202)
+++ trunk/Source/WebKit2/WebProcess/WebProcess.h 2012-12-20 00:38:22 UTC (rev 138203)
@@ -253,6 +253,7 @@
void allVisitedLinkStateChanged();
void didAddPlugInAutoStartOrigin(unsigned plugInOriginHash);
+ void plugInAutoStartOriginsChanged(const Vector<unsigned>& hashes);
void platformSetCacheModel(CacheModel);
void platformClearResourceCaches(ResourceCachesToClear);
Modified: trunk/Source/WebKit2/WebProcess/WebProcess.messages.in (138202 => 138203)
--- trunk/Source/WebKit2/WebProcess/WebProcess.messages.in 2012-12-20 00:27:40 UTC (rev 138202)
+++ trunk/Source/WebKit2/WebProcess/WebProcess.messages.in 2012-12-20 00:38:22 UTC (rev 138203)
@@ -68,6 +68,7 @@
ClearPluginSiteData(Vector<WTF::String> pluginPaths, Vector<WTF::String> sites, uint64_t flags, uint64_t maxAgeInSeconds, uint64_t callbackID)
#endif
DidAddPlugInAutoStartOrigin(uint32_t hash)
+ PlugInAutoStartOriginsChanged(Vector<uint32_t> hashes)
#if ENABLE(PLUGIN_PROCESS)
PluginProcessCrashed(String pluginProcess, uint32_t processType) DispatchOnConnectionQueue