Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(54)

Side by Side Diff: chrome/browser/extensions/plugin_apitest.cc

Issue 12066003: Remove TabStripModel wrapper use. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: gtk Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/extensions/extension_system.h"
9 #include "chrome/browser/prefs/pref_service.h" 9 #include "chrome/browser/prefs/pref_service.h"
10 #include "chrome/browser/ui/browser.h" 10 #include "chrome/browser/ui/browser.h"
11 #include "chrome/browser/ui/browser_commands.h" 11 #include "chrome/browser/ui/browser_commands.h"
12 #include "chrome/browser/ui/browser_tabstrip.h" 12 #include "chrome/browser/ui/tabs/tab_strip_model.h"
13 #include "chrome/common/extensions/extension.h" 13 #include "chrome/common/extensions/extension.h"
14 #include "chrome/common/pref_names.h" 14 #include "chrome/common/pref_names.h"
15 #include "chrome/test/base/ui_test_utils.h" 15 #include "chrome/test/base/ui_test_utils.h"
16 #include "content/public/browser/navigation_controller.h" 16 #include "content/public/browser/navigation_controller.h"
17 #include "content/public/browser/web_contents.h" 17 #include "content/public/browser/web_contents.h"
18 #include "content/public/test/browser_test_utils.h" 18 #include "content/public/test/browser_test_utils.h"
19 #include "net/base/net_util.h" 19 #include "net/base/net_util.h"
20 #include "webkit/plugins/npapi/plugin_utils.h" 20 #include "webkit/plugins/npapi/plugin_utils.h"
21 21
22 using content::NavigationController; 22 using content::NavigationController;
(...skipping 13 matching lines...) Expand all
36 if (!webkit::npapi::NPAPIPluginsSupported()) 36 if (!webkit::npapi::NPAPIPluginsSupported())
37 return; 37 return;
38 browser()->profile()->GetPrefs()->SetBoolean(prefs::kPluginsAlwaysAuthorize, 38 browser()->profile()->GetPrefs()->SetBoolean(prefs::kPluginsAlwaysAuthorize,
39 true); 39 true);
40 40
41 FilePath extension_dir = 41 FilePath extension_dir =
42 test_data_dir_.AppendASCII("uitest").AppendASCII("plugins"); 42 test_data_dir_.AppendASCII("uitest").AppendASCII("plugins");
43 43
44 ui_test_utils::NavigateToURL(browser(), 44 ui_test_utils::NavigateToURL(browser(),
45 net::FilePathToFileURL(extension_dir.AppendASCII("test.html"))); 45 net::FilePathToFileURL(extension_dir.AppendASCII("test.html")));
46 WebContents* tab = chrome::GetActiveWebContents(browser()); 46 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents();
47 47
48 // With no extensions, the plugin should not be loaded. 48 // With no extensions, the plugin should not be loaded.
49 bool result = false; 49 bool result = false;
50 ASSERT_TRUE(content::ExecuteScriptAndExtractBool( 50 ASSERT_TRUE(content::ExecuteScriptAndExtractBool(
51 tab, "testPluginWorks()", &result)); 51 tab, "testPluginWorks()", &result));
52 EXPECT_FALSE(result); 52 EXPECT_FALSE(result);
53 53
54 ExtensionService* service = extensions::ExtensionSystem::Get( 54 ExtensionService* service = extensions::ExtensionSystem::Get(
55 browser()->profile())->extension_service(); 55 browser()->profile())->extension_service();
56 service->set_show_extensions_prompts(false); 56 service->set_show_extensions_prompts(false);
(...skipping 22 matching lines...) Expand all
79 EXPECT_FALSE(result); 79 EXPECT_FALSE(result);
80 80
81 // If we reload the extension and page, it should work again. 81 // If we reload the extension and page, it should work again.
82 82
83 ASSERT_TRUE(LoadExtension(extension_dir)); 83 ASSERT_TRUE(LoadExtension(extension_dir));
84 EXPECT_EQ(size_before + 1, service->extensions()->size()); 84 EXPECT_EQ(size_before + 1, service->extensions()->size());
85 { 85 {
86 content::WindowedNotificationObserver observer( 86 content::WindowedNotificationObserver observer(
87 content::NOTIFICATION_LOAD_STOP, 87 content::NOTIFICATION_LOAD_STOP,
88 content::Source<NavigationController>( 88 content::Source<NavigationController>(
89 &chrome::GetActiveWebContents(browser())->GetController())); 89 &browser()->tab_strip_model()->GetActiveWebContents()->
90 GetController()));
90 chrome::Reload(browser(), CURRENT_TAB); 91 chrome::Reload(browser(), CURRENT_TAB);
91 observer.Wait(); 92 observer.Wait();
92 } 93 }
93 ASSERT_TRUE(content::ExecuteScriptAndExtractBool( 94 ASSERT_TRUE(content::ExecuteScriptAndExtractBool(
94 tab, "testPluginWorks()", &result)); 95 tab, "testPluginWorks()", &result));
95 // We don't allow extension plugins to run on ChromeOS. 96 // We don't allow extension plugins to run on ChromeOS.
96 #if defined(OS_CHROMEOS) 97 #if defined(OS_CHROMEOS)
97 EXPECT_FALSE(result); 98 EXPECT_FALSE(result);
98 #else 99 #else
99 EXPECT_TRUE(result); 100 EXPECT_TRUE(result);
(...skipping 15 matching lines...) Expand all
115 browser()->profile())->extension_service(); 116 browser()->profile())->extension_service();
116 service->set_show_extensions_prompts(false); 117 service->set_show_extensions_prompts(false);
117 const size_t size_before = service->extensions()->size(); 118 const size_t size_before = service->extensions()->size();
118 const Extension* extension = LoadExtension(extension_dir); 119 const Extension* extension = LoadExtension(extension_dir);
119 ASSERT_TRUE(extension); 120 ASSERT_TRUE(extension);
120 EXPECT_EQ(size_before + 1, service->extensions()->size()); 121 EXPECT_EQ(size_before + 1, service->extensions()->size());
121 122
122 // Load the test page through the extension URL, and the plugin should work. 123 // Load the test page through the extension URL, and the plugin should work.
123 ui_test_utils::NavigateToURL(browser(), 124 ui_test_utils::NavigateToURL(browser(),
124 extension->GetResourceURL("test.html")); 125 extension->GetResourceURL("test.html"));
125 WebContents* tab = chrome::GetActiveWebContents(browser()); 126 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents();
126 bool result = false; 127 bool result = false;
127 ASSERT_TRUE(content::ExecuteScriptAndExtractBool( 128 ASSERT_TRUE(content::ExecuteScriptAndExtractBool(
128 tab, "testPluginWorks()", &result)); 129 tab, "testPluginWorks()", &result));
129 // We don't allow extension plugins to run on ChromeOS. 130 // We don't allow extension plugins to run on ChromeOS.
130 #if defined(OS_CHROMEOS) 131 #if defined(OS_CHROMEOS)
131 EXPECT_FALSE(result); 132 EXPECT_FALSE(result);
132 #else 133 #else
133 // TODO(bauerb): This might wrongly fail if the plug-in takes too long 134 // TODO(bauerb): This might wrongly fail if the plug-in takes too long
134 // to load. Extension-private plug-ins don't appear in navigator.plugins, so 135 // to load. Extension-private plug-ins don't appear in navigator.plugins, so
135 // we can't check for the plug-in in Javascript. 136 // we can't check for the plug-in in Javascript.
(...skipping 14 matching lines...) Expand all
150 EXPECT_TRUE(result); 151 EXPECT_TRUE(result);
151 #endif 152 #endif
152 153
153 // Now load it through a file URL. The plugin should not load. 154 // Now load it through a file URL. The plugin should not load.
154 ui_test_utils::NavigateToURL(browser(), 155 ui_test_utils::NavigateToURL(browser(),
155 net::FilePathToFileURL(extension_dir.AppendASCII("test.html"))); 156 net::FilePathToFileURL(extension_dir.AppendASCII("test.html")));
156 ASSERT_TRUE(content::ExecuteScriptAndExtractBool( 157 ASSERT_TRUE(content::ExecuteScriptAndExtractBool(
157 tab, "testPluginWorks()", &result)); 158 tab, "testPluginWorks()", &result));
158 EXPECT_FALSE(result); 159 EXPECT_FALSE(result);
159 } 160 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/page_action_browsertest.cc ('k') | chrome/browser/extensions/web_contents_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698