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

Side by Side Diff: chrome/browser/extensions/api/extension_action/extension_action_api.cc

Issue 516633002: Stop showing page actions in the location bar with redesign enabled (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Latest CQ for Master Created 6 years, 3 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
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/extensions/api/extension_action/extension_action_api.h" 5 #include "chrome/browser/extensions/api/extension_action/extension_action_api.h"
6 6
7 #include "base/lazy_instance.h" 7 #include "base/lazy_instance.h"
8 #include "base/strings/string_number_conversions.h" 8 #include "base/strings/string_number_conversions.h"
9 #include "base/values.h" 9 #include "base/values.h"
10 #include "chrome/browser/extensions/active_script_controller.h" 10 #include "chrome/browser/extensions/active_script_controller.h"
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 const Extension* extension, 164 const Extension* extension,
165 Browser* browser, 165 Browser* browser,
166 bool grant_active_tab_permissions) { 166 bool grant_active_tab_permissions) {
167 content::WebContents* web_contents = 167 content::WebContents* web_contents =
168 browser->tab_strip_model()->GetActiveWebContents(); 168 browser->tab_strip_model()->GetActiveWebContents();
169 if (!web_contents) 169 if (!web_contents)
170 return ExtensionAction::ACTION_NONE; 170 return ExtensionAction::ACTION_NONE;
171 171
172 int tab_id = SessionTabHelper::IdForTab(web_contents); 172 int tab_id = SessionTabHelper::IdForTab(web_contents);
173 173
174 ExtensionAction* extension_action = 174 ActiveScriptController* active_script_controller =
175 ExtensionActionManager::Get(browser_context_)->GetExtensionAction( 175 ActiveScriptController::GetForWebContents(web_contents);
176 *extension); 176 bool has_pending_scripts = false;
177 177 if (active_script_controller &&
178 // Anything that calls this should have a page or browser action. 178 active_script_controller->GetActionForExtension(extension)) {
179 DCHECK(extension_action); 179 has_pending_scripts = true;
180 if (!extension_action->GetIsVisible(tab_id)) 180 }
181 return ExtensionAction::ACTION_NONE;
182 181
183 // Grant active tab if appropriate. 182 // Grant active tab if appropriate.
184 if (grant_active_tab_permissions) { 183 if (grant_active_tab_permissions) {
185 TabHelper::FromWebContents(web_contents)->active_tab_permission_granter()-> 184 TabHelper::FromWebContents(web_contents)->active_tab_permission_granter()->
186 GrantIfRequested(extension); 185 GrantIfRequested(extension);
187 } 186 }
188 187
189 // Notify ActiveScriptController that the action was clicked, if appropriate. 188 // If this was a request to run a script, it will have been run once active
190 ActiveScriptController* active_script_controller = 189 // tab was granted. Return without executing the action, since we should only
191 ActiveScriptController::GetForWebContents(web_contents); 190 // run pending scripts OR the extension action, not both.
192 if (active_script_controller && 191 if (has_pending_scripts)
193 active_script_controller->GetActionForExtension(extension)) { 192 return ExtensionAction::ACTION_NONE;
194 active_script_controller->OnClicked(extension); 193
195 } 194 ExtensionAction* extension_action =
195 ExtensionActionManager::Get(browser_context_)->GetExtensionAction(
196 *extension);
197
198 // Anything that gets here should have a page or browser action.
199 DCHECK(extension_action);
200 if (!extension_action->GetIsVisible(tab_id))
201 return ExtensionAction::ACTION_NONE;
196 202
197 if (extension_action->HasPopup(tab_id)) 203 if (extension_action->HasPopup(tab_id))
198 return ExtensionAction::ACTION_SHOW_POPUP; 204 return ExtensionAction::ACTION_SHOW_POPUP;
199 205
200 ExtensionActionExecuted(*extension_action, web_contents); 206 ExtensionActionExecuted(*extension_action, web_contents);
201 return ExtensionAction::ACTION_NONE; 207 return ExtensionAction::ACTION_NONE;
202 } 208 }
203 209
204 bool ExtensionActionAPI::ShowExtensionActionPopup( 210 bool ExtensionActionAPI::ShowExtensionActionPopup(
205 const Extension* extension, 211 const Extension* extension,
(...skipping 430 matching lines...) Expand 10 before | Expand all | Expand 10 after
636 if (host->extension_host_type() != VIEW_TYPE_EXTENSION_POPUP || 642 if (host->extension_host_type() != VIEW_TYPE_EXTENSION_POPUP ||
637 host->extension()->id() != extension_->id()) 643 host->extension()->id() != extension_->id())
638 return; 644 return;
639 645
640 SendResponse(true); 646 SendResponse(true);
641 response_sent_ = true; 647 response_sent_ = true;
642 registrar_.RemoveAll(); 648 registrar_.RemoveAll();
643 } 649 }
644 650
645 } // namespace extensions 651 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698