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

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: remove const 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 <memory> 9 #include <memory>
10 10
(...skipping 15 matching lines...) Expand all
26 #include "chrome/common/chrome_paths.h" 26 #include "chrome/common/chrome_paths.h"
27 #include "chrome/common/chrome_switches.h" 27 #include "chrome/common/chrome_switches.h"
28 #include "chrome/common/crash_keys.h" 28 #include "chrome/common/crash_keys.h"
29 #include "chrome/common/pepper_flash.h" 29 #include "chrome/common/pepper_flash.h"
30 #include "chrome/common/secure_origin_whitelist.h" 30 #include "chrome/common/secure_origin_whitelist.h"
31 #include "chrome/common/url_constants.h" 31 #include "chrome/common/url_constants.h"
32 #include "chrome/grit/common_resources.h" 32 #include "chrome/grit/common_resources.h"
33 #include "components/data_reduction_proxy/content/common/data_reduction_proxy_me ssages.h" 33 #include "components/data_reduction_proxy/content/common/data_reduction_proxy_me ssages.h"
34 #include "components/dom_distiller/core/url_constants.h" 34 #include "components/dom_distiller/core/url_constants.h"
35 #include "components/version_info/version_info.h" 35 #include "components/version_info/version_info.h"
36 #include "content/public/common/cdm_info.h"
36 #include "content/public/common/content_constants.h" 37 #include "content/public/common/content_constants.h"
37 #include "content/public/common/content_switches.h" 38 #include "content/public/common/content_switches.h"
38 #include "content/public/common/url_constants.h" 39 #include "content/public/common/url_constants.h"
39 #include "content/public/common/user_agent.h" 40 #include "content/public/common/user_agent.h"
40 #include "extensions/common/constants.h" 41 #include "extensions/common/constants.h"
41 #include "gpu/config/gpu_info.h" 42 #include "gpu/config/gpu_info.h"
42 #include "net/http/http_util.h" 43 #include "net/http/http_util.h"
43 #include "ui/base/l10n/l10n_util.h" 44 #include "ui/base/l10n/l10n_util.h"
44 #include "ui/base/layout.h" 45 #include "ui/base/layout.h"
45 #include "ui/base/resource/resource_bundle.h" 46 #include "ui/base/resource/resource_bundle.h"
(...skipping 19 matching lines...) Expand all
65 #include "chrome/common/extensions/extension_process_policy.h" 66 #include "chrome/common/extensions/extension_process_policy.h"
66 #include "chrome/common/extensions/features/feature_util.h" 67 #include "chrome/common/extensions/features/feature_util.h"
67 #endif 68 #endif
68 69
69 #if defined(ENABLE_PLUGINS) 70 #if defined(ENABLE_PLUGINS)
70 #include "content/public/common/pepper_plugin_info.h" 71 #include "content/public/common/pepper_plugin_info.h"
71 #include "flapper_version.h" // nogncheck In SHARED_INTERMEDIATE_DIR. 72 #include "flapper_version.h" // nogncheck In SHARED_INTERMEDIATE_DIR.
72 #include "ppapi/shared_impl/ppapi_permissions.h" 73 #include "ppapi/shared_impl/ppapi_permissions.h"
73 #endif 74 #endif
74 75
75 #if defined(WIDEVINE_CDM_AVAILABLE) && defined(ENABLE_PEPPER_CDMS) && \ 76 #if defined(WIDEVINE_CDM_AVAILABLE) && defined(ENABLE_PEPPER_CDMS) && \
Lei Zhang 2016/04/19 23:46:17 Do you want to #define something here and use that
jrummell 2016/04/20 21:08:44 Done.
76 !defined(WIDEVINE_CDM_IS_COMPONENT) 77 !defined(WIDEVINE_CDM_IS_COMPONENT)
77 #include "chrome/common/widevine_cdm_constants.h" 78 #include "chrome/common/widevine_cdm_constants.h"
78 #endif 79 #endif
79 80
80 namespace { 81 namespace {
81 82
82 #if defined(ENABLE_PLUGINS) 83 #if defined(ENABLE_PLUGINS)
83 #if defined(ENABLE_PDF) 84 #if defined(ENABLE_PDF)
84 const char kPDFPluginExtension[] = "pdf"; 85 const char kPDFPluginExtension[] = "pdf";
85 const char kPDFPluginDescription[] = "Portable Document Format"; 86 const char kPDFPluginDescription[] = "Portable Document Format";
86 const char kPDFPluginOutOfProcessMimeType[] = 87 const char kPDFPluginOutOfProcessMimeType[] =
87 "application/x-google-chrome-pdf"; 88 "application/x-google-chrome-pdf";
88 const uint32_t kPDFPluginPermissions = 89 const uint32_t kPDFPluginPermissions =
89 ppapi::PERMISSION_PRIVATE | ppapi::PERMISSION_DEV; 90 ppapi::PERMISSION_PRIVATE | ppapi::PERMISSION_DEV;
90 #endif // defined(ENABLE_PDF) 91 #endif // defined(ENABLE_PDF)
91 92
92 content::PepperPluginInfo::GetInterfaceFunc g_pdf_get_interface; 93 content::PepperPluginInfo::GetInterfaceFunc g_pdf_get_interface;
93 content::PepperPluginInfo::PPP_InitializeModuleFunc g_pdf_initialize_module; 94 content::PepperPluginInfo::PPP_InitializeModuleFunc g_pdf_initialize_module;
94 content::PepperPluginInfo::PPP_ShutdownModuleFunc g_pdf_shutdown_module; 95 content::PepperPluginInfo::PPP_ShutdownModuleFunc g_pdf_shutdown_module;
95 96
96 #if !defined(DISABLE_NACL) 97 #if !defined(DISABLE_NACL)
97 content::PepperPluginInfo::GetInterfaceFunc g_nacl_get_interface; 98 content::PepperPluginInfo::GetInterfaceFunc g_nacl_get_interface;
98 content::PepperPluginInfo::PPP_InitializeModuleFunc g_nacl_initialize_module; 99 content::PepperPluginInfo::PPP_InitializeModuleFunc g_nacl_initialize_module;
99 content::PepperPluginInfo::PPP_ShutdownModuleFunc g_nacl_shutdown_module; 100 content::PepperPluginInfo::PPP_ShutdownModuleFunc g_nacl_shutdown_module;
100 #endif 101 #endif
101 102
103 #if defined(WIDEVINE_CDM_AVAILABLE) && defined(ENABLE_PEPPER_CDMS) && \
104 !defined(WIDEVINE_CDM_IS_COMPONENT)
105 static bool IsWidevineAvailable(base::FilePath* adapter_path,
Lei Zhang 2016/04/19 23:46:17 You don't need to decl functions static inside an
jrummell 2016/04/20 21:08:44 Done.
106 base::FilePath* cdm_path,
107 std::vector<std::string>* codecs_supported) {
108 static bool skip_widevine_cdm_file_check = false;
Lei Zhang 2016/04/19 23:46:17 Questioning the original code - is the intention t
jrummell 2016/04/20 21:08:44 Back when this was added (https://chromiumcoderevi
109 // TODO(jrummell): We should add a new path for DIR_WIDEVINE_CDM and use that
110 // to locate the CDM and the CDM adapter.
111 if (PathService::Get(chrome::FILE_WIDEVINE_CDM_ADAPTER, adapter_path)) {
112 *cdm_path = adapter_path->DirName().AppendASCII(kWidevineCdmFileName);
113 if (skip_widevine_cdm_file_check ||
114 (base::PathExists(*adapter_path) && base::PathExists(*cdm_path))) {
115 skip_widevine_cdm_file_check = true;
116
117 // Add the supported codecs as if they came from the component manifest.
118 // This list must match the CDM that is being bundled with Chrome.
119 codecs_supported->push_back(kCdmSupportedCodecVp8);
120 codecs_supported->push_back(kCdmSupportedCodecVp9);
121 #if defined(USE_PROPRIETARY_CODECS)
122 codecs_supported->push_back(kCdmSupportedCodecAvc1);
123 #endif // defined(USE_PROPRIETARY_CODECS)
124 return true;
125 }
126 }
127
128 return false;
129 }
130 #endif // defined(WIDEVINE_CDM_AVAILABLE) && defined(ENABLE_PEPPER_CDMS) &&
131 // !defined(WIDEVINE_CDM_IS_COMPONENT)
132
102 // Appends the known built-in plugins to the given vector. Some built-in 133 // Appends the known built-in plugins to the given vector. Some built-in
103 // plugins are "internal" which means they are compiled into the Chrome binary, 134 // plugins are "internal" which means they are compiled into the Chrome binary,
104 // and some are extra shared libraries distributed with the browser (these are 135 // and some are extra shared libraries distributed with the browser (these are
105 // not marked internal, aside from being automatically registered, they're just 136 // not marked internal, aside from being automatically registered, they're just
106 // regular plugins). 137 // regular plugins).
107 void ComputeBuiltInPlugins(std::vector<content::PepperPluginInfo>* plugins) { 138 void ComputeBuiltInPlugins(std::vector<content::PepperPluginInfo>* plugins) {
108 #if defined(ENABLE_PDF) 139 #if defined(ENABLE_PDF)
109 content::PepperPluginInfo pdf_info; 140 content::PepperPluginInfo pdf_info;
110 pdf_info.is_internal = true; 141 pdf_info.is_internal = true;
111 pdf_info.is_out_of_process = true; 142 pdf_info.is_out_of_process = true;
112 pdf_info.name = ChromeContentClient::kPDFPluginName; 143 pdf_info.name = ChromeContentClient::kPDFPluginName;
113 pdf_info.description = kPDFPluginDescription; 144 pdf_info.description = kPDFPluginDescription;
114 pdf_info.path = base::FilePath::FromUTF8Unsafe( 145 pdf_info.path = base::FilePath::FromUTF8Unsafe(
115 ChromeContentClient::kPDFPluginPath); 146 ChromeContentClient::kPDFPluginPath);
116 content::WebPluginMimeType pdf_mime_type( 147 content::WebPluginMimeType pdf_mime_type(
117 kPDFPluginOutOfProcessMimeType, 148 kPDFPluginOutOfProcessMimeType,
118 kPDFPluginExtension, 149 kPDFPluginExtension,
119 kPDFPluginDescription); 150 kPDFPluginDescription);
120 pdf_info.mime_types.push_back(pdf_mime_type); 151 pdf_info.mime_types.push_back(pdf_mime_type);
121 pdf_info.internal_entry_points.get_interface = g_pdf_get_interface; 152 pdf_info.internal_entry_points.get_interface = g_pdf_get_interface;
122 pdf_info.internal_entry_points.initialize_module = g_pdf_initialize_module; 153 pdf_info.internal_entry_points.initialize_module = g_pdf_initialize_module;
123 pdf_info.internal_entry_points.shutdown_module = g_pdf_shutdown_module; 154 pdf_info.internal_entry_points.shutdown_module = g_pdf_shutdown_module;
124 pdf_info.permissions = kPDFPluginPermissions; 155 pdf_info.permissions = kPDFPluginPermissions;
125 plugins->push_back(pdf_info); 156 plugins->push_back(pdf_info);
126 #endif // defined(ENABLE_PDF) 157 #endif // defined(ENABLE_PDF)
127 158
128 base::FilePath path;
129
130 #if !defined(DISABLE_NACL) 159 #if !defined(DISABLE_NACL)
131 // Handle Native Client just like the PDF plugin. This means that it is 160 // Handle Native Client just like the PDF plugin. This means that it is
132 // enabled by default for the non-portable case. This allows apps installed 161 // enabled by default for the non-portable case. This allows apps installed
133 // from the Chrome Web Store to use NaCl even if the command line switch 162 // from the Chrome Web Store to use NaCl even if the command line switch
134 // isn't set. For other uses of NaCl we check for the command line switch. 163 // isn't set. For other uses of NaCl we check for the command line switch.
164 base::FilePath path;
135 if (PathService::Get(chrome::FILE_NACL_PLUGIN, &path)) { 165 if (PathService::Get(chrome::FILE_NACL_PLUGIN, &path)) {
136 content::PepperPluginInfo nacl; 166 content::PepperPluginInfo nacl;
137 // The nacl plugin is now built into the Chromium binary. 167 // The nacl plugin is now built into the Chromium binary.
138 nacl.is_internal = true; 168 nacl.is_internal = true;
139 nacl.path = path; 169 nacl.path = path;
140 nacl.name = nacl::kNaClPluginName; 170 nacl.name = nacl::kNaClPluginName;
141 content::WebPluginMimeType nacl_mime_type(nacl::kNaClPluginMimeType, 171 content::WebPluginMimeType nacl_mime_type(nacl::kNaClPluginMimeType,
142 nacl::kNaClPluginExtension, 172 nacl::kNaClPluginExtension,
143 nacl::kNaClPluginDescription); 173 nacl::kNaClPluginDescription);
144 nacl.mime_types.push_back(nacl_mime_type); 174 nacl.mime_types.push_back(nacl_mime_type);
145 content::WebPluginMimeType pnacl_mime_type(nacl::kPnaclPluginMimeType, 175 content::WebPluginMimeType pnacl_mime_type(nacl::kPnaclPluginMimeType,
146 nacl::kPnaclPluginExtension, 176 nacl::kPnaclPluginExtension,
147 nacl::kPnaclPluginDescription); 177 nacl::kPnaclPluginDescription);
148 nacl.mime_types.push_back(pnacl_mime_type); 178 nacl.mime_types.push_back(pnacl_mime_type);
149 nacl.internal_entry_points.get_interface = g_nacl_get_interface; 179 nacl.internal_entry_points.get_interface = g_nacl_get_interface;
150 nacl.internal_entry_points.initialize_module = g_nacl_initialize_module; 180 nacl.internal_entry_points.initialize_module = g_nacl_initialize_module;
151 nacl.internal_entry_points.shutdown_module = g_nacl_shutdown_module; 181 nacl.internal_entry_points.shutdown_module = g_nacl_shutdown_module;
152 nacl.permissions = ppapi::PERMISSION_PRIVATE | ppapi::PERMISSION_DEV; 182 nacl.permissions = ppapi::PERMISSION_PRIVATE | ppapi::PERMISSION_DEV;
153 plugins->push_back(nacl); 183 plugins->push_back(nacl);
154 } 184 }
155 #endif // !defined(DISABLE_NACL) 185 #endif // !defined(DISABLE_NACL)
156 186
157 #if defined(WIDEVINE_CDM_AVAILABLE) && defined(ENABLE_PEPPER_CDMS) && \ 187 #if defined(WIDEVINE_CDM_AVAILABLE) && defined(ENABLE_PEPPER_CDMS) && \
158 !defined(WIDEVINE_CDM_IS_COMPONENT) 188 !defined(WIDEVINE_CDM_IS_COMPONENT)
159 static bool skip_widevine_cdm_file_check = false; 189 base::FilePath adapter_path;
160 if (PathService::Get(chrome::FILE_WIDEVINE_CDM_ADAPTER, &path)) { 190 base::FilePath cdm_path;
161 if (skip_widevine_cdm_file_check || base::PathExists(path)) { 191 std::vector<std::string> codecs_supported;
162 content::PepperPluginInfo widevine_cdm; 192 if (IsWidevineAvailable(&adapter_path, &cdm_path, &codecs_supported)) {
163 widevine_cdm.is_out_of_process = true; 193 content::PepperPluginInfo widevine_cdm;
164 widevine_cdm.path = path; 194 widevine_cdm.is_out_of_process = true;
165 widevine_cdm.name = kWidevineCdmDisplayName; 195 widevine_cdm.path = adapter_path;
166 widevine_cdm.description = kWidevineCdmDescription + 196 widevine_cdm.name = kWidevineCdmDisplayName;
167 std::string(" (version: ") + 197 widevine_cdm.description =
168 WIDEVINE_CDM_VERSION_STRING + ")"; 198 base::StringPrintf("%s (version: " WIDEVINE_CDM_VERSION_STRING ")",
169 widevine_cdm.version = WIDEVINE_CDM_VERSION_STRING; 199 kWidevineCdmDescription);
170 content::WebPluginMimeType widevine_cdm_mime_type( 200 widevine_cdm.version = WIDEVINE_CDM_VERSION_STRING;
171 kWidevineCdmPluginMimeType, 201 content::WebPluginMimeType widevine_cdm_mime_type(
172 kWidevineCdmPluginExtension, 202 kWidevineCdmPluginMimeType, kWidevineCdmPluginExtension,
173 kWidevineCdmPluginMimeTypeDescription); 203 kWidevineCdmPluginMimeTypeDescription);
174 204
175 // Add the supported codecs as if they came from the component manifest. 205 widevine_cdm_mime_type.additional_param_names.push_back(
176 // This list must match the CDM that is being bundled with Chrome. 206 base::ASCIIToUTF16(kCdmSupportedCodecsParamName));
177 std::vector<std::string> codecs; 207 widevine_cdm_mime_type.additional_param_values.push_back(base::ASCIIToUTF16(
178 codecs.push_back(kCdmSupportedCodecVp8); 208 base::JoinString(codecs_supported,
179 codecs.push_back(kCdmSupportedCodecVp9); 209 std::string(1, kCdmSupportedCodecsValueDelimiter))));
180 #if defined(USE_PROPRIETARY_CODECS)
181 codecs.push_back(kCdmSupportedCodecAvc1);
182 #endif // defined(USE_PROPRIETARY_CODECS)
183 std::string codec_string = base::JoinString(
184 codecs, std::string(1, kCdmSupportedCodecsValueDelimiter));
185 widevine_cdm_mime_type.additional_param_names.push_back(
186 base::ASCIIToUTF16(kCdmSupportedCodecsParamName));
187 widevine_cdm_mime_type.additional_param_values.push_back(
188 base::ASCIIToUTF16(codec_string));
189 210
190 widevine_cdm.mime_types.push_back(widevine_cdm_mime_type); 211 widevine_cdm.mime_types.push_back(widevine_cdm_mime_type);
191 widevine_cdm.permissions = kWidevineCdmPluginPermissions; 212 widevine_cdm.permissions = kWidevineCdmPluginPermissions;
192 plugins->push_back(widevine_cdm); 213 plugins->push_back(widevine_cdm);
193
194 skip_widevine_cdm_file_check = true;
195 }
196 } 214 }
197 #endif // defined(WIDEVINE_CDM_AVAILABLE) && defined(ENABLE_PEPPER_CDMS) && 215 #endif // defined(WIDEVINE_CDM_AVAILABLE) && defined(ENABLE_PEPPER_CDMS) &&
198 // !defined(WIDEVINE_CDM_IS_COMPONENT) 216 // !defined(WIDEVINE_CDM_IS_COMPONENT)
199 } 217 }
200 218
201 content::PepperPluginInfo CreatePepperFlashInfo(const base::FilePath& path, 219 content::PepperPluginInfo CreatePepperFlashInfo(const base::FilePath& path,
202 const std::string& version, 220 const std::string& version,
203 bool is_debug) { 221 bool is_debug) {
204 content::PepperPluginInfo plugin; 222 content::PepperPluginInfo plugin;
205 223
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after
514 flash_versions.push_back(system_flash.release()); 532 flash_versions.push_back(system_flash.release());
515 533
516 // This function will return only the most recent version of the flash plugin. 534 // This function will return only the most recent version of the flash plugin.
517 content::PepperPluginInfo* max_flash = 535 content::PepperPluginInfo* max_flash =
518 FindMostRecentPlugin(flash_versions.get()); 536 FindMostRecentPlugin(flash_versions.get());
519 if (max_flash) 537 if (max_flash)
520 plugins->push_back(*max_flash); 538 plugins->push_back(*max_flash);
521 #endif // defined(ENABLE_PLUGINS) 539 #endif // defined(ENABLE_PLUGINS)
522 } 540 }
523 541
542 void ChromeContentClient::AddContentDecryptionModules(
543 std::vector<content::CdmInfo>* cdms) {
544 // TODO(jrummell): Need to have a better flag to indicate systems Widevine
545 // is available on. For now we continue to use ENABLE_PEPPER_CDMS so that
546 // we can experiment between pepper and mojo.
547 #if defined(WIDEVINE_CDM_AVAILABLE) && defined(ENABLE_PEPPER_CDMS) && \
548 !defined(WIDEVINE_CDM_IS_COMPONENT)
549 base::FilePath adapter_path;
550 base::FilePath cdm_path;
551 std::vector<std::string> codecs_supported;
552 if (IsWidevineAvailable(&adapter_path, &cdm_path, &codecs_supported)) {
553 // CdmInfo needs |path| to be the actual Widevine library,
554 // not the adapter, so adjust as necessary. It will be in the
555 // same directory as the installed adapter.
556 const base::Version version(WIDEVINE_CDM_VERSION_STRING);
557 DCHECK(version.IsValid());
558 cdms->push_back(content::CdmInfo(kWidevineCdmType, version, cdm_path,
559 codecs_supported));
560 }
561 #endif // defined(WIDEVINE_CDM_AVAILABLE) && defined(ENABLE_PEPPER_CDMS) &&
562 // !defined(WIDEVINE_CDM_IS_COMPONENT)
563
564 // TODO(jrummell): Add External Clear Key CDM for testing, if it's available.
565 }
566
524 #if defined(OS_CHROMEOS) 567 #if defined(OS_CHROMEOS)
525 static const int kNumChromeStandardURLSchemes = 6; 568 static const int kNumChromeStandardURLSchemes = 6;
526 #else 569 #else
527 static const int kNumChromeStandardURLSchemes = 5; 570 static const int kNumChromeStandardURLSchemes = 5;
528 #endif 571 #endif
529 static const url::SchemeWithType kChromeStandardURLSchemes[ 572 static const url::SchemeWithType kChromeStandardURLSchemes[
530 kNumChromeStandardURLSchemes] = { 573 kNumChromeStandardURLSchemes] = {
531 {extensions::kExtensionScheme, url::SCHEME_WITHOUT_PORT}, 574 {extensions::kExtensionScheme, url::SCHEME_WITHOUT_PORT},
532 {chrome::kChromeNativeScheme, url::SCHEME_WITHOUT_PORT}, 575 {chrome::kChromeNativeScheme, url::SCHEME_WITHOUT_PORT},
533 {extensions::kExtensionResourceScheme, url::SCHEME_WITHOUT_PORT}, 576 {extensions::kExtensionResourceScheme, url::SCHEME_WITHOUT_PORT},
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
640 #if defined(ENABLE_EXTENSIONS) 683 #if defined(ENABLE_EXTENSIONS)
641 return extensions::IsIsolateExtensionsEnabled(); 684 return extensions::IsIsolateExtensionsEnabled();
642 #else 685 #else
643 return false; 686 return false;
644 #endif 687 #endif
645 } 688 }
646 689
647 base::StringPiece ChromeContentClient::GetOriginTrialPublicKey() { 690 base::StringPiece ChromeContentClient::GetOriginTrialPublicKey() {
648 return origin_trial_key_manager_.GetPublicKey(); 691 return origin_trial_key_manager_.GetPublicKey();
649 } 692 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698