#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 "chrome/browser/plugins/plugin_prefs.h"
#include "chrome/browser/profiles/profile.h"
-#include "chrome/common/chrome_content_client.h"
-#include "chrome/common/content_settings.h"
#include "chrome/common/pref_names.h"
#include "chrome/common/render_messages.h"
+#include "components/content_settings/core/common/content_settings.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/plugin_service.h"
#include "content/public/browser/plugin_service_filter.h"
#include "widevine_cdm_version.h" // In SHARED_INTERMEDIATE_DIR.
+#if defined(ENABLE_EXTENSIONS)
+#include "extensions/browser/guest_view/web_view/web_view_renderer_state.h"
+#endif
+
#if defined(OS_WIN)
#include "base/win/metro.h"
#endif
+#if !defined(DISABLE_NACL)
+#include "components/nacl/common/nacl_constants.h"
+#endif
+
using content::PluginService;
using content::WebPluginInfo;
return false;
}
+#if !defined(DISABLE_NACL)
// Treat Native Client invocations like JavaScript.
- if (plugin.name == base::ASCIIToUTF16(ChromeContentClient::kNaClPluginName))
+ if (plugin.name == base::ASCIIToUTF16(nacl::kNaClPluginName))
return true;
+#endif
#if defined(WIDEVINE_CDM_AVAILABLE) && defined(ENABLE_PEPPER_CDMS)
// Treat CDM invocations like JavaScript.
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,
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
}
}
content_settings::SettingInfo info;
bool uses_plugin_specific_setting = false;
if (ShouldUseJavaScriptSettingForPlugin(plugin)) {
- value.reset(
- host_content_settings_map_->GetWebsiteSetting(
- policy_url, policy_url, CONTENT_SETTINGS_TYPE_JAVASCRIPT,
- std::string(), &info));
+ value = host_content_settings_map_->GetWebsiteSetting(
+ policy_url,
+ policy_url,
+ CONTENT_SETTINGS_TYPE_JAVASCRIPT,
+ std::string(),
+ &info);
} else {
content_settings::SettingInfo specific_info;
- scoped_ptr<base::Value> specific_setting(
+ scoped_ptr<base::Value> specific_setting =
host_content_settings_map_->GetWebsiteSetting(
- policy_url, plugin_url, CONTENT_SETTINGS_TYPE_PLUGINS, resource,
- &specific_info));
+ policy_url,
+ plugin_url,
+ CONTENT_SETTINGS_TYPE_PLUGINS,
+ resource,
+ &specific_info);
content_settings::SettingInfo general_info;
- scoped_ptr<base::Value> general_setting(
+ scoped_ptr<base::Value> general_setting =
host_content_settings_map_->GetWebsiteSetting(
- policy_url, plugin_url, CONTENT_SETTINGS_TYPE_PLUGINS,
- std::string(), &general_info));
+ 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.
}
}
+bool PluginInfoMessageFilter::Context::IsPluginEnabled(
+ const content::WebPluginInfo& plugin) const {
+ return plugin_prefs_->IsPluginEnabled(plugin);
+}