Title: [138185] trunk/Source/WebKit2
Revision
138185
Author
jon...@apple.com
Date
2012-12-19 12:01:53 -0800 (Wed, 19 Dec 2012)

Log Message

Notify context client of change to table, and allow client to get a copy of it
https://bugs.webkit.org/show_bug.cgi?id=105364
<rdar://problem/12906267>

Reviewed by Brady Eidson.

Add a callback to notify the context client that the origin hashes have changed.
The client may choose to get a copy of that table and save it to disk.

* UIProcess/API/C/WKContext.cpp:
(WKContextCopyPlugInAutoStartOriginHashes): Added to the context client.
* UIProcess/API/C/WKContext.h:
* UIProcess/WebContext.cpp:
(WebKit::WebContext::plugInAutoStartOriginHashes): Return a copy of the origin hash
table.
* UIProcess/WebContext.h:

* UIProcess/Plugins/PlugInAutoStartProvider.cpp:
(WebKit::PlugInAutoStartProvider::addAutoStartOrigin): When the origin is added to
the table, notify the context client.
(WebKit::PlugInAutoStartProvider::autoStartOriginsTableCopy): Create a copy of the
table.
* UIProcess/Plugins/PlugInAutoStartProvider.h:

* UIProcess/WebContextClient.cpp:
(WebKit::WebContextClient::plugInAutoStartOriginHashesChanged): Call the client.
* UIProcess/WebContextClient.h:

Modified Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (138184 => 138185)


--- trunk/Source/WebKit2/ChangeLog	2012-12-19 19:35:57 UTC (rev 138184)
+++ trunk/Source/WebKit2/ChangeLog	2012-12-19 20:01:53 UTC (rev 138185)
@@ -1,3 +1,33 @@
+2012-12-18  Jon Lee  <jon...@apple.com>
+
+        Notify context client of change to table, and allow client to get a copy of it
+        https://bugs.webkit.org/show_bug.cgi?id=105364
+        <rdar://problem/12906267>
+
+        Reviewed by Brady Eidson.
+
+        Add a callback to notify the context client that the origin hashes have changed.
+        The client may choose to get a copy of that table and save it to disk.
+
+        * UIProcess/API/C/WKContext.cpp:
+        (WKContextCopyPlugInAutoStartOriginHashes): Added to the context client.
+        * UIProcess/API/C/WKContext.h:
+        * UIProcess/WebContext.cpp:
+        (WebKit::WebContext::plugInAutoStartOriginHashes): Return a copy of the origin hash
+        table.
+        * UIProcess/WebContext.h:
+
+        * UIProcess/Plugins/PlugInAutoStartProvider.cpp:
+        (WebKit::PlugInAutoStartProvider::addAutoStartOrigin): When the origin is added to
+        the table, notify the context client.
+        (WebKit::PlugInAutoStartProvider::autoStartOriginsTableCopy): Create a copy of the
+        table.
+        * UIProcess/Plugins/PlugInAutoStartProvider.h:
+
+        * UIProcess/WebContextClient.cpp:
+        (WebKit::WebContextClient::plugInAutoStartOriginHashesChanged): Call the client.
+        * UIProcess/WebContextClient.h:
+
 2012-12-19  Alexis Menard  <ale...@webkit.org>
 
         Implement CSS parsing for CSS transitions unprefixed.

Modified: trunk/Source/WebKit2/UIProcess/API/C/WKContext.cpp (138184 => 138185)


--- trunk/Source/WebKit2/UIProcess/API/C/WKContext.cpp	2012-12-19 19:35:57 UTC (rev 138184)
+++ trunk/Source/WebKit2/UIProcess/API/C/WKContext.cpp	2012-12-19 20:01:53 UTC (rev 138185)
@@ -337,6 +337,11 @@
     toImpl(contextRef)->setUsesNetworkProcess(usesNetworkProcess);
 }
 
+WKDictionaryRef WKContextCopyPlugInAutoStartOriginHashes(WKContextRef contextRef)
+{
+    return toAPI(toImpl(contextRef)->plugInAutoStartOriginHashes().leakRef());
+}
+
 // Deprecated functions.
 void _WKContextSetAdditionalPluginsDirectory(WKContextRef context, WKStringRef pluginsDirectory)
 {

Modified: trunk/Source/WebKit2/UIProcess/API/C/WKContext.h (138184 => 138185)


--- trunk/Source/WebKit2/UIProcess/API/C/WKContext.h	2012-12-19 19:35:57 UTC (rev 138184)
+++ trunk/Source/WebKit2/UIProcess/API/C/WKContext.h	2012-12-19 20:01:53 UTC (rev 138185)
@@ -40,9 +40,12 @@
 typedef uint32_t WKCacheModel;
 
 // Context Client
+typedef void (*WKContextPlugInAutoStartOriginHashesChangedCallback)(WKContextRef context, const void *clientInfo);
+
 struct WKContextClient {
     int                                                                 version;
     const void *                                                        clientInfo;
+    WKContextPlugInAutoStartOriginHashesChangedCallback                 plugInAutoStartOriginHashesChanged;
 };
 typedef struct WKContextClient WKContextClient;
 
@@ -187,6 +190,8 @@
 WK_EXPORT void WKContextGarbageCollectJavaScriptObjects(WKContextRef context);
 WK_EXPORT void WKContextSetJavaScriptGarbageCollectorTimerEnabled(WKContextRef context, bool enable);
 
+WK_EXPORT WKDictionaryRef WKContextCopyPlugInAutoStartOriginHashes(WKContextRef context);
+
 #ifdef __cplusplus
 }
 #endif

Modified: trunk/Source/WebKit2/UIProcess/Plugins/PlugInAutoStartProvider.cpp (138184 => 138185)


--- trunk/Source/WebKit2/UIProcess/Plugins/PlugInAutoStartProvider.cpp	2012-12-19 19:35:57 UTC (rev 138184)
+++ trunk/Source/WebKit2/UIProcess/Plugins/PlugInAutoStartProvider.cpp	2012-12-19 20:01:53 UTC (rev 138185)
@@ -27,6 +27,7 @@
 #include "PlugInAutoStartProvider.h"
 
 #include "WebContext.h"
+#include "WebContextClient.h"
 #include "WebProcessMessages.h"
 
 using namespace WebCore;
@@ -50,6 +51,7 @@
     it->value.add(plugInOriginHash);
     m_autoStartHashes.add(plugInOriginHash);
     m_context->sendToAllProcesses(Messages::WebProcess::DidAddPlugInAutoStartOrigin(plugInOriginHash));
+    m_context->client().plugInAutoStartOriginHashesChanged(m_context);
 }
 
 Vector<unsigned> PlugInAutoStartProvider::autoStartOriginsCopy() const
@@ -59,4 +61,20 @@
     return copyVector;
 }
 
+PassRefPtr<ImmutableDictionary> PlugInAutoStartProvider::autoStartOriginsTableCopy() const
+{
+    ImmutableDictionary::MapType map;
+    AutoStartTable::const_iterator end = m_autoStartTable.end();
+    for (AutoStartTable::const_iterator it = m_autoStartTable.begin(); it != end; ++it) {
+        Vector<RefPtr<APIObject> > hashes;
+        HashSet<unsigned>::iterator valueEnd = it->value.end();
+        for (HashSet<unsigned>::iterator valueIt = it->value.begin(); valueIt != valueEnd; ++valueIt)
+            hashes.append(WebUInt64::create(*valueIt));
+
+        map.set(it->key, ImmutableArray::adopt(hashes));
+    }
+
+    return ImmutableDictionary::adopt(map);
+}
+
 } // namespace WebKit

Modified: trunk/Source/WebKit2/UIProcess/Plugins/PlugInAutoStartProvider.h (138184 => 138185)


--- trunk/Source/WebKit2/UIProcess/Plugins/PlugInAutoStartProvider.h	2012-12-19 19:35:57 UTC (rev 138184)
+++ trunk/Source/WebKit2/UIProcess/Plugins/PlugInAutoStartProvider.h	2012-12-19 20:01:53 UTC (rev 138185)
@@ -33,6 +33,7 @@
 
 namespace WebKit {
 
+class ImmutableDictionary;
 class WebContext;
 
 class PlugInAutoStartProvider {
@@ -41,7 +42,9 @@
     explicit PlugInAutoStartProvider(WebContext*);
 
     void addAutoStartOrigin(const String& pageOrigin, unsigned plugInOriginHash);
+
     Vector<unsigned> autoStartOriginsCopy() const;
+    PassRefPtr<ImmutableDictionary> autoStartOriginsTableCopy() const;
 
 private:
     WebContext* m_context;

Modified: trunk/Source/WebKit2/UIProcess/WebContext.cpp (138184 => 138185)


--- trunk/Source/WebKit2/UIProcess/WebContext.cpp	2012-12-19 19:35:57 UTC (rev 138184)
+++ trunk/Source/WebKit2/UIProcess/WebContext.cpp	2012-12-19 20:01:53 UTC (rev 138185)
@@ -1151,6 +1151,11 @@
     m_plugInAutoStartProvider.addAutoStartOrigin(pageOrigin, plugInOriginHash);
 }
 
+PassRefPtr<ImmutableDictionary> WebContext::plugInAutoStartOriginHashes() const
+{
+    return m_plugInAutoStartProvider.autoStartOriginsTableCopy();
+}
+
 #if ENABLE(CUSTOM_PROTOCOLS)
 void WebContext::registerSchemeForCustomProtocol(const WTF::String& scheme)
 {

Modified: trunk/Source/WebKit2/UIProcess/WebContext.h (138184 => 138185)


--- trunk/Source/WebKit2/UIProcess/WebContext.h	2012-12-19 19:35:57 UTC (rev 138184)
+++ trunk/Source/WebKit2/UIProcess/WebContext.h	2012-12-19 20:01:53 UTC (rev 138185)
@@ -29,6 +29,7 @@
 #include "APIObject.h"
 #include "DownloadProxyMap.h"
 #include "GenericCallback.h"
+#include "ImmutableDictionary.h"
 #include "MessageReceiver.h"
 #include "MessageReceiverMap.h"
 #include "PlugInAutoStartProvider.h"
@@ -257,6 +258,7 @@
 
     void textCheckerStateChanged();
 
+    PassRefPtr<ImmutableDictionary> plugInAutoStartOriginHashes() const;
 
     // Network Process Management
 

Modified: trunk/Source/WebKit2/UIProcess/WebContextClient.cpp (138184 => 138185)


--- trunk/Source/WebKit2/UIProcess/WebContextClient.cpp	2012-12-19 19:35:57 UTC (rev 138184)
+++ trunk/Source/WebKit2/UIProcess/WebContextClient.cpp	2012-12-19 20:01:53 UTC (rev 138185)
@@ -26,6 +26,16 @@
 #include "config.h"
 #include "WebContextClient.h"
 
+#include "WebContext.h"
+
 namespace WebKit {
 
+void WebContextClient::plugInAutoStartOriginHashesChanged(WebContext* context)
+{
+    if (!m_client.plugInAutoStartOriginHashesChanged)
+        return;
+
+    m_client.plugInAutoStartOriginHashesChanged(toAPI(context), m_client.clientInfo);
+}
+
 } // namespace WebKit

Modified: trunk/Source/WebKit2/UIProcess/WebContextClient.h (138184 => 138185)


--- trunk/Source/WebKit2/UIProcess/WebContextClient.h	2012-12-19 19:35:57 UTC (rev 138184)
+++ trunk/Source/WebKit2/UIProcess/WebContextClient.h	2012-12-19 20:01:53 UTC (rev 138185)
@@ -31,7 +31,11 @@
 
 namespace WebKit {
 
+class WebContext;
+
 class WebContextClient : public APIClient<WKContextClient, kWKContextClientCurrentVersion> {
+public:
+    void plugInAutoStartOriginHashesChanged(WebContext*);
 };
 
 } // namespace WebKit
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to