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