summaryrefslogtreecommitdiffstats
path: root/chrome/browser
diff options
context:
space:
mode:
authorandybons@chromium.org <andybons@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-18 21:50:01 +0000
committerandybons@chromium.org <andybons@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-18 21:50:01 +0000
commitfc9510c4bc745af79827216ca015ef3dd1607f62 (patch)
tree57ae230852bb52dcd76a3aeefe96db86aa5fe690 /chrome/browser
parent6d9e355a4421e37895a8492ab300cf918a8e1334 (diff)
downloadchromium_src-fc9510c4bc745af79827216ca015ef3dd1607f62.zip
chromium_src-fc9510c4bc745af79827216ca015ef3dd1607f62.tar.gz
chromium_src-fc9510c4bc745af79827216ca015ef3dd1607f62.tar.bz2
[Mac] Implement a basic overflow menu for hidden Browser Action buttons.
Known issues: o The ordering of the Browser Actions is not consistent within the menu. o Icons for the actions within the menu are not implemented yet. o It is a standard NSMenu, so drag and drop will not work and right click does not work for now. TEST=none BUG=32101 Review URL: http://codereview.chromium.org/1083001 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@42000 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
-rw-r--r--chrome/browser/cocoa/extension_installed_bubble_controller.mm23
-rw-r--r--chrome/browser/cocoa/extensions/browser_actions_container_view.h23
-rw-r--r--chrome/browser/cocoa/extensions/browser_actions_container_view.mm93
-rw-r--r--chrome/browser/cocoa/extensions/browser_actions_controller.h29
-rw-r--r--chrome/browser/cocoa/extensions/browser_actions_controller.mm175
-rw-r--r--chrome/browser/cocoa/extensions/browser_actions_overflow_menu.h16
-rw-r--r--chrome/browser/cocoa/extensions/browser_actions_overflow_menu.mm9
-rw-r--r--chrome/browser/cocoa/extensions/extension_action_context_menu.h1
-rw-r--r--chrome/browser/cocoa/extensions/extension_action_context_menu.mm2
-rw-r--r--chrome/browser/cocoa/extensions/extension_popup_controller.h2
-rw-r--r--chrome/browser/cocoa/extensions/extension_popup_controller.mm2
-rw-r--r--chrome/browser/cocoa/location_bar_view_mac.mm6
12 files changed, 194 insertions, 187 deletions
diff --git a/chrome/browser/cocoa/extension_installed_bubble_controller.mm b/chrome/browser/cocoa/extension_installed_bubble_controller.mm
index f65b455..fac8384 100644
--- a/chrome/browser/cocoa/extension_installed_bubble_controller.mm
+++ b/chrome/browser/cocoa/extension_installed_bubble_controller.mm
@@ -166,25 +166,10 @@ class ExtensionLoadedNotificationObserver : public NotificationObserver {
switch(type_) {
case extension_installed_bubble::kBrowserAction: {
- // Find the center of the bottom of the browser action icon.
- NSView* button = [[[window->cocoa_controller() toolbarController]
- browserActionsController] browserActionViewForExtension:extension_];
- DCHECK(button);
- NSRect boundsRect = [[button superview] convertRect:[button frame]
- toView:nil];
- CGFloat xPos = NSMidX(boundsRect);
- // If the button is hidden, display the button at the edge of the Browser
- // Actions container.
- // TODO(andybons): Make it point to the chevron once it's implemented.
- if ([button alphaValue] == 0.0) {
- NSView* superview = [button superview];
- NSRect superviewRect =
- [[superview superview] convertRect:[superview frame]
- toView:nil];
- xPos = NSMaxX(superviewRect);
- }
-
- arrowPoint = NSMakePoint(xPos, NSMinY(boundsRect));
+ BrowserActionsController* controller =
+ [[window->cocoa_controller() toolbarController]
+ browserActionsController];
+ arrowPoint = [controller popupPointForBrowserAction:extension_];
break;
}
case extension_installed_bubble::kPageAction: {
diff --git a/chrome/browser/cocoa/extensions/browser_actions_container_view.h b/chrome/browser/cocoa/extensions/browser_actions_container_view.h
index 73cee1b..e0a7f9d 100644
--- a/chrome/browser/cocoa/extensions/browser_actions_container_view.h
+++ b/chrome/browser/cocoa/extensions/browser_actions_container_view.h
@@ -7,11 +7,6 @@
#import <Cocoa/Cocoa.h>
-#import "base/scoped_nsobject.h"
-
-@class MenuButton;
-@class BrowserActionButton;
-
// Sent when a user-initiated drag to resize the container is initiated.
extern const NSString* kBrowserActionGrippyDragStartedNotification;
@@ -21,20 +16,10 @@ extern const NSString* kBrowserActionGrippyDraggingNotification;
// Sent when a user-initiated drag to resize the container has finished.
extern const NSString* kBrowserActionGrippyDragFinishedNotification;
-// The width of the chevron button in pixels.
-extern const CGFloat kChevronWidth;
-
-
// The view that encompasses the Browser Action buttons in the toolbar and
// provides mechanisms for resizing.
@interface BrowserActionsContainerView : NSView {
@private
- // The currently running animation.
- scoped_nsobject<NSAnimation> animation_;
-
- // The chevron button used when Browser Actions are hidden.
- scoped_nsobject<MenuButton> chevronMenuButton_;
-
// The frame encompasing the grippy used for resizing the container.
NSRect grippyRect_;
@@ -76,14 +61,6 @@ extern const CGFloat kChevronWidth;
// placement of surrounding elements.
- (CGFloat)resizeDeltaX;
-// Returns whether the chevron button is currently hidden or in the process of
-// being hidden (fading out). Will return NO if it is not hidden or is in the
-// process of fading in.
-- (BOOL)chevronIsHidden;
-
-// Sets whether to show the chevron button.
-- (void)setChevronHidden:(BOOL)hidden animate:(BOOL)animate;
-
@property(nonatomic) BOOL canDragLeft;
@property(nonatomic) BOOL canDragRight;
@property(nonatomic) BOOL grippyPinned;
diff --git a/chrome/browser/cocoa/extensions/browser_actions_container_view.mm b/chrome/browser/cocoa/extensions/browser_actions_container_view.mm
index 82490a5..ccb5148 100644
--- a/chrome/browser/cocoa/extensions/browser_actions_container_view.mm
+++ b/chrome/browser/cocoa/extensions/browser_actions_container_view.mm
@@ -2,16 +2,12 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#import "chrome/browser/cocoa/extensions/browser_actions_container_view.h"
+
#include <algorithm>
-#include "app/resource_bundle.h"
#include "base/logging.h"
#import "base/scoped_nsobject.h"
-#import "chrome/browser/cocoa/extensions/browser_action_button.h"
-#import "chrome/browser/cocoa/extensions/browser_actions_container_view.h"
-#import "chrome/browser/cocoa/menu_button.h"
-#include "grit/theme_resources.h"
-#import "third_party/GTM/AppKit/GTMNSAnimation+Duration.h"
extern const NSString* kBrowserActionGrippyDragStartedNotification =
@"BrowserActionGrippyDragStartedNotification";
@@ -19,12 +15,9 @@ extern const NSString* kBrowserActionGrippyDraggingNotification =
@"BrowserActionGrippyDraggingNotification";
extern const NSString* kBrowserActionGrippyDragFinishedNotification =
@"BrowserActionGrippyDragFinishedNotification";
-extern const CGFloat kChevronWidth = 14.0;
namespace {
const CGFloat kAnimationDuration = 0.2;
-const CGFloat kChevronHeight = 28.0;
-const CGFloat kChevronRightPadding = 5.0;
const CGFloat kGrippyLowerPadding = 4.0;
const CGFloat kGrippyUpperPadding = 8.0;
const CGFloat kGrippyWidth = 10.0;
@@ -39,7 +32,6 @@ const CGFloat kUpperPadding = 9.0;
@interface BrowserActionsContainerView(Private)
- (NSCursor*)appropriateCursorForGrippy;
- (void)drawGrippy;
-- (void)updateChevronPosition;
@end
@implementation BrowserActionsContainerView
@@ -53,9 +45,6 @@ const CGFloat kUpperPadding = 9.0;
- (id)initWithFrame:(NSRect)frameRect {
if ((self = [super initWithFrame:frameRect])) {
grippyRect_ = NSMakeRect(0.0, 0.0, kGrippyWidth, NSHeight([self bounds]));
- animation_.reset([[NSViewAnimation alloc] init]);
- [animation_ setDuration:kAnimationDuration];
- [animation_ setAnimationBlockingMode:NSAnimationNonblocking];
}
return self;
}
@@ -82,11 +71,6 @@ const CGFloat kUpperPadding = 9.0;
[self drawGrippy];
}
-- (void)setFrame:(NSRect)frameRect {
- [super setFrame:frameRect];
- [self updateChevronPosition];
-}
-
// Draws the area that the user can use to resize the container. Currently, two
// vertical "grip" bars.
- (void)drawGrippy {
@@ -160,8 +144,6 @@ const CGFloat kUpperPadding = 9.0;
if (!NSMouseInRect(initialDragPoint_, grippyRect_, [self isFlipped]))
return;
- [self setChevronHidden:YES animate:YES];
-
lastXPos_ = [self frame].origin.x;
userIsResizing_ = YES;
[[NSNotificationCenter defaultCenter]
@@ -229,75 +211,4 @@ const CGFloat kUpperPadding = 9.0;
return [self frame].origin.x - lastXPos_;
}
-- (BOOL)chevronIsHidden {
- if (!chevronMenuButton_.get())
- return YES;
-
- if (![animation_ isAnimating])
- return [chevronMenuButton_ isHidden];
-
- DCHECK([[animation_ viewAnimations] count] > 0);
-
- // The chevron is animating in or out. Determine which one and have the return
- // value reflect where the animation is headed.
- NSString* effect = [[[animation_ viewAnimations] objectAtIndex:0]
- valueForKey:NSViewAnimationEffectKey];
- if (effect == NSViewAnimationFadeInEffect) {
- return NO;
- } else if (effect == NSViewAnimationFadeOutEffect) {
- return YES;
- }
-
- NOTREACHED();
- return YES;
-}
-
-- (void)setChevronHidden:(BOOL)hidden animate:(BOOL)animate {
- if (hidden == [self chevronIsHidden])
- return;
-
- if (!chevronMenuButton_.get()) {
- chevronMenuButton_.reset([[MenuButton alloc] init]);
- [chevronMenuButton_ setBordered:NO];
- ResourceBundle& rb = ResourceBundle::GetSharedInstance();
- [chevronMenuButton_ setImage:rb.GetNSImageNamed(IDR_BOOKMARK_BAR_CHEVRONS)];
- [self addSubview:chevronMenuButton_];
- }
-
- [self updateChevronPosition];
- // Stop any running animation.
- [animation_ stopAnimation];
-
- if (!animate) {
- [chevronMenuButton_ setHidden:hidden];
- return;
- }
-
- NSDictionary* animationDictionary;
- if (hidden) {
- animationDictionary = [NSDictionary dictionaryWithObjectsAndKeys:
- chevronMenuButton_.get(), NSViewAnimationTargetKey,
- NSViewAnimationFadeOutEffect, NSViewAnimationEffectKey,
- nil];
- } else {
- [chevronMenuButton_ setHidden:NO];
- animationDictionary = [NSDictionary dictionaryWithObjectsAndKeys:
- chevronMenuButton_.get(), NSViewAnimationTargetKey,
- NSViewAnimationFadeInEffect, NSViewAnimationEffectKey,
- nil];
- }
- [animation_ setViewAnimations:
- [NSArray arrayWithObjects:animationDictionary, nil]];
- [animation_ startAnimation];
-}
-
-- (void)updateChevronPosition {
- CGFloat xPos = NSWidth([self frame]) - kChevronWidth - kChevronRightPadding;
- NSRect buttonFrame = NSMakeRect(xPos,
- kLowerPadding,
- kChevronWidth,
- kChevronHeight);
- [chevronMenuButton_ setFrame:buttonFrame];
-}
-
@end
diff --git a/chrome/browser/cocoa/extensions/browser_actions_controller.h b/chrome/browser/cocoa/extensions/browser_actions_controller.h
index cd39283..758b666 100644
--- a/chrome/browser/cocoa/extensions/browser_actions_controller.h
+++ b/chrome/browser/cocoa/extensions/browser_actions_controller.h
@@ -17,6 +17,7 @@ class Extension;
@class ExtensionPopupController;
class ExtensionToolbarModel;
class ExtensionsServiceObserverBridge;
+@class MenuButton;
class PrefService;
class Profile;
@@ -52,6 +53,15 @@ extern const NSString* kBrowserActionVisibilityChangedNotification;
// Array of hidden buttons in the correct order in which the user specified.
scoped_nsobject<NSMutableArray> hiddenButtons_;
+
+ // The currently running animation.
+ scoped_nsobject<NSAnimation> animation_;
+
+ // The chevron button used when Browser Actions are hidden.
+ scoped_nsobject<MenuButton> chevronMenuButton_;
+
+ // The Browser Actions overflow menu.
+ scoped_nsobject<NSMenu> overflowMenu_;
}
@property(readonly, nonatomic) BrowserActionsContainerView* containerView;
@@ -72,13 +82,13 @@ extern const NSString* kBrowserActionVisibilityChangedNotification;
// container.
- (NSUInteger)visibleButtonCount;
+// Returns a pointer to the chevron menu button.
+- (MenuButton*)chevronMenuButton;
+
// Resizes the container to fit all the visible buttons and other elements
// (grippy and overflow button).
- (void)resizeContainerWithAnimation:(BOOL)animate;
-// Executes the action designated by the extension.
-- (void)browserActionClicked:(BrowserActionButton*)sender;
-
// Returns the NSView for the action button associated with an extension.
- (NSView*)browserActionViewForExtension:(Extension*)extension;
@@ -87,6 +97,19 @@ extern const NSString* kBrowserActionVisibilityChangedNotification;
// set.
- (CGFloat)savedWidth;
+// Returns where the popup arrow should point to for a given Browser Action. If
+// it is passed an extension that is not a Browser Action, then it will return
+// NSZeroPoint.
+- (NSPoint)popupPointForBrowserAction:(Extension*)extension;
+
+// Returns whether the chevron button is currently hidden or in the process of
+// being hidden (fading out). Will return NO if it is not hidden or is in the
+// process of fading in.
+- (BOOL)chevronIsHidden;
+
+// Sets whether to show the chevron button.
+- (void)setChevronHidden:(BOOL)hidden animate:(BOOL)animate;
+
// Registers the user preferences used by this class.
+ (void)registerUserPrefs:(PrefService*)prefs;
diff --git a/chrome/browser/cocoa/extensions/browser_actions_controller.mm b/chrome/browser/cocoa/extensions/browser_actions_controller.mm
index 491c516..bd41e8b 100644
--- a/chrome/browser/cocoa/extensions/browser_actions_controller.mm
+++ b/chrome/browser/cocoa/extensions/browser_actions_controller.mm
@@ -6,12 +6,14 @@
#include <string>
+#include "app/resource_bundle.h"
#include "base/sys_string_conversions.h"
#include "chrome/browser/browser.h"
#include "chrome/browser/pref_service.h"
#import "chrome/browser/cocoa/extensions/browser_action_button.h"
#import "chrome/browser/cocoa/extensions/browser_actions_container_view.h"
#import "chrome/browser/cocoa/extensions/extension_popup_controller.h"
+#import "chrome/browser/cocoa/menu_button.h"
#include "chrome/browser/extensions/extension_browser_event_router.h"
#include "chrome/browser/extensions/extension_toolbar_model.h"
#include "chrome/browser/extensions/extensions_service.h"
@@ -20,6 +22,8 @@
#include "chrome/common/notification_observer.h"
#include "chrome/common/notification_registrar.h"
#include "chrome/common/pref_names.h"
+#include "grit/theme_resources.h"
+#import "third_party/GTM/AppKit/GTMNSAnimation+Duration.h"
extern const CGFloat kBrowserActionButtonPadding = 3;
@@ -28,9 +32,14 @@ extern const NSString* kBrowserActionVisibilityChangedNotification =
namespace {
const CGFloat kAnimationDuration = 0.2;
+const CGFloat kButtonOpacityLeadPadding = 5.0;
+const CGFloat kChevronHeight = 28.0;
+const CGFloat kChevronLowerPadding = 5.0;
+const CGFloat kChevronRightPadding = 5.0;
+const CGFloat kChevronWidth = 14.0;
const CGFloat kContainerPadding = 2.0;
const CGFloat kGrippyXOffset = 8.0;
-const CGFloat kButtonOpacityLeadPadding = 5.0;
+
} // namespace
@interface BrowserActionsController(Private)
@@ -46,9 +55,13 @@ const CGFloat kButtonOpacityLeadPadding = 5.0;
- (void)containerDragStart;
- (void)containerDragging;
- (void)containerDragFinished;
+- (void)browserActionClicked:(BrowserActionButton*)button;
- (int)currentTabId;
- (bool)shouldDisplayBrowserAction:(Extension*)extension;
- (void)showChevronIfNecessaryWithAnimation:(BOOL)animation;
+- (void)updateChevronPosition;
+- (void)updateOverflowMenu;
+- (void)chevronItemSelected:(BrowserActionButton*)button;
@end
// A helper class to proxy extension notifications to the view controller's
@@ -150,6 +163,11 @@ class ExtensionsServiceObserverBridge : public NotificationObserver,
name:kBrowserActionGrippyDragFinishedNotification
object:containerView_];
+ animation_.reset([[NSViewAnimation alloc] init]);
+ [animation_ gtm_setDuration:kAnimationDuration
+ eventMask:NSLeftMouseDownMask];
+ [animation_ setAnimationBlockingMode:NSAnimationNonblocking];
+
hiddenButtons_.reset([[NSMutableArray alloc] init]);
buttons_.reset([[NSMutableDictionary alloc] init]);
[self createButtons];
@@ -230,6 +248,7 @@ class ExtensionsServiceObserverBridge : public NotificationObserver,
} else {
[hiddenButtons_ addObject:newButton];
[newButton setAlphaValue:0.0];
+ [self updateOverflowMenu];
}
[self repositionActionButtons];
@@ -254,6 +273,7 @@ class ExtensionsServiceObserverBridge : public NotificationObserver,
// It may or may not be hidden, but it won't matter to NSMutableArray either
// way.
[hiddenButtons_ removeObject:button];
+ [self updateOverflowMenu];
[buttons_ removeObjectForKey:buttonKey];
if ([buttons_ count] == 0) {
@@ -352,9 +372,11 @@ class ExtensionsServiceObserverBridge : public NotificationObserver,
- (void)containerFrameChanged {
[self updateButtonOpacityAndDragAbilities];
+ [self updateChevronPosition];
}
- (void)containerDragStart {
+ [self setChevronHidden:YES animate:YES];
while([hiddenButtons_ count] > 0) {
[containerView_ addSubview:[hiddenButtons_ objectAtIndex:0]];
[hiddenButtons_ removeObjectAtIndex:0];
@@ -385,7 +407,7 @@ class ExtensionsServiceObserverBridge : public NotificationObserver,
[hiddenButtons_ addObject:button];
}
}
-
+ [self updateOverflowMenu];
[self resizeContainerWithAnimation:NO];
}
@@ -397,28 +419,20 @@ class ExtensionsServiceObserverBridge : public NotificationObserver,
return [buttons_ count] - [hiddenButtons_ count];
}
-- (void)browserActionClicked:(BrowserActionButton*)sender {
+- (MenuButton*)chevronMenuButton {
+ return chevronMenuButton_.get();
+}
+
+- (void)browserActionClicked:(BrowserActionButton*)button {
int tabId = [self currentTabId];
if (tabId < 0) {
NOTREACHED() << "No current tab.";
return;
}
- ExtensionAction* action = [sender extension]->browser_action();
+ ExtensionAction* action = [button extension]->browser_action();
if (action->HasPopup(tabId)) {
- NSString* extensionId = base::SysUTF8ToNSString([sender extension]->id());
- // If the extension ID is not valid UTF-8, then the NSString will be nil
- // and an exception will be thrown when calling objectForKey below, hosing
- // the browser. Check it.
- DCHECK(extensionId);
- if (!extensionId)
- return;
- BrowserActionButton* actionButton = [buttons_ objectForKey:extensionId];
- NSPoint arrowPoint = [actionButton frame].origin;
- // Adjust the anchor point to be at the center of the browser action button.
- arrowPoint.x += kBrowserActionWidth / 2;
- arrowPoint = [[actionButton superview] convertPoint:arrowPoint toView:nil];
- arrowPoint = [[actionButton window] convertBaseToScreen:arrowPoint];
+ NSPoint arrowPoint = [self popupPointForBrowserAction:[button extension]];
[ExtensionPopupController showURL:action->GetPopupUrl(tabId)
inBrowser:browser_
anchoredAt:arrowPoint
@@ -474,8 +488,131 @@ class ExtensionsServiceObserverBridge : public NotificationObserver,
}
- (void)showChevronIfNecessaryWithAnimation:(BOOL)animation {
- BOOL hideChevron = [self buttonCount] == [self visibleButtonCount];
- [containerView_ setChevronHidden:hideChevron animate:animation];
+ [self setChevronHidden:([self buttonCount] == [self visibleButtonCount])
+ animate:animation];
+}
+
+- (NSPoint)popupPointForBrowserAction:(Extension*)extension {
+ if (!extension->browser_action())
+ return NSZeroPoint;
+
+ NSString* extensionId = base::SysUTF8ToNSString(extension->id());
+ DCHECK(extensionId);
+ if (!extensionId)
+ return NSZeroPoint;
+
+ BrowserActionButton* button = [buttons_ objectForKey:extensionId];
+ NSView* view = button;
+ BOOL isHidden = [hiddenButtons_ containsObject:button];
+ if (isHidden)
+ view = chevronMenuButton_.get();
+
+ NSPoint arrowPoint = [view frame].origin;
+ // Adjust the anchor point to be at the center of the browser action button
+ // or chevron.
+ arrowPoint.x += NSWidth([view frame]) / 2;
+ // Move the arrow up a bit in the case that it's pointing to the chevron.
+ if (isHidden)
+ arrowPoint.y += NSHeight([view frame]) / 4;
+
+ return [[view superview] convertPoint:arrowPoint toView:nil];
+}
+
+- (BOOL)chevronIsHidden {
+ if (!chevronMenuButton_.get())
+ return YES;
+
+ if (![animation_ isAnimating])
+ return [chevronMenuButton_ isHidden];
+
+ DCHECK([[animation_ viewAnimations] count] > 0);
+
+ // The chevron is animating in or out. Determine which one and have the return
+ // value reflect where the animation is headed.
+ NSString* effect = [[[animation_ viewAnimations] objectAtIndex:0]
+ valueForKey:NSViewAnimationEffectKey];
+ if (effect == NSViewAnimationFadeInEffect) {
+ return NO;
+ } else if (effect == NSViewAnimationFadeOutEffect) {
+ return YES;
+ }
+
+ NOTREACHED();
+ return YES;
+}
+
+- (void)setChevronHidden:(BOOL)hidden animate:(BOOL)animate {
+ if (hidden == [self chevronIsHidden])
+ return;
+
+ if (!chevronMenuButton_.get()) {
+ chevronMenuButton_.reset([[MenuButton alloc] init]);
+ [chevronMenuButton_ setBordered:NO];
+ ResourceBundle& rb = ResourceBundle::GetSharedInstance();
+ [chevronMenuButton_ setImage:rb.GetNSImageNamed(IDR_BOOKMARK_BAR_CHEVRONS)];
+ [containerView_ addSubview:chevronMenuButton_];
+ }
+
+ if (!hidden)
+ [self updateOverflowMenu];
+
+ [self updateChevronPosition];
+
+ // Stop any running animation.
+ [animation_ stopAnimation];
+
+ if (!animate) {
+ [chevronMenuButton_ setHidden:hidden];
+ return;
+ }
+
+ NSDictionary* animationDictionary;
+ if (hidden) {
+ animationDictionary = [NSDictionary dictionaryWithObjectsAndKeys:
+ chevronMenuButton_.get(), NSViewAnimationTargetKey,
+ NSViewAnimationFadeOutEffect, NSViewAnimationEffectKey,
+ nil];
+ } else {
+ [chevronMenuButton_ setHidden:NO];
+ animationDictionary = [NSDictionary dictionaryWithObjectsAndKeys:
+ chevronMenuButton_.get(), NSViewAnimationTargetKey,
+ NSViewAnimationFadeInEffect, NSViewAnimationEffectKey,
+ nil];
+ }
+ [animation_ setViewAnimations:
+ [NSArray arrayWithObjects:animationDictionary, nil]];
+ [animation_ startAnimation];
+}
+
+- (void)updateChevronPosition {
+ CGFloat xPos = NSWidth([containerView_ frame]) - kChevronWidth -
+ kChevronRightPadding;
+ NSRect buttonFrame = NSMakeRect(xPos,
+ kChevronLowerPadding,
+ kChevronWidth,
+ kChevronHeight);
+ [chevronMenuButton_ setFrame:buttonFrame];
+}
+
+- (void)updateOverflowMenu {
+ overflowMenu_.reset([[NSMenu alloc] initWithTitle:@""]);
+ // See menu_button.h for documentation on why this is needed.
+ [overflowMenu_ addItemWithTitle:@"" action:nil keyEquivalent:@""];
+
+ for (BrowserActionButton* button in hiddenButtons_.get()) {
+ NSString* name = base::SysUTF8ToNSString([button extension]->name());
+ NSMenuItem* item =
+ [overflowMenu_ addItemWithTitle:name
+ action:@selector(chevronItemSelected:)
+ keyEquivalent:@""];
+ [item setRepresentedObject:button];
+ [item setTarget:self];
+ }
+ [chevronMenuButton_ setAttachedMenu:overflowMenu_];
+}
+
+- (void)chevronItemSelected:(id)menuItem {
+ [self browserActionClicked:[menuItem representedObject]];
}
+ (void)registerUserPrefs:(PrefService*)prefs {
diff --git a/chrome/browser/cocoa/extensions/browser_actions_overflow_menu.h b/chrome/browser/cocoa/extensions/browser_actions_overflow_menu.h
deleted file mode 100644
index aee3b42..0000000
--- a/chrome/browser/cocoa/extensions/browser_actions_overflow_menu.h
+++ /dev/null
@@ -1,16 +0,0 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef CHROME_BROWSER_COCOA_EXTENSIONS_BROWSER_ACTIONS_OVERFLOW_MENU_
-#define CHROME_BROWSER_COCOA_EXTENSIONS_BROWSER_ACTIONS_OVERFLOW_MENU_
-
-#import <Cocoa/Cocoa.h>
-
-@interface BrowserActionsOverflowMenu : NSMenu {
-
-}
-
-@end
-
-#endif // CHROME_BROWSER_COCOA_EXTENSIONS_BROWSER_ACTIONS_OVERFLOW_MENU_
diff --git a/chrome/browser/cocoa/extensions/browser_actions_overflow_menu.mm b/chrome/browser/cocoa/extensions/browser_actions_overflow_menu.mm
deleted file mode 100644
index 25b967a..0000000
--- a/chrome/browser/cocoa/extensions/browser_actions_overflow_menu.mm
+++ /dev/null
@@ -1,9 +0,0 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#import "browser_actions_overflow_menu.h"
-
-@implementation BrowserActionsOverflowMenu
-
-@end
diff --git a/chrome/browser/cocoa/extensions/extension_action_context_menu.h b/chrome/browser/cocoa/extensions/extension_action_context_menu.h
index 31c36cf..c43ba37 100644
--- a/chrome/browser/cocoa/extensions/extension_action_context_menu.h
+++ b/chrome/browser/cocoa/extensions/extension_action_context_menu.h
@@ -16,6 +16,7 @@ class Profile;
// A context menu used by the Browser and Page Action components that appears
// if a user right-clicks the view of the given extension.
@interface ExtensionActionContextMenu : NSMenu {
+ @private
// The extension that this menu belongs to. Weak.
Extension* extension_;
diff --git a/chrome/browser/cocoa/extensions/extension_action_context_menu.mm b/chrome/browser/cocoa/extensions/extension_action_context_menu.mm
index aaef5a4..30db253 100644
--- a/chrome/browser/cocoa/extensions/extension_action_context_menu.mm
+++ b/chrome/browser/cocoa/extensions/extension_action_context_menu.mm
@@ -135,7 +135,7 @@ enum {
if ([itemObj tag] == kExtensionContextOptions &&
extension_->options_url().spec().length() <= 0) {
// Setting the target to nil will disable the item. For some reason
- // setDisabled:NO does not work.
+ // setEnabled:NO does not work.
[itemObj setTarget:nil];
} else {
[itemObj setTarget:self];
diff --git a/chrome/browser/cocoa/extensions/extension_popup_controller.h b/chrome/browser/cocoa/extensions/extension_popup_controller.h
index 1c37c7a..e761470 100644
--- a/chrome/browser/cocoa/extensions/extension_popup_controller.h
+++ b/chrome/browser/cocoa/extensions/extension_popup_controller.h
@@ -48,7 +48,7 @@ class ExtensionHost;
// ExtensionPopupController with the parent window retrieved from |browser|, a
// host for the popup created by the extension process manager specific to the
// browser profile and the remaining arguments |anchoredAt| and |arrowLocation|.
-// |anchoredAt| is expected to be in the screen's coordinates at the bottom
+// |anchoredAt| is expected to be in the window's coordinates at the bottom
// center of the browser action button.
// The actual display of the popup is delayed until the page contents finish
// loading in order to minimize UI flashing and resizing.
diff --git a/chrome/browser/cocoa/extensions/extension_popup_controller.mm b/chrome/browser/cocoa/extensions/extension_popup_controller.mm
index c9f61f0..a4e868c 100644
--- a/chrome/browser/cocoa/extensions/extension_popup_controller.mm
+++ b/chrome/browser/cocoa/extensions/extension_popup_controller.mm
@@ -49,7 +49,7 @@ CGFloat Clamp(CGFloat value, CGFloat min, CGFloat max) {
anchoredAt:(NSPoint)anchoredAt
arrowLocation:(BubbleArrowLocation)arrowLocation {
parentWindow_ = parentWindow;
- anchor_ = anchoredAt;
+ anchor_ = [parentWindow convertBaseToScreen:anchoredAt];
host_.reset(host);
scoped_nsobject<InfoBubbleView> view([[InfoBubbleView alloc] init]);
diff --git a/chrome/browser/cocoa/location_bar_view_mac.mm b/chrome/browser/cocoa/location_bar_view_mac.mm
index ca09820..bbd30c1 100644
--- a/chrome/browser/cocoa/location_bar_view_mac.mm
+++ b/chrome/browser/cocoa/location_bar_view_mac.mm
@@ -674,10 +674,8 @@ void LocationBarViewMac::PageActionImageView::OnMousePressed(NSRect bounds) {
NSWindow* window = [textField window];
NSRect relativeBounds = [[window contentView] convertRect:bounds
fromView:textField];
- NSPoint arrowPoint = [window convertBaseToScreen:NSMakePoint(
- NSMinX(relativeBounds),
- NSMinY(relativeBounds))];
-
+ NSPoint arrowPoint = NSMakePoint(NSMinX(relativeBounds),
+ NSMinY(relativeBounds));
// Adjust the anchor point to be at the center of the page action icon.
arrowPoint.x += [GetImage() size].width / 2;