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/extensions/extension_system.h" |
8 #include "chrome/browser/prefs/pref_service.h" | 9 #include "chrome/browser/prefs/pref_service.h" |
9 #include "chrome/browser/ui/browser.h" | 10 #include "chrome/browser/ui/browser.h" |
10 #include "chrome/browser/ui/browser_commands.h" | 11 #include "chrome/browser/ui/browser_commands.h" |
11 #include "chrome/browser/ui/browser_tabstrip.h" | 12 #include "chrome/browser/ui/browser_tabstrip.h" |
12 #include "chrome/browser/ui/tab_contents/tab_contents.h" | 13 #include "chrome/browser/ui/tab_contents/tab_contents.h" |
13 #include "chrome/common/extensions/extension.h" | 14 #include "chrome/common/extensions/extension.h" |
14 #include "chrome/common/pref_names.h" | 15 #include "chrome/common/pref_names.h" |
15 #include "chrome/test/base/ui_test_utils.h" | 16 #include "chrome/test/base/ui_test_utils.h" |
16 #include "content/public/browser/navigation_controller.h" | 17 #include "content/public/browser/navigation_controller.h" |
17 #include "content/public/browser/web_contents.h" | 18 #include "content/public/browser/web_contents.h" |
(...skipping 23 matching lines...) Expand all Loading... |
41 ui_test_utils::NavigateToURL(browser(), | 42 ui_test_utils::NavigateToURL(browser(), |
42 net::FilePathToFileURL(extension_dir.AppendASCII("test.html"))); | 43 net::FilePathToFileURL(extension_dir.AppendASCII("test.html"))); |
43 WebContents* tab = chrome::GetActiveWebContents(browser()); | 44 WebContents* tab = chrome::GetActiveWebContents(browser()); |
44 | 45 |
45 // With no extensions, the plugin should not be loaded. | 46 // With no extensions, the plugin should not be loaded. |
46 bool result = false; | 47 bool result = false; |
47 ASSERT_TRUE(content::ExecuteJavaScriptAndExtractBool( | 48 ASSERT_TRUE(content::ExecuteJavaScriptAndExtractBool( |
48 tab->GetRenderViewHost(), L"", L"testPluginWorks()", &result)); | 49 tab->GetRenderViewHost(), L"", L"testPluginWorks()", &result)); |
49 EXPECT_FALSE(result); | 50 EXPECT_FALSE(result); |
50 | 51 |
51 ExtensionService* service = browser()->profile()->GetExtensionService(); | 52 ExtensionService* service = extensions::ExtensionSystem::Get( |
| 53 browser()->profile())->extension_service(); |
52 service->set_show_extensions_prompts(false); | 54 service->set_show_extensions_prompts(false); |
53 const size_t size_before = service->extensions()->size(); | 55 const size_t size_before = service->extensions()->size(); |
54 const Extension* extension = LoadExtension(extension_dir); | 56 const Extension* extension = LoadExtension(extension_dir); |
55 ASSERT_TRUE(extension); | 57 ASSERT_TRUE(extension); |
56 EXPECT_EQ(size_before + 1, service->extensions()->size()); | 58 EXPECT_EQ(size_before + 1, service->extensions()->size()); |
57 // Now the plugin should be in the cache. | 59 // Now the plugin should be in the cache. |
58 ASSERT_TRUE(content::ExecuteJavaScriptAndExtractBool( | 60 ASSERT_TRUE(content::ExecuteJavaScriptAndExtractBool( |
59 tab->GetRenderViewHost(), L"", L"testPluginWorks()", &result)); | 61 tab->GetRenderViewHost(), L"", L"testPluginWorks()", &result)); |
60 // We don't allow extension plugins to run on ChromeOS. | 62 // We don't allow extension plugins to run on ChromeOS. |
61 #if defined(OS_CHROMEOS) | 63 #if defined(OS_CHROMEOS) |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 } | 99 } |
98 | 100 |
99 // Tests that private extension plugins are only visible to the extension. | 101 // Tests that private extension plugins are only visible to the extension. |
100 IN_PROC_BROWSER_TEST_F(ExtensionBrowserTest, PluginPrivate) { | 102 IN_PROC_BROWSER_TEST_F(ExtensionBrowserTest, PluginPrivate) { |
101 browser()->profile()->GetPrefs()->SetBoolean(prefs::kPluginsAlwaysAuthorize, | 103 browser()->profile()->GetPrefs()->SetBoolean(prefs::kPluginsAlwaysAuthorize, |
102 true); | 104 true); |
103 | 105 |
104 FilePath extension_dir = | 106 FilePath extension_dir = |
105 test_data_dir_.AppendASCII("uitest").AppendASCII("plugins_private"); | 107 test_data_dir_.AppendASCII("uitest").AppendASCII("plugins_private"); |
106 | 108 |
107 ExtensionService* service = browser()->profile()->GetExtensionService(); | 109 ExtensionService* service = extensions::ExtensionSystem::Get( |
| 110 browser()->profile())->extension_service(); |
108 service->set_show_extensions_prompts(false); | 111 service->set_show_extensions_prompts(false); |
109 const size_t size_before = service->extensions()->size(); | 112 const size_t size_before = service->extensions()->size(); |
110 const Extension* extension = LoadExtension(extension_dir); | 113 const Extension* extension = LoadExtension(extension_dir); |
111 ASSERT_TRUE(extension); | 114 ASSERT_TRUE(extension); |
112 EXPECT_EQ(size_before + 1, service->extensions()->size()); | 115 EXPECT_EQ(size_before + 1, service->extensions()->size()); |
113 | 116 |
114 // Load the test page through the extension URL, and the plugin should work. | 117 // Load the test page through the extension URL, and the plugin should work. |
115 ui_test_utils::NavigateToURL(browser(), | 118 ui_test_utils::NavigateToURL(browser(), |
116 extension->GetResourceURL("test.html")); | 119 extension->GetResourceURL("test.html")); |
117 WebContents* tab = chrome::GetActiveWebContents(browser()); | 120 WebContents* tab = chrome::GetActiveWebContents(browser()); |
(...skipping 24 matching lines...) Expand all Loading... |
142 EXPECT_TRUE(result); | 145 EXPECT_TRUE(result); |
143 #endif | 146 #endif |
144 | 147 |
145 // Now load it through a file URL. The plugin should not load. | 148 // Now load it through a file URL. The plugin should not load. |
146 ui_test_utils::NavigateToURL(browser(), | 149 ui_test_utils::NavigateToURL(browser(), |
147 net::FilePathToFileURL(extension_dir.AppendASCII("test.html"))); | 150 net::FilePathToFileURL(extension_dir.AppendASCII("test.html"))); |
148 ASSERT_TRUE(content::ExecuteJavaScriptAndExtractBool( | 151 ASSERT_TRUE(content::ExecuteJavaScriptAndExtractBool( |
149 tab->GetRenderViewHost(), L"", L"testPluginWorks()", &result)); | 152 tab->GetRenderViewHost(), L"", L"testPluginWorks()", &result)); |
150 EXPECT_FALSE(result); | 153 EXPECT_FALSE(result); |
151 } | 154 } |
OLD | NEW |