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

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: Created 4 years, 10 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 15 matching lines...) Expand all
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_switches.h" 35 #include "content/public/common/content_switches.h"
36 #include "content/public/common/key_system_registration.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
45 #include "widevine_cdm_version.h" // In SHARED_INTERMEDIATE_DIR. 46 #include "widevine_cdm_version.h" // In SHARED_INTERMEDIATE_DIR.
(...skipping 25 matching lines...) Expand all
71 #include "ppapi/shared_impl/ppapi_permissions.h" 72 #include "ppapi/shared_impl/ppapi_permissions.h"
72 #endif 73 #endif
73 74
74 #if defined(WIDEVINE_CDM_AVAILABLE) && defined(ENABLE_PEPPER_CDMS) && \ 75 #if defined(WIDEVINE_CDM_AVAILABLE) && defined(ENABLE_PEPPER_CDMS) && \
75 !defined(WIDEVINE_CDM_IS_COMPONENT) 76 !defined(WIDEVINE_CDM_IS_COMPONENT)
76 #include "chrome/common/widevine_cdm_constants.h" 77 #include "chrome/common/widevine_cdm_constants.h"
77 #endif 78 #endif
78 79
79 namespace { 80 namespace {
80 81
82 // File name of the External ClearKey CDM on different platforms.
83 const base::FilePath::CharType kExternalClearKeyCdmFileName[] =
84 #if defined(OS_MACOSX)
85 FILE_PATH_LITERAL("libclearkeycdm.dylib");
86 #elif defined(OS_WIN)
87 FILE_PATH_LITERAL("clearkeycdm.dll");
88 #else // OS_LINUX, etc.
89 FILE_PATH_LITERAL("libclearkeycdm.so");
90 #endif
91
92 // Key system name for External Clear Key (used for testing). The different
93 // variations cause different behavior, but they all come from the same library.
94 const char kExternalClearKeyKeySystem[] = "org.chromium.externalclearkey";
95 const char kExternalClearKeyDecryptOnlyKeySystem[] =
96 "org.chromium.externalclearkey.decryptonly";
97 const char kExternalClearKeyFileIOTestKeySystem[] =
98 "org.chromium.externalclearkey.fileiotest";
99 const char kExternalClearKeyInitializeFailKeySystem[] =
100 "org.chromium.externalclearkey.initializefail";
101 const char kExternalClearKeyCrashKeySystem[] =
102 "org.chromium.externalclearkey.crash";
103
81 #if defined(ENABLE_PLUGINS) 104 #if defined(ENABLE_PLUGINS)
82 #if defined(ENABLE_PDF) 105 #if defined(ENABLE_PDF)
83 const char kPDFPluginExtension[] = "pdf"; 106 const char kPDFPluginExtension[] = "pdf";
84 const char kPDFPluginDescription[] = "Portable Document Format"; 107 const char kPDFPluginDescription[] = "Portable Document Format";
85 const char kPDFPluginOutOfProcessMimeType[] = 108 const char kPDFPluginOutOfProcessMimeType[] =
86 "application/x-google-chrome-pdf"; 109 "application/x-google-chrome-pdf";
87 const uint32_t kPDFPluginPermissions = 110 const uint32_t kPDFPluginPermissions =
88 ppapi::PERMISSION_PRIVATE | ppapi::PERMISSION_DEV; 111 ppapi::PERMISSION_PRIVATE | ppapi::PERMISSION_DEV;
89 #endif // defined(ENABLE_PDF) 112 #endif // defined(ENABLE_PDF)
90 113
91 content::PepperPluginInfo::GetInterfaceFunc g_pdf_get_interface; 114 content::PepperPluginInfo::GetInterfaceFunc g_pdf_get_interface;
92 content::PepperPluginInfo::PPP_InitializeModuleFunc g_pdf_initialize_module; 115 content::PepperPluginInfo::PPP_InitializeModuleFunc g_pdf_initialize_module;
93 content::PepperPluginInfo::PPP_ShutdownModuleFunc g_pdf_shutdown_module; 116 content::PepperPluginInfo::PPP_ShutdownModuleFunc g_pdf_shutdown_module;
94 117
95 #if !defined(DISABLE_NACL) 118 #if !defined(DISABLE_NACL)
96 content::PepperPluginInfo::GetInterfaceFunc g_nacl_get_interface; 119 content::PepperPluginInfo::GetInterfaceFunc g_nacl_get_interface;
97 content::PepperPluginInfo::PPP_InitializeModuleFunc g_nacl_initialize_module; 120 content::PepperPluginInfo::PPP_InitializeModuleFunc g_nacl_initialize_module;
98 content::PepperPluginInfo::PPP_ShutdownModuleFunc g_nacl_shutdown_module; 121 content::PepperPluginInfo::PPP_ShutdownModuleFunc g_nacl_shutdown_module;
99 #endif 122 #endif
100 123
124 #if defined(WIDEVINE_CDM_AVAILABLE) && !defined(WIDEVINE_CDM_IS_COMPONENT)
125 static bool IsWidevineAvailable(base::FilePath* cdm_adapter_path,
xhwang 2016/01/29 07:43:06 Probably we should move this function and the ECK
126 base::string16* codecs_supported) {
127 static bool skip_widevine_cdm_file_check = false;
128 if (PathService::Get(chrome::FILE_WIDEVINE_CDM_ADAPTER, cdm_adapter_path)) {
129 if (skip_widevine_cdm_file_check || base::PathExists(*cdm_adapter_path)) {
130 skip_widevine_cdm_file_check = true;
131
132 // Add the supported codecs as if they came from the component manifest.
133 std::vector<std::string> codecs;
134 codecs.push_back(kCdmSupportedCodecVorbis);
135 codecs.push_back(kCdmSupportedCodecVp8);
136 codecs.push_back(kCdmSupportedCodecVp9);
137 #if defined(USE_PROPRIETARY_CODECS)
138 codecs.push_back(kCdmSupportedCodecAac);
139 codecs.push_back(kCdmSupportedCodecAvc1);
140 #endif // defined(USE_PROPRIETARY_CODECS)
141 *codecs_supported = base::ASCIIToUTF16(base::JoinString(
142 codecs, std::string(1, kCdmSupportedCodecsValueDelimiter)));
143 return true;
144 }
145 }
146
147 return false;
148 }
149 #endif // defined(WIDEVINE_CDM_AVAILABLE) &&
150 // !defined(WIDEVINE_CDM_IS_COMPONENT)
151
101 // Appends the known built-in plugins to the given vector. Some built-in 152 // 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, 153 // 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 154 // and some are extra shared libraries distributed with the browser (these are
104 // not marked internal, aside from being automatically registered, they're just 155 // not marked internal, aside from being automatically registered, they're just
105 // regular plugins). 156 // regular plugins).
106 void ComputeBuiltInPlugins(std::vector<content::PepperPluginInfo>* plugins) { 157 void ComputeBuiltInPlugins(std::vector<content::PepperPluginInfo>* plugins) {
107 #if defined(ENABLE_PDF) 158 #if defined(ENABLE_PDF)
108 content::PepperPluginInfo pdf_info; 159 content::PepperPluginInfo pdf_info;
109 pdf_info.is_internal = true; 160 pdf_info.is_internal = true;
110 pdf_info.is_out_of_process = true; 161 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; 199 nacl.internal_entry_points.get_interface = g_nacl_get_interface;
149 nacl.internal_entry_points.initialize_module = g_nacl_initialize_module; 200 nacl.internal_entry_points.initialize_module = g_nacl_initialize_module;
150 nacl.internal_entry_points.shutdown_module = g_nacl_shutdown_module; 201 nacl.internal_entry_points.shutdown_module = g_nacl_shutdown_module;
151 nacl.permissions = ppapi::PERMISSION_PRIVATE | ppapi::PERMISSION_DEV; 202 nacl.permissions = ppapi::PERMISSION_PRIVATE | ppapi::PERMISSION_DEV;
152 plugins->push_back(nacl); 203 plugins->push_back(nacl);
153 } 204 }
154 #endif // !defined(DISABLE_NACL) 205 #endif // !defined(DISABLE_NACL)
155 206
156 #if defined(WIDEVINE_CDM_AVAILABLE) && defined(ENABLE_PEPPER_CDMS) && \ 207 #if defined(WIDEVINE_CDM_AVAILABLE) && defined(ENABLE_PEPPER_CDMS) && \
157 !defined(WIDEVINE_CDM_IS_COMPONENT) 208 !defined(WIDEVINE_CDM_IS_COMPONENT)
158 static bool skip_widevine_cdm_file_check = false; 209 base::string16 codecs_supported;
159 if (PathService::Get(chrome::FILE_WIDEVINE_CDM_ADAPTER, &path)) { 210 if (IsWidevineAvailable(&path, &codecs_supported)) {
160 if (skip_widevine_cdm_file_check || base::PathExists(path)) { 211 content::PepperPluginInfo widevine_cdm;
161 content::PepperPluginInfo widevine_cdm; 212 widevine_cdm.is_out_of_process = true;
162 widevine_cdm.is_out_of_process = true; 213 widevine_cdm.path = path;
163 widevine_cdm.path = path; 214 widevine_cdm.name = kWidevineCdmDisplayName;
164 widevine_cdm.name = kWidevineCdmDisplayName; 215 widevine_cdm.description = kWidevineCdmDescription +
165 widevine_cdm.description = kWidevineCdmDescription + 216 std::string(" (version: ") +
166 std::string(" (version: ") + 217 WIDEVINE_CDM_VERSION_STRING + ")";
167 WIDEVINE_CDM_VERSION_STRING + ")"; 218 widevine_cdm.version = WIDEVINE_CDM_VERSION_STRING;
168 widevine_cdm.version = WIDEVINE_CDM_VERSION_STRING; 219 content::WebPluginMimeType widevine_cdm_mime_type(
169 content::WebPluginMimeType widevine_cdm_mime_type( 220 kWidevineCdmPluginMimeType, kWidevineCdmPluginExtension,
170 kWidevineCdmPluginMimeType, 221 kWidevineCdmPluginMimeTypeDescription);
171 kWidevineCdmPluginExtension,
172 kWidevineCdmPluginMimeTypeDescription);
173 222
174 // Add the supported codecs as if they came from the component manifest. 223 widevine_cdm_mime_type.additional_param_names.push_back(
175 std::vector<std::string> codecs; 224 base::ASCIIToUTF16(kCdmSupportedCodecsParamName));
176 codecs.push_back(kCdmSupportedCodecVorbis); 225 widevine_cdm_mime_type.additional_param_values.push_back(codecs_supported);
177 codecs.push_back(kCdmSupportedCodecVp8);
178 codecs.push_back(kCdmSupportedCodecVp9);
179 #if defined(USE_PROPRIETARY_CODECS)
180 codecs.push_back(kCdmSupportedCodecAac);
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 226
190 widevine_cdm.mime_types.push_back(widevine_cdm_mime_type); 227 widevine_cdm.mime_types.push_back(widevine_cdm_mime_type);
191 widevine_cdm.permissions = kWidevineCdmPluginPermissions; 228 widevine_cdm.permissions = kWidevineCdmPluginPermissions;
192 plugins->push_back(widevine_cdm); 229 plugins->push_back(widevine_cdm);
193
194 skip_widevine_cdm_file_check = true;
195 }
196 } 230 }
197 #endif // defined(WIDEVINE_CDM_AVAILABLE) && defined(ENABLE_PEPPER_CDMS) && 231 #endif // defined(WIDEVINE_CDM_AVAILABLE) && defined(ENABLE_PEPPER_CDMS) &&
198 // !defined(WIDEVINE_CDM_IS_COMPONENT) 232 // !defined(WIDEVINE_CDM_IS_COMPONENT)
199 } 233 }
200 234
201 content::PepperPluginInfo CreatePepperFlashInfo(const base::FilePath& path, 235 content::PepperPluginInfo CreatePepperFlashInfo(const base::FilePath& path,
202 const std::string& version, 236 const std::string& version,
203 bool is_debug) { 237 bool is_debug) {
204 content::PepperPluginInfo plugin; 238 content::PepperPluginInfo plugin;
205 239
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after
514 flash_versions.push_back(system_flash.release()); 548 flash_versions.push_back(system_flash.release());
515 549
516 // This function will return only the most recent version of the flash plugin. 550 // This function will return only the most recent version of the flash plugin.
517 content::PepperPluginInfo* max_flash = 551 content::PepperPluginInfo* max_flash =
518 FindMostRecentPlugin(flash_versions.get()); 552 FindMostRecentPlugin(flash_versions.get());
519 if (max_flash) 553 if (max_flash)
520 plugins->push_back(*max_flash); 554 plugins->push_back(*max_flash);
521 #endif // defined(ENABLE_PLUGINS) 555 #endif // defined(ENABLE_PLUGINS)
522 } 556 }
523 557
558 void ChromeContentClient::AddKeySystems(
559 std::vector<content::KeySystemRegistration>* key_systems) {
560 #if defined(WIDEVINE_CDM_AVAILABLE) && !defined(WIDEVINE_CDM_IS_COMPONENT)
ddorwin 2016/01/26 20:21:53 This code will run on Android. Yes, we want to reg
561 base::FilePath widevine_adapter_path;
562 base::string16 codecs_supported;
563 if (IsWidevineAvailable(&widevine_adapter_path, &codecs_supported)) {
564 // |key_systems| needs |path| to be the actual Widevine library,
565 // not the adapter, so adjust as necessary. It will be in the
566 // same directory as the installed adapter.
567 key_systems->push_back(content::KeySystemRegistration(
568 kWidevineKeySystem,
569 widevine_adapter_path.DirName().AppendASCII(kWidevineCdmFileName),
570 codecs_supported));
571 }
572 #endif // defined(WIDEVINE_CDM_AVAILABLE) &&
573 // !defined(WIDEVINE_CDM_IS_COMPONENT)
574
575 // External Clear Key is used for testing the interface to key systems.
xhwang 2016/01/29 07:43:06 This CL is getting large. It seems we can split th
jrummell 2016/03/04 01:19:40 Done.
576 base::FilePath clearkey_path;
577 static bool skip_clearkey_cdm_file_check = false;
578 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
579 if (command_line->HasSwitch(switches::kEnableExternalClearKey)) {
580 if (PathService::Get(chrome::DIR_INTERNAL_PLUGINS, &clearkey_path)) {
581 clearkey_path = clearkey_path.AppendASCII(kExternalClearKeyCdmFileName);
582 if (skip_clearkey_cdm_file_check || base::PathExists(clearkey_path)) {
583 skip_clearkey_cdm_file_check = true;
584
585 // External Clear Key supports all codecs.
586 std::vector<std::string> codecs_supported;
587 codecs_supported.push_back(kCdmSupportedCodecVorbis);
588 codecs_supported.push_back(kCdmSupportedCodecVp8);
589 codecs_supported.push_back(kCdmSupportedCodecVp9);
590 #if defined(USE_PROPRIETARY_CODECS)
591 codecs_supported.push_back(kCdmSupportedCodecAac);
592 codecs_supported.push_back(kCdmSupportedCodecAvc1);
593 #endif // defined(USE_PROPRIETARY_CODECS)
594 base::string16 codecs = base::ASCIIToUTF16(base::JoinString(
595 codecs_supported,
596 std::string(1, kCdmSupportedCodecsValueDelimiter)));
597
598 key_systems->push_back(content::KeySystemRegistration(
599 kExternalClearKeyKeySystem, clearkey_path, codecs));
600 key_systems->push_back(content::KeySystemRegistration(
601 kExternalClearKeyDecryptOnlyKeySystem, clearkey_path, codecs));
602 key_systems->push_back(content::KeySystemRegistration(
603 kExternalClearKeyFileIOTestKeySystem, clearkey_path, codecs));
604 key_systems->push_back(content::KeySystemRegistration(
605 kExternalClearKeyInitializeFailKeySystem, clearkey_path, codecs));
606 key_systems->push_back(content::KeySystemRegistration(
607 kExternalClearKeyCrashKeySystem, clearkey_path, codecs));
608 }
609 }
610 }
611 }
612
524 #if defined(OS_CHROMEOS) 613 #if defined(OS_CHROMEOS)
525 static const int kNumChromeStandardURLSchemes = 6; 614 static const int kNumChromeStandardURLSchemes = 6;
526 #else 615 #else
527 static const int kNumChromeStandardURLSchemes = 5; 616 static const int kNumChromeStandardURLSchemes = 5;
528 #endif 617 #endif
529 static const url::SchemeWithType kChromeStandardURLSchemes[ 618 static const url::SchemeWithType kChromeStandardURLSchemes[
530 kNumChromeStandardURLSchemes] = { 619 kNumChromeStandardURLSchemes] = {
531 {extensions::kExtensionScheme, url::SCHEME_WITHOUT_PORT}, 620 {extensions::kExtensionScheme, url::SCHEME_WITHOUT_PORT},
532 {chrome::kChromeNativeScheme, url::SCHEME_WITHOUT_PORT}, 621 {chrome::kChromeNativeScheme, url::SCHEME_WITHOUT_PORT},
533 {extensions::kExtensionResourceScheme, url::SCHEME_WITHOUT_PORT}, 622 {extensions::kExtensionResourceScheme, url::SCHEME_WITHOUT_PORT},
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
630 #endif 719 #endif
631 } 720 }
632 721
633 bool ChromeContentClient::IsSupplementarySiteIsolationModeEnabled() { 722 bool ChromeContentClient::IsSupplementarySiteIsolationModeEnabled() {
634 #if defined(ENABLE_EXTENSIONS) 723 #if defined(ENABLE_EXTENSIONS)
635 return extensions::IsIsolateExtensionsEnabled(); 724 return extensions::IsIsolateExtensionsEnabled();
636 #else 725 #else
637 return false; 726 return false;
638 #endif 727 #endif
639 } 728 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698