#include "base/strings/utf_string_conversions.h"
#include "chrome/browser/content_settings/content_settings_utils.h"
#include "chrome/browser/content_settings/host_content_settings_map.h"
-#include "chrome/browser/extensions/extension_renderer_state.h"
#include "chrome/browser/plugins/chrome_plugin_service_filter.h"
#include "chrome/browser/plugins/plugin_finder.h"
#include "chrome/browser/plugins/plugin_metadata.h"
#include "widevine_cdm_version.h" // In SHARED_INTERMEDIATE_DIR.
+#if defined(ENABLE_EXTENSIONS)
+#include "chrome/browser/guest_view/web_view/web_view_renderer_state.h"
+#endif
+
#if defined(OS_WIN)
#include "base/win/metro.h"
#endif
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,
content::BrowserThread::IO));
}
-PluginInfoMessageFilter::Context::Context()
- : render_process_id_(0),
- resource_context_(NULL),
- host_content_settings_map_(NULL) {
-}
-
PluginInfoMessageFilter::Context::~Context() {
}
PluginInfoMessageFilter::PluginInfoMessageFilter(
int render_process_id,
Profile* profile)
- : context_(render_process_id, profile),
+ : BrowserMessageFilter(ChromeMsgStart),
+ context_(render_process_id, profile),
weak_ptr_factory_(this) {
}
-bool PluginInfoMessageFilter::OnMessageReceived(const IPC::Message& message,
- bool* message_was_ok) {
- IPC_BEGIN_MESSAGE_MAP_EX(PluginInfoMessageFilter, message, *message_was_ok)
+bool PluginInfoMessageFilter::OnMessageReceived(const IPC::Message& message) {
+ IPC_BEGIN_MESSAGE_MAP(PluginInfoMessageFilter, message)
IPC_MESSAGE_HANDLER_DELAY_REPLY(ChromeViewHostMsg_GetPluginInfo,
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()
return true;
Send(reply_msg);
}
-void PluginInfoMessageFilter::OnIsInternalPluginRegisteredForMimeType(
+#if defined(ENABLE_PEPPER_CDMS)
+
+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 // defined(ENABLE_PEPPER_CDMS)
+
void PluginInfoMessageFilter::Context::DecidePluginStatus(
const GetPluginInfo_Params& params,
const WebPluginInfo& plugin,
if (plugin.type == WebPluginInfo::PLUGIN_TYPE_NPAPI) {
CHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO));
// NPAPI plugins are not supported inside <webview> guests.
- if (ExtensionRendererState::GetInstance()->IsWebViewRenderer(
- render_process_id_)) {
+#if defined(ENABLE_EXTENSIONS)
+ if (extensions::WebViewRendererState::GetInstance()->IsGuest(
+ render_process_id_)) {
status->value =
ChromeViewHostMsg_GetPluginInfo_Status::kNPAPINotSupported;
return;
}
+#endif
}
ContentSetting plugin_setting = CONTENT_SETTING_DEFAULT;
// the guest. In order to do this, set the status to 'Unauthorized' here,
// and update the status as appropriate depending on the response from the
// embedder.
- if (ExtensionRendererState::GetInstance()->IsWebViewRenderer(
- render_process_id_)) {
+#if defined(ENABLE_EXTENSIONS)
+ if (extensions::WebViewRendererState::GetInstance()->IsGuest(
+ render_process_id_))
status->value = ChromeViewHostMsg_GetPluginInfo_Status::kUnauthorized;
- }
+
+#endif
}
}
policy_url, policy_url, CONTENT_SETTINGS_TYPE_JAVASCRIPT,
std::string(), &info));
} else {
- value.reset(
+ content_settings::SettingInfo specific_info;
+ scoped_ptr<base::Value> specific_setting(
host_content_settings_map_->GetWebsiteSetting(
policy_url, plugin_url, CONTENT_SETTINGS_TYPE_PLUGINS, resource,
- &info));
- if (value.get()) {
- uses_plugin_specific_setting = true;
+ &specific_info));
+ content_settings::SettingInfo general_info;
+ scoped_ptr<base::Value> general_setting(
+ host_content_settings_map_->GetWebsiteSetting(
+ policy_url, plugin_url, CONTENT_SETTINGS_TYPE_PLUGINS,
+ std::string(), &general_info));
+
+ // If there is a plugin-specific setting, we use it, unless the general
+ // setting was set by policy, in which case it takes precedence.
+ uses_plugin_specific_setting = specific_setting &&
+ (general_info.source != content_settings::SETTING_SOURCE_POLICY);
+ if (uses_plugin_specific_setting) {
+ value = specific_setting.Pass();
+ info = specific_info;
} else {
- value.reset(host_content_settings_map_->GetWebsiteSetting(
- policy_url, plugin_url, CONTENT_SETTINGS_TYPE_PLUGINS, std::string(),
- &info));
+ value = general_setting.Pass();
+ info = general_info;
}
}
*setting = content_settings::ValueToContentSetting(value.get());
}
}
+bool PluginInfoMessageFilter::Context::IsPluginEnabled(
+ const content::WebPluginInfo& plugin) const {
+ return plugin_prefs_->IsPluginEnabled(plugin);
+}