| 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/common/chrome_content_client.h" | 5 #include "chrome/common/chrome_content_client.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/debug/crash_logging.h" | 10 #include "base/debug/crash_logging.h" |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 #include "chrome/common/chrome_switches.h" | 25 #include "chrome/common/chrome_switches.h" |
| 26 #include "chrome/common/crash_keys.h" | 26 #include "chrome/common/crash_keys.h" |
| 27 #include "chrome/common/pepper_flash.h" | 27 #include "chrome/common/pepper_flash.h" |
| 28 #include "chrome/common/secure_origin_whitelist.h" | 28 #include "chrome/common/secure_origin_whitelist.h" |
| 29 #include "chrome/common/url_constants.h" | 29 #include "chrome/common/url_constants.h" |
| 30 #include "chrome/grit/common_resources.h" | 30 #include "chrome/grit/common_resources.h" |
| 31 #include "components/data_reduction_proxy/content/common/data_reduction_proxy_me
ssages.h" | 31 #include "components/data_reduction_proxy/content/common/data_reduction_proxy_me
ssages.h" |
| 32 #include "components/dom_distiller/core/url_constants.h" | 32 #include "components/dom_distiller/core/url_constants.h" |
| 33 #include "components/version_info/version_info.h" | 33 #include "components/version_info/version_info.h" |
| 34 #include "content/public/common/content_constants.h" | 34 #include "content/public/common/content_constants.h" |
| 35 #include "content/public/common/content_decryption_module_registration.h" |
| 35 #include "content/public/common/content_switches.h" | 36 #include "content/public/common/content_switches.h" |
| 36 #include "content/public/common/url_constants.h" | 37 #include "content/public/common/url_constants.h" |
| 37 #include "content/public/common/user_agent.h" | 38 #include "content/public/common/user_agent.h" |
| 38 #include "extensions/common/constants.h" | 39 #include "extensions/common/constants.h" |
| 39 #include "gpu/config/gpu_info.h" | 40 #include "gpu/config/gpu_info.h" |
| 40 #include "net/http/http_util.h" | 41 #include "net/http/http_util.h" |
| 41 #include "ui/base/l10n/l10n_util.h" | 42 #include "ui/base/l10n/l10n_util.h" |
| 42 #include "ui/base/layout.h" | 43 #include "ui/base/layout.h" |
| 43 #include "ui/base/resource/resource_bundle.h" | 44 #include "ui/base/resource/resource_bundle.h" |
| 44 | 45 |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 content::PepperPluginInfo::GetInterfaceFunc g_pdf_get_interface; | 92 content::PepperPluginInfo::GetInterfaceFunc g_pdf_get_interface; |
| 92 content::PepperPluginInfo::PPP_InitializeModuleFunc g_pdf_initialize_module; | 93 content::PepperPluginInfo::PPP_InitializeModuleFunc g_pdf_initialize_module; |
| 93 content::PepperPluginInfo::PPP_ShutdownModuleFunc g_pdf_shutdown_module; | 94 content::PepperPluginInfo::PPP_ShutdownModuleFunc g_pdf_shutdown_module; |
| 94 | 95 |
| 95 #if !defined(DISABLE_NACL) | 96 #if !defined(DISABLE_NACL) |
| 96 content::PepperPluginInfo::GetInterfaceFunc g_nacl_get_interface; | 97 content::PepperPluginInfo::GetInterfaceFunc g_nacl_get_interface; |
| 97 content::PepperPluginInfo::PPP_InitializeModuleFunc g_nacl_initialize_module; | 98 content::PepperPluginInfo::PPP_InitializeModuleFunc g_nacl_initialize_module; |
| 98 content::PepperPluginInfo::PPP_ShutdownModuleFunc g_nacl_shutdown_module; | 99 content::PepperPluginInfo::PPP_ShutdownModuleFunc g_nacl_shutdown_module; |
| 99 #endif | 100 #endif |
| 100 | 101 |
| 102 #if defined(WIDEVINE_CDM_AVAILABLE) && !defined(WIDEVINE_CDM_IS_COMPONENT) |
| 103 static bool IsWidevineAvailable( |
| 104 base::FilePath* cdm_adapter_path, |
| 105 std::vector<base::string16>* codecs_supported, |
| 106 std::vector<base::string16>* supported_init_data_types) { |
| 107 static bool skip_widevine_cdm_file_check = false; |
| 108 if (PathService::Get(chrome::FILE_WIDEVINE_CDM_ADAPTER, cdm_adapter_path)) { |
| 109 if (skip_widevine_cdm_file_check || base::PathExists(*cdm_adapter_path)) { |
| 110 skip_widevine_cdm_file_check = true; |
| 111 |
| 112 // Add the supported codecs as if they came from the component manifest. |
| 113 // This list must match the CDM that is being bundled with Chrome. |
| 114 codecs_supported->push_back(base::ASCIIToUTF16(kCdmSupportedCodecVp8)); |
| 115 codecs_supported->push_back(base::ASCIIToUTF16(kCdmSupportedCodecVp9)); |
| 116 #if defined(USE_PROPRIETARY_CODECS) |
| 117 codecs_supported->push_back(base::ASCIIToUTF16(kCdmSupportedCodecAvc1)); |
| 118 #endif // defined(USE_PROPRIETARY_CODECS) |
| 119 |
| 120 // TODO(crbug.com/469202). Add support for initDataTypes in the component |
| 121 // manifest, and then duplicate the settings here. |
| 122 return true; |
| 123 } |
| 124 } |
| 125 |
| 126 return false; |
| 127 } |
| 128 #endif // defined(WIDEVINE_CDM_AVAILABLE) && |
| 129 // !defined(WIDEVINE_CDM_IS_COMPONENT) |
| 130 |
| 101 // Appends the known built-in plugins to the given vector. Some built-in | 131 // Appends the known built-in plugins to the given vector. Some built-in |
| 102 // plugins are "internal" which means they are compiled into the Chrome binary, | 132 // plugins are "internal" which means they are compiled into the Chrome binary, |
| 103 // and some are extra shared libraries distributed with the browser (these are | 133 // and some are extra shared libraries distributed with the browser (these are |
| 104 // not marked internal, aside from being automatically registered, they're just | 134 // not marked internal, aside from being automatically registered, they're just |
| 105 // regular plugins). | 135 // regular plugins). |
| 106 void ComputeBuiltInPlugins(std::vector<content::PepperPluginInfo>* plugins) { | 136 void ComputeBuiltInPlugins(std::vector<content::PepperPluginInfo>* plugins) { |
| 107 #if defined(ENABLE_PDF) | 137 #if defined(ENABLE_PDF) |
| 108 content::PepperPluginInfo pdf_info; | 138 content::PepperPluginInfo pdf_info; |
| 109 pdf_info.is_internal = true; | 139 pdf_info.is_internal = true; |
| 110 pdf_info.is_out_of_process = true; | 140 pdf_info.is_out_of_process = true; |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 148 nacl.internal_entry_points.get_interface = g_nacl_get_interface; | 178 nacl.internal_entry_points.get_interface = g_nacl_get_interface; |
| 149 nacl.internal_entry_points.initialize_module = g_nacl_initialize_module; | 179 nacl.internal_entry_points.initialize_module = g_nacl_initialize_module; |
| 150 nacl.internal_entry_points.shutdown_module = g_nacl_shutdown_module; | 180 nacl.internal_entry_points.shutdown_module = g_nacl_shutdown_module; |
| 151 nacl.permissions = ppapi::PERMISSION_PRIVATE | ppapi::PERMISSION_DEV; | 181 nacl.permissions = ppapi::PERMISSION_PRIVATE | ppapi::PERMISSION_DEV; |
| 152 plugins->push_back(nacl); | 182 plugins->push_back(nacl); |
| 153 } | 183 } |
| 154 #endif // !defined(DISABLE_NACL) | 184 #endif // !defined(DISABLE_NACL) |
| 155 | 185 |
| 156 #if defined(WIDEVINE_CDM_AVAILABLE) && defined(ENABLE_PEPPER_CDMS) && \ | 186 #if defined(WIDEVINE_CDM_AVAILABLE) && defined(ENABLE_PEPPER_CDMS) && \ |
| 157 !defined(WIDEVINE_CDM_IS_COMPONENT) | 187 !defined(WIDEVINE_CDM_IS_COMPONENT) |
| 158 static bool skip_widevine_cdm_file_check = false; | 188 std::vector<base::string16> codecs_supported; |
| 159 if (PathService::Get(chrome::FILE_WIDEVINE_CDM_ADAPTER, &path)) { | 189 std::vector<base::string16> supported_init_data_types; |
| 160 if (skip_widevine_cdm_file_check || base::PathExists(path)) { | 190 if (IsWidevineAvailable(&path, &codecs_supported, |
| 161 content::PepperPluginInfo widevine_cdm; | 191 &supported_init_data_types)) { |
| 162 widevine_cdm.is_out_of_process = true; | 192 content::PepperPluginInfo widevine_cdm; |
| 163 widevine_cdm.path = path; | 193 widevine_cdm.is_out_of_process = true; |
| 164 widevine_cdm.name = kWidevineCdmDisplayName; | 194 widevine_cdm.path = path; |
| 165 widevine_cdm.description = kWidevineCdmDescription + | 195 widevine_cdm.name = kWidevineCdmDisplayName; |
| 166 std::string(" (version: ") + | 196 widevine_cdm.description = kWidevineCdmDescription + |
| 167 WIDEVINE_CDM_VERSION_STRING + ")"; | 197 std::string(" (version: ") + |
| 168 widevine_cdm.version = WIDEVINE_CDM_VERSION_STRING; | 198 WIDEVINE_CDM_VERSION_STRING + ")"; |
| 169 content::WebPluginMimeType widevine_cdm_mime_type( | 199 widevine_cdm.version = WIDEVINE_CDM_VERSION_STRING; |
| 170 kWidevineCdmPluginMimeType, | 200 content::WebPluginMimeType widevine_cdm_mime_type( |
| 171 kWidevineCdmPluginExtension, | 201 kWidevineCdmPluginMimeType, kWidevineCdmPluginExtension, |
| 172 kWidevineCdmPluginMimeTypeDescription); | 202 kWidevineCdmPluginMimeTypeDescription); |
| 173 | 203 |
| 174 // Add the supported codecs as if they came from the component manifest. | 204 widevine_cdm_mime_type.additional_param_names.push_back( |
| 175 // This list must match the CDM that is being bundled with Chrome. | 205 base::ASCIIToUTF16(kCdmSupportedCodecsParamName)); |
| 176 std::vector<std::string> codecs; | 206 widevine_cdm_mime_type.additional_param_values.push_back(base::JoinString( |
| 177 codecs.push_back(kCdmSupportedCodecVp8); | 207 codecs_supported, |
| 178 codecs.push_back(kCdmSupportedCodecVp9); | 208 base::ASCIIToUTF16(std::string(1, kCdmSupportedCodecsValueDelimiter)))); |
| 179 #if defined(USE_PROPRIETARY_CODECS) | |
| 180 codecs.push_back(kCdmSupportedCodecAvc1); | |
| 181 #endif // defined(USE_PROPRIETARY_CODECS) | |
| 182 std::string codec_string = base::JoinString( | |
| 183 codecs, std::string(1, kCdmSupportedCodecsValueDelimiter)); | |
| 184 widevine_cdm_mime_type.additional_param_names.push_back( | |
| 185 base::ASCIIToUTF16(kCdmSupportedCodecsParamName)); | |
| 186 widevine_cdm_mime_type.additional_param_values.push_back( | |
| 187 base::ASCIIToUTF16(codec_string)); | |
| 188 | 209 |
| 189 widevine_cdm.mime_types.push_back(widevine_cdm_mime_type); | 210 widevine_cdm.mime_types.push_back(widevine_cdm_mime_type); |
| 190 widevine_cdm.permissions = kWidevineCdmPluginPermissions; | 211 widevine_cdm.permissions = kWidevineCdmPluginPermissions; |
| 191 plugins->push_back(widevine_cdm); | 212 plugins->push_back(widevine_cdm); |
| 192 | |
| 193 skip_widevine_cdm_file_check = true; | |
| 194 } | |
| 195 } | 213 } |
| 196 #endif // defined(WIDEVINE_CDM_AVAILABLE) && defined(ENABLE_PEPPER_CDMS) && | 214 #endif // defined(WIDEVINE_CDM_AVAILABLE) && defined(ENABLE_PEPPER_CDMS) && |
| 197 // !defined(WIDEVINE_CDM_IS_COMPONENT) | 215 // !defined(WIDEVINE_CDM_IS_COMPONENT) |
| 198 } | 216 } |
| 199 | 217 |
| 200 content::PepperPluginInfo CreatePepperFlashInfo(const base::FilePath& path, | 218 content::PepperPluginInfo CreatePepperFlashInfo(const base::FilePath& path, |
| 201 const std::string& version, | 219 const std::string& version, |
| 202 bool is_debug) { | 220 bool is_debug) { |
| 203 content::PepperPluginInfo plugin; | 221 content::PepperPluginInfo plugin; |
| 204 | 222 |
| (...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 513 flash_versions.push_back(system_flash.release()); | 531 flash_versions.push_back(system_flash.release()); |
| 514 | 532 |
| 515 // This function will return only the most recent version of the flash plugin. | 533 // This function will return only the most recent version of the flash plugin. |
| 516 content::PepperPluginInfo* max_flash = | 534 content::PepperPluginInfo* max_flash = |
| 517 FindMostRecentPlugin(flash_versions.get()); | 535 FindMostRecentPlugin(flash_versions.get()); |
| 518 if (max_flash) | 536 if (max_flash) |
| 519 plugins->push_back(*max_flash); | 537 plugins->push_back(*max_flash); |
| 520 #endif // defined(ENABLE_PLUGINS) | 538 #endif // defined(ENABLE_PLUGINS) |
| 521 } | 539 } |
| 522 | 540 |
| 541 void ChromeContentClient::AddContentDecryptionModules( |
| 542 std::vector<content::ContentDecryptionModuleRegistration>* modules) { |
| 543 #if defined(WIDEVINE_CDM_AVAILABLE) && !defined(WIDEVINE_CDM_IS_COMPONENT) |
| 544 base::FilePath widevine_adapter_path; |
| 545 std::vector<base::string16> codecs_supported; |
| 546 std::vector<base::string16> supported_init_data_types; |
| 547 if (IsWidevineAvailable(&widevine_adapter_path, &codecs_supported, |
| 548 &supported_init_data_types)) { |
| 549 // |key_systems| needs |path| to be the actual Widevine library, |
| 550 // not the adapter, so adjust as necessary. It will be in the |
| 551 // same directory as the installed adapter. |
| 552 modules->push_back(content::ContentDecryptionModuleRegistration( |
| 553 kWidevineKeySystem, WIDEVINE_CDM_VERSION_STRING, |
| 554 widevine_adapter_path.DirName().AppendASCII(kWidevineCdmFileName), |
| 555 codecs_supported, supported_init_data_types)); |
| 556 } |
| 557 #endif // defined(WIDEVINE_CDM_AVAILABLE) && |
| 558 // !defined(WIDEVINE_CDM_IS_COMPONENT) |
| 559 |
| 560 } |
| 561 |
| 523 #if defined(OS_CHROMEOS) | 562 #if defined(OS_CHROMEOS) |
| 524 static const int kNumChromeStandardURLSchemes = 6; | 563 static const int kNumChromeStandardURLSchemes = 6; |
| 525 #else | 564 #else |
| 526 static const int kNumChromeStandardURLSchemes = 5; | 565 static const int kNumChromeStandardURLSchemes = 5; |
| 527 #endif | 566 #endif |
| 528 static const url::SchemeWithType kChromeStandardURLSchemes[ | 567 static const url::SchemeWithType kChromeStandardURLSchemes[ |
| 529 kNumChromeStandardURLSchemes] = { | 568 kNumChromeStandardURLSchemes] = { |
| 530 {extensions::kExtensionScheme, url::SCHEME_WITHOUT_PORT}, | 569 {extensions::kExtensionScheme, url::SCHEME_WITHOUT_PORT}, |
| 531 {chrome::kChromeNativeScheme, url::SCHEME_WITHOUT_PORT}, | 570 {chrome::kChromeNativeScheme, url::SCHEME_WITHOUT_PORT}, |
| 532 {extensions::kExtensionResourceScheme, url::SCHEME_WITHOUT_PORT}, | 571 {extensions::kExtensionResourceScheme, url::SCHEME_WITHOUT_PORT}, |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 635 #endif | 674 #endif |
| 636 } | 675 } |
| 637 | 676 |
| 638 bool ChromeContentClient::IsSupplementarySiteIsolationModeEnabled() { | 677 bool ChromeContentClient::IsSupplementarySiteIsolationModeEnabled() { |
| 639 #if defined(ENABLE_EXTENSIONS) | 678 #if defined(ENABLE_EXTENSIONS) |
| 640 return extensions::IsIsolateExtensionsEnabled(); | 679 return extensions::IsIsolateExtensionsEnabled(); |
| 641 #else | 680 #else |
| 642 return false; | 681 return false; |
| 643 #endif | 682 #endif |
| 644 } | 683 } |
| OLD | NEW |