| 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/extensions/api/extension_action/extension_action_api.h" | 5 #include "chrome/browser/extensions/api/extension_action/extension_action_api.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/lazy_instance.h" | 10 #include "base/lazy_instance.h" |
| (...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 225 if (!extension_action) | 225 if (!extension_action) |
| 226 return false; | 226 return false; |
| 227 | 227 |
| 228 if (extension_action->action_type() == ActionInfo::TYPE_PAGE && | 228 if (extension_action->action_type() == ActionInfo::TYPE_PAGE && |
| 229 !FeatureSwitch::extension_action_redesign()->IsEnabled()) { | 229 !FeatureSwitch::extension_action_redesign()->IsEnabled()) { |
| 230 // We show page actions in the location bar unless the new toolbar is | 230 // We show page actions in the location bar unless the new toolbar is |
| 231 // enabled. | 231 // enabled. |
| 232 return browser->window()->GetLocationBar()->ShowPageActionPopup( | 232 return browser->window()->GetLocationBar()->ShowPageActionPopup( |
| 233 extension, grant_active_tab_permissions); | 233 extension, grant_active_tab_permissions); |
| 234 } | 234 } |
| 235 return browser->window()->GetToolbarActionsBar()->ShowToolbarActionPopup( | 235 ToolbarActionsBar* toolbar_actions_bar = |
| 236 extension->id(), grant_active_tab_permissions); | 236 browser->window()->GetToolbarActionsBar(); |
| 237 // ToolbarActionsBar could be null if, e.g., this is a popup window with no |
| 238 // toolbar. |
| 239 return toolbar_actions_bar && |
| 240 toolbar_actions_bar->ShowToolbarActionPopup( |
| 241 extension->id(), grant_active_tab_permissions); |
| 237 } | 242 } |
| 238 | 243 |
| 239 bool ExtensionActionAPI::ExtensionWantsToRun( | 244 bool ExtensionActionAPI::ExtensionWantsToRun( |
| 240 const Extension* extension, content::WebContents* web_contents) { | 245 const Extension* extension, content::WebContents* web_contents) { |
| 241 // An extension wants to act if it has a visible page action on the given | 246 // An extension wants to act if it has a visible page action on the given |
| 242 // page... | 247 // page... |
| 243 ExtensionAction* page_action = | 248 ExtensionAction* page_action = |
| 244 ExtensionActionManager::Get(browser_context_)->GetPageAction(*extension); | 249 ExtensionActionManager::Get(browser_context_)->GetPageAction(*extension); |
| 245 if (page_action && | 250 if (page_action && |
| 246 page_action->GetIsVisible(SessionTabHelper::IdForTab(web_contents))) | 251 page_action->GetIsVisible(SessionTabHelper::IdForTab(web_contents))) |
| (...skipping 440 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 687 if (host->extension_host_type() != VIEW_TYPE_EXTENSION_POPUP || | 692 if (host->extension_host_type() != VIEW_TYPE_EXTENSION_POPUP || |
| 688 host->extension()->id() != extension_->id()) | 693 host->extension()->id() != extension_->id()) |
| 689 return; | 694 return; |
| 690 | 695 |
| 691 SendResponse(true); | 696 SendResponse(true); |
| 692 response_sent_ = true; | 697 response_sent_ = true; |
| 693 registrar_.RemoveAll(); | 698 registrar_.RemoveAll(); |
| 694 } | 699 } |
| 695 | 700 |
| 696 } // namespace extensions | 701 } // namespace extensions |
| OLD | NEW |