Commit 32fecf3d authored by weinig@apple.com's avatar weinig@apple.com

[WebKit2] Need SPI to determine whether a plug-in is blocked

https://bugs.webkit.org/show_bug.cgi?id=113463

Reviewed by Anders Carlsson.

Add new SPI, WKContextCopyPlugInInfoForBundleIdetifier, to get data about a plug-in,
including whether it is blocked by x-protect.

* UIProcess/WebLoaderClient.cpp:
* UIProcess/API/C/WKAPICast.h:
(WebKit::toWKPluginLoadPolicy):
(WebKit::toPluginModuleLoadPolicy):
Move to a shared location.

* UIProcess/API/C/mac/WKContextPrivateMac.h:
* UIProcess/API/C/mac/WKContextPrivateMac.mm:
(WKContextIsPlugInUpdateAvailable):
(WKPlugInInfoPathKey):
(WKPlugInInfoBundleIdentifierKey):
(WKPlugInInfoVersionKey):
(WKPlugInInfoLoadPolicyKey):
(WKPlugInInfoUpdatePastLastBlockedVersionIsKnownAvailableKey):
(WKContextCopyPlugInInfoForBundleIdetifier):
Add new SPI and dictionary keys.

* UIProcess/Plugins/PluginInfoStore.cpp:
(WebKit::PluginInfoStore::findPluginWithBundleIdentifer):
* UIProcess/Plugins/PluginInfoStore.h:
* UIProcess/Plugins/mac/PluginInfoStoreMac.mm:
(WebKit::PluginInfoStore::findPluginWithBundleIdentifer):
Add function to lookup plug-ins by bundle identifier.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@147052 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent fa7d5440
2013-03-27 Sam Weinig <sam@webkit.org>
[WebKit2] Need SPI to determine whether a plug-in is blocked
https://bugs.webkit.org/show_bug.cgi?id=113463
Reviewed by Anders Carlsson.
Add new SPI, WKContextCopyPlugInInfoForBundleIdetifier, to get data about a plug-in,
including whether it is blocked by x-protect.
* UIProcess/WebLoaderClient.cpp:
* UIProcess/API/C/WKAPICast.h:
(WebKit::toWKPluginLoadPolicy):
(WebKit::toPluginModuleLoadPolicy):
Move to a shared location.
* UIProcess/API/C/mac/WKContextPrivateMac.h:
* UIProcess/API/C/mac/WKContextPrivateMac.mm:
(WKContextIsPlugInUpdateAvailable):
(WKPlugInInfoPathKey):
(WKPlugInInfoBundleIdentifierKey):
(WKPlugInInfoVersionKey):
(WKPlugInInfoLoadPolicyKey):
(WKPlugInInfoUpdatePastLastBlockedVersionIsKnownAvailableKey):
(WKContextCopyPlugInInfoForBundleIdetifier):
Add new SPI and dictionary keys.
* UIProcess/Plugins/PluginInfoStore.cpp:
(WebKit::PluginInfoStore::findPluginWithBundleIdentifer):
* UIProcess/Plugins/PluginInfoStore.h:
* UIProcess/Plugins/mac/PluginInfoStoreMac.mm:
(WebKit::PluginInfoStore::findPluginWithBundleIdentifer):
Add function to lookup plug-ins by bundle identifier.
2013-03-27 Beth Dakin <bdakin@apple.com>
WKBundlePagePrivateMac.h is not being exported
......@@ -30,9 +30,9 @@
#include "CacheModel.h"
#include "FontSmoothingLevel.h"
#include "HTTPCookieAcceptPolicy.h"
#include "PluginModuleInfo.h"
#include "ProcessModel.h"
#include "ResourceCachesToClear.h"
#include "WebGrammarDetail.h"
#include "WKContext.h"
#include "WKCookieManager.h"
#include "WKCredentialTypes.h"
......@@ -42,6 +42,7 @@
#include "WKProtectionSpaceTypes.h"
#include "WKResourceCacheManager.h"
#include "WKSharedAPICast.h"
#include "WebGrammarDetail.h"
#include <WebCore/Credential.h>
#include <WebCore/FrameLoaderTypes.h>
#include <WebCore/ProtectionSpace.h>
......@@ -402,6 +403,36 @@ inline WKStorageBlockingPolicy toAPI(WebCore::SecurityOrigin::StorageBlockingPol
return kWKAllowAllStorage;
}
inline WKPluginLoadPolicy toWKPluginLoadPolicy(PluginModuleLoadPolicy pluginModuleLoadPolicy)
{
switch (pluginModuleLoadPolicy) {
case PluginModuleLoadNormally:
return kWKPluginLoadPolicyLoadNormally;
case PluginModuleBlocked:
return kWKPluginLoadPolicyBlocked;
case PluginModuleInactive:
return kWKPluginLoadPolicyInactive;
}
ASSERT_NOT_REACHED();
return kWKPluginLoadPolicyBlocked;
}
inline PluginModuleLoadPolicy toPluginModuleLoadPolicy(WKPluginLoadPolicy pluginLoadPolicy)
{
switch (pluginLoadPolicy) {
case kWKPluginLoadPolicyLoadNormally:
return PluginModuleLoadNormally;
case kWKPluginLoadPolicyBlocked:
return PluginModuleBlocked;
case kWKPluginLoadPolicyInactive:
return PluginModuleInactive;
}
ASSERT_NOT_REACHED();
return PluginModuleBlocked;
}
inline ProxyingRefPtr<WebGrammarDetail> toAPI(const WebCore::GrammarDetail& grammarDetail)
{
return ProxyingRefPtr<WebGrammarDetail>(WebGrammarDetail::create(grammarDetail));
......
......@@ -37,6 +37,24 @@ WK_EXPORT void WKContextSetProcessSuppressionEnabled(WKContextRef context, bool
WK_EXPORT bool WKContextIsPlugInUpdateAvailable(WKContextRef context, WKStringRef plugInBundleIdentifier);
/* Value type: WKStringRef */
WK_EXPORT WKStringRef WKPlugInInfoPathKey();
/* Value type: WKStringRef */
WK_EXPORT WKStringRef WKPlugInInfoBundleIdentifierKey();
/* Value type: WKStringRef */
WK_EXPORT WKStringRef WKPlugInInfoVersionKey();
/* Value type: WKUInt64Ref */
WK_EXPORT WKStringRef WKPlugInInfoLoadPolicyKey();
/* Value type: WKBooleanRef */
WK_EXPORT WKStringRef WKPlugInInfoUpdatePastLastBlockedVersionIsKnownAvailableKey();
WK_EXPORT WKDictionaryRef WKContextCopyPlugInInfoForBundleIdentifier(WKContextRef context, WKStringRef plugInBundleIdentifier);
#ifdef __cplusplus
}
#endif
......
......@@ -26,9 +26,15 @@
#import "config.h"
#import "WKContextPrivateMac.h"
#import "ImmutableDictionary.h"
#import "PluginInfoStore.h"
#import "StringUtilities.h"
#import "WKAPICast.h"
#import "WKSharedAPICast.h"
#import "WKStringCF.h"
#import "WebContext.h"
#import "WebNumber.h"
#import "WebString.h"
#import <WebKitSystemInterface.h>
#import <wtf/RetainPtr.h>
......@@ -44,7 +50,54 @@ void WKContextSetProcessSuppressionEnabled(WKContextRef contextRef, bool enabled
toImpl(contextRef)->setProcessSuppressionEnabled(enabled);
}
bool WKContextIsPlugInUpdateAvailable(WKContextRef context, WKStringRef plugInBundleIdentifier)
bool WKContextIsPlugInUpdateAvailable(WKContextRef contextRef, WKStringRef plugInBundleIdentifierRef)
{
return WKIsPluginUpdateAvailable((NSString *)adoptCF(WKStringCopyCFString(kCFAllocatorDefault, plugInBundleIdentifier)).get());
return WKIsPluginUpdateAvailable((NSString *)adoptCF(WKStringCopyCFString(kCFAllocatorDefault, plugInBundleIdentifierRef)).get());
}
WKStringRef WKPlugInInfoPathKey()
{
static WebString* key = WebString::createFromUTF8String("WKPlugInInfoPath").leakRef();
return toAPI(key);
}
WKStringRef WKPlugInInfoBundleIdentifierKey()
{
static WebString* key = WebString::createFromUTF8String("WKPlugInInfoBundleIdentifier").leakRef();
return toAPI(key);
}
WKStringRef WKPlugInInfoVersionKey()
{
static WebString* key = WebString::createFromUTF8String("WKPlugInInfoVersion").leakRef();
return toAPI(key);
}
WKStringRef WKPlugInInfoLoadPolicyKey()
{
static WebString* key = WebString::createFromUTF8String("WKPlugInInfoLoadPolicy").leakRef();
return toAPI(key);
}
WKStringRef WKPlugInInfoUpdatePastLastBlockedVersionIsKnownAvailableKey()
{
static WebString* key = WebString::createFromUTF8String("WKPlugInInfoUpdatePastLastBlockedVersionIsKnownAvailable").leakRef();
return toAPI(key);
}
WKDictionaryRef WKContextCopyPlugInInfoForBundleIdentifier(WKContextRef contextRef, WKStringRef plugInBundleIdentifierRef)
{
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));
map.set(toWTFString(WKPlugInInfoVersionKey()), WebString::create(info.versionString));
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());
}
......@@ -190,6 +190,13 @@ String PluginInfoStore::getMIMETypeForExtension(const String& extension)
{
return MIMETypeRegistry::getMIMETypeForExtension(extension);
}
PluginModuleInfo PluginInfoStore::findPluginWithBundleIdentifier(const String&)
{
ASSERT_NOT_REACHED();
return PluginModuleInfo();
}
#endif
PluginModuleInfo PluginInfoStore::findPlugin(String& mimeType, const KURL& url)
......
......@@ -62,7 +62,10 @@ public:
// If the MIME type is null, the file extension of the given url will be used to infer the
// plug-in type. In that case, mimeType will be filled in with the right MIME type.
PluginModuleInfo findPlugin(String& mimeType, const WebCore::KURL&);
// Returns the info for the plug-in with the given bundle identifier.
PluginModuleInfo findPluginWithBundleIdentifier(const String& bundleIdentifier);
// Returns the info for the plug-in with the given path.
PluginModuleInfo infoForPluginWithPath(const String& pluginPath) const;
......
......@@ -171,6 +171,18 @@ String PluginInfoStore::getMIMETypeForExtension(const String& extension)
return WKGetMIMETypeForExtension((NSString *)extensionCFString.get());
}
PluginModuleInfo PluginInfoStore::findPluginWithBundleIdentifier(const String& bundleIdentifier)
{
loadPluginsIfNecessary();
for (size_t i = 0; i < m_plugins.size(); ++i) {
if (m_plugins[i].bundleIdentifier == bundleIdentifier)
return m_plugins[i];
}
return PluginModuleInfo();
}
} // namespace WebKit
#endif // ENABLE(NETSCAPE_PLUGIN_API)
......@@ -299,36 +299,6 @@ void WebLoaderClient::didBlockInsecurePluginVersion(WebPageProxy* page, const St
}
}
static inline WKPluginLoadPolicy toWKPluginLoadPolicy(PluginModuleLoadPolicy pluginModuleLoadPolicy)
{
switch (pluginModuleLoadPolicy) {
case PluginModuleLoadNormally:
return kWKPluginLoadPolicyLoadNormally;
case PluginModuleBlocked:
return kWKPluginLoadPolicyBlocked;
case PluginModuleInactive:
return kWKPluginLoadPolicyInactive;
}
ASSERT_NOT_REACHED();
return kWKPluginLoadPolicyBlocked;
}
static inline PluginModuleLoadPolicy toPluginModuleLoadPolicy(WKPluginLoadPolicy pluginLoadPolicy)
{
switch (pluginLoadPolicy) {
case kWKPluginLoadPolicyLoadNormally:
return PluginModuleLoadNormally;
case kWKPluginLoadPolicyBlocked:
return PluginModuleBlocked;
case kWKPluginLoadPolicyInactive:
return PluginModuleInactive;
}
ASSERT_NOT_REACHED();
return PluginModuleBlocked;
}
PluginModuleLoadPolicy WebLoaderClient::pluginLoadPolicy(WebPageProxy* page, const String& pluginBundleIdentifier, const String& pluginBundleVersion, const String& displayName, const String& frameURLString, const String& pageURLString, PluginModuleLoadPolicy currentPluginLoadPolicy)
{
if (!m_client.pluginLoadPolicy)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment