| 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 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 236 } | 236 } |
| 237 case kExtensionContextInspect: { | 237 case kExtensionContextInspect: { |
| 238 NSPoint popupPoint; | 238 NSPoint popupPoint; |
| 239 BrowserWindowCocoa* window = | 239 BrowserWindowCocoa* window = |
| 240 static_cast<BrowserWindowCocoa*>(browser->window()); | 240 static_cast<BrowserWindowCocoa*>(browser->window()); |
| 241 LocationBar* locationBar = window->GetLocationBar(); | 241 LocationBar* locationBar = window->GetLocationBar(); |
| 242 AutocompleteTextField* field = | 242 AutocompleteTextField* field = |
| 243 (AutocompleteTextField*)locationBar->location_entry()-> | 243 (AutocompleteTextField*)locationBar->location_entry()-> |
| 244 GetNativeView(); | 244 GetNativeView(); |
| 245 AutocompleteTextFieldCell* fieldCell = [field autocompleteTextFieldCell]; | 245 AutocompleteTextFieldCell* fieldCell = [field autocompleteTextFieldCell]; |
| 246 DCHECK(action_); |
| 246 NSRect popupRect = | 247 NSRect popupRect = |
| 247 [fieldCell pageActionFrameForExtensionAction:action_ | 248 [fieldCell pageActionFrameForExtensionAction:action_ |
| 248 inFrame:[field bounds]]; | 249 inFrame:[field bounds]]; |
| 249 if (!NSEqualRects(popupRect, NSZeroRect)) { | 250 if (!NSEqualRects(popupRect, NSZeroRect)) { |
| 250 popupRect = [[field superview] convertRect:popupRect toView:nil]; | 251 popupRect = [[field superview] convertRect:popupRect toView:nil]; |
| 251 popupPoint = popupRect.origin; | 252 popupPoint = popupRect.origin; |
| 252 NSRect fieldFrame = [field bounds]; | 253 NSRect fieldFrame = [field bounds]; |
| 253 fieldFrame = [field convertRect:fieldFrame toView:nil]; | 254 fieldFrame = [field convertRect:fieldFrame toView:nil]; |
| 254 popupPoint.x += fieldFrame.origin.x + popupRect.size.width / 2; | 255 popupPoint.x += fieldFrame.origin.x + popupRect.size.width / 2; |
| 255 } else { | 256 } else { |
| (...skipping 13 matching lines...) Expand all Loading... |
| 269 devMode:YES]; | 270 devMode:YES]; |
| 270 break; | 271 break; |
| 271 } | 272 } |
| 272 default: | 273 default: |
| 273 NOTREACHED(); | 274 NOTREACHED(); |
| 274 break; | 275 break; |
| 275 } | 276 } |
| 276 } | 277 } |
| 277 | 278 |
| 278 - (BOOL)validateMenuItem:(NSMenuItem*)menuItem { | 279 - (BOOL)validateMenuItem:(NSMenuItem*)menuItem { |
| 279 if([menuItem isEqualTo: inspectorItem_.get()]) { | 280 if([menuItem isEqualTo:inspectorItem_.get()]) { |
| 280 return (action_->HasPopup(CurrentTabId())); | 281 return action_ && action_->HasPopup(CurrentTabId()); |
| 281 } | 282 } |
| 282 return YES; | 283 return YES; |
| 283 } | 284 } |
| 284 | 285 |
| 285 @end | 286 @end |
| OLD | NEW |