Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 #import "chrome/browser/ui/cocoa/extensions/extension_action_platform_delegate_c ocoa.h" | 5 #import "chrome/browser/ui/cocoa/extensions/extension_action_platform_delegate_c ocoa.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| 11 #include "chrome/browser/extensions/extension_action.h" | 11 #include "chrome/browser/extensions/extension_action.h" |
| 12 #include "chrome/browser/extensions/extension_view_host.h" | 12 #include "chrome/browser/extensions/extension_view_host.h" |
| 13 #include "chrome/browser/ui/browser.h" | 13 #include "chrome/browser/ui/browser.h" |
| 14 #include "chrome/browser/ui/browser_window.h" | 14 #include "chrome/browser/ui/browser_window.h" |
| 15 #import "chrome/browser/ui/cocoa/app_menu/app_menu_controller.h" | |
| 15 #import "chrome/browser/ui/cocoa/browser_window_controller.h" | 16 #import "chrome/browser/ui/cocoa/browser_window_controller.h" |
| 16 #import "chrome/browser/ui/cocoa/extensions/browser_actions_controller.h" | 17 #import "chrome/browser/ui/cocoa/extensions/browser_actions_controller.h" |
| 17 #import "chrome/browser/ui/cocoa/extensions/extension_popup_controller.h" | 18 #import "chrome/browser/ui/cocoa/extensions/extension_popup_controller.h" |
| 18 #import "chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.h" | 19 #import "chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.h" |
| 19 #import "chrome/browser/ui/cocoa/toolbar/toolbar_controller.h" | 20 #import "chrome/browser/ui/cocoa/toolbar/toolbar_controller.h" |
| 20 #import "chrome/browser/ui/cocoa/wrench_menu/wrench_menu_controller.h" | |
| 21 #include "chrome/browser/ui/toolbar/toolbar_action_view_delegate.h" | 21 #include "chrome/browser/ui/toolbar/toolbar_action_view_delegate.h" |
| 22 #include "chrome/common/extensions/api/extension_action/action_info.h" | 22 #include "chrome/common/extensions/api/extension_action/action_info.h" |
| 23 #include "content/public/browser/notification_details.h" | 23 #include "content/public/browser/notification_details.h" |
| 24 #include "content/public/browser/notification_source.h" | 24 #include "content/public/browser/notification_source.h" |
| 25 #include "extensions/browser/notification_types.h" | 25 #include "extensions/browser/notification_types.h" |
| 26 #include "extensions/common/extension.h" | 26 #include "extensions/common/extension.h" |
| 27 #include "extensions/common/feature_switch.h" | 27 #include "extensions/common/feature_switch.h" |
| 28 | 28 |
| 29 namespace { | 29 namespace { |
| 30 | 30 |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 74 BOOL devMode = | 74 BOOL devMode = |
| 75 show_action == ExtensionActionViewController::SHOW_POPUP_AND_INSPECT; | 75 show_action == ExtensionActionViewController::SHOW_POPUP_AND_INSPECT; |
| 76 [ExtensionPopupController host:host.Pass() | 76 [ExtensionPopupController host:host.Pass() |
| 77 inBrowser:controller_->browser() | 77 inBrowser:controller_->browser() |
| 78 anchoredAt:GetPopupPoint() | 78 anchoredAt:GetPopupPoint() |
| 79 arrowLocation:info_bubble::kTopRight | 79 arrowLocation:info_bubble::kTopRight |
| 80 devMode:devMode]; | 80 devMode:devMode]; |
| 81 } | 81 } |
| 82 | 82 |
| 83 void ExtensionActionPlatformDelegateCocoa::CloseOverflowMenu() { | 83 void ExtensionActionPlatformDelegateCocoa::CloseOverflowMenu() { |
| 84 // If this was triggered by an action overflowed to the wrench menu, then | 84 // If this was triggered by an action overflowed to the app menu, then |
|
Peter Kasting
2015/11/06 22:21:28
Nit: Rewrap comment
| |
| 85 // the wrench menu will be open. Close it before opening the popup. | 85 // the app menu will be open. Close it before opening the popup. |
| 86 WrenchMenuController* wrenchMenuController = | 86 AppMenuController* appMenuController = |
| 87 [[[BrowserWindowController | 87 [[[BrowserWindowController |
| 88 browserWindowControllerForWindow: | 88 browserWindowControllerForWindow: |
| 89 controller_->browser()->window()->GetNativeWindow()] | 89 controller_->browser()->window()->GetNativeWindow()] |
| 90 toolbarController] wrenchMenuController]; | 90 toolbarController] appMenuController]; |
| 91 if ([wrenchMenuController isMenuOpen]) | 91 if ([appMenuController isMenuOpen]) |
| 92 [wrenchMenuController cancel]; | 92 [appMenuController cancel]; |
| 93 } | 93 } |
| 94 | 94 |
| 95 NSPoint ExtensionActionPlatformDelegateCocoa::GetPopupPoint() const { | 95 NSPoint ExtensionActionPlatformDelegateCocoa::GetPopupPoint() const { |
| 96 BrowserWindowController* windowController = | 96 BrowserWindowController* windowController = |
| 97 [BrowserWindowController browserWindowControllerForWindow: | 97 [BrowserWindowController browserWindowControllerForWindow: |
| 98 controller_->browser()->window()->GetNativeWindow()]; | 98 controller_->browser()->window()->GetNativeWindow()]; |
| 99 NSPoint popupPoint; | 99 NSPoint popupPoint; |
| 100 if (controller_->extension_action()->action_type() == | 100 if (controller_->extension_action()->action_type() == |
| 101 extensions::ActionInfo::TYPE_BROWSER || | 101 extensions::ActionInfo::TYPE_BROWSER || |
| 102 extensions::FeatureSwitch::extension_action_redesign()->IsEnabled()) { | 102 extensions::FeatureSwitch::extension_action_redesign()->IsEnabled()) { |
| (...skipping 28 matching lines...) Expand all Loading... | |
| 131 controller_->IsEnabled( | 131 controller_->IsEnabled( |
| 132 controller_->view_delegate()->GetCurrentWebContents())) { | 132 controller_->view_delegate()->GetCurrentWebContents())) { |
| 133 controller_->ExecuteAction(true); | 133 controller_->ExecuteAction(true); |
| 134 } | 134 } |
| 135 break; | 135 break; |
| 136 } | 136 } |
| 137 default: | 137 default: |
| 138 NOTREACHED() << L"Unexpected notification"; | 138 NOTREACHED() << L"Unexpected notification"; |
| 139 } | 139 } |
| 140 } | 140 } |
| OLD | NEW |