diff options
37 files changed, 130 insertions, 11 deletions
diff --git a/chrome/app/chrome_command_ids.h b/chrome/app/chrome_command_ids.h index b49bf84..f00d9c0 100644 --- a/chrome/app/chrome_command_ids.h +++ b/chrome/app/chrome_command_ids.h @@ -173,6 +173,7 @@ #define IDC_EXTENSION_ERRORS 40031 #define IDC_SHOW_SYNC_ERROR 40032 #define IDC_SHOW_SETTINGS_CHANGES 40033 +#define IDC_SHOW_AVATAR_MENU 40034 // Spell-check // Insert any additional suggestions before _LAST; these have to be consecutive. diff --git a/chrome/app/chrome_dll.rc b/chrome/app/chrome_dll.rc index 7a24204..452c9ae 100644 --- a/chrome/app/chrome_dll.rc +++ b/chrome/app/chrome_dll.rc @@ -109,6 +109,7 @@ BEGIN "H", IDC_SHOW_HISTORY, VIRTKEY, CONTROL "F", IDC_SHOW_APP_MENU, VIRTKEY, ALT "E", IDC_SHOW_APP_MENU, VIRTKEY, ALT + "M", IDC_SHOW_AVATAR_MENU, VIRTKEY, CONTROL, SHIFT VK_ESCAPE, IDC_STOP, VIRTKEY VK_ESCAPE, IDC_TASK_MANAGER, VIRTKEY, SHIFT VK_OEM_PERIOD, IDC_TOGGLE_SPEECH_INPUT, VIRTKEY, CONTROL, SHIFT diff --git a/chrome/browser/global_keyboard_shortcuts_mac.mm b/chrome/browser/global_keyboard_shortcuts_mac.mm index 76bdbe9..9076f0c 100644 --- a/chrome/browser/global_keyboard_shortcuts_mac.mm +++ b/chrome/browser/global_keyboard_shortcuts_mac.mm @@ -51,6 +51,7 @@ const KeyboardShortcutData* GetWindowKeyboardShortcutTable( {true, false, false, false, kVK_ANSI_Keypad8, 0, IDC_SELECT_TAB_7}, {true, false, false, false, kVK_ANSI_9, 0, IDC_SELECT_LAST_TAB}, {true, false, false, false, kVK_ANSI_Keypad9, 0, IDC_SELECT_LAST_TAB}, + {true, true, false, false, 0, 'm', IDC_SHOW_AVATAR_MENU}, }; *num_entries = arraysize(keyboard_shortcuts); diff --git a/chrome/browser/ui/browser.cc b/chrome/browser/ui/browser.cc index 909e2b5..cfc396e 100644 --- a/chrome/browser/ui/browser.cc +++ b/chrome/browser/ui/browser.cc @@ -2135,6 +2135,10 @@ void Browser::ShowAppMenu() { window_->ShowAppMenu(); } +void Browser::ShowAvatarMenu() { + window_->ShowAvatarBubbleFromAvatarButton(); +} + void Browser::ShowHistoryTab() { UserMetrics::RecordAction(UserMetricsAction("ShowHistory")); ShowSingletonTabOverwritingNTP( @@ -2830,6 +2834,7 @@ void Browser::ExecuteCommandWithDisposition( case IDC_SHOW_BOOKMARK_MANAGER: OpenBookmarkManager(); break; case IDC_SHOW_APP_MENU: ShowAppMenu(); break; + case IDC_SHOW_AVATAR_MENU: ShowAvatarMenu(); break; case IDC_SHOW_HISTORY: ShowHistoryTab(); break; case IDC_SHOW_DOWNLOADS: ShowDownloadsTab(); break; case IDC_MANAGE_EXTENSIONS: ShowExtensionsTab(); break; @@ -4685,6 +4690,8 @@ void Browser::UpdateCommandsForFullscreenMode(bool is_fullscreen) { command_updater_.UpdateCommandEnabled(IDC_VIEW_PASSWORDS, show_main_ui); command_updater_.UpdateCommandEnabled(IDC_ABOUT, show_main_ui); command_updater_.UpdateCommandEnabled(IDC_SHOW_APP_MENU, show_main_ui); + command_updater_.UpdateCommandEnabled(IDC_SHOW_AVATAR_MENU, + show_main_ui && !profile()->IsOffTheRecord()); #if defined (ENABLE_PROFILING) && !defined(NO_TCMALLOC) command_updater_.UpdateCommandEnabled(IDC_PROFILING_ENABLED, show_main_ui); #endif diff --git a/chrome/browser/ui/browser.h b/chrome/browser/ui/browser.h index 90e33f2..bf6ca36 100644 --- a/chrome/browser/ui/browser.h +++ b/chrome/browser/ui/browser.h @@ -601,6 +601,7 @@ class Browser : public TabHandlerDelegate, void OpenBookmarkManagerEditNode(int64 node_id); void OpenBookmarkManagerAddNodeIn(int64 node_id); void ShowAppMenu(); + void ShowAvatarMenu(); void ShowHistoryTab(); void ShowDownloadsTab(); void ShowExtensionsTab(); diff --git a/chrome/browser/ui/browser_window.h b/chrome/browser/ui/browser_window.h index 926cd65..06b0dc4 100644 --- a/chrome/browser/ui/browser_window.h +++ b/chrome/browser/ui/browser_window.h @@ -358,6 +358,9 @@ class BrowserWindow { virtual void ShowAvatarBubble(TabContents* tab_contents, const gfx::Rect& rect) = 0; + // Shows the avatar bubble on the window frame off of the avatar button. + virtual void ShowAvatarBubbleFromAvatarButton() = 0; + protected: friend class BrowserList; friend class BrowserView; diff --git a/chrome/browser/ui/cocoa/browser/avatar_button_controller.h b/chrome/browser/ui/cocoa/browser/avatar_button_controller.h index 21464bf..c5adcb2 100644 --- a/chrome/browser/ui/cocoa/browser/avatar_button_controller.h +++ b/chrome/browser/ui/cocoa/browser/avatar_button_controller.h @@ -42,6 +42,9 @@ class Observer; // and will be resized to the frame of the button. - (void)setImage:(NSImage*)image; +// Shows the avatar bubble. +- (void)showAvatarBubble; + @end @interface AvatarButtonController (ExposedForTesting) diff --git a/chrome/browser/ui/cocoa/browser/avatar_button_controller.mm b/chrome/browser/ui/cocoa/browser/avatar_button_controller.mm index 0e05ef4..39aa4f0 100644 --- a/chrome/browser/ui/cocoa/browser/avatar_button_controller.mm +++ b/chrome/browser/ui/cocoa/browser/avatar_button_controller.mm @@ -140,17 +140,17 @@ const CGFloat kMenuYOffsetAdjust = 1.0; [self.buttonView setImage:[self compositeImageWithShadow:image]]; } -// Private ///////////////////////////////////////////////////////////////////// - -- (void)setOpenMenuOnClick:(BOOL)flag { - [self.buttonView setEnabled:flag]; -} - -- (IBAction)buttonClicked:(id)sender { - DCHECK_EQ(self.buttonView, sender); +- (void)showAvatarBubble { if (menuController_) return; + NSWindowController* wc = + [browser_->window()->GetNativeHandle() windowController]; + if ([wc isKindOfClass:[BrowserWindowController class]]) { + [static_cast<BrowserWindowController*>(wc) + lockBarVisibilityForOwner:self withAnimation:NO delay:NO]; + } + NSView* view = self.view; NSPoint point = NSMakePoint(NSMidX([view bounds]), NSMaxY([view bounds]) - kMenuYOffsetAdjust); @@ -168,7 +168,24 @@ const CGFloat kMenuYOffsetAdjust = 1.0; [menuController_ showWindow:self]; } +// Private ///////////////////////////////////////////////////////////////////// + +- (void)setOpenMenuOnClick:(BOOL)flag { + [self.buttonView setEnabled:flag]; +} + +- (IBAction)buttonClicked:(id)sender { + DCHECK_EQ(self.buttonView, sender); + [self showAvatarBubble]; +} + - (void)bubbleWillClose:(NSNotification*)notif { + NSWindowController* wc = + [browser_->window()->GetNativeHandle() windowController]; + if ([wc isKindOfClass:[BrowserWindowController class]]) { + [static_cast<BrowserWindowController*>(wc) + releaseBarVisibilityForOwner:self withAnimation:YES delay:NO]; + } menuController_ = nil; } diff --git a/chrome/browser/ui/cocoa/browser_window_cocoa.h b/chrome/browser/ui/cocoa/browser_window_cocoa.h index 7f60a7a..9f40a98 100644 --- a/chrome/browser/ui/cocoa/browser_window_cocoa.h +++ b/chrome/browser/ui/cocoa/browser_window_cocoa.h @@ -123,6 +123,7 @@ class BrowserWindowCocoa : public BrowserWindow, virtual FindBar* CreateFindBar() OVERRIDE; virtual void ShowAvatarBubble(TabContents* tab_contents, const gfx::Rect& rect) OVERRIDE; + virtual void ShowAvatarBubbleFromAvatarButton() OVERRIDE; // Overridden from NotificationObserver virtual void Observe(int type, diff --git a/chrome/browser/ui/cocoa/browser_window_cocoa.mm b/chrome/browser/ui/cocoa/browser_window_cocoa.mm index 3980096..6f811f2 100644 --- a/chrome/browser/ui/cocoa/browser_window_cocoa.mm +++ b/chrome/browser/ui/cocoa/browser_window_cocoa.mm @@ -18,6 +18,7 @@ #include "chrome/browser/sidebar/sidebar_manager.h" #include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/browser_list.h" +#import "chrome/browser/ui/cocoa/browser/avatar_button_controller.h" #import "chrome/browser/ui/cocoa/browser/avatar_menu_bubble_controller.h" #import "chrome/browser/ui/cocoa/browser/edit_search_engine_cocoa_controller.h" #import "chrome/browser/ui/cocoa/browser_window_controller.h" @@ -618,3 +619,7 @@ void BrowserWindowCocoa::ShowAvatarBubble(TabContents* tab_contents, anchoredAt:point]; [menu showWindow:nil]; } + +void BrowserWindowCocoa::ShowAvatarBubbleFromAvatarButton() { + [[controller_ avatarButtonController] showAvatarBubble]; +} diff --git a/chrome/browser/ui/cocoa/browser_window_controller.h b/chrome/browser/ui/cocoa/browser_window_controller.h index 760bd31..cf77b7d 100644 --- a/chrome/browser/ui/cocoa/browser_window_controller.h +++ b/chrome/browser/ui/cocoa/browser_window_controller.h @@ -199,6 +199,9 @@ class TabContents; // Access the Profile object that backs this Browser. - (Profile*)profile; +// Access the avatar button controller. +- (AvatarButtonController*)avatarButtonController; + // Updates the toolbar (and transitively the location bar) with the states of // the specified |tab|. If |shouldRestore| is true, we're switching // (back?) to this tab and should restore any previous location bar state diff --git a/chrome/browser/ui/cocoa/browser_window_controller.mm b/chrome/browser/ui/cocoa/browser_window_controller.mm index 304bbd3..cfef089 100644 --- a/chrome/browser/ui/cocoa/browser_window_controller.mm +++ b/chrome/browser/ui/cocoa/browser_window_controller.mm @@ -471,6 +471,10 @@ enum { return browser_->profile(); } +- (AvatarButtonController*)avatarButtonController { + return avatarButtonController_.get(); +} + - (void)destroyBrowser { [NSApp removeWindowsItem:[self window]]; diff --git a/chrome/browser/ui/gtk/accelerators_gtk.cc b/chrome/browser/ui/gtk/accelerators_gtk.cc index cbc35e1..509c248 100644 --- a/chrome/browser/ui/gtk/accelerators_gtk.cc +++ b/chrome/browser/ui/gtk/accelerators_gtk.cc @@ -173,6 +173,8 @@ const struct AcceleratorMapping { { GDK_s, IDC_SAVE_PAGE, GDK_CONTROL_MASK }, { GDK_e, IDC_SHOW_APP_MENU, GDK_MOD1_MASK }, { GDK_f, IDC_SHOW_APP_MENU, GDK_MOD1_MASK }, + { GDK_m, IDC_SHOW_AVATAR_MENU, + GdkModifierType(GDK_CONTROL_MASK | GDK_SHIFT_MASK)}, { GDK_greater, IDC_TOGGLE_SPEECH_INPUT, GdkModifierType(GDK_CONTROL_MASK | GDK_SHIFT_MASK) }, }; diff --git a/chrome/browser/ui/gtk/avatar_menu_button_gtk.cc b/chrome/browser/ui/gtk/avatar_menu_button_gtk.cc index 133f361..9d57f28 100644 --- a/chrome/browser/ui/gtk/avatar_menu_button_gtk.cc +++ b/chrome/browser/ui/gtk/avatar_menu_button_gtk.cc @@ -42,6 +42,10 @@ gboolean AvatarMenuButtonGtk::OnButtonPressed(GtkWidget* widget, if (event->button != 1) return FALSE; - new AvatarMenuBubbleGtk(browser_, widget, arrow_location_, NULL); + ShowAvatarBubble(); return TRUE; } + +void AvatarMenuButtonGtk::ShowAvatarBubble() { + new AvatarMenuBubbleGtk(browser_, widget_.get(), arrow_location_, NULL); +} diff --git a/chrome/browser/ui/gtk/avatar_menu_button_gtk.h b/chrome/browser/ui/gtk/avatar_menu_button_gtk.h index 5e05e24..1f8c268 100644 --- a/chrome/browser/ui/gtk/avatar_menu_button_gtk.h +++ b/chrome/browser/ui/gtk/avatar_menu_button_gtk.h @@ -34,6 +34,9 @@ class AvatarMenuButtonGtk { // Sets the image to display on the button, typically the profile icon. void SetIcon(const SkBitmap &icon); + // Show the avatar bubble. + void ShowAvatarBubble(); + private: CHROMEGTK_CALLBACK_1(AvatarMenuButtonGtk, gboolean, OnButtonPressed, GdkEventButton*); diff --git a/chrome/browser/ui/gtk/browser_titlebar.h b/chrome/browser/ui/gtk/browser_titlebar.h index d929278..eca9a27 100644 --- a/chrome/browser/ui/gtk/browser_titlebar.h +++ b/chrome/browser/ui/gtk/browser_titlebar.h @@ -67,6 +67,8 @@ class BrowserTitlebar : public content::NotificationObserver, // add to the menu. void ShowContextMenu(GdkEventButton* event); + AvatarMenuButtonGtk* avatar_button() { return avatar_button_.get(); } + private: // A helper class to keep track of which frame of the throbber animation // we're showing. diff --git a/chrome/browser/ui/gtk/browser_window_gtk.cc b/chrome/browser/ui/gtk/browser_window_gtk.cc index 674b6e1..fc7e9c9 100644 --- a/chrome/browser/ui/gtk/browser_window_gtk.cc +++ b/chrome/browser/ui/gtk/browser_window_gtk.cc @@ -41,6 +41,7 @@ #include "chrome/browser/ui/find_bar/find_tab_helper.h" #include "chrome/browser/ui/gtk/about_chrome_dialog.h" #include "chrome/browser/ui/gtk/accelerators_gtk.h" +#include "chrome/browser/ui/gtk/avatar_menu_button_gtk.h" #include "chrome/browser/ui/gtk/avatar_menu_bubble_gtk.h" #include "chrome/browser/ui/gtk/bookmarks/bookmark_bar_gtk.h" #include "chrome/browser/ui/gtk/browser_titlebar.h" @@ -1196,6 +1197,11 @@ void BrowserWindowGtk::ShowAvatarBubble(TabContents* tab_contents, BubbleGtk::ARROW_LOCATION_TOP_LEFT, &rect); } +void BrowserWindowGtk::ShowAvatarBubbleFromAvatarButton() { + if (titlebar_->avatar_button()) + titlebar_->avatar_button()->ShowAvatarBubble(); +} + void BrowserWindowGtk::ConfirmBrowserCloseWithPendingDownloads() { new DownloadInProgressDialogGtk(browser()); } diff --git a/chrome/browser/ui/gtk/browser_window_gtk.h b/chrome/browser/ui/gtk/browser_window_gtk.h index f1af45e..7a1c323 100644 --- a/chrome/browser/ui/gtk/browser_window_gtk.h +++ b/chrome/browser/ui/gtk/browser_window_gtk.h @@ -153,6 +153,7 @@ class BrowserWindowGtk : public BrowserWindow, virtual FindBar* CreateFindBar() OVERRIDE; virtual void ShowAvatarBubble(TabContents* tab_contents, const gfx::Rect& rect) OVERRIDE; + virtual void ShowAvatarBubbleFromAvatarButton() OVERRIDE; // Overridden from NotificationObserver: virtual void Observe(int type, diff --git a/chrome/browser/ui/panels/panel.cc b/chrome/browser/ui/panels/panel.cc index 8ead905..418f43f 100644 --- a/chrome/browser/ui/panels/panel.cc +++ b/chrome/browser/ui/panels/panel.cc @@ -535,6 +535,11 @@ void Panel::ShowAvatarBubble(TabContents* tab_contents, const gfx::Rect& rect) { NOTREACHED(); } +void Panel::ShowAvatarBubbleFromAvatarButton() { + // Panels will never show an avatar button so this should never be called. + NOTREACHED(); +} + void Panel::Observe(int type, const content::NotificationSource& source, const content::NotificationDetails& details) { diff --git a/chrome/browser/ui/panels/panel.h b/chrome/browser/ui/panels/panel.h index c3d3e1f..70f5a882 100644 --- a/chrome/browser/ui/panels/panel.h +++ b/chrome/browser/ui/panels/panel.h @@ -168,6 +168,7 @@ class Panel : public BrowserWindow, public content::NotificationObserver { const gfx::Size& pref_size) OVERRIDE; virtual void ShowAvatarBubble(TabContents* tab_contents, const gfx::Rect& rect) OVERRIDE; + virtual void ShowAvatarBubbleFromAvatarButton() OVERRIDE; // content::NotificationObserver overrides. virtual void Observe(int type, diff --git a/chrome/browser/ui/panels/panel_browser_frame_view.cc b/chrome/browser/ui/panels/panel_browser_frame_view.cc index d6b0523..3a7d261 100644 --- a/chrome/browser/ui/panels/panel_browser_frame_view.cc +++ b/chrome/browser/ui/panels/panel_browser_frame_view.cc @@ -308,6 +308,10 @@ void PanelBrowserFrameView::UpdateThrobber(bool running) { title_icon_->Update(); } +AvatarMenuButton* PanelBrowserFrameView::GetAvatarMenuButton() { + return NULL; +} + gfx::Rect PanelBrowserFrameView::GetBoundsForClientView() const { return client_view_bounds_; } diff --git a/chrome/browser/ui/panels/panel_browser_frame_view.h b/chrome/browser/ui/panels/panel_browser_frame_view.h index d5a72c4..2dc3c5e 100644 --- a/chrome/browser/ui/panels/panel_browser_frame_view.h +++ b/chrome/browser/ui/panels/panel_browser_frame_view.h @@ -58,6 +58,7 @@ class PanelBrowserFrameView : public BrowserNonClientFrameView, virtual gfx::Rect GetBoundsForTabStrip(views::View* tabstrip) const OVERRIDE; virtual int GetHorizontalTabStripVerticalOffset(bool restored) const OVERRIDE; virtual void UpdateThrobber(bool running) OVERRIDE; + virtual AvatarMenuButton* GetAvatarMenuButton() OVERRIDE; // Overridden from views::NonClientFrameView: virtual gfx::Rect GetBoundsForClientView() const OVERRIDE; diff --git a/chrome/browser/ui/views/accelerator_table_linux.cc b/chrome/browser/ui/views/accelerator_table_linux.cc index 8472d4b..8b712d7 100644 --- a/chrome/browser/ui/views/accelerator_table_linux.cc +++ b/chrome/browser/ui/views/accelerator_table_linux.cc @@ -142,6 +142,9 @@ const AcceleratorMapping kAcceleratorMap[] = { { ui::VKEY_H, false, true, false, IDC_SHOW_HISTORY }, { ui::VKEY_F, false, false, true, IDC_SHOW_APP_MENU}, { ui::VKEY_E, false, false, true, IDC_SHOW_APP_MENU}, +#if !defined(OS_CHROMEOS) + { ui::VKEY_M, true, true, false, IDC_SHOW_AVATAR_MENU}, +#endif { ui::VKEY_ESCAPE, false, false, false, IDC_STOP }, { ui::VKEY_ESCAPE, true, false, false, IDC_TASK_MANAGER }, { ui::VKEY_OEM_PERIOD, true, true, false, IDC_TOGGLE_SPEECH_INPUT }, diff --git a/chrome/browser/ui/views/avatar_menu_button.cc b/chrome/browser/ui/views/avatar_menu_button.cc index f3e8c8e..36a899d 100644 --- a/chrome/browser/ui/views/avatar_menu_button.cc +++ b/chrome/browser/ui/views/avatar_menu_button.cc @@ -142,6 +142,10 @@ void AvatarMenuButton::SetIcon(const SkBitmap& icon) { // views::ViewMenuDelegate implementation void AvatarMenuButton::RunMenu(views::View* source, const gfx::Point& pt) { + ShowAvatarBubble(); +} + +void AvatarMenuButton::ShowAvatarBubble() { if (!has_menu_ || bubble_) return; diff --git a/chrome/browser/ui/views/avatar_menu_button.h b/chrome/browser/ui/views/avatar_menu_button.h index 329d8fb..71609b6 100644 --- a/chrome/browser/ui/views/avatar_menu_button.h +++ b/chrome/browser/ui/views/avatar_menu_button.h @@ -41,6 +41,8 @@ class AvatarMenuButton : public views::MenuButton, // views::TextButton virtual void SetIcon(const SkBitmap& icon) OVERRIDE; + void ShowAvatarBubble(); + private: // views::ViewMenuDelegate virtual void RunMenu(views::View* source, const gfx::Point& pt) OVERRIDE; diff --git a/chrome/browser/ui/views/frame/browser_frame.cc b/chrome/browser/ui/views/frame/browser_frame.cc index 864e442..dd30f6f 100644 --- a/chrome/browser/ui/views/frame/browser_frame.cc +++ b/chrome/browser/ui/views/frame/browser_frame.cc @@ -149,3 +149,7 @@ void BrowserFrame::OnNativeWidgetActivationChanged(bool active) { } Widget::OnNativeWidgetActivationChanged(active); } + +AvatarMenuButton* BrowserFrame::GetAvatarMenuButton() { + return browser_frame_view_->GetAvatarMenuButton(); +} diff --git a/chrome/browser/ui/views/frame/browser_frame.h b/chrome/browser/ui/views/frame/browser_frame.h index 4fc1661..3f5b792 100644 --- a/chrome/browser/ui/views/frame/browser_frame.h +++ b/chrome/browser/ui/views/frame/browser_frame.h @@ -13,6 +13,7 @@ #include "views/widget/widget.h" class AeroGlassNonClientView; +class AvatarMenuButton; class BrowserNonClientFrameView; class BrowserRootView; class BrowserView; @@ -76,6 +77,8 @@ class BrowserFrame : public views::Widget { virtual ui::ThemeProvider* GetThemeProvider() const OVERRIDE; virtual void OnNativeWidgetActivationChanged(bool active) OVERRIDE; + AvatarMenuButton* GetAvatarMenuButton(); + private: NativeBrowserFrame* native_browser_frame_; diff --git a/chrome/browser/ui/views/frame/browser_non_client_frame_view.h b/chrome/browser/ui/views/frame/browser_non_client_frame_view.h index 6d69dcb2..c781f38 100644 --- a/chrome/browser/ui/views/frame/browser_non_client_frame_view.h +++ b/chrome/browser/ui/views/frame/browser_non_client_frame_view.h @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 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. @@ -8,6 +8,7 @@ #include "views/window/non_client_view.h" +class AvatarMenuButton; class BrowserFrame; class BrowserView; @@ -29,6 +30,9 @@ class BrowserNonClientFrameView : public views::NonClientFrameView { // Updates the throbber. virtual void UpdateThrobber(bool running) = 0; + + // Gets the avatar menu button. The button maybe NULL. + virtual AvatarMenuButton* GetAvatarMenuButton() = 0; }; namespace browser { diff --git a/chrome/browser/ui/views/frame/browser_view.cc b/chrome/browser/ui/views/frame/browser_view.cc index 586e8c9..7353e5b 100644 --- a/chrome/browser/ui/views/frame/browser_view.cc +++ b/chrome/browser/ui/views/frame/browser_view.cc @@ -48,6 +48,7 @@ #include "chrome/browser/ui/toolbar/wrench_menu_model.h" #include "chrome/browser/ui/view_ids.h" #include "chrome/browser/ui/views/avatar_menu_bubble_view.h" +#include "chrome/browser/ui/views/avatar_menu_button.h" #include "chrome/browser/ui/views/bookmarks/bookmark_bar_view.h" #include "chrome/browser/ui/views/browser_dialogs.h" #include "chrome/browser/ui/views/default_search_view.h" @@ -2624,3 +2625,9 @@ void BrowserView::ShowAvatarBubble(TabContents* tab_contents, views::BubbleBorder::TOP_RIGHT, bubble_view, bubble_view); } + +void BrowserView::ShowAvatarBubbleFromAvatarButton() { + AvatarMenuButton* button = frame_->GetAvatarMenuButton(); + if (button) + button->ShowAvatarBubble(); +} diff --git a/chrome/browser/ui/views/frame/browser_view.h b/chrome/browser/ui/views/frame/browser_view.h index 6e55943..265280b 100644 --- a/chrome/browser/ui/views/frame/browser_view.h +++ b/chrome/browser/ui/views/frame/browser_view.h @@ -332,6 +332,7 @@ class BrowserView : public BrowserBubbleHost, #endif virtual void ShowAvatarBubble(TabContents* tab_contents, const gfx::Rect& rect) OVERRIDE; + virtual void ShowAvatarBubbleFromAvatarButton() OVERRIDE; // Overridden from BrowserWindowTesting: virtual BookmarkBarView* GetBookmarkBarView() const OVERRIDE; diff --git a/chrome/browser/ui/views/frame/glass_browser_frame_view.cc b/chrome/browser/ui/views/frame/glass_browser_frame_view.cc index 8086cee..8187a6c 100644 --- a/chrome/browser/ui/views/frame/glass_browser_frame_view.cc +++ b/chrome/browser/ui/views/frame/glass_browser_frame_view.cc @@ -221,6 +221,10 @@ int GlassBrowserFrameView::NonClientHitTest(const gfx::Point& point) { return (window_component == HTNOWHERE) ? HTCAPTION : window_component; } +AvatarMenuButton* GlassBrowserFrameView::GetAvatarMenuButton() { + return avatar_button_.get(); +} + /////////////////////////////////////////////////////////////////////////////// // GlassBrowserFrameView, views::View overrides: diff --git a/chrome/browser/ui/views/frame/glass_browser_frame_view.h b/chrome/browser/ui/views/frame/glass_browser_frame_view.h index c993244..60b3b45 100644 --- a/chrome/browser/ui/views/frame/glass_browser_frame_view.h +++ b/chrome/browser/ui/views/frame/glass_browser_frame_view.h @@ -41,6 +41,7 @@ class GlassBrowserFrameView : public BrowserNonClientFrameView, virtual void EnableClose(bool enable) OVERRIDE { } virtual void ResetWindowControls() OVERRIDE { } virtual void UpdateWindowIcon() OVERRIDE { } + virtual AvatarMenuButton* GetAvatarMenuButton() OVERRIDE; protected: // Overridden from views::View: diff --git a/chrome/browser/ui/views/frame/opaque_browser_frame_view.cc b/chrome/browser/ui/views/frame/opaque_browser_frame_view.cc index d47a170..a306850 100644 --- a/chrome/browser/ui/views/frame/opaque_browser_frame_view.cc +++ b/chrome/browser/ui/views/frame/opaque_browser_frame_view.cc @@ -398,6 +398,10 @@ void OpaqueBrowserFrameView::UpdateWindowIcon() { window_icon_->SchedulePaint(); } +AvatarMenuButton* OpaqueBrowserFrameView::GetAvatarMenuButton() { + return avatar_button_.get(); +} + /////////////////////////////////////////////////////////////////////////////// // OpaqueBrowserFrameView, views::View overrides: diff --git a/chrome/browser/ui/views/frame/opaque_browser_frame_view.h b/chrome/browser/ui/views/frame/opaque_browser_frame_view.h index 09a52c2..c6a2b1e 100644 --- a/chrome/browser/ui/views/frame/opaque_browser_frame_view.h +++ b/chrome/browser/ui/views/frame/opaque_browser_frame_view.h @@ -19,7 +19,6 @@ class BrowserView; namespace gfx { class Font; } -class AvatarMenuButton; class TabContents; namespace views { class ImageButton; @@ -82,6 +81,7 @@ class OpaqueBrowserFrameView : public BrowserNonClientFrameView, virtual void EnableClose(bool enable) OVERRIDE; virtual void ResetWindowControls() OVERRIDE; virtual void UpdateWindowIcon() OVERRIDE; + virtual AvatarMenuButton* GetAvatarMenuButton() OVERRIDE; // Overridden from views::View: virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE; diff --git a/chrome/browser/ui/views/frame/popup_non_client_frame_view.cc b/chrome/browser/ui/views/frame/popup_non_client_frame_view.cc index 624a4ae..b9764a5 100644 --- a/chrome/browser/ui/views/frame/popup_non_client_frame_view.cc +++ b/chrome/browser/ui/views/frame/popup_non_client_frame_view.cc @@ -55,3 +55,7 @@ int PopupNonClientFrameView::GetHorizontalTabStripVerticalOffset( void PopupNonClientFrameView::UpdateThrobber(bool running) { } + +AvatarMenuButton* PopupNonClientFrameView::GetAvatarMenuButton() { + return NULL; +} diff --git a/chrome/browser/ui/views/frame/popup_non_client_frame_view.h b/chrome/browser/ui/views/frame/popup_non_client_frame_view.h index d15cd9b..9f89915 100644 --- a/chrome/browser/ui/views/frame/popup_non_client_frame_view.h +++ b/chrome/browser/ui/views/frame/popup_non_client_frame_view.h @@ -30,6 +30,7 @@ class PopupNonClientFrameView : public BrowserNonClientFrameView { virtual gfx::Rect GetBoundsForTabStrip(views::View* tabstrip) const OVERRIDE; virtual int GetHorizontalTabStripVerticalOffset(bool restored) const OVERRIDE; virtual void UpdateThrobber(bool running) OVERRIDE; + virtual AvatarMenuButton* GetAvatarMenuButton() OVERRIDE; private: DISALLOW_COPY_AND_ASSIGN(PopupNonClientFrameView); diff --git a/chrome/test/base/test_browser_window.h b/chrome/test/base/test_browser_window.h index 3072388..18915c1 100644 --- a/chrome/test/base/test_browser_window.h +++ b/chrome/test/base/test_browser_window.h @@ -120,6 +120,7 @@ class TestBrowserWindow : public BrowserWindow { virtual FindBar* CreateFindBar() OVERRIDE; virtual void ShowAvatarBubble(TabContents* tab_contents, const gfx::Rect& rect) OVERRIDE {} + virtual void ShowAvatarBubbleFromAvatarButton() OVERRIDE {} #if defined(OS_CHROMEOS) virtual void ShowMobileSetup() OVERRIDE {} |