| 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 "base/lazy_instance.h" | 7 #include "base/lazy_instance.h" |
| 8 #include "base/location.h" | 8 #include "base/location.h" |
| 9 #include "base/single_thread_task_runner.h" | 9 #include "base/single_thread_task_runner.h" |
| 10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
| 11 #include "base/thread_task_runner_handle.h" | 11 #include "base/thread_task_runner_handle.h" |
| 12 #include "base/values.h" | 12 #include "base/values.h" |
| 13 #include "chrome/browser/extensions/active_script_controller.h" | 13 #include "chrome/browser/extensions/active_script_controller.h" |
| 14 #include "chrome/browser/extensions/extension_action_manager.h" | 14 #include "chrome/browser/extensions/extension_action_manager.h" |
| 15 #include "chrome/browser/extensions/extension_tab_util.h" | 15 #include "chrome/browser/extensions/extension_tab_util.h" |
| 16 #include "chrome/browser/extensions/extension_toolbar_model.h" | |
| 17 #include "chrome/browser/extensions/extension_util.h" | 16 #include "chrome/browser/extensions/extension_util.h" |
| 18 #include "chrome/browser/extensions/tab_helper.h" | 17 #include "chrome/browser/extensions/tab_helper.h" |
| 19 #include "chrome/browser/profiles/profile.h" | 18 #include "chrome/browser/profiles/profile.h" |
| 20 #include "chrome/browser/sessions/session_tab_helper.h" | 19 #include "chrome/browser/sessions/session_tab_helper.h" |
| 21 #include "chrome/browser/ui/browser.h" | 20 #include "chrome/browser/ui/browser.h" |
| 22 #include "chrome/browser/ui/browser_finder.h" | 21 #include "chrome/browser/ui/browser_finder.h" |
| 23 #include "chrome/browser/ui/browser_window.h" | 22 #include "chrome/browser/ui/browser_window.h" |
| 24 #include "chrome/browser/ui/location_bar/location_bar.h" | 23 #include "chrome/browser/ui/location_bar/location_bar.h" |
| 25 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 24 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 25 #include "chrome/browser/ui/toolbar/toolbar_actions_model.h" |
| 26 #include "chrome/common/extensions/api/extension_action/action_info.h" | 26 #include "chrome/common/extensions/api/extension_action/action_info.h" |
| 27 #include "content/public/browser/notification_service.h" | 27 #include "content/public/browser/notification_service.h" |
| 28 #include "extensions/browser/event_router.h" | 28 #include "extensions/browser/event_router.h" |
| 29 #include "extensions/browser/extension_function_registry.h" | 29 #include "extensions/browser/extension_function_registry.h" |
| 30 #include "extensions/browser/extension_host.h" | 30 #include "extensions/browser/extension_host.h" |
| 31 #include "extensions/browser/extension_registry.h" | 31 #include "extensions/browser/extension_registry.h" |
| 32 #include "extensions/browser/notification_types.h" | 32 #include "extensions/browser/notification_types.h" |
| 33 #include "extensions/common/error_utils.h" | 33 #include "extensions/common/error_utils.h" |
| 34 #include "extensions/common/feature_switch.h" | 34 #include "extensions/common/feature_switch.h" |
| 35 #include "extensions/common/image_util.h" | 35 #include "extensions/common/image_util.h" |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 221 if (!extension_action) | 221 if (!extension_action) |
| 222 return false; | 222 return false; |
| 223 | 223 |
| 224 if (extension_action->action_type() == ActionInfo::TYPE_PAGE && | 224 if (extension_action->action_type() == ActionInfo::TYPE_PAGE && |
| 225 !FeatureSwitch::extension_action_redesign()->IsEnabled()) { | 225 !FeatureSwitch::extension_action_redesign()->IsEnabled()) { |
| 226 // We show page actions in the location bar unless the new toolbar is | 226 // We show page actions in the location bar unless the new toolbar is |
| 227 // enabled. | 227 // enabled. |
| 228 return browser->window()->GetLocationBar()->ShowPageActionPopup( | 228 return browser->window()->GetLocationBar()->ShowPageActionPopup( |
| 229 extension, grant_active_tab_permissions); | 229 extension, grant_active_tab_permissions); |
| 230 } else { | 230 } else { |
| 231 return ExtensionToolbarModel::Get(browser->profile())-> | 231 return ToolbarActionsModel::Get(browser->profile())-> |
| 232 ShowExtensionActionPopup( | 232 ShowToolbarActionPopup(extension->id(), |
| 233 extension, browser, grant_active_tab_permissions); | 233 browser, |
| 234 grant_active_tab_permissions); |
| 234 } | 235 } |
| 235 } | 236 } |
| 236 | 237 |
| 237 bool ExtensionActionAPI::ExtensionWantsToRun( | 238 bool ExtensionActionAPI::ExtensionWantsToRun( |
| 238 const Extension* extension, content::WebContents* web_contents) { | 239 const Extension* extension, content::WebContents* web_contents) { |
| 239 // An extension wants to act if it has a visible page action on the given | 240 // An extension wants to act if it has a visible page action on the given |
| 240 // page... | 241 // page... |
| 241 ExtensionAction* page_action = | 242 ExtensionAction* page_action = |
| 242 ExtensionActionManager::Get(browser_context_)->GetPageAction(*extension); | 243 ExtensionActionManager::Get(browser_context_)->GetPageAction(*extension); |
| 243 if (page_action && | 244 if (page_action && |
| (...skipping 436 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 680 if (host->extension_host_type() != VIEW_TYPE_EXTENSION_POPUP || | 681 if (host->extension_host_type() != VIEW_TYPE_EXTENSION_POPUP || |
| 681 host->extension()->id() != extension_->id()) | 682 host->extension()->id() != extension_->id()) |
| 682 return; | 683 return; |
| 683 | 684 |
| 684 SendResponse(true); | 685 SendResponse(true); |
| 685 response_sent_ = true; | 686 response_sent_ = true; |
| 686 registrar_.RemoveAll(); | 687 registrar_.RemoveAll(); |
| 687 } | 688 } |
| 688 | 689 |
| 689 } // namespace extensions | 690 } // namespace extensions |
| OLD | NEW |