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

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: changes + file move Created 4 years, 9 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* cdm_adapter_path,
105 std::vector<std::string>* codecs_supported) {
106 static bool skip_widevine_cdm_file_check = false;
107 if (PathService::Get(chrome::FILE_WIDEVINE_CDM_ADAPTER, cdm_adapter_path)) {
108 if (skip_widevine_cdm_file_check || base::PathExists(*cdm_adapter_path)) {
109 skip_widevine_cdm_file_check = true;
110
111 // Add the supported codecs as if they came from the component manifest.
112 // This list must match the CDM that is being bundled with Chrome.
113 codecs_supported->push_back(kCdmSupportedCodecVp8);
114 codecs_supported->push_back(kCdmSupportedCodecVp9);
115 #if defined(USE_PROPRIETARY_CODECS)
116 codecs_supported->push_back(kCdmSupportedCodecAvc1);
117 #endif // defined(USE_PROPRIETARY_CODECS)
118 return true;
119 }
120 }
121
122 return false;
123 }
124 #endif // defined(WIDEVINE_CDM_AVAILABLE) && defined(ENABLE_PEPPER_CDMS) &&
125 // !defined(WIDEVINE_CDM_IS_COMPONENT)
126
101 // Appends the known built-in plugins to the given vector. Some built-in 127 // 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, 128 // 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 129 // and some are extra shared libraries distributed with the browser (these are
104 // not marked internal, aside from being automatically registered, they're just 130 // not marked internal, aside from being automatically registered, they're just
105 // regular plugins). 131 // regular plugins).
106 void ComputeBuiltInPlugins(std::vector<content::PepperPluginInfo>* plugins) { 132 void ComputeBuiltInPlugins(std::vector<content::PepperPluginInfo>* plugins) {
107 #if defined(ENABLE_PDF) 133 #if defined(ENABLE_PDF)
108 content::PepperPluginInfo pdf_info; 134 content::PepperPluginInfo pdf_info;
109 pdf_info.is_internal = true; 135 pdf_info.is_internal = true;
110 pdf_info.is_out_of_process = true; 136 pdf_info.is_out_of_process = true;
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 nacl.internal_entry_points.get_interface = g_nacl_get_interface; 174 nacl.internal_entry_points.get_interface = g_nacl_get_interface;
149 nacl.internal_entry_points.initialize_module = g_nacl_initialize_module; 175 nacl.internal_entry_points.initialize_module = g_nacl_initialize_module;
150 nacl.internal_entry_points.shutdown_module = g_nacl_shutdown_module; 176 nacl.internal_entry_points.shutdown_module = g_nacl_shutdown_module;
151 nacl.permissions = ppapi::PERMISSION_PRIVATE | ppapi::PERMISSION_DEV; 177 nacl.permissions = ppapi::PERMISSION_PRIVATE | ppapi::PERMISSION_DEV;
152 plugins->push_back(nacl); 178 plugins->push_back(nacl);
153 } 179 }
154 #endif // !defined(DISABLE_NACL) 180 #endif // !defined(DISABLE_NACL)
155 181
156 #if defined(WIDEVINE_CDM_AVAILABLE) && defined(ENABLE_PEPPER_CDMS) && \ 182 #if defined(WIDEVINE_CDM_AVAILABLE) && defined(ENABLE_PEPPER_CDMS) && \
157 !defined(WIDEVINE_CDM_IS_COMPONENT) 183 !defined(WIDEVINE_CDM_IS_COMPONENT)
158 static bool skip_widevine_cdm_file_check = false; 184 std::vector<std::string> codecs_supported;
159 if (PathService::Get(chrome::FILE_WIDEVINE_CDM_ADAPTER, &path)) { 185 if (IsWidevineAvailable(&path, &codecs_supported)) {
160 if (skip_widevine_cdm_file_check || base::PathExists(path)) { 186 content::PepperPluginInfo widevine_cdm;
161 content::PepperPluginInfo widevine_cdm; 187 widevine_cdm.is_out_of_process = true;
162 widevine_cdm.is_out_of_process = true; 188 widevine_cdm.path = path;
163 widevine_cdm.path = path; 189 widevine_cdm.name = kWidevineCdmDisplayName;
164 widevine_cdm.name = kWidevineCdmDisplayName; 190 widevine_cdm.description = kWidevineCdmDescription +
165 widevine_cdm.description = kWidevineCdmDescription + 191 std::string(" (version: ") +
166 std::string(" (version: ") + 192 WIDEVINE_CDM_VERSION_STRING + ")";
167 WIDEVINE_CDM_VERSION_STRING + ")"; 193 widevine_cdm.version = WIDEVINE_CDM_VERSION_STRING;
168 widevine_cdm.version = WIDEVINE_CDM_VERSION_STRING; 194 content::WebPluginMimeType widevine_cdm_mime_type(
169 content::WebPluginMimeType widevine_cdm_mime_type( 195 kWidevineCdmPluginMimeType, kWidevineCdmPluginExtension,
170 kWidevineCdmPluginMimeType, 196 kWidevineCdmPluginMimeTypeDescription);
171 kWidevineCdmPluginExtension,
172 kWidevineCdmPluginMimeTypeDescription);
173 197
174 // Add the supported codecs as if they came from the component manifest. 198 widevine_cdm_mime_type.additional_param_names.push_back(
175 // This list must match the CDM that is being bundled with Chrome. 199 base::ASCIIToUTF16(kCdmSupportedCodecsParamName));
176 std::vector<std::string> codecs; 200 widevine_cdm_mime_type.additional_param_values.push_back(base::ASCIIToUTF16(
177 codecs.push_back(kCdmSupportedCodecVp8); 201 base::JoinString(codecs_supported,
178 codecs.push_back(kCdmSupportedCodecVp9); 202 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 203
189 widevine_cdm.mime_types.push_back(widevine_cdm_mime_type); 204 widevine_cdm.mime_types.push_back(widevine_cdm_mime_type);
190 widevine_cdm.permissions = kWidevineCdmPluginPermissions; 205 widevine_cdm.permissions = kWidevineCdmPluginPermissions;
191 plugins->push_back(widevine_cdm); 206 plugins->push_back(widevine_cdm);
192
193 skip_widevine_cdm_file_check = true;
194 }
195 } 207 }
196 #endif // defined(WIDEVINE_CDM_AVAILABLE) && defined(ENABLE_PEPPER_CDMS) && 208 #endif // defined(WIDEVINE_CDM_AVAILABLE) && defined(ENABLE_PEPPER_CDMS) &&
197 // !defined(WIDEVINE_CDM_IS_COMPONENT) 209 // !defined(WIDEVINE_CDM_IS_COMPONENT)
198 } 210 }
199 211
200 content::PepperPluginInfo CreatePepperFlashInfo(const base::FilePath& path, 212 content::PepperPluginInfo CreatePepperFlashInfo(const base::FilePath& path,
201 const std::string& version, 213 const std::string& version,
202 bool is_debug) { 214 bool is_debug) {
203 content::PepperPluginInfo plugin; 215 content::PepperPluginInfo plugin;
204 216
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after
513 flash_versions.push_back(system_flash.release()); 525 flash_versions.push_back(system_flash.release());
514 526
515 // This function will return only the most recent version of the flash plugin. 527 // This function will return only the most recent version of the flash plugin.
516 content::PepperPluginInfo* max_flash = 528 content::PepperPluginInfo* max_flash =
517 FindMostRecentPlugin(flash_versions.get()); 529 FindMostRecentPlugin(flash_versions.get());
518 if (max_flash) 530 if (max_flash)
519 plugins->push_back(*max_flash); 531 plugins->push_back(*max_flash);
520 #endif // defined(ENABLE_PLUGINS) 532 #endif // defined(ENABLE_PLUGINS)
521 } 533 }
522 534
535 void ChromeContentClient::AddContentDecryptionModules(
536 std::vector<content::CdmInfo>* modules) {
537 // TODO(jrummell): Need to have a better flag to indicate systems Widevine
538 // is available on. For now we continue to use ENABLE_PEPPER_CDMS so that
539 // we can experiment between pepper and mojo.
540 #if defined(WIDEVINE_CDM_AVAILABLE) && defined(ENABLE_PEPPER_CDMS) && \
541 !defined(WIDEVINE_CDM_IS_COMPONENT)
542 base::FilePath widevine_adapter_path;
543 std::vector<std::string> codecs_supported;
544 if (IsWidevineAvailable(&widevine_adapter_path, &codecs_supported)) {
545 // CdmInfo needs |path| to be the actual Widevine library,
546 // not the adapter, so adjust as necessary. It will be in the
547 // same directory as the installed adapter.
548 base::FilePath cdm_install_path =
549 widevine_adapter_path.DirName().AppendASCII(kWidevineCdmFileName);
550 base::Version version(WIDEVINE_CDM_VERSION_STRING);
551 DCHECK(version.IsValid());
552 modules->push_back(content::CdmInfo(kWidevineCdmName, version,
553 cdm_install_path, codecs_supported));
554 }
555 #endif // defined(WIDEVINE_CDM_AVAILABLE) && defined(ENABLE_PEPPER_CDMS) &&
556 // !defined(WIDEVINE_CDM_IS_COMPONENT)
557
558 // TODO(jrummell): Add External Clear Key CDM for testing, if it's available.
559 }
560
523 #if defined(OS_CHROMEOS) 561 #if defined(OS_CHROMEOS)
524 static const int kNumChromeStandardURLSchemes = 6; 562 static const int kNumChromeStandardURLSchemes = 6;
525 #else 563 #else
526 static const int kNumChromeStandardURLSchemes = 5; 564 static const int kNumChromeStandardURLSchemes = 5;
527 #endif 565 #endif
528 static const url::SchemeWithType kChromeStandardURLSchemes[ 566 static const url::SchemeWithType kChromeStandardURLSchemes[
529 kNumChromeStandardURLSchemes] = { 567 kNumChromeStandardURLSchemes] = {
530 {extensions::kExtensionScheme, url::SCHEME_WITHOUT_PORT}, 568 {extensions::kExtensionScheme, url::SCHEME_WITHOUT_PORT},
531 {chrome::kChromeNativeScheme, url::SCHEME_WITHOUT_PORT}, 569 {chrome::kChromeNativeScheme, url::SCHEME_WITHOUT_PORT},
532 {extensions::kExtensionResourceScheme, url::SCHEME_WITHOUT_PORT}, 570 {extensions::kExtensionResourceScheme, url::SCHEME_WITHOUT_PORT},
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
639 #if defined(ENABLE_EXTENSIONS) 677 #if defined(ENABLE_EXTENSIONS)
640 return extensions::IsIsolateExtensionsEnabled(); 678 return extensions::IsIsolateExtensionsEnabled();
641 #else 679 #else
642 return false; 680 return false;
643 #endif 681 #endif
644 } 682 }
645 683
646 base::StringPiece ChromeContentClient::GetOriginTrialPublicKey() { 684 base::StringPiece ChromeContentClient::GetOriginTrialPublicKey() {
647 return origin_trial_key_manager_.GetPublicKey(); 685 return origin_trial_key_manager_.GetPublicKey();
648 } 686 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698