| 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 "chrome/browser/content_settings/host_content_settings_map.h" | 5 #include "chrome/browser/content_settings/host_content_settings_map.h" |
| 6 #include "chrome/browser/extensions/extension_browsertest.h" | 6 #include "chrome/browser/extensions/extension_browsertest.h" |
| 7 #include "chrome/browser/extensions/extension_service.h" | 7 #include "chrome/browser/extensions/extension_service.h" |
| 8 #include "chrome/browser/prefs/pref_service.h" | 8 #include "chrome/browser/prefs/pref_service.h" |
| 9 #include "chrome/browser/ui/browser.h" | 9 #include "chrome/browser/ui/browser.h" |
| 10 #include "chrome/browser/ui/browser_commands.h" | 10 #include "chrome/browser/ui/browser_commands.h" |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 { | 81 { |
| 82 content::WindowedNotificationObserver observer( | 82 content::WindowedNotificationObserver observer( |
| 83 content::NOTIFICATION_LOAD_STOP, | 83 content::NOTIFICATION_LOAD_STOP, |
| 84 content::Source<NavigationController>( | 84 content::Source<NavigationController>( |
| 85 &chrome::GetActiveWebContents(browser())->GetController())); | 85 &chrome::GetActiveWebContents(browser())->GetController())); |
| 86 chrome::Reload(browser(), CURRENT_TAB); | 86 chrome::Reload(browser(), CURRENT_TAB); |
| 87 observer.Wait(); | 87 observer.Wait(); |
| 88 } | 88 } |
| 89 ASSERT_TRUE(content::ExecuteJavaScriptAndExtractBool( | 89 ASSERT_TRUE(content::ExecuteJavaScriptAndExtractBool( |
| 90 tab->GetRenderViewHost(), L"", L"testPluginWorks()", &result)); | 90 tab->GetRenderViewHost(), L"", L"testPluginWorks()", &result)); |
| 91 // We don't allow extension plugins to run on ChromeOS. | 91 // We don't allow extension plugins to run on ChromeOS. |
| 92 #if defined(OS_CHROMEOS) | 92 #if defined(OS_CHROMEOS) |
| 93 EXPECT_FALSE(result); | 93 EXPECT_FALSE(result); |
| 94 #else | 94 #else |
| 95 EXPECT_TRUE(result); | 95 EXPECT_TRUE(result); |
| 96 #endif | 96 #endif |
| 97 } | 97 } |
| 98 | 98 |
| 99 // Tests that private extension plugins are only visible to the extension. | 99 // Tests that private extension plugins are only visible to the extension. |
| 100 IN_PROC_BROWSER_TEST_F(ExtensionBrowserTest, PluginPrivate) { | 100 IN_PROC_BROWSER_TEST_F(ExtensionBrowserTest, PluginPrivate) { |
| 101 browser()->profile()->GetPrefs()->SetBoolean(prefs::kPluginsAlwaysAuthorize, | 101 browser()->profile()->GetPrefs()->SetBoolean(prefs::kPluginsAlwaysAuthorize, |
| 102 true); | 102 true); |
| 103 | 103 |
| 104 FilePath extension_dir = | 104 FilePath extension_dir = |
| 105 test_data_dir_.AppendASCII("uitest").AppendASCII("plugins_private"); | 105 test_data_dir_.AppendASCII("uitest").AppendASCII("plugins_private"); |
| 106 | 106 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 128 EXPECT_TRUE(result); | 128 EXPECT_TRUE(result); |
| 129 #endif | 129 #endif |
| 130 | 130 |
| 131 // Regression test for http://crbug.com/131811: The plug-in should be | 131 // Regression test for http://crbug.com/131811: The plug-in should be |
| 132 // whitelisted for the extension (and only for the extension), so it should be | 132 // whitelisted for the extension (and only for the extension), so it should be |
| 133 // loaded even if content settings are set to block plug-ins. | 133 // loaded even if content settings are set to block plug-ins. |
| 134 browser()->profile()->GetHostContentSettingsMap()->SetDefaultContentSetting( | 134 browser()->profile()->GetHostContentSettingsMap()->SetDefaultContentSetting( |
| 135 CONTENT_SETTINGS_TYPE_PLUGINS, CONTENT_SETTING_BLOCK); | 135 CONTENT_SETTINGS_TYPE_PLUGINS, CONTENT_SETTING_BLOCK); |
| 136 ASSERT_TRUE(content::ExecuteJavaScriptAndExtractBool( | 136 ASSERT_TRUE(content::ExecuteJavaScriptAndExtractBool( |
| 137 tab->GetRenderViewHost(), L"", L"testPluginWorks()", &result)); | 137 tab->GetRenderViewHost(), L"", L"testPluginWorks()", &result)); |
| 138 // We don't allow extension plugins to run on ChromeOS. |
| 138 #if defined(OS_CHROMEOS) | 139 #if defined(OS_CHROMEOS) |
| 139 EXPECT_FALSE(result); | 140 EXPECT_FALSE(result); |
| 140 #else | 141 #else |
| 141 EXPECT_TRUE(result); | 142 EXPECT_TRUE(result); |
| 142 #endif | 143 #endif |
| 143 | 144 |
| 144 // Now load it through a file URL. The plugin should not load. | 145 // Now load it through a file URL. The plugin should not load. |
| 145 ui_test_utils::NavigateToURL(browser(), | 146 ui_test_utils::NavigateToURL(browser(), |
| 146 net::FilePathToFileURL(extension_dir.AppendASCII("test.html"))); | 147 net::FilePathToFileURL(extension_dir.AppendASCII("test.html"))); |
| 147 ASSERT_TRUE(content::ExecuteJavaScriptAndExtractBool( | 148 ASSERT_TRUE(content::ExecuteJavaScriptAndExtractBool( |
| 148 tab->GetRenderViewHost(), L"", L"testPluginWorks()", &result)); | 149 tab->GetRenderViewHost(), L"", L"testPluginWorks()", &result)); |
| 149 EXPECT_FALSE(result); | 150 EXPECT_FALSE(result); |
| 150 } | 151 } |
| OLD | NEW |