OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/cocoa/extensions/extension_action_context_menu.h" | 5 #import "chrome/browser/cocoa/extensions/extension_action_context_menu.h" |
6 | 6 |
7 #include "app/l10n_util_mac.h" | 7 #include "app/l10n_util_mac.h" |
8 #include "base/sys_string_conversions.h" | 8 #include "base/sys_string_conversions.h" |
9 #include "base/task.h" | 9 #include "base/task.h" |
10 #include "chrome/browser/browser_list.h" | 10 #include "chrome/browser/browser_list.h" |
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
234 NEW_FOREGROUND_TAB, PageTransition::LINK); | 234 NEW_FOREGROUND_TAB, PageTransition::LINK); |
235 break; | 235 break; |
236 } | 236 } |
237 case kExtensionContextInspect: { | 237 case kExtensionContextInspect: { |
238 BrowserWindowCocoa* window = | 238 BrowserWindowCocoa* window = |
239 static_cast<BrowserWindowCocoa*>(browser->window()); | 239 static_cast<BrowserWindowCocoa*>(browser->window()); |
240 ToolbarController* toolbarController = | 240 ToolbarController* toolbarController = |
241 [window->cocoa_controller() toolbarController]; | 241 [window->cocoa_controller() toolbarController]; |
242 LocationBarViewMac* locationBarView = | 242 LocationBarViewMac* locationBarView = |
243 [toolbarController locationBarBridge]; | 243 [toolbarController locationBarBridge]; |
244 NSPoint popupPoint = locationBarView->GetPageActionBubblePoint(action_); | |
245 | 244 |
246 // If there was no matching page action, it was a browser action. | 245 NSPoint popupPoint = NSZeroPoint; |
247 if (NSEqualPoints(popupPoint, NSZeroPoint)) { | 246 if (extension_->page_action() == action_) { |
| 247 popupPoint = locationBarView->GetPageActionBubblePoint(action_); |
| 248 |
| 249 } else if (extension_->browser_action() == action_) { |
248 BrowserActionsController* controller = | 250 BrowserActionsController* controller = |
249 [toolbarController browserActionsController]; | 251 [toolbarController browserActionsController]; |
250 popupPoint = [controller popupPointForBrowserAction:extension_]; | 252 popupPoint = [controller popupPointForBrowserAction:extension_]; |
| 253 |
| 254 } else { |
| 255 NOTREACHED() << "action_ is not a page action or browser action?"; |
251 } | 256 } |
252 | 257 |
253 int tabId = CurrentTabId(); | 258 int tabId = CurrentTabId(); |
254 GURL url = action_->GetPopupUrl(tabId); | 259 GURL url = action_->GetPopupUrl(tabId); |
255 DCHECK(url.is_valid()); | 260 DCHECK(url.is_valid()); |
256 [ExtensionPopupController showURL:url | 261 [ExtensionPopupController showURL:url |
257 inBrowser:BrowserList::GetLastActive() | 262 inBrowser:BrowserList::GetLastActive() |
258 anchoredAt:popupPoint | 263 anchoredAt:popupPoint |
259 arrowLocation:info_bubble::kTopRight | 264 arrowLocation:info_bubble::kTopRight |
260 devMode:YES]; | 265 devMode:YES]; |
261 break; | 266 break; |
262 } | 267 } |
263 default: | 268 default: |
264 NOTREACHED(); | 269 NOTREACHED(); |
265 break; | 270 break; |
266 } | 271 } |
267 } | 272 } |
268 | 273 |
269 - (BOOL)validateMenuItem:(NSMenuItem*)menuItem { | 274 - (BOOL)validateMenuItem:(NSMenuItem*)menuItem { |
270 if([menuItem isEqualTo:inspectorItem_.get()]) { | 275 if([menuItem isEqualTo:inspectorItem_.get()]) { |
271 return action_ && action_->HasPopup(CurrentTabId()); | 276 return action_ && action_->HasPopup(CurrentTabId()); |
272 } | 277 } |
273 return YES; | 278 return YES; |
274 } | 279 } |
275 | 280 |
276 @end | 281 @end |
OLD | NEW |