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 adatper should be located in |adapter_base_dir| in DIR_MODULE. If | |
Lei Zhang
2016/05/12 17:22:02
typo
xhwang
2016/05/13 16:44:12
Done.
| |
282 // |adapter_base_dir| is empty, then the adapter should be located in | |
Lei Zhang
2016/05/12 17:22:02
Does the |adapter_base_dir| case still apply?
xhwang
2016/05/13 16:44:12
Removed.
| |
283 // DIR_MODULE directly. | |
276 void RegisterPepperCdm(base::CommandLine* command_line, | 284 void RegisterPepperCdm(base::CommandLine* command_line, |
285 const std::string& adapter_base_dir, | |
277 const std::string& adapter_name, | 286 const std::string& adapter_name, |
278 const std::string& key_system) { | 287 const std::string& key_system) { |
279 DCHECK(!is_pepper_cdm_registered_) | 288 DCHECK(!is_pepper_cdm_registered_) |
280 << "RegisterPepperCdm() can only be called once."; | 289 << "RegisterPepperCdm() can only be called once."; |
281 is_pepper_cdm_registered_ = true; | 290 is_pepper_cdm_registered_ = true; |
282 | 291 |
283 // Append the switch to register the Clear Key CDM Adapter. | 292 // Build the CDM adapter path. |
284 base::FilePath plugin_dir; | 293 base::FilePath plugin_dir; |
285 EXPECT_TRUE(PathService::Get(base::DIR_MODULE, &plugin_dir)); | 294 EXPECT_TRUE(PathService::Get(base::DIR_MODULE, &plugin_dir)); |
295 plugin_dir = plugin_dir.AppendASCII(adapter_base_dir); | |
296 | |
286 base::FilePath plugin_lib = plugin_dir.AppendASCII(adapter_name); | 297 base::FilePath plugin_lib = plugin_dir.AppendASCII(adapter_name); |
287 EXPECT_TRUE(base::PathExists(plugin_lib)) << plugin_lib.value(); | 298 EXPECT_TRUE(base::PathExists(plugin_lib)) << plugin_lib.value(); |
299 | |
300 // Build pepper plugin registration switch. | |
288 base::FilePath::StringType pepper_plugin = plugin_lib.value(); | 301 base::FilePath::StringType pepper_plugin = plugin_lib.value(); |
289 pepper_plugin.append(FILE_PATH_LITERAL("#CDM#0.1.0.0;")); | 302 pepper_plugin.append(FILE_PATH_LITERAL("#CDM#0.1.0.0;")); |
290 #if defined(OS_WIN) | 303 #if defined(OS_WIN) |
291 pepper_plugin.append(base::ASCIIToUTF16(GetPepperType(key_system))); | 304 pepper_plugin.append(base::ASCIIToUTF16(GetPepperType(key_system))); |
292 #else | 305 #else |
293 pepper_plugin.append(GetPepperType(key_system)); | 306 pepper_plugin.append(GetPepperType(key_system)); |
294 #endif | 307 #endif |
308 | |
309 // Append the switch to register the CDM Adapter. | |
295 command_line->AppendSwitchNative(switches::kRegisterPepperPlugins, | 310 command_line->AppendSwitchNative(switches::kRegisterPepperPlugins, |
296 pepper_plugin); | 311 pepper_plugin); |
297 } | 312 } |
298 | 313 |
299 // Adapted from key_systems.cc. | 314 // Adapted from key_systems.cc. |
300 std::string GetPepperType(const std::string& key_system) { | 315 std::string GetPepperType(const std::string& key_system) { |
301 if (IsExternalClearKey(key_system)) | 316 if (IsExternalClearKey(key_system)) |
302 return kClearKeyCdmPluginMimeType; | 317 return kClearKeyCdmPluginMimeType; |
303 #if defined(WIDEVINE_CDM_AVAILABLE) | 318 #if defined(WIDEVINE_CDM_AVAILABLE) |
304 if (IsWidevine(key_system)) | 319 if (IsWidevine(key_system)) |
(...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
670 | 685 |
671 IN_PROC_BROWSER_TEST_F(ECKEncryptedMediaTest, LoadLoadableSession) { | 686 IN_PROC_BROWSER_TEST_F(ECKEncryptedMediaTest, LoadLoadableSession) { |
672 TestPlaybackCase(kLoadableSession, kEnded); | 687 TestPlaybackCase(kLoadableSession, kEnded); |
673 } | 688 } |
674 | 689 |
675 IN_PROC_BROWSER_TEST_F(ECKEncryptedMediaTest, LoadUnknownSession) { | 690 IN_PROC_BROWSER_TEST_F(ECKEncryptedMediaTest, LoadUnknownSession) { |
676 TestPlaybackCase(kUnknownSession, kEmeSessionNotFound); | 691 TestPlaybackCase(kUnknownSession, kEmeSessionNotFound); |
677 } | 692 } |
678 | 693 |
679 #endif // defined(ENABLE_PEPPER_CDMS) | 694 #endif // defined(ENABLE_PEPPER_CDMS) |
OLD | NEW |