diff --git a/dom/plugins/base/nsIPluginHost.idl b/dom/plugins/base/nsIPluginHost.idl index d0c90c12647d..6a4310f372d5 100644 --- a/dom/plugins/base/nsIPluginHost.idl +++ b/dom/plugins/base/nsIPluginHost.idl @@ -20,7 +20,7 @@ interface nsIPluginPlayPreviewInfo : nsISupports readonly attribute AUTF8String redirectURL; }; -[scriptable, uuid(15f97490-7bdf-4947-885c-9258072af878)] +[scriptable, uuid(e8fe94f0-b877-46d0-931a-090967fb1e83)] interface nsIPluginHost : nsISupports { /** @@ -97,9 +97,24 @@ interface nsIPluginHost : nsISupports 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. */ unsigned long getStateForType(in AUTF8String mimeType); + + /** + * Get the blocklist state for a MIME type. + */ + uint32_t getBlocklistStateForType(in string aMimeType); }; diff --git a/dom/plugins/base/nsPluginHost.cpp b/dom/plugins/base/nsPluginHost.cpp index 09f9975a80d0..8998ed7ff9df 100644 --- a/dom/plugins/base/nsPluginHost.cpp +++ b/dom/plugins/base/nsPluginHost.cpp @@ -1051,10 +1051,28 @@ nsPluginHost::PluginExistsForType(const char* aMimeType) 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 nsPluginHost::GetStateForType(const nsACString &aMimeType, uint32_t* aResult) { nsPluginTag *plugin = FindPluginForType(aMimeType.Data(), true); + if (!plugin) { + plugin = FindPluginForType(aMimeType.Data(), false); + } if (!plugin) { return NS_ERROR_UNEXPECTED; } @@ -1062,7 +1080,7 @@ nsPluginHost::GetStateForType(const nsACString &aMimeType, uint32_t* aResult) return plugin->GetEnabledState(aResult); } -nsresult +NS_IMETHODIMP nsPluginHost::GetBlocklistStateForType(const char *aMimeType, uint32_t *aState) { nsPluginTag *plugin = FindPluginForType(aMimeType, true); diff --git a/dom/plugins/base/nsPluginHost.h b/dom/plugins/base/nsPluginHost.h index e02fb5b5791b..066c9ce85419 100644 --- a/dom/plugins/base/nsPluginHost.h +++ b/dom/plugins/base/nsPluginHost.h @@ -82,7 +82,6 @@ public: bool PluginExistsForType(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 GetPlugins(uint32_t aPluginCount, nsIDOMPlugin** aPluginArray);