Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/browser/component_updater/widevine_cdm_component_installer.h" | 5 #include "chrome/browser/component_updater/widevine_cdm_component_installer.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 #include <string.h> | 9 #include <string.h> |
| 10 #include <string> | 10 #include <string> |
| 11 #include <utility> | 11 #include <utility> |
| 12 #include <vector> | 12 #include <vector> |
| 13 | 13 |
| 14 #include "base/base_paths.h" | 14 #include "base/base_paths.h" |
| 15 #include "base/bind.h" | 15 #include "base/bind.h" |
| 16 #include "base/files/file_path.h" | 16 #include "base/files/file_path.h" |
| 17 #include "base/files/file_util.h" | 17 #include "base/files/file_util.h" |
| 18 #include "base/logging.h" | 18 #include "base/logging.h" |
| 19 #include "base/macros.h" | 19 #include "base/macros.h" |
| 20 #include "base/path_service.h" | 20 #include "base/path_service.h" |
| 21 #include "base/strings/string16.h" | 21 #include "base/strings/string16.h" |
| 22 #include "base/strings/string_number_conversions.h" | 22 #include "base/strings/string_number_conversions.h" |
| 23 #include "base/strings/string_split.h" | 23 #include "base/strings/string_split.h" |
| 24 #include "base/strings/string_util.h" | |
| 24 #include "base/strings/utf_string_conversions.h" | 25 #include "base/strings/utf_string_conversions.h" |
| 25 #include "base/values.h" | 26 #include "base/values.h" |
| 26 #include "build/build_config.h" | 27 #include "build/build_config.h" |
| 27 #include "chrome/common/chrome_paths.h" | 28 #include "chrome/common/chrome_paths.h" |
| 28 #include "chrome/common/widevine_cdm_constants.h" | 29 #include "chrome/common/widevine_cdm_constants.h" |
| 29 #include "components/component_updater/component_updater_service.h" | 30 #include "components/component_updater/component_updater_service.h" |
| 30 #include "components/component_updater/default_component_installer.h" | 31 #include "components/component_updater/default_component_installer.h" |
| 31 #include "components/version_info/version_info.h" | 32 #include "components/version_info/version_info.h" |
| 32 #include "content/public/browser/browser_thread.h" | 33 #include "content/public/browser/browser_thread.h" |
| 33 #include "content/public/browser/plugin_service.h" | 34 #include "content/public/browser/plugin_service.h" |
| 35 #include "content/public/common/cdm_service.h" | |
| 34 #include "content/public/common/pepper_plugin_info.h" | 36 #include "content/public/common/pepper_plugin_info.h" |
| 35 #include "media/cdm/supported_cdm_versions.h" | 37 #include "media/cdm/supported_cdm_versions.h" |
| 36 #include "third_party/widevine/cdm/widevine_cdm_common.h" | 38 #include "third_party/widevine/cdm/widevine_cdm_common.h" |
| 37 | 39 |
| 38 #include "widevine_cdm_version.h" // In SHARED_INTERMEDIATE_DIR. NOLINT | 40 #include "widevine_cdm_version.h" // In SHARED_INTERMEDIATE_DIR. NOLINT |
| 39 | 41 |
| 40 using content::BrowserThread; | 42 using content::BrowserThread; |
| 43 using content::CdmService; | |
| 41 using content::PluginService; | 44 using content::PluginService; |
| 42 | 45 |
| 43 namespace component_updater { | 46 namespace component_updater { |
| 44 | 47 |
| 45 #if defined(WIDEVINE_CDM_AVAILABLE) && defined(WIDEVINE_CDM_IS_COMPONENT) | 48 #if defined(WIDEVINE_CDM_AVAILABLE) && defined(WIDEVINE_CDM_IS_COMPONENT) |
| 46 | 49 |
| 47 namespace { | 50 namespace { |
| 48 | 51 |
| 49 // CRX hash. The extension id is: oimompecagnajdejgnnjijobebaeigek. | 52 // CRX hash. The extension id is: oimompecagnajdejgnnjijobebaeigek. |
| 50 const uint8_t kSha2Hash[] = {0xe8, 0xce, 0xcf, 0x42, 0x06, 0xd0, 0x93, 0x49, | 53 const uint8_t kSha2Hash[] = {0xe8, 0xce, 0xcf, 0x42, 0x06, 0xd0, 0x93, 0x49, |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 101 // Widevine CDM is packaged as a multi-CRX. Widevine CDM binaries are located in | 104 // Widevine CDM is packaged as a multi-CRX. Widevine CDM binaries are located in |
| 102 // _platform_specific/<platform_arch> folder in the package. This function | 105 // _platform_specific/<platform_arch> folder in the package. This function |
| 103 // returns the platform-specific subdirectory that is part of that multi-CRX. | 106 // returns the platform-specific subdirectory that is part of that multi-CRX. |
| 104 base::FilePath GetPlatformDirectory(const base::FilePath& base_path) { | 107 base::FilePath GetPlatformDirectory(const base::FilePath& base_path) { |
| 105 std::string platform_arch = kWidevineCdmPlatform; | 108 std::string platform_arch = kWidevineCdmPlatform; |
| 106 platform_arch += '_'; | 109 platform_arch += '_'; |
| 107 platform_arch += kWidevineCdmArch; | 110 platform_arch += kWidevineCdmArch; |
| 108 return base_path.AppendASCII("_platform_specific").AppendASCII(platform_arch); | 111 return base_path.AppendASCII("_platform_specific").AppendASCII(platform_arch); |
| 109 } | 112 } |
| 110 | 113 |
| 111 bool MakeWidevineCdmPluginInfo( | 114 bool MakeWidevineCdmPluginInfo(const base::Version& version, |
| 112 const base::Version& version, | 115 const base::FilePath& path, |
| 113 const base::FilePath& path, | 116 base::string16 codecs, |
| 114 const std::vector<base::string16>& additional_param_names, | 117 content::PepperPluginInfo* plugin_info) { |
| 115 const std::vector<base::string16>& additional_param_values, | |
| 116 content::PepperPluginInfo* plugin_info) { | |
| 117 if (!version.IsValid() || | 118 if (!version.IsValid() || |
| 118 version.components().size() != | 119 version.components().size() != |
| 119 static_cast<size_t>(kWidevineCdmVersionNumComponents)) { | 120 static_cast<size_t>(kWidevineCdmVersionNumComponents)) { |
| 120 return false; | 121 return false; |
| 121 } | 122 } |
| 122 | 123 |
| 123 plugin_info->is_internal = false; | 124 plugin_info->is_internal = false; |
| 124 // Widevine CDM must run out of process. | 125 // Widevine CDM must run out of process. |
| 125 plugin_info->is_out_of_process = true; | 126 plugin_info->is_out_of_process = true; |
| 126 plugin_info->path = path; | 127 plugin_info->path = path; |
| 127 plugin_info->name = kWidevineCdmDisplayName; | 128 plugin_info->name = kWidevineCdmDisplayName; |
| 128 plugin_info->description = kWidevineCdmDescription + | 129 plugin_info->description = kWidevineCdmDescription + |
| 129 std::string(" (version: ") + version.GetString() + | 130 std::string(" (version: ") + version.GetString() + |
| 130 ")"; | 131 ")"; |
| 131 plugin_info->version = version.GetString(); | 132 plugin_info->version = version.GetString(); |
| 132 content::WebPluginMimeType widevine_cdm_mime_type( | 133 content::WebPluginMimeType widevine_cdm_mime_type( |
| 133 kWidevineCdmPluginMimeType, | 134 kWidevineCdmPluginMimeType, |
| 134 kWidevineCdmPluginExtension, | 135 kWidevineCdmPluginExtension, |
| 135 kWidevineCdmPluginMimeTypeDescription); | 136 kWidevineCdmPluginMimeTypeDescription); |
| 136 widevine_cdm_mime_type.additional_param_names = additional_param_names; | 137 widevine_cdm_mime_type.additional_param_names.push_back( |
| 137 widevine_cdm_mime_type.additional_param_values = additional_param_values; | 138 base::ASCIIToUTF16(kCdmSupportedCodecsParamName)); |
| 139 widevine_cdm_mime_type.additional_param_values.push_back(codecs); | |
| 140 | |
| 138 plugin_info->mime_types.push_back(widevine_cdm_mime_type); | 141 plugin_info->mime_types.push_back(widevine_cdm_mime_type); |
| 139 plugin_info->permissions = kWidevineCdmPluginPermissions; | 142 plugin_info->permissions = kWidevineCdmPluginPermissions; |
| 140 | 143 |
| 141 return true; | 144 return true; |
| 142 } | 145 } |
| 143 | 146 |
| 144 typedef bool (*VersionCheckFunc)(int version); | 147 typedef bool (*VersionCheckFunc)(int version); |
| 145 | 148 |
| 146 bool CheckForCompatibleVersion(const base::DictionaryValue& manifest, | 149 bool CheckForCompatibleVersion(const base::DictionaryValue& manifest, |
| 147 const std::string version_name, | 150 const std::string version_name, |
| (...skipping 30 matching lines...) Expand all Loading... | |
| 178 kCdmModuleVersionsName, | 181 kCdmModuleVersionsName, |
| 179 media::IsSupportedCdmModuleVersion) && | 182 media::IsSupportedCdmModuleVersion) && |
| 180 CheckForCompatibleVersion(manifest, | 183 CheckForCompatibleVersion(manifest, |
| 181 kCdmInterfaceVersionsName, | 184 kCdmInterfaceVersionsName, |
| 182 media::IsSupportedCdmInterfaceVersion) && | 185 media::IsSupportedCdmInterfaceVersion) && |
| 183 CheckForCompatibleVersion(manifest, | 186 CheckForCompatibleVersion(manifest, |
| 184 kCdmHostVersionsName, | 187 kCdmHostVersionsName, |
| 185 media::IsSupportedCdmHostVersion); | 188 media::IsSupportedCdmHostVersion); |
| 186 } | 189 } |
| 187 | 190 |
| 188 void GetAdditionalParams(const base::DictionaryValue& manifest, | 191 base::string16 GetCodecs(const base::DictionaryValue& manifest) { |
| 189 std::vector<base::string16>* additional_param_names, | |
| 190 std::vector<base::string16>* additional_param_values) { | |
| 191 base::string16 codecs; | 192 base::string16 codecs; |
| 192 if (manifest.GetString(kCdmCodecsListName, &codecs)) { | 193 if (manifest.GetString(kCdmCodecsListName, &codecs)) { |
| 193 DLOG_IF(WARNING, codecs.empty()) | 194 DLOG_IF(WARNING, codecs.empty()) |
| 194 << "Widevine CDM component manifest has empty codecs list"; | 195 << "Widevine CDM component manifest has empty codecs list"; |
| 195 additional_param_names->push_back( | 196 return codecs; |
| 196 base::ASCIIToUTF16(kCdmSupportedCodecsParamName)); | |
| 197 additional_param_values->push_back(codecs); | |
| 198 } else { | |
| 199 DLOG(WARNING) << "Widevine CDM component manifest is missing codecs"; | |
| 200 } | 197 } |
| 198 | |
| 199 DLOG(WARNING) << "Widevine CDM component manifest is missing codecs"; | |
| 200 return base::string16(); | |
|
xhwang
2016/03/18 19:35:38
move line 196 here?
jrummell
2016/03/23 21:38:09
Done.
| |
| 201 } | |
| 202 | |
| 203 std::vector<base::string16> GetInitDataTypes() { | |
| 204 // TODO(http://crbug.com/469202): Add this to the manifest and extract here. | |
|
xhwang
2016/03/18 19:35:38
nit: TODO(jrummell) or TODO(xhwang)
jrummell
2016/03/23 21:38:09
Removed this.
| |
| 205 return std::vector<base::string16>(); | |
| 201 } | 206 } |
| 202 | 207 |
| 203 void RegisterWidevineCdmWithChrome(const base::Version& cdm_version, | 208 void RegisterWidevineCdmWithChrome(const base::Version& cdm_version, |
| 204 const base::FilePath& adapter_install_path, | 209 const base::FilePath& adapter_install_path, |
| 205 scoped_ptr<base::DictionaryValue> manifest) { | 210 scoped_ptr<base::DictionaryValue> manifest) { |
| 206 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 211 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 207 std::vector<base::string16> additional_param_names; | 212 base::string16 codecs = GetCodecs(*manifest); |
| 208 std::vector<base::string16> additional_param_values; | |
| 209 GetAdditionalParams( | |
| 210 *manifest, &additional_param_names, &additional_param_values); | |
| 211 content::PepperPluginInfo plugin_info; | 213 content::PepperPluginInfo plugin_info; |
| 212 if (!MakeWidevineCdmPluginInfo(cdm_version, | 214 if (!MakeWidevineCdmPluginInfo(cdm_version, adapter_install_path, codecs, |
| 213 adapter_install_path, | |
| 214 additional_param_names, | |
| 215 additional_param_values, | |
| 216 &plugin_info)) { | 215 &plugin_info)) { |
| 217 return; | 216 return; |
| 218 } | 217 } |
| 219 | 218 |
| 220 // true = Add to beginning of list to override any existing registrations. | 219 // true = Add to beginning of list to override any existing registrations. |
| 221 PluginService::GetInstance()->RegisterInternalPlugin( | 220 PluginService::GetInstance()->RegisterInternalPlugin( |
| 222 plugin_info.ToWebPluginInfo(), true); | 221 plugin_info.ToWebPluginInfo(), true); |
| 223 // Tell the browser to refresh the plugin list. Then tell all renderers to | 222 // Tell the browser to refresh the plugin list. Then tell all renderers to |
| 224 // update their plugin list caches. | 223 // update their plugin list caches. |
| 225 PluginService::GetInstance()->RefreshPlugins(); | 224 PluginService::GetInstance()->RefreshPlugins(); |
| 226 PluginService::GetInstance()->PurgePluginListCache(NULL, false); | 225 PluginService::GetInstance()->PurgePluginListCache(NULL, false); |
| 226 | |
| 227 // Also register Widevine with the CdmService. It needs | |
| 228 // |path| to be the actual Widevine library, not the adapter, so adjust as | |
| 229 // necessary. It will be in the same directory as the installed adapter. | |
| 230 // TODO(crbug.com/469202). Add support for initDataTypes in the manifest, | |
|
xhwang
2016/03/18 19:35:38
ditto about TODO
jrummell
2016/03/23 21:38:09
Also removed.
| |
| 231 // and then derive |supported_init_data_types| from it. | |
| 232 std::vector<base::string16> supported_codecs = base::SplitString( | |
| 233 codecs, | |
| 234 base::ASCIIToUTF16(std::string(1, kCdmSupportedCodecsValueDelimiter)), | |
| 235 base::KEEP_WHITESPACE, base::SPLIT_WANT_ALL); | |
| 236 CdmService::GetInstance()->Register( | |
| 237 kWidevineKeySystem, cdm_version.GetString(), | |
| 238 adapter_install_path.DirName().AppendASCII(kWidevineCdmFileName), | |
| 239 supported_codecs, GetInitDataTypes()); | |
| 227 } | 240 } |
| 228 | 241 |
| 229 } // namespace | 242 } // namespace |
| 230 | 243 |
| 231 class WidevineCdmComponentInstallerTraits : public ComponentInstallerTraits { | 244 class WidevineCdmComponentInstallerTraits : public ComponentInstallerTraits { |
| 232 public: | 245 public: |
| 233 WidevineCdmComponentInstallerTraits(); | 246 WidevineCdmComponentInstallerTraits(); |
| 234 ~WidevineCdmComponentInstallerTraits() override {} | 247 ~WidevineCdmComponentInstallerTraits() override {} |
| 235 | 248 |
| 236 private: | 249 private: |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 369 scoped_ptr<ComponentInstallerTraits> traits( | 382 scoped_ptr<ComponentInstallerTraits> traits( |
| 370 new WidevineCdmComponentInstallerTraits); | 383 new WidevineCdmComponentInstallerTraits); |
| 371 // |cus| will take ownership of |installer| during installer->Register(cus). | 384 // |cus| will take ownership of |installer| during installer->Register(cus). |
| 372 DefaultComponentInstaller* installer = | 385 DefaultComponentInstaller* installer = |
| 373 new DefaultComponentInstaller(std::move(traits)); | 386 new DefaultComponentInstaller(std::move(traits)); |
| 374 installer->Register(cus, base::Closure()); | 387 installer->Register(cus, base::Closure()); |
| 375 #endif // defined(WIDEVINE_CDM_AVAILABLE) && defined(WIDEVINE_CDM_IS_COMPONENT) | 388 #endif // defined(WIDEVINE_CDM_AVAILABLE) && defined(WIDEVINE_CDM_IS_COMPONENT) |
| 376 } | 389 } |
| 377 | 390 |
| 378 } // namespace component_updater | 391 } // namespace component_updater |
| OLD | NEW |