Chromium Code Reviews| Index: chrome/browser/ui/cocoa/location_bar/plus_decoration.mm |
| diff --git a/chrome/browser/ui/cocoa/location_bar/plus_decoration.mm b/chrome/browser/ui/cocoa/location_bar/plus_decoration.mm |
| index 084e65d10248ba41a7ecec156058cc98583caa5a..8f5a0adff0b592a05ea921c7d87020b8d2bb5d9d 100644 |
| --- a/chrome/browser/ui/cocoa/location_bar/plus_decoration.mm |
| +++ b/chrome/browser/ui/cocoa/location_bar/plus_decoration.mm |
| @@ -4,12 +4,10 @@ |
| #import "chrome/browser/ui/cocoa/location_bar/plus_decoration.h" |
| -#include "chrome/browser/ui/browser.h" |
| -#include "chrome/browser/ui/browser_commands.h" |
| -#import "chrome/browser/ui/cocoa/omnibox/omnibox_view_mac.h" |
| +#import "chrome/browser/ui/cocoa/location_bar/action_box_menu_bubble_controller.h" |
| #import "chrome/browser/ui/cocoa/location_bar/autocomplete_text_field.h" |
| #import "chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.h" |
| -#import "chrome/browser/ui/cocoa/menu_controller.h" |
| +#import "chrome/browser/ui/cocoa/omnibox/omnibox_view_mac.h" |
| #include "grit/generated_resources.h" |
| #include "grit/theme_resources.h" |
| #include "ui/base/l10n/l10n_util_mac.h" |
| @@ -36,7 +34,9 @@ PlusDecoration::~PlusDecoration() { |
| NSPoint PlusDecoration::GetActionBoxAnchorPoint() { |
| AutocompleteTextField* field = owner_->GetAutocompleteTextField(); |
| NSRect bounds = [field bounds]; |
| - return NSMakePoint(NSMaxX(bounds), NSMaxY(bounds)); |
| + NSPoint anchor = NSMakePoint(NSMaxX(bounds) - 1, NSMaxY(bounds) - 2); |
|
Scott Hess - ex-Googler
2012/10/12 23:02:47
Provide some explanation of the magic constants.
beaudoin
2012/10/13 00:20:55
Done.
|
| + anchor = [field convertPoint:anchor toView:nil]; |
| + return [[field window] convertBaseToScreen:anchor]; |
|
Scott Hess - ex-Googler
2012/10/12 23:02:47
-[ChromeToMobileBubbleController showWindow:] also
beaudoin
2012/10/13 00:20:55
The alignment concerns are slighty different here
|
| } |
| void PlusDecoration::ResetIcon() { |
| @@ -65,26 +65,14 @@ NSString* PlusDecoration::GetToolTip() { |
| void PlusDecoration::ShowMenu(scoped_ptr<ActionBoxMenuModel> menu_model) { |
|
Scott Hess - ex-Googler
2012/10/12 23:02:47
This will close the existing menu and open a new o
beaudoin
2012/10/13 00:20:55
This is exactly what happened. I have created crbu
|
| // Controller for the menu attached to the plus decoration. |
| - scoped_nsobject<MenuController> menu_controller( |
| - [[MenuController alloc] initWithModel:menu_model.get() |
| - useWithPopUpButtonCell:YES]); |
| - |
| - NSMenu* menu = [menu_controller menu]; |
| - |
| - // Align the menu popup to that its top-right corner matches the bottom-right |
| - // corner of the omnibox. |
| - AutocompleteTextField* field = owner_->GetAutocompleteTextField(); |
| - NSPoint point = GetActionBoxAnchorPoint(); |
| - NSRect popUpFrame = NSMakeRect(point.x - menu.size.width, |
| - kAnchorPointYOffset, menu.size.width, kAnchorPointFrameHeight); |
| - scoped_nsobject<NSPopUpButtonCell> pop_up_cell( |
| - [[NSPopUpButtonCell alloc] initTextCell:@"" pullsDown:YES]); |
| - DCHECK(pop_up_cell.get()); |
| - |
| - [pop_up_cell setMenu:menu]; |
| - [pop_up_cell selectItem:nil]; |
| - [pop_up_cell attachPopUpWithFrame:popUpFrame inView:field]; |
| - [pop_up_cell performClickWithFrame:popUpFrame inView:field]; |
| + // |menu_controller_| will automatically release itself on close. |
| + ActionBoxMenuBubbleController* menu_controller = |
| + [[ActionBoxMenuBubbleController alloc] |
| + initWithBrowser:browser_ |
| + usingModel:menu_model.PassAs<ui::MenuModel>() |
| + anchoredAt:GetActionBoxAnchorPoint()]; |
| + |
| + [menu_controller showWindow:nil]; |
| } |
| void PlusDecoration::SetIcons(int normal_id, int hover_id, int pressed_id) { |