Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(448)

Side by Side Diff: chrome/common/chrome_content_client.cc

Issue 1637083002: Add CdmService to keep track of CDMs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: more changes Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 13 matching lines...) Expand all
24 #include "chrome/common/chrome_paths.h" 24 #include "chrome/common/chrome_paths.h"
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/cdm_info.h"
34 #include "content/public/common/content_constants.h" 35 #include "content/public/common/content_constants.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"
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
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(ENABLE_PEPPER_CDMS) && \
103 !defined(WIDEVINE_CDM_IS_COMPONENT)
104 static bool IsWidevineAvailable(base::FilePath* adapter_path,
105 base::FilePath* cdm_path,
106 std::vector<std::string>* codecs_supported) {
107 static bool skip_widevine_cdm_file_check = false;
108 // TODO(jrummell): We should add a new path for DIR_WIDEVINE_CDM and use that
109 // to locate the CDM and the CDM adapter.
110 if (PathService::Get(chrome::FILE_WIDEVINE_CDM_ADAPTER, adapter_path)) {
111 *cdm_path = adapter_path->DirName().AppendASCII(kWidevineCdmFileName);
112 if (skip_widevine_cdm_file_check ||
113 (base::PathExists(*adapter_path) && base::PathExists(*cdm_path))) {
114 skip_widevine_cdm_file_check = true;
115
116 // Add the supported codecs as if they came from the component manifest.
117 // This list must match the CDM that is being bundled with Chrome.
118 codecs_supported->push_back(kCdmSupportedCodecVp8);
119 codecs_supported->push_back(kCdmSupportedCodecVp9);
120 #if defined(USE_PROPRIETARY_CODECS)
121 codecs_supported->push_back(kCdmSupportedCodecAvc1);
122 #endif // defined(USE_PROPRIETARY_CODECS)
123 return true;
124 }
125 }
126
127 return false;
128 }
129 #endif // defined(WIDEVINE_CDM_AVAILABLE) && defined(ENABLE_PEPPER_CDMS) &&
130 // !defined(WIDEVINE_CDM_IS_COMPONENT)
131
101 // Appends the known built-in plugins to the given vector. Some built-in 132 // 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, 133 // 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 134 // and some are extra shared libraries distributed with the browser (these are
104 // not marked internal, aside from being automatically registered, they're just 135 // not marked internal, aside from being automatically registered, they're just
105 // regular plugins). 136 // regular plugins).
106 void ComputeBuiltInPlugins(std::vector<content::PepperPluginInfo>* plugins) { 137 void ComputeBuiltInPlugins(std::vector<content::PepperPluginInfo>* plugins) {
107 #if defined(ENABLE_PDF) 138 #if defined(ENABLE_PDF)
108 content::PepperPluginInfo pdf_info; 139 content::PepperPluginInfo pdf_info;
109 pdf_info.is_internal = true; 140 pdf_info.is_internal = true;
110 pdf_info.is_out_of_process = true; 141 pdf_info.is_out_of_process = true;
111 pdf_info.name = ChromeContentClient::kPDFPluginName; 142 pdf_info.name = ChromeContentClient::kPDFPluginName;
112 pdf_info.description = kPDFPluginDescription; 143 pdf_info.description = kPDFPluginDescription;
113 pdf_info.path = base::FilePath::FromUTF8Unsafe( 144 pdf_info.path = base::FilePath::FromUTF8Unsafe(
114 ChromeContentClient::kPDFPluginPath); 145 ChromeContentClient::kPDFPluginPath);
115 content::WebPluginMimeType pdf_mime_type( 146 content::WebPluginMimeType pdf_mime_type(
116 kPDFPluginOutOfProcessMimeType, 147 kPDFPluginOutOfProcessMimeType,
117 kPDFPluginExtension, 148 kPDFPluginExtension,
118 kPDFPluginDescription); 149 kPDFPluginDescription);
119 pdf_info.mime_types.push_back(pdf_mime_type); 150 pdf_info.mime_types.push_back(pdf_mime_type);
120 pdf_info.internal_entry_points.get_interface = g_pdf_get_interface; 151 pdf_info.internal_entry_points.get_interface = g_pdf_get_interface;
121 pdf_info.internal_entry_points.initialize_module = g_pdf_initialize_module; 152 pdf_info.internal_entry_points.initialize_module = g_pdf_initialize_module;
122 pdf_info.internal_entry_points.shutdown_module = g_pdf_shutdown_module; 153 pdf_info.internal_entry_points.shutdown_module = g_pdf_shutdown_module;
123 pdf_info.permissions = kPDFPluginPermissions; 154 pdf_info.permissions = kPDFPluginPermissions;
124 plugins->push_back(pdf_info); 155 plugins->push_back(pdf_info);
125 #endif // defined(ENABLE_PDF) 156 #endif // defined(ENABLE_PDF)
126 157
127 base::FilePath path;
128
129 #if !defined(DISABLE_NACL) 158 #if !defined(DISABLE_NACL)
130 // Handle Native Client just like the PDF plugin. This means that it is 159 // Handle Native Client just like the PDF plugin. This means that it is
131 // enabled by default for the non-portable case. This allows apps installed 160 // enabled by default for the non-portable case. This allows apps installed
132 // from the Chrome Web Store to use NaCl even if the command line switch 161 // from the Chrome Web Store to use NaCl even if the command line switch
133 // isn't set. For other uses of NaCl we check for the command line switch. 162 // isn't set. For other uses of NaCl we check for the command line switch.
163 base::FilePath path;
134 if (PathService::Get(chrome::FILE_NACL_PLUGIN, &path)) { 164 if (PathService::Get(chrome::FILE_NACL_PLUGIN, &path)) {
135 content::PepperPluginInfo nacl; 165 content::PepperPluginInfo nacl;
136 // The nacl plugin is now built into the Chromium binary. 166 // The nacl plugin is now built into the Chromium binary.
137 nacl.is_internal = true; 167 nacl.is_internal = true;
138 nacl.path = path; 168 nacl.path = path;
139 nacl.name = nacl::kNaClPluginName; 169 nacl.name = nacl::kNaClPluginName;
140 content::WebPluginMimeType nacl_mime_type(nacl::kNaClPluginMimeType, 170 content::WebPluginMimeType nacl_mime_type(nacl::kNaClPluginMimeType,
141 nacl::kNaClPluginExtension, 171 nacl::kNaClPluginExtension,
142 nacl::kNaClPluginDescription); 172 nacl::kNaClPluginDescription);
143 nacl.mime_types.push_back(nacl_mime_type); 173 nacl.mime_types.push_back(nacl_mime_type);
144 content::WebPluginMimeType pnacl_mime_type(nacl::kPnaclPluginMimeType, 174 content::WebPluginMimeType pnacl_mime_type(nacl::kPnaclPluginMimeType,
145 nacl::kPnaclPluginExtension, 175 nacl::kPnaclPluginExtension,
146 nacl::kPnaclPluginDescription); 176 nacl::kPnaclPluginDescription);
147 nacl.mime_types.push_back(pnacl_mime_type); 177 nacl.mime_types.push_back(pnacl_mime_type);
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 base::FilePath adapter_path;
159 if (PathService::Get(chrome::FILE_WIDEVINE_CDM_ADAPTER, &path)) { 189 base::FilePath cdm_path;
160 if (skip_widevine_cdm_file_check || base::PathExists(path)) { 190 std::vector<std::string> codecs_supported;
161 content::PepperPluginInfo widevine_cdm; 191 if (IsWidevineAvailable(&adapter_path, &cdm_path, &codecs_supported)) {
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 = adapter_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::ASCIIToUTF16(
177 codecs.push_back(kCdmSupportedCodecVp8); 207 base::JoinString(codecs_supported,
178 codecs.push_back(kCdmSupportedCodecVp9); 208 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
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::CdmInfo>* cdms) {
543 // TODO(jrummell): Need to have a better flag to indicate systems Widevine
544 // is available on. For now we continue to use ENABLE_PEPPER_CDMS so that
545 // we can experiment between pepper and mojo.
546 #if defined(WIDEVINE_CDM_AVAILABLE) && defined(ENABLE_PEPPER_CDMS) && \
547 !defined(WIDEVINE_CDM_IS_COMPONENT)
548 base::FilePath adapter_path;
549 base::FilePath cdm_path;
550 std::vector<std::string> codecs_supported;
551 if (IsWidevineAvailable(&adapter_path, &cdm_path, &codecs_supported)) {
552 // CdmInfo needs |path| to be the actual Widevine library,
553 // not the adapter, so adjust as necessary. It will be in the
554 // same directory as the installed adapter.
555 base::Version version(WIDEVINE_CDM_VERSION_STRING);
556 DCHECK(version.IsValid());
557 cdms->push_back(content::CdmInfo(kWidevineCdmType, version, cdm_path,
558 codecs_supported));
559 }
560 #endif // defined(WIDEVINE_CDM_AVAILABLE) && defined(ENABLE_PEPPER_CDMS) &&
561 // !defined(WIDEVINE_CDM_IS_COMPONENT)
562
563 // TODO(jrummell): Add External Clear Key CDM for testing, if it's available.
564 }
565
523 #if defined(OS_CHROMEOS) 566 #if defined(OS_CHROMEOS)
524 static const int kNumChromeStandardURLSchemes = 6; 567 static const int kNumChromeStandardURLSchemes = 6;
525 #else 568 #else
526 static const int kNumChromeStandardURLSchemes = 5; 569 static const int kNumChromeStandardURLSchemes = 5;
527 #endif 570 #endif
528 static const url::SchemeWithType kChromeStandardURLSchemes[ 571 static const url::SchemeWithType kChromeStandardURLSchemes[
529 kNumChromeStandardURLSchemes] = { 572 kNumChromeStandardURLSchemes] = {
530 {extensions::kExtensionScheme, url::SCHEME_WITHOUT_PORT}, 573 {extensions::kExtensionScheme, url::SCHEME_WITHOUT_PORT},
531 {chrome::kChromeNativeScheme, url::SCHEME_WITHOUT_PORT}, 574 {chrome::kChromeNativeScheme, url::SCHEME_WITHOUT_PORT},
532 {extensions::kExtensionResourceScheme, url::SCHEME_WITHOUT_PORT}, 575 {extensions::kExtensionResourceScheme, url::SCHEME_WITHOUT_PORT},
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
639 #if defined(ENABLE_EXTENSIONS) 682 #if defined(ENABLE_EXTENSIONS)
640 return extensions::IsIsolateExtensionsEnabled(); 683 return extensions::IsIsolateExtensionsEnabled();
641 #else 684 #else
642 return false; 685 return false;
643 #endif 686 #endif
644 } 687 }
645 688
646 base::StringPiece ChromeContentClient::GetOriginTrialPublicKey() { 689 base::StringPiece ChromeContentClient::GetOriginTrialPublicKey() {
647 return origin_trial_key_manager_.GetPublicKey(); 690 return origin_trial_key_manager_.GetPublicKey();
648 } 691 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698