OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "base/command_line.h" | 5 #include "base/command_line.h" |
6 #include "base/path_service.h" | 6 #include "base/path_service.h" |
7 #include "base/stringprintf.h" | 7 #include "base/stringprintf.h" |
8 #include "base/utf_string_conversions.h" | 8 #include "base/utf_string_conversions.h" |
9 #include "chrome/browser/content_settings/cookie_settings.h" | 9 #include "chrome/browser/content_settings/cookie_settings.h" |
10 #include "chrome/browser/content_settings/host_content_settings_map.h" | 10 #include "chrome/browser/content_settings/host_content_settings_map.h" |
(...skipping 453 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
464 | 464 |
465 class PepperContentSettingsTest : public ContentSettingsTest { | 465 class PepperContentSettingsTest : public ContentSettingsTest { |
466 public: | 466 public: |
467 PepperContentSettingsTest() {} | 467 PepperContentSettingsTest() {} |
468 | 468 |
469 protected: | 469 protected: |
470 static const char* const kExternalClearKeyMimeType; | 470 static const char* const kExternalClearKeyMimeType; |
471 | 471 |
472 // Registers any CDM plugins not registered by default. | 472 // Registers any CDM plugins not registered by default. |
473 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { | 473 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { |
| 474 #if defined(ENABLE_PEPPER_CDMS) |
474 // Platform-specific filename relative to the chrome executable. | 475 // Platform-specific filename relative to the chrome executable. |
475 #if defined(OS_WIN) | 476 #if defined(OS_WIN) |
476 const wchar_t kLibraryName[] = L"clearkeycdmadapter.dll"; | |
477 const std::wstring external_clear_key_mime_type = | 477 const std::wstring external_clear_key_mime_type = |
478 ASCIIToWide(kExternalClearKeyMimeType); | 478 ASCIIToWide(kExternalClearKeyMimeType); |
| 479 const char kLibraryName[] = "clearkeycdmadapter.dll"; |
479 #else // !defined(OS_WIN) | 480 #else // !defined(OS_WIN) |
480 const char* external_clear_key_mime_type = kExternalClearKeyMimeType; | 481 const char* external_clear_key_mime_type = kExternalClearKeyMimeType; |
481 #if defined(OS_MACOSX) | 482 #if defined(OS_MACOSX) |
482 const char kLibraryName[] = "clearkeycdmadapter.plugin"; | 483 const char kLibraryName[] = "clearkeycdmadapter.plugin"; |
483 #elif defined(OS_POSIX) | 484 #elif defined(OS_POSIX) |
484 const char kLibraryName[] = "libclearkeycdmadapter.so"; | 485 const char kLibraryName[] = "libclearkeycdmadapter.so"; |
485 #endif | 486 #endif |
486 #endif // defined(OS_WIN) | 487 #endif // defined(OS_WIN) |
487 | 488 |
488 // Append the switch to register the External Clear Key CDM. | 489 // Append the switch to register the External Clear Key CDM. |
489 base::FilePath plugin_dir; | 490 base::FilePath plugin_dir; |
490 EXPECT_TRUE(PathService::Get(base::DIR_MODULE, &plugin_dir)); | 491 EXPECT_TRUE(PathService::Get(base::DIR_MODULE, &plugin_dir)); |
491 base::FilePath plugin_lib = plugin_dir.Append(kLibraryName); | 492 base::FilePath plugin_lib = plugin_dir.AppendASCII(kLibraryName); |
492 EXPECT_TRUE(file_util::PathExists(plugin_lib)); | 493 EXPECT_TRUE(file_util::PathExists(plugin_lib)); |
493 base::FilePath::StringType pepper_plugin = plugin_lib.value(); | 494 base::FilePath::StringType pepper_plugin = plugin_lib.value(); |
494 pepper_plugin.append(FILE_PATH_LITERAL( | 495 pepper_plugin.append(FILE_PATH_LITERAL( |
495 "#Clear Key CDM#Clear Key CDM 0.1.0.0#0.1.0.0;")); | 496 "#Clear Key CDM#Clear Key CDM 0.1.0.0#0.1.0.0;")); |
496 pepper_plugin.append(external_clear_key_mime_type); | 497 pepper_plugin.append(external_clear_key_mime_type); |
497 command_line->AppendSwitchNative(switches::kRegisterPepperPlugins, | 498 command_line->AppendSwitchNative(switches::kRegisterPepperPlugins, |
498 pepper_plugin); | 499 pepper_plugin); |
| 500 #endif // defined(ENABLE_PEPPER_CDMS) |
| 501 |
499 #if !defined(DISABLE_NACL) | 502 #if !defined(DISABLE_NACL) |
500 // Ensure NaCl can run. | 503 // Ensure NaCl can run. |
501 command_line->AppendSwitch(switches::kEnableNaCl); | 504 command_line->AppendSwitch(switches::kEnableNaCl); |
502 #endif | 505 #endif |
503 } | 506 } |
504 | 507 |
505 void RunLoadPepperPluginTest(const char* mime_type, bool expect_loaded) { | 508 void RunLoadPepperPluginTest(const char* mime_type, bool expect_loaded) { |
506 const char* expected_result = expect_loaded ? "Loaded" : "Not Loaded"; | 509 const char* expected_result = expect_loaded ? "Loaded" : "Not Loaded"; |
507 content::WebContents* web_contents = | 510 content::WebContents* web_contents = |
508 browser()->tab_strip_model()->GetActiveWebContents(); | 511 browser()->tab_strip_model()->GetActiveWebContents(); |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
553 | 556 |
554 // Tests Pepper plugins that use JavaScript instead of Plug-ins settings. | 557 // Tests Pepper plugins that use JavaScript instead of Plug-ins settings. |
555 IN_PROC_BROWSER_TEST_F(PepperContentSettingsTest, PluginSpecialCases) { | 558 IN_PROC_BROWSER_TEST_F(PepperContentSettingsTest, PluginSpecialCases) { |
556 HostContentSettingsMap* content_settings = | 559 HostContentSettingsMap* content_settings = |
557 browser()->profile()->GetHostContentSettingsMap(); | 560 browser()->profile()->GetHostContentSettingsMap(); |
558 | 561 |
559 // First, verify that this plugin can be loaded. | 562 // First, verify that this plugin can be loaded. |
560 content_settings->SetDefaultContentSetting( | 563 content_settings->SetDefaultContentSetting( |
561 CONTENT_SETTINGS_TYPE_PLUGINS, CONTENT_SETTING_ALLOW); | 564 CONTENT_SETTINGS_TYPE_PLUGINS, CONTENT_SETTING_ALLOW); |
562 | 565 |
| 566 #if defined(ENABLE_PEPPER_CDMS) |
563 RunLoadPepperPluginTest(kExternalClearKeyMimeType, true); | 567 RunLoadPepperPluginTest(kExternalClearKeyMimeType, true); |
| 568 #endif |
564 | 569 |
565 // Next, test behavior when plug-ins are blocked. | 570 // Next, test behavior when plug-ins are blocked. |
566 content_settings->SetDefaultContentSetting( | 571 content_settings->SetDefaultContentSetting( |
567 CONTENT_SETTINGS_TYPE_PLUGINS, CONTENT_SETTING_BLOCK); | 572 CONTENT_SETTINGS_TYPE_PLUGINS, CONTENT_SETTING_BLOCK); |
568 | 573 |
| 574 #if defined(ENABLE_PEPPER_CDMS) |
569 // The plugin we loaded above does not load now. | 575 // The plugin we loaded above does not load now. |
570 RunLoadPepperPluginTest(kExternalClearKeyMimeType, false); | 576 RunLoadPepperPluginTest(kExternalClearKeyMimeType, false); |
571 | 577 |
572 #if defined(WIDEVINE_CDM_AVAILABLE) | 578 #if defined(WIDEVINE_CDM_AVAILABLE) |
573 RunLoadPepperPluginTest(kWidevineCdmPluginMimeType, true); | 579 RunLoadPepperPluginTest(kWidevineCdmPluginMimeType, true); |
574 #endif | 580 #endif |
| 581 #endif // defined(ENABLE_PEPPER_CDMS) |
575 | 582 |
576 #if !defined(DISABLE_NACL) | 583 #if !defined(DISABLE_NACL) |
577 RunLoadPepperPluginTest("application/x-nacl", true); | 584 RunLoadPepperPluginTest("application/x-nacl", true); |
578 #endif | 585 #endif |
579 | 586 |
580 // Finally, test behavior when (just) JavaScript is blocked. | 587 // Finally, test behavior when (just) JavaScript is blocked. |
581 content_settings->SetDefaultContentSetting( | 588 content_settings->SetDefaultContentSetting( |
582 CONTENT_SETTINGS_TYPE_PLUGINS, CONTENT_SETTING_ALLOW); | 589 CONTENT_SETTINGS_TYPE_PLUGINS, CONTENT_SETTING_ALLOW); |
583 content_settings->SetDefaultContentSetting( | 590 content_settings->SetDefaultContentSetting( |
584 CONTENT_SETTINGS_TYPE_JAVASCRIPT, CONTENT_SETTING_BLOCK); | 591 CONTENT_SETTINGS_TYPE_JAVASCRIPT, CONTENT_SETTING_BLOCK); |
585 | 592 |
| 593 #if defined(ENABLE_PEPPER_CDMS) |
586 // This plugin has no special behavior and does not require JavaScript. | 594 // This plugin has no special behavior and does not require JavaScript. |
587 RunJavaScriptBlockedTest("load_clearkey_no_js.html", false); | 595 RunJavaScriptBlockedTest("load_clearkey_no_js.html", false); |
588 | 596 |
589 #if defined(WIDEVINE_CDM_AVAILABLE) | 597 #if defined(WIDEVINE_CDM_AVAILABLE) |
590 RunJavaScriptBlockedTest("load_widevine_no_js.html", true); | 598 RunJavaScriptBlockedTest("load_widevine_no_js.html", true); |
591 #endif | 599 #endif |
| 600 #endif // defined(ENABLE_PEPPER_CDMS) |
592 | 601 |
593 #if !defined(DISABLE_NACL) | 602 #if !defined(DISABLE_NACL) |
594 RunJavaScriptBlockedTest("load_nacl_no_js.html", true); | 603 RunJavaScriptBlockedTest("load_nacl_no_js.html", true); |
595 #endif | 604 #endif |
596 } | 605 } |
597 | 606 |
598 #endif // defined(ENABLE_PLUGINS) | 607 #endif // defined(ENABLE_PLUGINS) |
OLD | NEW |