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

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

Issue 597413003: Introduce an "ExtensionWantsToAct" method (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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
« no previous file with comments | « chrome/browser/extensions/api/extension_action/extension_action_api.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <string> 5 #include <string>
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "base/message_loop/message_loop.h" 9 #include "base/message_loop/message_loop.h"
10 #include "chrome/browser/extensions/active_script_controller.h" 10 #include "chrome/browser/extensions/active_script_controller.h"
11 #include "chrome/browser/extensions/api/extension_action/extension_action_api.h"
11 #include "chrome/browser/extensions/extension_action.h" 12 #include "chrome/browser/extensions/extension_action.h"
12 #include "chrome/browser/extensions/extension_action_manager.h" 13 #include "chrome/browser/extensions/extension_action_manager.h"
13 #include "chrome/browser/extensions/extension_service.h" 14 #include "chrome/browser/extensions/extension_service.h"
14 #include "chrome/browser/extensions/location_bar_controller.h" 15 #include "chrome/browser/extensions/location_bar_controller.h"
15 #include "chrome/browser/extensions/tab_helper.h" 16 #include "chrome/browser/extensions/tab_helper.h"
16 #include "chrome/browser/extensions/test_extension_system.h" 17 #include "chrome/browser/extensions/test_extension_system.h"
17 #include "chrome/browser/sessions/session_tab_helper.h" 18 #include "chrome/browser/sessions/session_tab_helper.h"
18 #include "chrome/test/base/chrome_render_view_host_test_harness.h" 19 #include "chrome/test/base/chrome_render_view_host_test_harness.h"
19 #include "chrome/test/base/testing_profile.h" 20 #include "chrome/test/base/testing_profile.h"
20 #include "components/crx_file/id_util.h" 21 #include "components/crx_file/id_util.h"
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 TEST_F(LocationBarControllerUnitTest, NavigationClearsState) { 153 TEST_F(LocationBarControllerUnitTest, NavigationClearsState) {
153 const Extension* extension = AddExtension(true, "page_actions"); 154 const Extension* extension = AddExtension(true, "page_actions");
154 155
155 NavigateAndCommit(GURL("http://www.google.com")); 156 NavigateAndCommit(GURL("http://www.google.com"));
156 157
157 ExtensionAction& page_action = 158 ExtensionAction& page_action =
158 *ExtensionActionManager::Get(profile())->GetPageAction(*extension); 159 *ExtensionActionManager::Get(profile())->GetPageAction(*extension);
159 page_action.SetTitle(tab_id(), "Goodbye"); 160 page_action.SetTitle(tab_id(), "Goodbye");
160 page_action.SetPopupUrl(tab_id(), extension->GetResourceURL("popup.html")); 161 page_action.SetPopupUrl(tab_id(), extension->GetResourceURL("popup.html"));
161 162
163 ExtensionActionAPI* extension_action_api =
164 ExtensionActionAPI::Get(profile());
165 // By default, extensions shouldn't want to act on a page.
166 extension_action_api->ExtensionWantsToRun(extension, web_contents());
Finnur 2014/09/26 09:53:33 EXPECT_FALSE?
Devlin 2014/09/29 22:56:51 Done.
167 // Showing the page action should indicate that an extension *does* want to
168 // run on the page.
169 page_action.SetIsVisible(tab_id(), true);
170 EXPECT_TRUE(extension_action_api->ExtensionWantsToRun(extension,
171 web_contents()));
172
162 EXPECT_EQ("Goodbye", page_action.GetTitle(tab_id())); 173 EXPECT_EQ("Goodbye", page_action.GetTitle(tab_id()));
163 EXPECT_EQ(extension->GetResourceURL("popup.html"), 174 EXPECT_EQ(extension->GetResourceURL("popup.html"),
164 page_action.GetPopupUrl(tab_id())); 175 page_action.GetPopupUrl(tab_id()));
165 176
166 // Within-page navigation should keep the settings. 177 // Within-page navigation should keep the settings.
167 NavigateAndCommit(GURL("http://www.google.com/#hash")); 178 NavigateAndCommit(GURL("http://www.google.com/#hash"));
168 179
169 EXPECT_EQ("Goodbye", page_action.GetTitle(tab_id())); 180 EXPECT_EQ("Goodbye", page_action.GetTitle(tab_id()));
170 EXPECT_EQ(extension->GetResourceURL("popup.html"), 181 EXPECT_EQ(extension->GetResourceURL("popup.html"),
171 page_action.GetPopupUrl(tab_id())); 182 page_action.GetPopupUrl(tab_id()));
183 EXPECT_TRUE(extension_action_api->ExtensionWantsToRun(extension,
184 web_contents()));
172 185
173 // Should discard the settings, and go back to the defaults. 186 // Should discard the settings, and go back to the defaults.
174 NavigateAndCommit(GURL("http://www.yahoo.com")); 187 NavigateAndCommit(GURL("http://www.yahoo.com"));
175 188
176 EXPECT_EQ("Hello", page_action.GetTitle(tab_id())); 189 EXPECT_EQ("Hello", page_action.GetTitle(tab_id()));
177 EXPECT_EQ(GURL(), page_action.GetPopupUrl(tab_id())); 190 EXPECT_EQ(GURL(), page_action.GetPopupUrl(tab_id()));
191 EXPECT_FALSE(extension_action_api->ExtensionWantsToRun(extension,
192 web_contents()));
178 } 193 }
179 194
180 } // namespace 195 } // namespace
181 } // namespace extensions 196 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/extensions/api/extension_action/extension_action_api.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698