| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/plugins/plugin_info_message_filter.h" | 5 #include "chrome/browser/plugins/plugin_info_message_filter.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <memory> | 10 #include <memory> |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 #include "components/content_settings/core/browser/content_settings_utils.h" | 34 #include "components/content_settings/core/browser/content_settings_utils.h" |
| 35 #include "components/content_settings/core/browser/host_content_settings_map.h" | 35 #include "components/content_settings/core/browser/host_content_settings_map.h" |
| 36 #include "components/content_settings/core/common/content_settings.h" | 36 #include "components/content_settings/core/common/content_settings.h" |
| 37 #include "components/prefs/pref_service.h" | 37 #include "components/prefs/pref_service.h" |
| 38 #include "components/rappor/rappor_service.h" | 38 #include "components/rappor/rappor_service.h" |
| 39 #include "content/public/browser/browser_thread.h" | 39 #include "content/public/browser/browser_thread.h" |
| 40 #include "content/public/browser/plugin_service.h" | 40 #include "content/public/browser/plugin_service.h" |
| 41 #include "content/public/browser/plugin_service_filter.h" | 41 #include "content/public/browser/plugin_service_filter.h" |
| 42 #include "content/public/common/content_constants.h" | 42 #include "content/public/common/content_constants.h" |
| 43 #include "net/base/registry_controlled_domains/registry_controlled_domain.h" | 43 #include "net/base/registry_controlled_domains/registry_controlled_domain.h" |
| 44 #include "ppapi/features/features.h" |
| 44 #include "url/gurl.h" | 45 #include "url/gurl.h" |
| 45 #include "url/origin.h" | 46 #include "url/origin.h" |
| 46 #include "widevine_cdm_version.h" // In SHARED_INTERMEDIATE_DIR. | 47 #include "widevine_cdm_version.h" // In SHARED_INTERMEDIATE_DIR. |
| 47 | 48 |
| 48 #if defined(ENABLE_EXTENSIONS) | 49 #if defined(ENABLE_EXTENSIONS) |
| 49 #include "components/guest_view/browser/guest_view_base.h" | 50 #include "components/guest_view/browser/guest_view_base.h" |
| 50 #include "extensions/browser/extension_registry.h" | 51 #include "extensions/browser/extension_registry.h" |
| 51 #include "extensions/browser/guest_view/web_view/web_view_renderer_state.h" | 52 #include "extensions/browser/guest_view/web_view/web_view_renderer_state.h" |
| 52 #include "extensions/common/constants.h" | 53 #include "extensions/common/constants.h" |
| 53 #include "extensions/common/extension.h" | 54 #include "extensions/common/extension.h" |
| 54 #include "extensions/common/manifest_handlers/webview_info.h" | 55 #include "extensions/common/manifest_handlers/webview_info.h" |
| 55 #endif | 56 #endif |
| 56 | 57 |
| 57 #if !defined(DISABLE_NACL) | 58 #if !defined(DISABLE_NACL) |
| 58 #include "components/nacl/common/nacl_constants.h" | 59 #include "components/nacl/common/nacl_constants.h" |
| 59 #endif | 60 #endif |
| 60 | 61 |
| 61 using content::PluginService; | 62 using content::PluginService; |
| 62 using content::WebPluginInfo; | 63 using content::WebPluginInfo; |
| 63 | 64 |
| 64 namespace { | 65 namespace { |
| 65 | 66 |
| 66 #if defined(ENABLE_PEPPER_CDMS) | 67 #if BUILDFLAG(ENABLE_PEPPER_CDMS) |
| 67 | 68 |
| 68 enum PluginAvailabilityStatusForUMA { | 69 enum PluginAvailabilityStatusForUMA { |
| 69 PLUGIN_NOT_REGISTERED, | 70 PLUGIN_NOT_REGISTERED, |
| 70 PLUGIN_AVAILABLE, | 71 PLUGIN_AVAILABLE, |
| 71 PLUGIN_DISABLED, | 72 PLUGIN_DISABLED, |
| 72 PLUGIN_AVAILABILITY_STATUS_MAX | 73 PLUGIN_AVAILABILITY_STATUS_MAX |
| 73 }; | 74 }; |
| 74 | 75 |
| 75 static void SendPluginAvailabilityUMA(const std::string& mime_type, | 76 static void SendPluginAvailabilityUMA(const std::string& mime_type, |
| 76 PluginAvailabilityStatusForUMA status) { | 77 PluginAvailabilityStatusForUMA status) { |
| 77 #if defined(WIDEVINE_CDM_AVAILABLE) | 78 #if defined(WIDEVINE_CDM_AVAILABLE) |
| 78 // Only report results for Widevine CDM. | 79 // Only report results for Widevine CDM. |
| 79 if (mime_type != kWidevineCdmPluginMimeType) | 80 if (mime_type != kWidevineCdmPluginMimeType) |
| 80 return; | 81 return; |
| 81 | 82 |
| 82 UMA_HISTOGRAM_ENUMERATION("Plugin.AvailabilityStatus.WidevineCdm", | 83 UMA_HISTOGRAM_ENUMERATION("Plugin.AvailabilityStatus.WidevineCdm", |
| 83 status, PLUGIN_AVAILABILITY_STATUS_MAX); | 84 status, PLUGIN_AVAILABILITY_STATUS_MAX); |
| 84 #endif // defined(WIDEVINE_CDM_AVAILABLE) | 85 #endif // defined(WIDEVINE_CDM_AVAILABLE) |
| 85 } | 86 } |
| 86 | 87 |
| 87 #endif // defined(ENABLE_PEPPER_CDMS) | 88 #endif // BUILDFLAG(ENABLE_PEPPER_CDMS) |
| 88 | 89 |
| 89 // Report usage metrics for Silverlight and Flash plugin instantiations to the | 90 // Report usage metrics for Silverlight and Flash plugin instantiations to the |
| 90 // RAPPOR service. | 91 // RAPPOR service. |
| 91 void ReportMetrics(const std::string& mime_type, | 92 void ReportMetrics(const std::string& mime_type, |
| 92 const GURL& url, | 93 const GURL& url, |
| 93 const url::Origin& main_frame_origin) { | 94 const url::Origin& main_frame_origin) { |
| 94 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 95 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 95 | 96 |
| 96 if (chrome::IsIncognitoSessionActive()) | 97 if (chrome::IsIncognitoSessionActive()) |
| 97 return; | 98 return; |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 180 : BrowserMessageFilter(ChromeMsgStart), | 181 : BrowserMessageFilter(ChromeMsgStart), |
| 181 context_(render_process_id, profile), | 182 context_(render_process_id, profile), |
| 182 main_thread_task_runner_(base::ThreadTaskRunnerHandle::Get()), | 183 main_thread_task_runner_(base::ThreadTaskRunnerHandle::Get()), |
| 183 weak_ptr_factory_(this) { | 184 weak_ptr_factory_(this) { |
| 184 } | 185 } |
| 185 | 186 |
| 186 bool PluginInfoMessageFilter::OnMessageReceived(const IPC::Message& message) { | 187 bool PluginInfoMessageFilter::OnMessageReceived(const IPC::Message& message) { |
| 187 IPC_BEGIN_MESSAGE_MAP(PluginInfoMessageFilter, message) | 188 IPC_BEGIN_MESSAGE_MAP(PluginInfoMessageFilter, message) |
| 188 IPC_MESSAGE_HANDLER_DELAY_REPLY(ChromeViewHostMsg_GetPluginInfo, | 189 IPC_MESSAGE_HANDLER_DELAY_REPLY(ChromeViewHostMsg_GetPluginInfo, |
| 189 OnGetPluginInfo) | 190 OnGetPluginInfo) |
| 190 #if defined(ENABLE_PEPPER_CDMS) | 191 #if BUILDFLAG(ENABLE_PEPPER_CDMS) |
| 191 IPC_MESSAGE_HANDLER( | 192 IPC_MESSAGE_HANDLER( |
| 192 ChromeViewHostMsg_IsInternalPluginAvailableForMimeType, | 193 ChromeViewHostMsg_IsInternalPluginAvailableForMimeType, |
| 193 OnIsInternalPluginAvailableForMimeType) | 194 OnIsInternalPluginAvailableForMimeType) |
| 194 #endif | 195 #endif |
| 195 IPC_MESSAGE_UNHANDLED(return false) | 196 IPC_MESSAGE_UNHANDLED(return false) |
| 196 IPC_END_MESSAGE_MAP() | 197 IPC_END_MESSAGE_MAP() |
| 197 return true; | 198 return true; |
| 198 } | 199 } |
| 199 | 200 |
| 200 void PluginInfoMessageFilter::OnDestruct() const { | 201 void PluginInfoMessageFilter::OnDestruct() const { |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 254 params.mime_type), | 255 params.mime_type), |
| 255 base::Bind(&PluginInfoMessageFilter::ComponentPluginLookupDone, this, | 256 base::Bind(&PluginInfoMessageFilter::ComponentPluginLookupDone, this, |
| 256 params, base::Passed(&output), | 257 params, base::Passed(&output), |
| 257 base::Passed(&plugin_metadata), reply_msg)); | 258 base::Passed(&plugin_metadata), reply_msg)); |
| 258 } else { | 259 } else { |
| 259 GetPluginInfoReply(params, std::move(output), std::move(plugin_metadata), | 260 GetPluginInfoReply(params, std::move(output), std::move(plugin_metadata), |
| 260 reply_msg); | 261 reply_msg); |
| 261 } | 262 } |
| 262 } | 263 } |
| 263 | 264 |
| 264 #if defined(ENABLE_PEPPER_CDMS) | 265 #if BUILDFLAG(ENABLE_PEPPER_CDMS) |
| 265 | 266 |
| 266 void PluginInfoMessageFilter::OnIsInternalPluginAvailableForMimeType( | 267 void PluginInfoMessageFilter::OnIsInternalPluginAvailableForMimeType( |
| 267 const std::string& mime_type, | 268 const std::string& mime_type, |
| 268 bool* is_available, | 269 bool* is_available, |
| 269 std::vector<base::string16>* additional_param_names, | 270 std::vector<base::string16>* additional_param_names, |
| 270 std::vector<base::string16>* additional_param_values) { | 271 std::vector<base::string16>* additional_param_values) { |
| 271 std::vector<WebPluginInfo> plugins; | 272 std::vector<WebPluginInfo> plugins; |
| 272 PluginService::GetInstance()->GetInternalPlugins(&plugins); | 273 PluginService::GetInstance()->GetInternalPlugins(&plugins); |
| 273 | 274 |
| 274 bool is_plugin_disabled = false; | 275 bool is_plugin_disabled = false; |
| (...skipping 15 matching lines...) Expand all Loading... |
| 290 return; | 291 return; |
| 291 } | 292 } |
| 292 } | 293 } |
| 293 } | 294 } |
| 294 | 295 |
| 295 *is_available = false; | 296 *is_available = false; |
| 296 SendPluginAvailabilityUMA( | 297 SendPluginAvailabilityUMA( |
| 297 mime_type, is_plugin_disabled ? PLUGIN_DISABLED : PLUGIN_NOT_REGISTERED); | 298 mime_type, is_plugin_disabled ? PLUGIN_DISABLED : PLUGIN_NOT_REGISTERED); |
| 298 } | 299 } |
| 299 | 300 |
| 300 #endif // defined(ENABLE_PEPPER_CDMS) | 301 #endif // BUILDFLAG(ENABLE_PEPPER_CDMS) |
| 301 | 302 |
| 302 void PluginInfoMessageFilter::Context::DecidePluginStatus( | 303 void PluginInfoMessageFilter::Context::DecidePluginStatus( |
| 303 const GetPluginInfo_Params& params, | 304 const GetPluginInfo_Params& params, |
| 304 const WebPluginInfo& plugin, | 305 const WebPluginInfo& plugin, |
| 305 const PluginMetadata* plugin_metadata, | 306 const PluginMetadata* plugin_metadata, |
| 306 ChromeViewHostMsg_GetPluginInfo_Status* status) const { | 307 ChromeViewHostMsg_GetPluginInfo_Status* status) const { |
| 307 PluginMetadata::SecurityStatus plugin_status = | 308 PluginMetadata::SecurityStatus plugin_status = |
| 308 plugin_metadata->GetSecurityStatus(plugin); | 309 plugin_metadata->GetSecurityStatus(plugin); |
| 309 | 310 |
| 310 if (plugin_status == PluginMetadata::SECURITY_STATUS_FULLY_TRUSTED) { | 311 if (plugin_status == PluginMetadata::SECURITY_STATUS_FULLY_TRUSTED) { |
| (...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 507 status == ChromeViewHostMsg_GetPluginInfo_Status::kPlayImportantContent) { | 508 status == ChromeViewHostMsg_GetPluginInfo_Status::kPlayImportantContent) { |
| 508 ChromePluginServiceFilter::GetInstance()->AuthorizePlugin( | 509 ChromePluginServiceFilter::GetInstance()->AuthorizePlugin( |
| 509 render_process_id_, path); | 510 render_process_id_, path); |
| 510 } | 511 } |
| 511 } | 512 } |
| 512 | 513 |
| 513 bool PluginInfoMessageFilter::Context::IsPluginEnabled( | 514 bool PluginInfoMessageFilter::Context::IsPluginEnabled( |
| 514 const content::WebPluginInfo& plugin) const { | 515 const content::WebPluginInfo& plugin) const { |
| 515 return plugin_prefs_->IsPluginEnabled(plugin); | 516 return plugin_prefs_->IsPluginEnabled(plugin); |
| 516 } | 517 } |
| OLD | NEW |