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

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: rebase + add default copy constructor 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
« no previous file with comments | « chrome/common/chrome_content_client.h ('k') | content/browser/browser_main_loop.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 21 matching lines...) Expand all
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) && \
76 !defined(WIDEVINE_CDM_IS_COMPONENT) 77 !defined(WIDEVINE_CDM_IS_COMPONENT)
78 #define WIDEVINE_CDM_AVAILABLE_NOT_COMPONENT
77 #include "chrome/common/widevine_cdm_constants.h" 79 #include "chrome/common/widevine_cdm_constants.h"
78 #endif 80 #endif
79 81
80 namespace { 82 namespace {
81 83
82 #if defined(ENABLE_PLUGINS) 84 #if defined(ENABLE_PLUGINS)
83 #if defined(ENABLE_PDF) 85 #if defined(ENABLE_PDF)
84 const char kPDFPluginExtension[] = "pdf"; 86 const char kPDFPluginExtension[] = "pdf";
85 const char kPDFPluginDescription[] = "Portable Document Format"; 87 const char kPDFPluginDescription[] = "Portable Document Format";
86 const char kPDFPluginOutOfProcessMimeType[] = 88 const char kPDFPluginOutOfProcessMimeType[] =
87 "application/x-google-chrome-pdf"; 89 "application/x-google-chrome-pdf";
88 const uint32_t kPDFPluginPermissions = 90 const uint32_t kPDFPluginPermissions =
89 ppapi::PERMISSION_PRIVATE | ppapi::PERMISSION_DEV; 91 ppapi::PERMISSION_PRIVATE | ppapi::PERMISSION_DEV;
90 #endif // defined(ENABLE_PDF) 92 #endif // defined(ENABLE_PDF)
91 93
92 content::PepperPluginInfo::GetInterfaceFunc g_pdf_get_interface; 94 content::PepperPluginInfo::GetInterfaceFunc g_pdf_get_interface;
93 content::PepperPluginInfo::PPP_InitializeModuleFunc g_pdf_initialize_module; 95 content::PepperPluginInfo::PPP_InitializeModuleFunc g_pdf_initialize_module;
94 content::PepperPluginInfo::PPP_ShutdownModuleFunc g_pdf_shutdown_module; 96 content::PepperPluginInfo::PPP_ShutdownModuleFunc g_pdf_shutdown_module;
95 97
96 #if !defined(DISABLE_NACL) 98 #if !defined(DISABLE_NACL)
97 content::PepperPluginInfo::GetInterfaceFunc g_nacl_get_interface; 99 content::PepperPluginInfo::GetInterfaceFunc g_nacl_get_interface;
98 content::PepperPluginInfo::PPP_InitializeModuleFunc g_nacl_initialize_module; 100 content::PepperPluginInfo::PPP_InitializeModuleFunc g_nacl_initialize_module;
99 content::PepperPluginInfo::PPP_ShutdownModuleFunc g_nacl_shutdown_module; 101 content::PepperPluginInfo::PPP_ShutdownModuleFunc g_nacl_shutdown_module;
100 #endif 102 #endif
101 103
104 #if defined(WIDEVINE_CDM_AVAILABLE_NOT_COMPONENT)
105 bool IsWidevineAvailable(base::FilePath* adapter_path,
106 base::FilePath* cdm_path,
107 std::vector<std::string>* codecs_supported) {
108 static bool skip_widevine_cdm_file_check = false;
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_NOT_COMPONENT)
131
102 // 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
103 // 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,
104 // 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
105 // not marked internal, aside from being automatically registered, they're just 135 // not marked internal, aside from being automatically registered, they're just
106 // regular plugins). 136 // regular plugins).
107 void ComputeBuiltInPlugins(std::vector<content::PepperPluginInfo>* plugins) { 137 void ComputeBuiltInPlugins(std::vector<content::PepperPluginInfo>* plugins) {
108 #if defined(ENABLE_PDF) 138 #if defined(ENABLE_PDF)
109 content::PepperPluginInfo pdf_info; 139 content::PepperPluginInfo pdf_info;
110 pdf_info.is_internal = true; 140 pdf_info.is_internal = true;
111 pdf_info.is_out_of_process = true; 141 pdf_info.is_out_of_process = true;
112 pdf_info.name = ChromeContentClient::kPDFPluginName; 142 pdf_info.name = ChromeContentClient::kPDFPluginName;
113 pdf_info.description = kPDFPluginDescription; 143 pdf_info.description = kPDFPluginDescription;
114 pdf_info.path = base::FilePath::FromUTF8Unsafe( 144 pdf_info.path = base::FilePath::FromUTF8Unsafe(
115 ChromeContentClient::kPDFPluginPath); 145 ChromeContentClient::kPDFPluginPath);
116 content::WebPluginMimeType pdf_mime_type( 146 content::WebPluginMimeType pdf_mime_type(
117 kPDFPluginOutOfProcessMimeType, 147 kPDFPluginOutOfProcessMimeType,
118 kPDFPluginExtension, 148 kPDFPluginExtension,
119 kPDFPluginDescription); 149 kPDFPluginDescription);
120 pdf_info.mime_types.push_back(pdf_mime_type); 150 pdf_info.mime_types.push_back(pdf_mime_type);
121 pdf_info.internal_entry_points.get_interface = g_pdf_get_interface; 151 pdf_info.internal_entry_points.get_interface = g_pdf_get_interface;
122 pdf_info.internal_entry_points.initialize_module = g_pdf_initialize_module; 152 pdf_info.internal_entry_points.initialize_module = g_pdf_initialize_module;
123 pdf_info.internal_entry_points.shutdown_module = g_pdf_shutdown_module; 153 pdf_info.internal_entry_points.shutdown_module = g_pdf_shutdown_module;
124 pdf_info.permissions = kPDFPluginPermissions; 154 pdf_info.permissions = kPDFPluginPermissions;
125 plugins->push_back(pdf_info); 155 plugins->push_back(pdf_info);
126 #endif // defined(ENABLE_PDF) 156 #endif // defined(ENABLE_PDF)
127 157
128 base::FilePath path;
129
130 #if !defined(DISABLE_NACL) 158 #if !defined(DISABLE_NACL)
131 // 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
132 // 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
133 // 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
134 // 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;
135 if (PathService::Get(chrome::FILE_NACL_PLUGIN, &path)) { 164 if (PathService::Get(chrome::FILE_NACL_PLUGIN, &path)) {
136 content::PepperPluginInfo nacl; 165 content::PepperPluginInfo nacl;
137 // The nacl plugin is now built into the Chromium binary. 166 // The nacl plugin is now built into the Chromium binary.
138 nacl.is_internal = true; 167 nacl.is_internal = true;
139 nacl.path = path; 168 nacl.path = path;
140 nacl.name = nacl::kNaClPluginName; 169 nacl.name = nacl::kNaClPluginName;
141 content::WebPluginMimeType nacl_mime_type(nacl::kNaClPluginMimeType, 170 content::WebPluginMimeType nacl_mime_type(nacl::kNaClPluginMimeType,
142 nacl::kNaClPluginExtension, 171 nacl::kNaClPluginExtension,
143 nacl::kNaClPluginDescription); 172 nacl::kNaClPluginDescription);
144 nacl.mime_types.push_back(nacl_mime_type); 173 nacl.mime_types.push_back(nacl_mime_type);
145 content::WebPluginMimeType pnacl_mime_type(nacl::kPnaclPluginMimeType, 174 content::WebPluginMimeType pnacl_mime_type(nacl::kPnaclPluginMimeType,
146 nacl::kPnaclPluginExtension, 175 nacl::kPnaclPluginExtension,
147 nacl::kPnaclPluginDescription); 176 nacl::kPnaclPluginDescription);
148 nacl.mime_types.push_back(pnacl_mime_type); 177 nacl.mime_types.push_back(pnacl_mime_type);
149 nacl.internal_entry_points.get_interface = g_nacl_get_interface; 178 nacl.internal_entry_points.get_interface = g_nacl_get_interface;
150 nacl.internal_entry_points.initialize_module = g_nacl_initialize_module; 179 nacl.internal_entry_points.initialize_module = g_nacl_initialize_module;
151 nacl.internal_entry_points.shutdown_module = g_nacl_shutdown_module; 180 nacl.internal_entry_points.shutdown_module = g_nacl_shutdown_module;
152 nacl.permissions = ppapi::PERMISSION_PRIVATE | ppapi::PERMISSION_DEV; 181 nacl.permissions = ppapi::PERMISSION_PRIVATE | ppapi::PERMISSION_DEV;
153 plugins->push_back(nacl); 182 plugins->push_back(nacl);
154 } 183 }
155 #endif // !defined(DISABLE_NACL) 184 #endif // !defined(DISABLE_NACL)
156 185
157 #if defined(WIDEVINE_CDM_AVAILABLE) && defined(ENABLE_PEPPER_CDMS) && \ 186 #if defined(WIDEVINE_CDM_AVAILABLE_NOT_COMPONENT)
158 !defined(WIDEVINE_CDM_IS_COMPONENT) 187 base::FilePath adapter_path;
159 static bool skip_widevine_cdm_file_check = false; 188 base::FilePath cdm_path;
160 if (PathService::Get(chrome::FILE_WIDEVINE_CDM_ADAPTER, &path)) { 189 std::vector<std::string> codecs_supported;
161 if (skip_widevine_cdm_file_check || base::PathExists(path)) { 190 if (IsWidevineAvailable(&adapter_path, &cdm_path, &codecs_supported)) {
162 content::PepperPluginInfo widevine_cdm; 191 content::PepperPluginInfo widevine_cdm;
163 widevine_cdm.is_out_of_process = true; 192 widevine_cdm.is_out_of_process = true;
164 widevine_cdm.path = path; 193 widevine_cdm.path = adapter_path;
165 widevine_cdm.name = kWidevineCdmDisplayName; 194 widevine_cdm.name = kWidevineCdmDisplayName;
166 widevine_cdm.description = kWidevineCdmDescription + 195 widevine_cdm.description =
167 std::string(" (version: ") + 196 base::StringPrintf("%s (version: " WIDEVINE_CDM_VERSION_STRING ")",
168 WIDEVINE_CDM_VERSION_STRING + ")"; 197 kWidevineCdmDescription);
169 widevine_cdm.version = WIDEVINE_CDM_VERSION_STRING; 198 widevine_cdm.version = WIDEVINE_CDM_VERSION_STRING;
170 content::WebPluginMimeType widevine_cdm_mime_type( 199 content::WebPluginMimeType widevine_cdm_mime_type(
171 kWidevineCdmPluginMimeType, 200 kWidevineCdmPluginMimeType, kWidevineCdmPluginExtension,
172 kWidevineCdmPluginExtension, 201 kWidevineCdmPluginMimeTypeDescription);
173 kWidevineCdmPluginMimeTypeDescription);
174 202
175 // Add the supported codecs as if they came from the component manifest. 203 widevine_cdm_mime_type.additional_param_names.push_back(
176 // This list must match the CDM that is being bundled with Chrome. 204 base::ASCIIToUTF16(kCdmSupportedCodecsParamName));
177 std::vector<std::string> codecs; 205 widevine_cdm_mime_type.additional_param_values.push_back(base::ASCIIToUTF16(
178 codecs.push_back(kCdmSupportedCodecVp8); 206 base::JoinString(codecs_supported,
179 codecs.push_back(kCdmSupportedCodecVp9); 207 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 208
190 widevine_cdm.mime_types.push_back(widevine_cdm_mime_type); 209 widevine_cdm.mime_types.push_back(widevine_cdm_mime_type);
191 widevine_cdm.permissions = kWidevineCdmPluginPermissions; 210 widevine_cdm.permissions = kWidevineCdmPluginPermissions;
192 plugins->push_back(widevine_cdm); 211 plugins->push_back(widevine_cdm);
193
194 skip_widevine_cdm_file_check = true;
195 }
196 } 212 }
197 #endif // defined(WIDEVINE_CDM_AVAILABLE) && defined(ENABLE_PEPPER_CDMS) && 213 #endif // defined(WIDEVINE_CDM_AVAILABLE_NOT_COMPONENT)
198 // !defined(WIDEVINE_CDM_IS_COMPONENT)
199 } 214 }
200 215
201 content::PepperPluginInfo CreatePepperFlashInfo(const base::FilePath& path, 216 content::PepperPluginInfo CreatePepperFlashInfo(const base::FilePath& path,
202 const std::string& version, 217 const std::string& version,
203 bool is_debug) { 218 bool is_debug) {
204 content::PepperPluginInfo plugin; 219 content::PepperPluginInfo plugin;
205 220
206 plugin.is_out_of_process = true; 221 plugin.is_out_of_process = true;
207 plugin.name = content::kFlashPluginName; 222 plugin.name = content::kFlashPluginName;
208 plugin.path = path; 223 plugin.path = path;
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after
514 flash_versions.push_back(system_flash.release()); 529 flash_versions.push_back(system_flash.release());
515 530
516 // This function will return only the most recent version of the flash plugin. 531 // This function will return only the most recent version of the flash plugin.
517 content::PepperPluginInfo* max_flash = 532 content::PepperPluginInfo* max_flash =
518 FindMostRecentPlugin(flash_versions.get()); 533 FindMostRecentPlugin(flash_versions.get());
519 if (max_flash) 534 if (max_flash)
520 plugins->push_back(*max_flash); 535 plugins->push_back(*max_flash);
521 #endif // defined(ENABLE_PLUGINS) 536 #endif // defined(ENABLE_PLUGINS)
522 } 537 }
523 538
539 void ChromeContentClient::AddContentDecryptionModules(
540 std::vector<content::CdmInfo>* cdms) {
541 // TODO(jrummell): Need to have a better flag to indicate systems Widevine
542 // is available on. For now we continue to use ENABLE_PEPPER_CDMS so that
543 // we can experiment between pepper and mojo.
544 #if defined(WIDEVINE_CDM_AVAILABLE_NOT_COMPONENT)
545 base::FilePath adapter_path;
546 base::FilePath cdm_path;
547 std::vector<std::string> codecs_supported;
548 if (IsWidevineAvailable(&adapter_path, &cdm_path, &codecs_supported)) {
549 // CdmInfo 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 const base::Version version(WIDEVINE_CDM_VERSION_STRING);
553 DCHECK(version.IsValid());
554 cdms->push_back(content::CdmInfo(kWidevineCdmType, version, cdm_path,
555 codecs_supported));
556 }
557 #endif // defined(WIDEVINE_CDM_AVAILABLE_NOT_COMPONENT)
558
559 // TODO(jrummell): Add External Clear Key CDM for testing, if it's available.
560 }
561
524 #if defined(OS_CHROMEOS) 562 #if defined(OS_CHROMEOS)
525 static const int kNumChromeStandardURLSchemes = 6; 563 static const int kNumChromeStandardURLSchemes = 6;
526 #else 564 #else
527 static const int kNumChromeStandardURLSchemes = 5; 565 static const int kNumChromeStandardURLSchemes = 5;
528 #endif 566 #endif
529 static const url::SchemeWithType kChromeStandardURLSchemes[ 567 static const url::SchemeWithType kChromeStandardURLSchemes[
530 kNumChromeStandardURLSchemes] = { 568 kNumChromeStandardURLSchemes] = {
531 {extensions::kExtensionScheme, url::SCHEME_WITHOUT_PORT}, 569 {extensions::kExtensionScheme, url::SCHEME_WITHOUT_PORT},
532 {chrome::kChromeNativeScheme, url::SCHEME_WITHOUT_PORT}, 570 {chrome::kChromeNativeScheme, url::SCHEME_WITHOUT_PORT},
533 {extensions::kExtensionResourceScheme, url::SCHEME_WITHOUT_PORT}, 571 {extensions::kExtensionResourceScheme, url::SCHEME_WITHOUT_PORT},
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
640 #if defined(ENABLE_EXTENSIONS) 678 #if defined(ENABLE_EXTENSIONS)
641 return extensions::IsIsolateExtensionsEnabled(); 679 return extensions::IsIsolateExtensionsEnabled();
642 #else 680 #else
643 return false; 681 return false;
644 #endif 682 #endif
645 } 683 }
646 684
647 base::StringPiece ChromeContentClient::GetOriginTrialPublicKey() { 685 base::StringPiece ChromeContentClient::GetOriginTrialPublicKey() {
648 return origin_trial_key_manager_.GetPublicKey(); 686 return origin_trial_key_manager_.GetPublicKey();
649 } 687 }
OLDNEW
« no previous file with comments | « chrome/common/chrome_content_client.h ('k') | content/browser/browser_main_loop.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698