| 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::PageActionWantsToRun( | 244 bool ExtensionActionAPI::PageActionWantsToRun( |
| 240 const Extension* extension, | 245 const Extension* extension, |
| 241 content::WebContents* web_contents) { | 246 content::WebContents* web_contents) { |
| 242 ExtensionAction* page_action = | 247 ExtensionAction* page_action = |
| 243 ExtensionActionManager::Get(browser_context_)->GetPageAction(*extension); | 248 ExtensionActionManager::Get(browser_context_)->GetPageAction(*extension); |
| 244 return page_action && | 249 return page_action && |
| 245 page_action->GetIsVisible(SessionTabHelper::IdForTab(web_contents)); | 250 page_action->GetIsVisible(SessionTabHelper::IdForTab(web_contents)); |
| 246 } | 251 } |
| (...skipping 436 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 683 if (host->extension_host_type() != VIEW_TYPE_EXTENSION_POPUP || | 688 if (host->extension_host_type() != VIEW_TYPE_EXTENSION_POPUP || |
| 684 host->extension()->id() != extension_->id()) | 689 host->extension()->id() != extension_->id()) |
| 685 return; | 690 return; |
| 686 | 691 |
| 687 SendResponse(true); | 692 SendResponse(true); |
| 688 response_sent_ = true; | 693 response_sent_ = true; |
| 689 registrar_.RemoveAll(); | 694 registrar_.RemoveAll(); |
| 690 } | 695 } |
| 691 | 696 |
| 692 } // namespace extensions | 697 } // namespace extensions |
| OLD | NEW |