Bug 880735 part B - add .getPluginTagForType and make .getBlocklistStateForType scriptable, r=johns

This commit is contained in:
Benjamin Smedberg 2013-06-24 08:51:07 -04:00
Родитель c82d472dfd
Коммит eb1818d0be
3 изменённых файлов: 35 добавлений и 3 удалений

Просмотреть файл

@ -20,7 +20,7 @@ interface nsIPluginPlayPreviewInfo : nsISupports
readonly attribute AUTF8String redirectURL; readonly attribute AUTF8String redirectURL;
}; };
[scriptable, uuid(15f97490-7bdf-4947-885c-9258072af878)] [scriptable, uuid(e8fe94f0-b877-46d0-931a-090967fb1e83)]
interface nsIPluginHost : nsISupports interface nsIPluginHost : nsISupports
{ {
/** /**
@ -97,9 +97,24 @@ interface nsIPluginHost : nsISupports
ACString getPermissionStringForType(in AUTF8String mimeType); ACString getPermissionStringForType(in AUTF8String mimeType);
/**
* Get the nsIPluginTag for this MIME type. This method works with both
* enabled and disabled/blocklisted plugins, but an enabled plugin will
* always be returned if available.
*
* @throws NS_ERROR_NOT_AVAILABLE if no plugin is available for this MIME
* type.
*/
nsIPluginTag getPluginTagForType(in AUTF8String mimeType);
/** /**
* Get the nsIPluginTag state for this MIME type. * Get the nsIPluginTag state for this MIME type.
*/ */
unsigned long getStateForType(in AUTF8String mimeType); unsigned long getStateForType(in AUTF8String mimeType);
/**
* Get the blocklist state for a MIME type.
*/
uint32_t getBlocklistStateForType(in string aMimeType);
}; };

Просмотреть файл

@ -1051,10 +1051,28 @@ nsPluginHost::PluginExistsForType(const char* aMimeType)
return nullptr != plugin; return nullptr != plugin;
} }
NS_IMETHODIMP
nsPluginHost::GetPluginTagForType(const nsACString& aMimeType,
nsIPluginTag** aResult)
{
nsPluginTag* plugin = FindPluginForType(aMimeType.Data(), true);
if (!plugin) {
plugin = FindPluginForType(aMimeType.Data(), false);
}
if (!plugin) {
return NS_ERROR_NOT_AVAILABLE;
}
NS_ADDREF(*aResult = plugin);
return NS_OK;
}
NS_IMETHODIMP NS_IMETHODIMP
nsPluginHost::GetStateForType(const nsACString &aMimeType, uint32_t* aResult) nsPluginHost::GetStateForType(const nsACString &aMimeType, uint32_t* aResult)
{ {
nsPluginTag *plugin = FindPluginForType(aMimeType.Data(), true); nsPluginTag *plugin = FindPluginForType(aMimeType.Data(), true);
if (!plugin) {
plugin = FindPluginForType(aMimeType.Data(), false);
}
if (!plugin) { if (!plugin) {
return NS_ERROR_UNEXPECTED; return NS_ERROR_UNEXPECTED;
} }
@ -1062,7 +1080,7 @@ nsPluginHost::GetStateForType(const nsACString &aMimeType, uint32_t* aResult)
return plugin->GetEnabledState(aResult); return plugin->GetEnabledState(aResult);
} }
nsresult NS_IMETHODIMP
nsPluginHost::GetBlocklistStateForType(const char *aMimeType, uint32_t *aState) nsPluginHost::GetBlocklistStateForType(const char *aMimeType, uint32_t *aState)
{ {
nsPluginTag *plugin = FindPluginForType(aMimeType, true); nsPluginTag *plugin = FindPluginForType(aMimeType, true);

Просмотреть файл

@ -82,7 +82,6 @@ public:
bool PluginExistsForType(const char* aMimeType); bool PluginExistsForType(const char* aMimeType);
nsresult IsPluginEnabledForExtension(const char* aExtension, const char* &aMimeType); nsresult IsPluginEnabledForExtension(const char* aExtension, const char* &aMimeType);
nsresult GetBlocklistStateForType(const char *aMimeType, uint32_t *state);
nsresult GetPluginCount(uint32_t* aPluginCount); nsresult GetPluginCount(uint32_t* aPluginCount);
nsresult GetPlugins(uint32_t aPluginCount, nsIDOMPlugin** aPluginArray); nsresult GetPlugins(uint32_t aPluginCount, nsIDOMPlugin** aPluginArray);