Title: [149701] trunk/Source/WebKit2
Revision
149701
Author
[email protected]
Date
2013-05-07 17:11:19 -0700 (Tue, 07 May 2013)

Log Message

Add SPI to get an array of all the installed plug-ins
https://bugs.webkit.org/show_bug.cgi?id=115688

Reviewed by Anders Carlsson.

* UIProcess/API/C/mac/WKContextPrivateMac.h:
* UIProcess/API/C/mac/WKContextPrivateMac.mm:
(createInfoDictionary):
Extract creation of info dictionary into helper.
(WKContextCopyPlugInInfoForBundleIdentifier):
Modified to use the new helper.
(WKContextGetInfoForInstalledPlugIns):
Added.

Modified Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (149700 => 149701)


--- trunk/Source/WebKit2/ChangeLog	2013-05-07 23:07:14 UTC (rev 149700)
+++ trunk/Source/WebKit2/ChangeLog	2013-05-08 00:11:19 UTC (rev 149701)
@@ -1,3 +1,19 @@
+2013-05-06  Sam Weinig  <[email protected]>
+
+        Add SPI to get an array of all the installed plug-ins
+        https://bugs.webkit.org/show_bug.cgi?id=115688
+
+        Reviewed by Anders Carlsson.
+
+        * UIProcess/API/C/mac/WKContextPrivateMac.h:
+        * UIProcess/API/C/mac/WKContextPrivateMac.mm:
+        (createInfoDictionary):
+        Extract creation of info dictionary into helper.
+        (WKContextCopyPlugInInfoForBundleIdentifier):
+        Modified to use the new helper.
+        (WKContextGetInfoForInstalledPlugIns):
+        Added.
+
 2013-05-07  Anders Carlsson  <[email protected]>
 
         Clean up KeyframeValueList and related classes

Modified: trunk/Source/WebKit2/UIProcess/API/C/mac/WKContextPrivateMac.h (149700 => 149701)


--- trunk/Source/WebKit2/UIProcess/API/C/mac/WKContextPrivateMac.h	2013-05-07 23:07:14 UTC (rev 149700)
+++ trunk/Source/WebKit2/UIProcess/API/C/mac/WKContextPrivateMac.h	2013-05-08 00:11:19 UTC (rev 149701)
@@ -55,6 +55,9 @@
 
 WK_EXPORT WKDictionaryRef WKContextCopyPlugInInfoForBundleIdentifier(WKContextRef context, WKStringRef plugInBundleIdentifier);
 
+typedef void (^WKContextGetInfoForInstalledPlugInsBlock)(WKArrayRef, WKErrorRef);
+WK_EXPORT void WKContextGetInfoForInstalledPlugIns(WKContextRef context, WKContextGetInfoForInstalledPlugInsBlock block);
+
 #ifdef __cplusplus
 }
 #endif

Modified: trunk/Source/WebKit2/UIProcess/API/C/mac/WKContextPrivateMac.mm (149700 => 149701)


--- trunk/Source/WebKit2/UIProcess/API/C/mac/WKContextPrivateMac.mm	2013-05-07 23:07:14 UTC (rev 149700)
+++ trunk/Source/WebKit2/UIProcess/API/C/mac/WKContextPrivateMac.mm	2013-05-08 00:11:19 UTC (rev 149701)
@@ -26,6 +26,7 @@
 #import "config.h"
 #import "WKContextPrivateMac.h"
 
+#import "ImmutableArray.h"
 #import "ImmutableDictionary.h"
 #import "PluginInfoStore.h"
 #import "StringUtilities.h"
@@ -86,12 +87,8 @@
     return toAPI(key);
 }
 
-WKDictionaryRef WKContextCopyPlugInInfoForBundleIdentifier(WKContextRef contextRef, WKStringRef plugInBundleIdentifierRef)
+static PassRefPtr<ImmutableDictionary> createInfoDictionary(const PluginModuleInfo& info)
 {
-    PluginModuleInfo info = toImpl(contextRef)->pluginInfoStore().findPluginWithBundleIdentifier(toWTFString(plugInBundleIdentifierRef));
-    if (info.path.isNull())
-        return 0;
-
     ImmutableDictionary::MapType map;
     map.set(toWTFString(WKPlugInInfoPathKey()), WebString::create(info.path));
     map.set(toWTFString(WKPlugInInfoBundleIdentifierKey()), WebString::create(info.bundleIdentifier));
@@ -99,5 +96,33 @@
     map.set(toWTFString(WKPlugInInfoLoadPolicyKey()), WebUInt64::create(toWKPluginLoadPolicy(PluginInfoStore::policyForPlugin(info))));
     map.set(toWTFString(WKPlugInInfoUpdatePastLastBlockedVersionIsKnownAvailableKey()), WebBoolean::create(WKIsPluginUpdateAvailable(nsStringFromWebCoreString(info.bundleIdentifier))));
 
-    return toAPI(ImmutableDictionary::adopt(map).leakRef());
+    return ImmutableDictionary::adopt(map);
 }
+
+WKDictionaryRef WKContextCopyPlugInInfoForBundleIdentifier(WKContextRef contextRef, WKStringRef plugInBundleIdentifierRef)
+{
+    PluginModuleInfo plugin = toImpl(contextRef)->pluginInfoStore().findPluginWithBundleIdentifier(toWTFString(plugInBundleIdentifierRef));
+    if (plugin.path.isNull())
+        return 0;
+
+    RefPtr<ImmutableDictionary> dictionary = createInfoDictionary(plugin);
+    return toAPI(dictionary.release().leakRef());
+}
+
+void WKContextGetInfoForInstalledPlugIns(WKContextRef contextRef, WKContextGetInfoForInstalledPlugInsBlock block)
+{
+    Vector<PluginModuleInfo> plugins = toImpl(contextRef)->pluginInfoStore().plugins();
+
+    Vector<RefPtr<APIObject>> pluginInfoDictionaries;
+    for (const auto& plugin: plugins)
+        pluginInfoDictionaries.append(createInfoDictionary(plugin));
+
+    RefPtr<ImmutableArray> array = ImmutableArray::adopt(pluginInfoDictionaries);
+
+    toImpl(contextRef)->ref();
+    dispatch_async(dispatch_get_main_queue(), ^() {
+        block(toAPI(array.get()), 0);
+    
+        toImpl(contextRef)->deref();
+    });
+}
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to