| 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/prefs/pref_service.h" | 6 #include "base/prefs/pref_service.h" |
| 7 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" |
| 7 #include "chrome/browser/extensions/extension_browsertest.h" | 8 #include "chrome/browser/extensions/extension_browsertest.h" |
| 8 #include "chrome/browser/extensions/extension_service.h" | 9 #include "chrome/browser/extensions/extension_service.h" |
| 9 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
| 10 #include "chrome/browser/ui/browser.h" | 11 #include "chrome/browser/ui/browser.h" |
| 11 #include "chrome/browser/ui/browser_commands.h" | 12 #include "chrome/browser/ui/browser_commands.h" |
| 12 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 13 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 13 #include "chrome/common/pref_names.h" | 14 #include "chrome/common/pref_names.h" |
| 14 #include "chrome/test/base/test_switches.h" | 15 #include "chrome/test/base/test_switches.h" |
| 15 #include "chrome/test/base/ui_test_utils.h" | 16 #include "chrome/test/base/ui_test_utils.h" |
| 16 #include "components/content_settings/core/browser/host_content_settings_map.h" | 17 #include "components/content_settings/core/browser/host_content_settings_map.h" |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 168 #else | 169 #else |
| 169 // TODO(bauerb): This might wrongly fail if the plugin takes too long | 170 // TODO(bauerb): This might wrongly fail if the plugin takes too long |
| 170 // to load. Extension-private plugins don't appear in navigator.plugins, so | 171 // to load. Extension-private plugins don't appear in navigator.plugins, so |
| 171 // we can't check for the plugin in Javascript. | 172 // we can't check for the plugin in Javascript. |
| 172 EXPECT_TRUE(result); | 173 EXPECT_TRUE(result); |
| 173 #endif | 174 #endif |
| 174 | 175 |
| 175 // Regression test for http://crbug.com/131811: The plugin should be | 176 // Regression test for http://crbug.com/131811: The plugin should be |
| 176 // whitelisted for the extension (and only for the extension), so it should be | 177 // whitelisted for the extension (and only for the extension), so it should be |
| 177 // loaded even if content settings are set to block plugins. | 178 // loaded even if content settings are set to block plugins. |
| 178 browser()->profile()->GetHostContentSettingsMap()->SetDefaultContentSetting( | 179 HostContentSettingsMapFactory::GetForProfile(browser()->profile()) |
| 179 CONTENT_SETTINGS_TYPE_PLUGINS, CONTENT_SETTING_BLOCK); | 180 ->SetDefaultContentSetting(CONTENT_SETTINGS_TYPE_PLUGINS, |
| 181 CONTENT_SETTING_BLOCK); |
| 180 ASSERT_TRUE(content::ExecuteScriptAndExtractBool( | 182 ASSERT_TRUE(content::ExecuteScriptAndExtractBool( |
| 181 tab, "testPluginWorks()", &result)); | 183 tab, "testPluginWorks()", &result)); |
| 182 // We don't allow extension plugins to run on ChromeOS. | 184 // We don't allow extension plugins to run on ChromeOS. |
| 183 #if defined(OS_CHROMEOS) | 185 #if defined(OS_CHROMEOS) |
| 184 EXPECT_FALSE(result); | 186 EXPECT_FALSE(result); |
| 185 #else | 187 #else |
| 186 EXPECT_TRUE(result); | 188 EXPECT_TRUE(result); |
| 187 #endif | 189 #endif |
| 188 | 190 |
| 189 // Now load it through a file URL. The plugin should not load. | 191 // Now load it through a file URL. The plugin should not load. |
| 190 ui_test_utils::NavigateToURL(browser(), | 192 ui_test_utils::NavigateToURL(browser(), |
| 191 net::FilePathToFileURL(extension_dir.AppendASCII("test.html"))); | 193 net::FilePathToFileURL(extension_dir.AppendASCII("test.html"))); |
| 192 ASSERT_TRUE(content::ExecuteScriptAndExtractBool( | 194 ASSERT_TRUE(content::ExecuteScriptAndExtractBool( |
| 193 tab, "testPluginWorks()", &result)); | 195 tab, "testPluginWorks()", &result)); |
| 194 EXPECT_FALSE(result); | 196 EXPECT_FALSE(result); |
| 195 } | 197 } |
| OLD | NEW |