| 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/strings/stringprintf.h" | 7 #include "base/strings/stringprintf.h" |
| 8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
| 9 #include "chrome/browser/chrome_notification_types.h" | 9 #include "chrome/browser/chrome_notification_types.h" |
| 10 #include "chrome/browser/content_settings/cookie_settings.h" | 10 #include "chrome/browser/content_settings/cookie_settings.h" |
| (...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 292 } | 292 } |
| 293 | 293 |
| 294 // On Aura NPAPI only works on Windows. | 294 // On Aura NPAPI only works on Windows. |
| 295 #if !defined(USE_AURA) || defined(OS_WIN) | 295 #if !defined(USE_AURA) || defined(OS_WIN) |
| 296 | 296 |
| 297 class ClickToPlayPluginTest : public ContentSettingsTest { | 297 class ClickToPlayPluginTest : public ContentSettingsTest { |
| 298 public: | 298 public: |
| 299 ClickToPlayPluginTest() {} | 299 ClickToPlayPluginTest() {} |
| 300 | 300 |
| 301 #if defined(OS_MACOSX) | 301 #if defined(OS_MACOSX) |
| 302 void SetUpCommandLine(CommandLine* command_line) override { | 302 void SetUpCommandLine(base::CommandLine* command_line) override { |
| 303 base::FilePath plugin_dir; | 303 base::FilePath plugin_dir; |
| 304 PathService::Get(base::DIR_MODULE, &plugin_dir); | 304 PathService::Get(base::DIR_MODULE, &plugin_dir); |
| 305 plugin_dir = plugin_dir.AppendASCII("plugins"); | 305 plugin_dir = plugin_dir.AppendASCII("plugins"); |
| 306 // The plugins directory isn't read by default on the Mac, so it needs to be | 306 // The plugins directory isn't read by default on the Mac, so it needs to be |
| 307 // explicitly registered. | 307 // explicitly registered. |
| 308 command_line->AppendSwitchPath(switches::kExtraPluginDir, plugin_dir); | 308 command_line->AppendSwitchPath(switches::kExtraPluginDir, plugin_dir); |
| 309 } | 309 } |
| 310 #endif | 310 #endif |
| 311 }; | 311 }; |
| 312 | 312 |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 463 } | 463 } |
| 464 | 464 |
| 465 #endif // !defined(USE_AURA) || defined(OS_WIN) | 465 #endif // !defined(USE_AURA) || defined(OS_WIN) |
| 466 | 466 |
| 467 #if defined(ENABLE_PLUGINS) | 467 #if defined(ENABLE_PLUGINS) |
| 468 class PepperContentSettingsSpecialCasesTest : public ContentSettingsTest { | 468 class PepperContentSettingsSpecialCasesTest : public ContentSettingsTest { |
| 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 void SetUpCommandLine(CommandLine* command_line) override { | 473 void SetUpCommandLine(base::CommandLine* command_line) override { |
| 474 #if defined(ENABLE_PEPPER_CDMS) | 474 #if defined(ENABLE_PEPPER_CDMS) |
| 475 // Platform-specific filename relative to the chrome executable. | 475 // Platform-specific filename relative to the chrome executable. |
| 476 #if defined(OS_WIN) | 476 #if defined(OS_WIN) |
| 477 const char kLibraryName[] = "clearkeycdmadapter.dll"; | 477 const char kLibraryName[] = "clearkeycdmadapter.dll"; |
| 478 #else // !defined(OS_WIN) | 478 #else // !defined(OS_WIN) |
| 479 #if defined(OS_MACOSX) | 479 #if defined(OS_MACOSX) |
| 480 const char kLibraryName[] = "clearkeycdmadapter.plugin"; | 480 const char kLibraryName[] = "clearkeycdmadapter.plugin"; |
| 481 #elif defined(OS_POSIX) | 481 #elif defined(OS_POSIX) |
| 482 const char kLibraryName[] = "libclearkeycdmadapter.so"; | 482 const char kLibraryName[] = "libclearkeycdmadapter.so"; |
| 483 #endif // defined(OS_MACOSX) | 483 #endif // defined(OS_MACOSX) |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 634 CONTENT_SETTINGS_TYPE_JAVASCRIPT, CONTENT_SETTING_BLOCK); | 634 CONTENT_SETTINGS_TYPE_JAVASCRIPT, CONTENT_SETTING_BLOCK); |
| 635 } | 635 } |
| 636 }; | 636 }; |
| 637 | 637 |
| 638 #if defined(ENABLE_PEPPER_CDMS) | 638 #if defined(ENABLE_PEPPER_CDMS) |
| 639 // A sanity check to verify that the plugin that is used as a baseline below | 639 // A sanity check to verify that the plugin that is used as a baseline below |
| 640 // can be loaded. | 640 // can be loaded. |
| 641 IN_PROC_BROWSER_TEST_F(PepperContentSettingsSpecialCasesTest, Baseline) { | 641 IN_PROC_BROWSER_TEST_F(PepperContentSettingsSpecialCasesTest, Baseline) { |
| 642 #if defined(OS_WIN) && defined(USE_ASH) | 642 #if defined(OS_WIN) && defined(USE_ASH) |
| 643 // Disable this test in Metro+Ash for now (http://crbug.com/262796). | 643 // Disable this test in Metro+Ash for now (http://crbug.com/262796). |
| 644 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAshBrowserTests)) | 644 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 645 switches::kAshBrowserTests)) |
| 645 return; | 646 return; |
| 646 #endif | 647 #endif |
| 647 browser()->profile()->GetHostContentSettingsMap()->SetDefaultContentSetting( | 648 browser()->profile()->GetHostContentSettingsMap()->SetDefaultContentSetting( |
| 648 CONTENT_SETTINGS_TYPE_PLUGINS, CONTENT_SETTING_ALLOW); | 649 CONTENT_SETTINGS_TYPE_PLUGINS, CONTENT_SETTING_ALLOW); |
| 649 | 650 |
| 650 RunLoadPepperPluginTest(kExternalClearKeyMimeType, true); | 651 RunLoadPepperPluginTest(kExternalClearKeyMimeType, true); |
| 651 } | 652 } |
| 652 #endif // defined(ENABLE_PEPPER_CDMS) | 653 #endif // defined(ENABLE_PEPPER_CDMS) |
| 653 | 654 |
| 654 // The following tests verify that Pepper plugins that use JavaScript settings | 655 // The following tests verify that Pepper plugins that use JavaScript settings |
| 655 // instead of Plug-ins settings still work when Plug-ins are blocked. | 656 // instead of Plug-ins settings still work when Plug-ins are blocked. |
| 656 | 657 |
| 657 #if defined(ENABLE_PEPPER_CDMS) | 658 #if defined(ENABLE_PEPPER_CDMS) |
| 658 // The plugin successfully loaded above is blocked. | 659 // The plugin successfully loaded above is blocked. |
| 659 IN_PROC_BROWSER_TEST_F(PepperContentSettingsSpecialCasesPluginsBlockedTest, | 660 IN_PROC_BROWSER_TEST_F(PepperContentSettingsSpecialCasesPluginsBlockedTest, |
| 660 Normal) { | 661 Normal) { |
| 661 #if defined(OS_WIN) && defined(USE_ASH) | 662 #if defined(OS_WIN) && defined(USE_ASH) |
| 662 // Disable this test in Metro+Ash for now (http://crbug.com/262796). | 663 // Disable this test in Metro+Ash for now (http://crbug.com/262796). |
| 663 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAshBrowserTests)) | 664 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 665 switches::kAshBrowserTests)) |
| 664 return; | 666 return; |
| 665 #endif | 667 #endif |
| 666 RunLoadPepperPluginTest(kExternalClearKeyMimeType, false); | 668 RunLoadPepperPluginTest(kExternalClearKeyMimeType, false); |
| 667 } | 669 } |
| 668 | 670 |
| 669 #if defined(WIDEVINE_CDM_AVAILABLE) | 671 #if defined(WIDEVINE_CDM_AVAILABLE) |
| 670 IN_PROC_BROWSER_TEST_F(PepperContentSettingsSpecialCasesPluginsBlockedTest, | 672 IN_PROC_BROWSER_TEST_F(PepperContentSettingsSpecialCasesPluginsBlockedTest, |
| 671 WidevineCdm) { | 673 WidevineCdm) { |
| 672 #if defined(OS_WIN) && defined(USE_ASH) | 674 #if defined(OS_WIN) && defined(USE_ASH) |
| 673 // Disable this test in Metro+Ash for now (http://crbug.com/262796). | 675 // Disable this test in Metro+Ash for now (http://crbug.com/262796). |
| 674 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAshBrowserTests)) | 676 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 677 switches::kAshBrowserTests)) |
| 675 return; | 678 return; |
| 676 #endif | 679 #endif |
| 677 RunLoadPepperPluginTest(kWidevineCdmPluginMimeType, true); | 680 RunLoadPepperPluginTest(kWidevineCdmPluginMimeType, true); |
| 678 } | 681 } |
| 679 #endif // defined(WIDEVINE_CDM_AVAILABLE) | 682 #endif // defined(WIDEVINE_CDM_AVAILABLE) |
| 680 #endif // defined(ENABLE_PEPPER_CDMS) | 683 #endif // defined(ENABLE_PEPPER_CDMS) |
| 681 | 684 |
| 682 #if !defined(DISABLE_NACL) | 685 #if !defined(DISABLE_NACL) |
| 683 IN_PROC_BROWSER_TEST_F(PepperContentSettingsSpecialCasesPluginsBlockedTest, | 686 IN_PROC_BROWSER_TEST_F(PepperContentSettingsSpecialCasesPluginsBlockedTest, |
| 684 NaCl) { | 687 NaCl) { |
| 685 #if defined(OS_WIN) && defined(USE_ASH) | 688 #if defined(OS_WIN) && defined(USE_ASH) |
| 686 // Disable this test in Metro+Ash for now (http://crbug.com/262796). | 689 // Disable this test in Metro+Ash for now (http://crbug.com/262796). |
| 687 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAshBrowserTests)) | 690 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 691 switches::kAshBrowserTests)) |
| 688 return; | 692 return; |
| 689 #endif | 693 #endif |
| 690 RunLoadPepperPluginTest("application/x-nacl", true); | 694 RunLoadPepperPluginTest("application/x-nacl", true); |
| 691 } | 695 } |
| 692 #endif // !defined(DISABLE_NACL) | 696 #endif // !defined(DISABLE_NACL) |
| 693 | 697 |
| 694 // The following tests verify that those same Pepper plugins do not work when | 698 // The following tests verify that those same Pepper plugins do not work when |
| 695 // JavaScript is blocked. | 699 // JavaScript is blocked. |
| 696 | 700 |
| 697 #if defined(ENABLE_PEPPER_CDMS) | 701 #if defined(ENABLE_PEPPER_CDMS) |
| 698 // A plugin with no special behavior is not blocked when JavaScript is blocked. | 702 // A plugin with no special behavior is not blocked when JavaScript is blocked. |
| 699 IN_PROC_BROWSER_TEST_F(PepperContentSettingsSpecialCasesJavaScriptBlockedTest, | 703 IN_PROC_BROWSER_TEST_F(PepperContentSettingsSpecialCasesJavaScriptBlockedTest, |
| 700 Normal) { | 704 Normal) { |
| 701 #if defined(OS_WIN) && defined(USE_ASH) | 705 #if defined(OS_WIN) && defined(USE_ASH) |
| 702 // Disable this test in Metro+Ash for now (http://crbug.com/262796). | 706 // Disable this test in Metro+Ash for now (http://crbug.com/262796). |
| 703 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAshBrowserTests)) | 707 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 708 switches::kAshBrowserTests)) |
| 704 return; | 709 return; |
| 705 #endif | 710 #endif |
| 706 RunJavaScriptBlockedTest("load_clearkey_no_js.html", false); | 711 RunJavaScriptBlockedTest("load_clearkey_no_js.html", false); |
| 707 } | 712 } |
| 708 | 713 |
| 709 #if defined(WIDEVINE_CDM_AVAILABLE) | 714 #if defined(WIDEVINE_CDM_AVAILABLE) |
| 710 IN_PROC_BROWSER_TEST_F(PepperContentSettingsSpecialCasesJavaScriptBlockedTest, | 715 IN_PROC_BROWSER_TEST_F(PepperContentSettingsSpecialCasesJavaScriptBlockedTest, |
| 711 WidevineCdm) { | 716 WidevineCdm) { |
| 712 #if defined(OS_WIN) && defined(USE_ASH) | 717 #if defined(OS_WIN) && defined(USE_ASH) |
| 713 // Disable this test in Metro+Ash for now (http://crbug.com/262796). | 718 // Disable this test in Metro+Ash for now (http://crbug.com/262796). |
| 714 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAshBrowserTests)) | 719 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 720 switches::kAshBrowserTests)) |
| 715 return; | 721 return; |
| 716 #endif | 722 #endif |
| 717 RunJavaScriptBlockedTest("load_widevine_no_js.html", true); | 723 RunJavaScriptBlockedTest("load_widevine_no_js.html", true); |
| 718 } | 724 } |
| 719 #endif // defined(WIDEVINE_CDM_AVAILABLE) | 725 #endif // defined(WIDEVINE_CDM_AVAILABLE) |
| 720 #endif // defined(ENABLE_PEPPER_CDMS) | 726 #endif // defined(ENABLE_PEPPER_CDMS) |
| 721 | 727 |
| 722 #if !defined(DISABLE_NACL) | 728 #if !defined(DISABLE_NACL) |
| 723 IN_PROC_BROWSER_TEST_F(PepperContentSettingsSpecialCasesJavaScriptBlockedTest, | 729 IN_PROC_BROWSER_TEST_F(PepperContentSettingsSpecialCasesJavaScriptBlockedTest, |
| 724 NaCl) { | 730 NaCl) { |
| 725 #if defined(OS_WIN) && defined(USE_ASH) | 731 #if defined(OS_WIN) && defined(USE_ASH) |
| 726 // Disable this test in Metro+Ash for now (http://crbug.com/262796). | 732 // Disable this test in Metro+Ash for now (http://crbug.com/262796). |
| 727 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAshBrowserTests)) | 733 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 734 switches::kAshBrowserTests)) |
| 728 return; | 735 return; |
| 729 #endif | 736 #endif |
| 730 RunJavaScriptBlockedTest("load_nacl_no_js.html", true); | 737 RunJavaScriptBlockedTest("load_nacl_no_js.html", true); |
| 731 } | 738 } |
| 732 #endif // !defined(DISABLE_NACL) | 739 #endif // !defined(DISABLE_NACL) |
| 733 | 740 |
| 734 #endif // defined(ENABLE_PLUGINS) | 741 #endif // defined(ENABLE_PLUGINS) |
| OLD | NEW |