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" |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 registrar_.Add( | 70 registrar_.Add( |
71 this, | 71 this, |
72 extensions::NOTIFICATION_EXTENSION_HOST_VIEW_SHOULD_CLOSE, | 72 extensions::NOTIFICATION_EXTENSION_HOST_VIEW_SHOULD_CLOSE, |
73 content::Source<Profile>(controller_->browser()->profile())); | 73 content::Source<Profile>(controller_->browser()->profile())); |
74 registrar_.Add( | 74 registrar_.Add( |
75 this, | 75 this, |
76 GetNotificationTypeForAction(*controller_->extension_action()), | 76 GetNotificationTypeForAction(*controller_->extension_action()), |
77 content::Source<Profile>(controller_->browser()->profile())); | 77 content::Source<Profile>(controller_->browser()->profile())); |
78 } | 78 } |
79 | 79 |
80 bool ExtensionActionPlatformDelegateCocoa::IsShowingPopup() const { | |
81 return GetPopup() != nil; | |
82 } | |
83 | |
84 void ExtensionActionPlatformDelegateCocoa::CloseActivePopup() { | 80 void ExtensionActionPlatformDelegateCocoa::CloseActivePopup() { |
85 ExtensionPopupController* popup = [ExtensionPopupController popup]; | 81 ExtensionPopupController* popup = [ExtensionPopupController popup]; |
86 if (popup && ![popup isClosing]) | 82 if (popup && ![popup isClosing]) |
87 [popup close]; | 83 [popup close]; |
88 } | 84 } |
89 | 85 |
90 void ExtensionActionPlatformDelegateCocoa::CloseOwnPopup() { | 86 void ExtensionActionPlatformDelegateCocoa::CloseOwnPopup() { |
91 ExtensionPopupController* popup = GetPopup(); | 87 ExtensionPopupController* popup = GetPopup(); |
92 DCHECK(popup); | |
93 if (popup && ![popup isClosing]) | 88 if (popup && ![popup isClosing]) |
94 [popup close]; | 89 [popup close]; |
95 } | 90 } |
96 | 91 |
97 bool ExtensionActionPlatformDelegateCocoa::ShowPopupWithUrl( | 92 extensions::ExtensionViewHost* |
| 93 ExtensionActionPlatformDelegateCocoa::ShowPopupWithUrl( |
98 ExtensionActionViewController::PopupShowAction show_action, | 94 ExtensionActionViewController::PopupShowAction show_action, |
99 const GURL& popup_url, | 95 const GURL& popup_url, |
100 bool grant_tab_permissions) { | 96 bool grant_tab_permissions) { |
101 NSPoint arrowPoint = GetDelegateCocoa()->GetPopupPoint(); | 97 NSPoint arrowPoint = GetDelegateCocoa()->GetPopupPoint(); |
102 | 98 |
103 // If this was triggered by an action overflowed to the wrench menu, then | 99 // If this was triggered by an action overflowed to the wrench menu, then |
104 // the wrench menu will be open. Close it before opening the popup. | 100 // the wrench menu will be open. Close it before opening the popup. |
105 WrenchMenuController* wrenchMenuController = | 101 WrenchMenuController* wrenchMenuController = |
106 [[[BrowserWindowController | 102 [[[BrowserWindowController |
107 browserWindowControllerForWindow: | 103 browserWindowControllerForWindow: |
108 controller_->browser()->window()->GetNativeWindow()] | 104 controller_->browser()->window()->GetNativeWindow()] |
109 toolbarController] wrenchMenuController]; | 105 toolbarController] wrenchMenuController]; |
110 if ([wrenchMenuController isMenuOpen]) | 106 if ([wrenchMenuController isMenuOpen]) |
111 [wrenchMenuController cancel]; | 107 [wrenchMenuController cancel]; |
112 | 108 |
113 BOOL devMode = | 109 BOOL devMode = |
114 show_action == ExtensionActionViewController::SHOW_POPUP_AND_INSPECT; | 110 show_action == ExtensionActionViewController::SHOW_POPUP_AND_INSPECT; |
115 [ExtensionPopupController showURL:popup_url | 111 ExtensionPopupController* popupController = |
116 inBrowser:controller_->browser() | 112 [ExtensionPopupController showURL:popup_url |
117 anchoredAt:arrowPoint | 113 inBrowser:controller_->browser() |
118 arrowLocation:info_bubble::kTopRight | 114 anchoredAt:arrowPoint |
119 devMode:devMode]; | 115 arrowLocation:info_bubble::kTopRight |
120 return true; | 116 devMode:devMode]; |
| 117 return [popupController extensionViewHost]; |
121 } | 118 } |
122 | 119 |
123 ToolbarActionViewDelegateCocoa* | 120 ToolbarActionViewDelegateCocoa* |
124 ExtensionActionPlatformDelegateCocoa::GetDelegateCocoa() { | 121 ExtensionActionPlatformDelegateCocoa::GetDelegateCocoa() { |
125 return static_cast<ToolbarActionViewDelegateCocoa*>( | 122 return static_cast<ToolbarActionViewDelegateCocoa*>( |
126 controller_->view_delegate()); | 123 controller_->view_delegate()); |
127 } | 124 } |
128 | 125 |
129 ExtensionPopupController* ExtensionActionPlatformDelegateCocoa::GetPopup() | 126 ExtensionPopupController* ExtensionActionPlatformDelegateCocoa::GetPopup() |
130 const { | 127 const { |
(...skipping 24 matching lines...) Expand all Loading... |
155 controller_->IsEnabled( | 152 controller_->IsEnabled( |
156 controller_->view_delegate()->GetCurrentWebContents())) { | 153 controller_->view_delegate()->GetCurrentWebContents())) { |
157 controller_->ExecuteAction(true); | 154 controller_->ExecuteAction(true); |
158 } | 155 } |
159 break; | 156 break; |
160 } | 157 } |
161 default: | 158 default: |
162 NOTREACHED() << L"Unexpected notification"; | 159 NOTREACHED() << L"Unexpected notification"; |
163 } | 160 } |
164 } | 161 } |
OLD | NEW |