Commit 4cbbeb41 authored by xhwang@chromium.org's avatar xhwang@chromium.org

Check whether the plugin is disabled in OnIsInternalPluginRegisteredForMimeType().

BUG=395294
TEST=Manually tested disabling the plugin and canPlayType() returns "".
R=ddorwin@chromium.org

Review URL: https://codereview.chromium.org/399063004

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@284753 0039d316-1c4b-4281-b951-d872f2087c98
parent 6e8974bf
......@@ -62,6 +62,29 @@ bool ShouldUseJavaScriptSettingForPlugin(const WebPluginInfo& plugin) {
return false;
}
#if defined(ENABLE_PEPPER_CDMS)
enum PluginAvailabilityStatusForUMA {
PLUGIN_NOT_REGISTERED,
PLUGIN_AVAILABLE,
PLUGIN_DISABLED,
PLUGIN_AVAILABILITY_STATUS_MAX
};
static void SendPluginAvailabilityUMA(const std::string& mime_type,
PluginAvailabilityStatusForUMA status) {
#if defined(WIDEVINE_CDM_AVAILABLE)
// Only report results for Widevine CDM.
if (mime_type != kWidevineCdmPluginMimeType)
return;
UMA_HISTOGRAM_ENUMERATION("Plugin.AvailabilityStatus.WidevineCdm",
status, PLUGIN_AVAILABILITY_STATUS_MAX);
#endif // defined(WIDEVINE_CDM_AVAILABLE)
}
#endif // defined(ENABLE_PEPPER_CDMS)
} // namespace
PluginInfoMessageFilter::Context::Context(int render_process_id,
......@@ -99,8 +122,8 @@ bool PluginInfoMessageFilter::OnMessageReceived(const IPC::Message& message) {
OnGetPluginInfo)
#if defined(ENABLE_PEPPER_CDMS)
IPC_MESSAGE_HANDLER(
ChromeViewHostMsg_IsInternalPluginRegisteredForMimeType,
OnIsInternalPluginRegisteredForMimeType)
ChromeViewHostMsg_IsInternalPluginAvailableForMimeType,
OnIsInternalPluginAvailableForMimeType)
#endif
IPC_MESSAGE_UNHANDLED(return false)
IPC_END_MESSAGE_MAP()
......@@ -170,29 +193,42 @@ void PluginInfoMessageFilter::PluginsLoaded(
}
#if defined(ENABLE_PEPPER_CDMS)
void PluginInfoMessageFilter::OnIsInternalPluginRegisteredForMimeType(
void PluginInfoMessageFilter::OnIsInternalPluginAvailableForMimeType(
const std::string& mime_type,
bool* is_registered,
bool* is_available,
std::vector<base::string16>* additional_param_names,
std::vector<base::string16>* additional_param_values) {
std::vector<WebPluginInfo> plugins;
PluginService::GetInstance()->GetInternalPlugins(&plugins);
bool is_plugin_disabled = false;
for (size_t i = 0; i < plugins.size(); ++i) {
const WebPluginInfo& plugin = plugins[i];
const std::vector<content::WebPluginMimeType>& mime_types =
plugins[i].mime_types;
plugin.mime_types;
for (size_t j = 0; j < mime_types.size(); ++j) {
if (mime_types[j].mime_type == mime_type) {
*is_registered = true;
if (!context_.IsPluginEnabled(plugin)) {
is_plugin_disabled = true;
break;
}
*is_available = true;
*additional_param_names = mime_types[j].additional_param_names;
*additional_param_values = mime_types[j].additional_param_values;
SendPluginAvailabilityUMA(mime_type, PLUGIN_AVAILABLE);
return;
}
}
}
*is_registered = false;
*is_available = false;
SendPluginAvailabilityUMA(
mime_type, is_plugin_disabled ? PLUGIN_DISABLED : PLUGIN_NOT_REGISTERED);
}
#endif
#endif // defined(ENABLE_PEPPER_CDMS)
void PluginInfoMessageFilter::Context::DecidePluginStatus(
const GetPluginInfo_Params& params,
......@@ -403,3 +439,7 @@ void PluginInfoMessageFilter::Context::MaybeGrantAccess(
}
}
bool PluginInfoMessageFilter::Context::IsPluginEnabled(
const content::WebPluginInfo& plugin) const {
return plugin_prefs_->IsPluginEnabled(plugin);
}
......@@ -63,6 +63,7 @@ class PluginInfoMessageFilter : public content::BrowserMessageFilter {
bool* is_managed) const;
void MaybeGrantAccess(const ChromeViewHostMsg_GetPluginInfo_Status& status,
const base::FilePath& path) const;
bool IsPluginEnabled(const content::WebPluginInfo& plugin) const;
private:
int render_process_id_;
......@@ -100,15 +101,16 @@ class PluginInfoMessageFilter : public content::BrowserMessageFilter {
const std::vector<content::WebPluginInfo>& plugins);
#if defined(ENABLE_PEPPER_CDMS)
// Returns whether any internal plugin supporting |mime_type| is registered.
// Does not determine whether the plugin can actually be instantiated
// (e.g. whether it is allowed or has all its dependencies).
// When the returned *|is_registered| is true, |additional_param_names| and
// Returns whether any internal plugin supporting |mime_type| is registered
// and enabled. Does not determine whether the plugin can actually be
// instantiated (e.g. whether it has all its dependencies).
// When the returned *|is_available| is true, |additional_param_names| and
// |additional_param_values| contain the name-value pairs, if any, specified
// for the *first* plugin found that is registered for |mime_type|.
void OnIsInternalPluginRegisteredForMimeType(
// for the *first* non-disabled plugin found that is registered for
// |mime_type|.
void OnIsInternalPluginAvailableForMimeType(
const std::string& mime_type,
bool* is_registered,
bool* is_available,
std::vector<base::string16>* additional_param_names,
std::vector<base::string16>* additional_param_values);
#endif
......
......@@ -430,16 +430,16 @@ IPC_SYNC_MESSAGE_CONTROL4_1(ChromeViewHostMsg_GetPluginInfo,
ChromeViewHostMsg_GetPluginInfo_Output /* output */)
#if defined(ENABLE_PEPPER_CDMS)
// Returns whether any internal plugin supporting |mime_type| is registered
// Does not determine whether the plugin can actually be instantiated
// (e.g. whether it is allowed or has all its dependencies).
// When the returned *|is_registered| is true, |additional_param_names| and
// Returns whether any internal plugin supporting |mime_type| is registered and
// enabled. Does not determine whether the plugin can actually be instantiated
// (e.g. whether it has all its dependencies).
// When the returned *|is_available| is true, |additional_param_names| and
// |additional_param_values| contain the name-value pairs, if any, specified
// for the *first* plugin found that is registered for |mime_type|.
// for the *first* non-disabled plugin found that is registered for |mime_type|.
IPC_SYNC_MESSAGE_CONTROL1_3(
ChromeViewHostMsg_IsInternalPluginRegisteredForMimeType,
ChromeViewHostMsg_IsInternalPluginAvailableForMimeType,
std::string /* mime_type */,
bool /* registered */,
bool /* is_available */,
std::vector<base::string16> /* additional_param_names */,
std::vector<base::string16> /* additional_param_values */)
#endif
......
......@@ -32,19 +32,19 @@ using content::KeySystemInfo;
using content::SupportedCodecs;
#if defined(ENABLE_PEPPER_CDMS)
static bool IsPepperCdmRegistered(
static bool IsPepperCdmAvailable(
const std::string& pepper_type,
std::vector<base::string16>* additional_param_names,
std::vector<base::string16>* additional_param_values) {
bool is_registered = false;
bool is_available = false;
content::RenderThread::Get()->Send(
new ChromeViewHostMsg_IsInternalPluginRegisteredForMimeType(
new ChromeViewHostMsg_IsInternalPluginAvailableForMimeType(
pepper_type,
&is_registered,
&is_available,
additional_param_names,
additional_param_values));
return is_registered;
return is_available;
}
// External Clear Key (used for testing).
......@@ -65,7 +65,7 @@ static void AddExternalClearKey(
std::vector<base::string16> additional_param_names;
std::vector<base::string16> additional_param_values;
if (!IsPepperCdmRegistered(kExternalClearKeyPepperType,
if (!IsPepperCdmAvailable(kExternalClearKeyPepperType,
&additional_param_names,
&additional_param_values)) {
return;
......@@ -141,7 +141,7 @@ static void AddPepperBasedWidevine(
std::vector<base::string16> additional_param_names;
std::vector<base::string16> additional_param_values;
if (!IsPepperCdmRegistered(kWidevineCdmPluginMimeType,
if (!IsPepperCdmAvailable(kWidevineCdmPluginMimeType,
&additional_param_names,
&additional_param_values)) {
DVLOG(1) << "Widevine CDM is not currently available.";
......
......@@ -22020,6 +22020,17 @@ Therefore, the affected-histogram name has to have at least one dot in it.
</summary>
</histogram>
<histogram name="Plugin.AvailabilityStatus.WidevineCdm"
enum="PluginAvailabilityStatus">
<owner>xhwang@chromium.org</owner>
<summary>
The availability status of Widevine CDM. In normal cases, this is reported
per render process if EME API is used. This is not reported if EME API is
not used. This could be reported multiple times per render process until
PLUGIN_AVAILABLE is reported (which should be a rare case).
</summary>
</histogram>
<histogram name="Plugin.FlashNavigateUsage" enum="FlashNavigateUsageType">
<owner>Please list the metric's owners. Add more owner tags as needed.</owner>
<summary>Record usage of PPB_Flash.Navigate() Pepper API.</summary>
......@@ -44578,6 +44589,12 @@ Therefore, the affected-histogram name has to have at least one dot in it.
<int value="16" label="I/O"/>
</enum>
<enum name="PluginAvailabilityStatus" type="int">
<int value="0" label="PLUGIN_NOT_REGISTERED"/>
<int value="1" label="PLUGIN_AVAILABLE"/>
<int value="2" label="PLUGIN_DISABLED"/>
</enum>
<enum name="PluginLoadResult" type="int">
<int value="0" label="LOAD_SUCCESS"/>
<int value="1" label="LOAD_FAILED"/>
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