| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 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 <memory> | 5 #include <memory> |
| 6 #include <utility> | 6 #include <utility> |
| 7 | 7 |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/path_service.h" | 9 #include "base/path_service.h" |
| 10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
| 11 #include "base/win/windows_version.h" | 11 #include "base/win/windows_version.h" |
| 12 #include "build/build_config.h" | 12 #include "build/build_config.h" |
| 13 #include "chrome/browser/media/media_browsertest.h" | 13 #include "chrome/browser/media/media_browsertest.h" |
| 14 #include "chrome/browser/media/test_license_server.h" | 14 #include "chrome/browser/media/test_license_server.h" |
| 15 #include "chrome/browser/media/wv_test_license_server_config.h" | 15 #include "chrome/browser/media/wv_test_license_server_config.h" |
| 16 #include "chrome/browser/ui/browser.h" | 16 #include "chrome/browser/ui/browser.h" |
| 17 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 17 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 18 #include "chrome/common/chrome_switches.h" | 18 #include "chrome/common/chrome_switches.h" |
| 19 #include "content/public/common/content_switches.h" | 19 #include "content/public/common/content_switches.h" |
| 20 #include "content/public/test/browser_test_utils.h" | 20 #include "content/public/test/browser_test_utils.h" |
| 21 #include "testing/gtest/include/gtest/gtest-spi.h" | 21 #include "testing/gtest/include/gtest/gtest-spi.h" |
| 22 #if defined(OS_ANDROID) | 22 #if defined(OS_ANDROID) |
| 23 #include "base/android/build_info.h" | 23 #include "base/android/build_info.h" |
| 24 #endif | 24 #endif |
| 25 | 25 |
| 26 #include "widevine_cdm_version.h" // In SHARED_INTERMEDIATE_DIR. | 26 #include "widevine_cdm_version.h" // In SHARED_INTERMEDIATE_DIR. |
| 27 | 27 |
| 28 #if defined(ENABLE_PEPPER_CDMS) | 28 #if defined(ENABLE_PEPPER_CDMS) |
| 29 // Platform-specific filename relative to the chrome executable. | 29 // Base path for Clear Key CDM (relative to the chrome executable). |
| 30 const char kClearKeyCdmBaseDirectory[] = "ClearKeyCdm"; |
| 31 |
| 32 // Platform-specific filename relative to kClearKeyCdmBaseDirectory. |
| 30 const char kClearKeyCdmAdapterFileName[] = | 33 const char kClearKeyCdmAdapterFileName[] = |
| 31 #if defined(OS_MACOSX) | 34 #if defined(OS_MACOSX) |
| 32 "clearkeycdmadapter.plugin"; | 35 "clearkeycdmadapter.plugin"; |
| 33 #elif defined(OS_WIN) | 36 #elif defined(OS_WIN) |
| 34 "clearkeycdmadapter.dll"; | 37 "clearkeycdmadapter.dll"; |
| 35 #elif defined(OS_POSIX) | 38 #elif defined(OS_POSIX) |
| 36 "libclearkeycdmadapter.so"; | 39 "libclearkeycdmadapter.so"; |
| 37 #endif | 40 #endif |
| 38 | 41 |
| 39 const char kClearKeyCdmPluginMimeType[] = "application/x-ppapi-clearkey-cdm"; | 42 const char kClearKeyCdmPluginMimeType[] = "application/x-ppapi-clearkey-cdm"; |
| (...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 254 void SetUpCommandLineForKeySystem(const std::string& key_system, | 257 void SetUpCommandLineForKeySystem(const std::string& key_system, |
| 255 base::CommandLine* command_line) { | 258 base::CommandLine* command_line) { |
| 256 if (GetServerConfig(key_system)) | 259 if (GetServerConfig(key_system)) |
| 257 // Since the web and license servers listen on different ports, we need to | 260 // Since the web and license servers listen on different ports, we need to |
| 258 // disable web-security to send license requests to the license server. | 261 // disable web-security to send license requests to the license server. |
| 259 // TODO(shadi): Add port forwarding to the test web server configuration. | 262 // TODO(shadi): Add port forwarding to the test web server configuration. |
| 260 command_line->AppendSwitch(switches::kDisableWebSecurity); | 263 command_line->AppendSwitch(switches::kDisableWebSecurity); |
| 261 | 264 |
| 262 #if defined(ENABLE_PEPPER_CDMS) | 265 #if defined(ENABLE_PEPPER_CDMS) |
| 263 if (IsExternalClearKey(key_system)) { | 266 if (IsExternalClearKey(key_system)) { |
| 264 RegisterPepperCdm(command_line, kClearKeyCdmAdapterFileName, key_system); | 267 RegisterPepperCdm(command_line, kClearKeyCdmBaseDirectory, |
| 268 kClearKeyCdmAdapterFileName, key_system); |
| 265 } | 269 } |
| 266 #if defined(WIDEVINE_CDM_AVAILABLE) && defined(WIDEVINE_CDM_IS_COMPONENT) | 270 #if defined(WIDEVINE_CDM_AVAILABLE) && defined(WIDEVINE_CDM_IS_COMPONENT) |
| 267 else if (IsWidevine(key_system)) { // NOLINT | 271 else if (IsWidevine(key_system)) { // NOLINT |
| 268 RegisterPepperCdm(command_line, kWidevineCdmAdapterFileName, key_system); | 272 RegisterPepperCdm(command_line, kWidevineCdmBaseDirectory, |
| 273 kWidevineCdmAdapterFileName, key_system); |
| 269 } | 274 } |
| 270 #endif // defined(WIDEVINE_CDM_AVAILABLE) && defined(WIDEVINE_CDM_IS_COMPONENT) | 275 #endif // defined(WIDEVINE_CDM_AVAILABLE) && defined(WIDEVINE_CDM_IS_COMPONENT) |
| 271 #endif // defined(ENABLE_PEPPER_CDMS) | 276 #endif // defined(ENABLE_PEPPER_CDMS) |
| 272 } | 277 } |
| 273 | 278 |
| 274 private: | 279 private: |
| 275 #if defined(ENABLE_PEPPER_CDMS) | 280 #if defined(ENABLE_PEPPER_CDMS) |
| 281 // The CDM adapter should be located in |adapter_base_dir| in DIR_MODULE. |
| 276 void RegisterPepperCdm(base::CommandLine* command_line, | 282 void RegisterPepperCdm(base::CommandLine* command_line, |
| 283 const std::string& adapter_base_dir, |
| 277 const std::string& adapter_name, | 284 const std::string& adapter_name, |
| 278 const std::string& key_system) { | 285 const std::string& key_system) { |
| 279 DCHECK(!is_pepper_cdm_registered_) | 286 DCHECK(!is_pepper_cdm_registered_) |
| 280 << "RegisterPepperCdm() can only be called once."; | 287 << "RegisterPepperCdm() can only be called once."; |
| 281 is_pepper_cdm_registered_ = true; | 288 is_pepper_cdm_registered_ = true; |
| 282 | 289 |
| 283 // Append the switch to register the Clear Key CDM Adapter. | 290 // Build the CDM adapter path. |
| 284 base::FilePath plugin_dir; | 291 base::FilePath plugin_dir; |
| 285 EXPECT_TRUE(PathService::Get(base::DIR_MODULE, &plugin_dir)); | 292 EXPECT_TRUE(PathService::Get(base::DIR_MODULE, &plugin_dir)); |
| 293 plugin_dir = plugin_dir.AppendASCII(adapter_base_dir); |
| 294 |
| 286 base::FilePath plugin_lib = plugin_dir.AppendASCII(adapter_name); | 295 base::FilePath plugin_lib = plugin_dir.AppendASCII(adapter_name); |
| 287 EXPECT_TRUE(base::PathExists(plugin_lib)) << plugin_lib.value(); | 296 EXPECT_TRUE(base::PathExists(plugin_lib)) << plugin_lib.value(); |
| 297 |
| 298 // Build pepper plugin registration switch. |
| 288 base::FilePath::StringType pepper_plugin = plugin_lib.value(); | 299 base::FilePath::StringType pepper_plugin = plugin_lib.value(); |
| 289 pepper_plugin.append(FILE_PATH_LITERAL("#CDM#0.1.0.0;")); | 300 pepper_plugin.append(FILE_PATH_LITERAL("#CDM#0.1.0.0;")); |
| 290 #if defined(OS_WIN) | 301 #if defined(OS_WIN) |
| 291 pepper_plugin.append(base::ASCIIToUTF16(GetPepperType(key_system))); | 302 pepper_plugin.append(base::ASCIIToUTF16(GetPepperType(key_system))); |
| 292 #else | 303 #else |
| 293 pepper_plugin.append(GetPepperType(key_system)); | 304 pepper_plugin.append(GetPepperType(key_system)); |
| 294 #endif | 305 #endif |
| 306 |
| 307 // Append the switch to register the CDM Adapter. |
| 295 command_line->AppendSwitchNative(switches::kRegisterPepperPlugins, | 308 command_line->AppendSwitchNative(switches::kRegisterPepperPlugins, |
| 296 pepper_plugin); | 309 pepper_plugin); |
| 297 } | 310 } |
| 298 | 311 |
| 299 // Adapted from key_systems.cc. | 312 // Adapted from key_systems.cc. |
| 300 std::string GetPepperType(const std::string& key_system) { | 313 std::string GetPepperType(const std::string& key_system) { |
| 301 if (IsExternalClearKey(key_system)) | 314 if (IsExternalClearKey(key_system)) |
| 302 return kClearKeyCdmPluginMimeType; | 315 return kClearKeyCdmPluginMimeType; |
| 303 #if defined(WIDEVINE_CDM_AVAILABLE) | 316 #if defined(WIDEVINE_CDM_AVAILABLE) |
| 304 if (IsWidevine(key_system)) | 317 if (IsWidevine(key_system)) |
| (...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 670 | 683 |
| 671 IN_PROC_BROWSER_TEST_F(ECKEncryptedMediaTest, LoadLoadableSession) { | 684 IN_PROC_BROWSER_TEST_F(ECKEncryptedMediaTest, LoadLoadableSession) { |
| 672 TestPlaybackCase(kLoadableSession, kEnded); | 685 TestPlaybackCase(kLoadableSession, kEnded); |
| 673 } | 686 } |
| 674 | 687 |
| 675 IN_PROC_BROWSER_TEST_F(ECKEncryptedMediaTest, LoadUnknownSession) { | 688 IN_PROC_BROWSER_TEST_F(ECKEncryptedMediaTest, LoadUnknownSession) { |
| 676 TestPlaybackCase(kUnknownSession, kEmeSessionNotFound); | 689 TestPlaybackCase(kUnknownSession, kEmeSessionNotFound); |
| 677 } | 690 } |
| 678 | 691 |
| 679 #endif // defined(ENABLE_PEPPER_CDMS) | 692 #endif // defined(ENABLE_PEPPER_CDMS) |
| OLD | NEW |