| 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/native_library.h" |
| 20 #include "base/path_service.h" | 21 #include "base/path_service.h" |
| 21 #include "base/strings/string16.h" | 22 #include "base/strings/string16.h" |
| 22 #include "base/strings/string_number_conversions.h" | 23 #include "base/strings/string_number_conversions.h" |
| 23 #include "base/strings/string_split.h" | 24 #include "base/strings/string_split.h" |
| 24 #include "base/strings/string_util.h" | 25 #include "base/strings/string_util.h" |
| 25 #include "base/strings/utf_string_conversions.h" | 26 #include "base/strings/utf_string_conversions.h" |
| 26 #include "base/values.h" | 27 #include "base/values.h" |
| 27 #include "build/build_config.h" | 28 #include "build/build_config.h" |
| 28 #include "chrome/common/chrome_paths.h" | 29 #include "chrome/common/chrome_paths.h" |
| 29 #include "chrome/common/widevine_cdm_constants.h" | 30 #include "chrome/common/widevine_cdm_constants.h" |
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 221 // true = Add to beginning of list to override any existing registrations. | 222 // true = Add to beginning of list to override any existing registrations. |
| 222 PluginService::GetInstance()->RegisterInternalPlugin( | 223 PluginService::GetInstance()->RegisterInternalPlugin( |
| 223 plugin_info.ToWebPluginInfo(), true); | 224 plugin_info.ToWebPluginInfo(), true); |
| 224 // Tell the browser to refresh the plugin list. Then tell all renderers to | 225 // Tell the browser to refresh the plugin list. Then tell all renderers to |
| 225 // update their plugin list caches. | 226 // update their plugin list caches. |
| 226 PluginService::GetInstance()->RefreshPlugins(); | 227 PluginService::GetInstance()->RefreshPlugins(); |
| 227 PluginService::GetInstance()->PurgePluginListCache(NULL, false); | 228 PluginService::GetInstance()->PurgePluginListCache(NULL, false); |
| 228 | 229 |
| 229 // Also register Widevine with the CdmService. | 230 // Also register Widevine with the CdmService. |
| 230 const base::FilePath cdm_path = | 231 const base::FilePath cdm_path = |
| 231 GetPlatformDirectory(cdm_install_dir).AppendASCII(kWidevineCdmFileName); | 232 GetPlatformDirectory(cdm_install_dir) |
| 233 .AppendASCII(base::GetNativeLibraryName(kWidevineCdmLibraryName)); |
| 232 const std::vector<std::string> supported_codecs = base::SplitString( | 234 const std::vector<std::string> supported_codecs = base::SplitString( |
| 233 codecs, std::string(1, kCdmSupportedCodecsValueDelimiter), | 235 codecs, std::string(1, kCdmSupportedCodecsValueDelimiter), |
| 234 base::TRIM_WHITESPACE, base::SPLIT_WANT_NONEMPTY); | 236 base::TRIM_WHITESPACE, base::SPLIT_WANT_NONEMPTY); |
| 235 CdmService::GetInstance()->RegisterCdm(content::CdmInfo( | 237 CdmService::GetInstance()->RegisterCdm(content::CdmInfo( |
| 236 kWidevineCdmType, cdm_version, cdm_path, supported_codecs)); | 238 kWidevineCdmType, cdm_version, cdm_path, supported_codecs)); |
| 237 } | 239 } |
| 238 | 240 |
| 239 } // namespace | 241 } // namespace |
| 240 | 242 |
| 241 class WidevineCdmComponentInstallerTraits : public ComponentInstallerTraits { | 243 class WidevineCdmComponentInstallerTraits : public ComponentInstallerTraits { |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 306 version, | 308 version, |
| 307 path, | 309 path, |
| 308 base::Passed(&manifest))); | 310 base::Passed(&manifest))); |
| 309 } | 311 } |
| 310 | 312 |
| 311 bool WidevineCdmComponentInstallerTraits::VerifyInstallation( | 313 bool WidevineCdmComponentInstallerTraits::VerifyInstallation( |
| 312 const base::DictionaryValue& manifest, | 314 const base::DictionaryValue& manifest, |
| 313 const base::FilePath& install_dir) const { | 315 const base::FilePath& install_dir) const { |
| 314 return IsCompatibleWithChrome(manifest) && | 316 return IsCompatibleWithChrome(manifest) && |
| 315 base::PathExists(GetPlatformDirectory(install_dir) | 317 base::PathExists(GetPlatformDirectory(install_dir) |
| 316 .AppendASCII(kWidevineCdmFileName)); | 318 .AppendASCII(base::GetNativeLibraryName( |
| 319 kWidevineCdmLibraryName))); |
| 317 } | 320 } |
| 318 | 321 |
| 319 // The base directory on Windows looks like: | 322 // The base directory on Windows looks like: |
| 320 // <profile>\AppData\Local\Google\Chrome\User Data\WidevineCdm\. | 323 // <profile>\AppData\Local\Google\Chrome\User Data\WidevineCdm\. |
| 321 base::FilePath WidevineCdmComponentInstallerTraits::GetRelativeInstallDir() | 324 base::FilePath WidevineCdmComponentInstallerTraits::GetRelativeInstallDir() |
| 322 const { | 325 const { |
| 323 return base::FilePath(FILE_PATH_LITERAL("WidevineCdm")); | 326 return base::FilePath(FILE_PATH_LITERAL("WidevineCdm")); |
| 324 } | 327 } |
| 325 | 328 |
| 326 void WidevineCdmComponentInstallerTraits::GetHash( | 329 void WidevineCdmComponentInstallerTraits::GetHash( |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 402 std::unique_ptr<ComponentInstallerTraits> traits( | 405 std::unique_ptr<ComponentInstallerTraits> traits( |
| 403 new WidevineCdmComponentInstallerTraits); | 406 new WidevineCdmComponentInstallerTraits); |
| 404 // |cus| will take ownership of |installer| during installer->Register(cus). | 407 // |cus| will take ownership of |installer| during installer->Register(cus). |
| 405 DefaultComponentInstaller* installer = | 408 DefaultComponentInstaller* installer = |
| 406 new DefaultComponentInstaller(std::move(traits)); | 409 new DefaultComponentInstaller(std::move(traits)); |
| 407 installer->Register(cus, base::Closure()); | 410 installer->Register(cus, base::Closure()); |
| 408 #endif // defined(WIDEVINE_CDM_AVAILABLE) && defined(WIDEVINE_CDM_IS_COMPONENT) | 411 #endif // defined(WIDEVINE_CDM_AVAILABLE) && defined(WIDEVINE_CDM_IS_COMPONENT) |
| 409 } | 412 } |
| 410 | 413 |
| 411 } // namespace component_updater | 414 } // namespace component_updater |
| OLD | NEW |