Commit 582ab975 authored by guohui@chromium.org's avatar guohui@chromium.org

show avatar bubble in edit mode on mac

BUG=335208

Review URL: https://codereview.chromium.org/216523005

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@260221 0039d316-1c4b-4281-b951-d872f2087c98
parent 4bd78e9c
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#import "base/mac/scoped_nsobject.h" #import "base/mac/scoped_nsobject.h"
#include "base/memory/scoped_ptr.h" #include "base/memory/scoped_ptr.h"
#include "chrome/browser/ui/browser_window.h"
@class BaseBubbleController; @class BaseBubbleController;
class Browser; class Browser;
...@@ -38,8 +39,9 @@ class ProfileInfoUpdateObserver; ...@@ -38,8 +39,9 @@ class ProfileInfoUpdateObserver;
// Designated initializer. // Designated initializer.
- (id)initWithBrowser:(Browser*)browser; - (id)initWithBrowser:(Browser*)browser;
// Shows the avatar bubble. // Shows the avatar bubble in the given mode.
- (void)showAvatarBubble:(NSView*)anchor; - (void)showAvatarBubble:(NSView*)anchor
withMode:(BrowserWindow::AvatarBubbleMode)mode;
@end @end
......
...@@ -97,7 +97,8 @@ class ProfileInfoUpdateObserver : public ProfileInfoCacheObserver { ...@@ -97,7 +97,8 @@ class ProfileInfoUpdateObserver : public ProfileInfoCacheObserver {
return button_.get(); return button_.get();
} }
- (void)showAvatarBubble:(NSView*)anchor { - (void)showAvatarBubble:(NSView*)anchor
withMode:(BrowserWindow::AvatarBubbleMode)mode {
if (menuController_) if (menuController_)
return; return;
...@@ -121,9 +122,14 @@ class ProfileInfoUpdateObserver : public ProfileInfoCacheObserver { ...@@ -121,9 +122,14 @@ class ProfileInfoUpdateObserver : public ProfileInfoCacheObserver {
// |menuController_| will automatically release itself on close. // |menuController_| will automatically release itself on close.
if (switches::IsNewProfileManagement()) { if (switches::IsNewProfileManagement()) {
BubbleViewMode viewMode =
mode == BrowserWindow::AVATAR_BUBBLE_MODE_DEFAULT ?
PROFILE_CHOOSER_VIEW :
ACCOUNT_MANAGEMENT_VIEW;
menuController_ = menuController_ =
[[ProfileChooserController alloc] initWithBrowser:browser_ [[ProfileChooserController alloc] initWithBrowser:browser_
anchoredAt:point]; anchoredAt:point
withMode:viewMode];
} else { } else {
menuController_ = menuController_ =
[[AvatarMenuBubbleController alloc] initWithBrowser:browser_ [[AvatarMenuBubbleController alloc] initWithBrowser:browser_
...@@ -142,7 +148,8 @@ class ProfileInfoUpdateObserver : public ProfileInfoCacheObserver { ...@@ -142,7 +148,8 @@ class ProfileInfoUpdateObserver : public ProfileInfoCacheObserver {
- (IBAction)buttonClicked:(id)sender { - (IBAction)buttonClicked:(id)sender {
DCHECK_EQ(sender, button_.get()); DCHECK_EQ(sender, button_.get());
[self showAvatarBubble:button_]; [self showAvatarBubble:button_
withMode:BrowserWindow::AVATAR_BUBBLE_MODE_DEFAULT];
} }
- (void)bubbleWillClose:(NSNotification*)notif { - (void)bubbleWillClose:(NSNotification*)notif {
......
...@@ -23,7 +23,7 @@ class WebContents; ...@@ -23,7 +23,7 @@ class WebContents;
// This window controller manages the bubble that displays a "menu" of profiles. // This window controller manages the bubble that displays a "menu" of profiles.
// It is brought open by clicking on the avatar icon in the window frame. // It is brought open by clicking on the avatar icon in the window frame.
@interface ProfileChooserController : BaseBubbleController { @interface ProfileChooserController : BaseBubbleController {
@private @public
// Different views that can be displayed in the bubble. // Different views that can be displayed in the bubble.
enum BubbleViewMode { enum BubbleViewMode {
PROFILE_CHOOSER_VIEW, // Shows a "fast profile switcher" view. PROFILE_CHOOSER_VIEW, // Shows a "fast profile switcher" view.
...@@ -32,6 +32,7 @@ class WebContents; ...@@ -32,6 +32,7 @@ class WebContents;
GAIA_ADD_ACCOUNT_VIEW // Shows a web view for adding secondary accounts. GAIA_ADD_ACCOUNT_VIEW // Shows a web view for adding secondary accounts.
}; };
@private
// The menu that contains the data from the backend. // The menu that contains the data from the backend.
scoped_ptr<AvatarMenu> avatarMenu_; scoped_ptr<AvatarMenu> avatarMenu_;
...@@ -60,7 +61,9 @@ class WebContents; ...@@ -60,7 +61,9 @@ class WebContents;
BOOL isGuestSession_; BOOL isGuestSession_;
} }
- (id)initWithBrowser:(Browser*)browser anchoredAt:(NSPoint)point; - (id)initWithBrowser:(Browser*)browser
anchoredAt:(NSPoint)point
withMode:(BubbleViewMode)mode;
// Creates all the subviews of the avatar bubble for |viewToDisplay|. // Creates all the subviews of the avatar bubble for |viewToDisplay|.
- (void)initMenuContentsWithView:(BubbleViewMode)viewToDisplay; - (void)initMenuContentsWithView:(BubbleViewMode)viewToDisplay;
...@@ -96,7 +99,9 @@ class WebContents; ...@@ -96,7 +99,9 @@ class WebContents;
// Testing API ///////////////////////////////////////////////////////////////// // Testing API /////////////////////////////////////////////////////////////////
@interface ProfileChooserController (ExposedForTesting) @interface ProfileChooserController (ExposedForTesting)
- (id)initWithBrowser:(Browser*)browser anchoredAt:(NSPoint)point; - (id)initWithBrowser:(Browser*)browser
anchoredAt:(NSPoint)point
withMode:(BubbleViewMode)mode;
@end @end
#endif // CHROME_BROWSER_UI_COCOA_BROWSER_PROFILE_CHOOSER_CONTROLLER_H_ #endif // CHROME_BROWSER_UI_COCOA_BROWSER_PROFILE_CHOOSER_CONTROLLER_H_
...@@ -627,7 +627,9 @@ class ActiveProfileObserverBridge : public AvatarMenuObserver, ...@@ -627,7 +627,9 @@ class ActiveProfileObserverBridge : public AvatarMenuObserver,
webContents_.reset(); webContents_.reset();
} }
- (id)initWithBrowser:(Browser*)browser anchoredAt:(NSPoint)point { - (id)initWithBrowser:(Browser*)browser
anchoredAt:(NSPoint)point
withMode:(BubbleViewMode)mode {
base::scoped_nsobject<InfoBubbleWindow> window([[InfoBubbleWindow alloc] base::scoped_nsobject<InfoBubbleWindow> window([[InfoBubbleWindow alloc]
initWithContentRect:ui::kWindowSizeDeterminedLater initWithContentRect:ui::kWindowSizeDeterminedLater
styleMask:NSBorderlessWindowMask styleMask:NSBorderlessWindowMask
...@@ -638,7 +640,7 @@ class ActiveProfileObserverBridge : public AvatarMenuObserver, ...@@ -638,7 +640,7 @@ class ActiveProfileObserverBridge : public AvatarMenuObserver,
parentWindow:browser->window()->GetNativeWindow() parentWindow:browser->window()->GetNativeWindow()
anchoredAt:point])) { anchoredAt:point])) {
browser_ = browser; browser_ = browser;
viewMode_ = PROFILE_CHOOSER_VIEW; viewMode_ = mode;
tutorialShowing_ = false; tutorialShowing_ = false;
observer_.reset(new ActiveProfileObserverBridge(self, browser_)); observer_.reset(new ActiveProfileObserverBridge(self, browser_));
......
...@@ -65,9 +65,10 @@ class ProfileChooserControllerTest : public CocoaProfileTest { ...@@ -65,9 +65,10 @@ class ProfileChooserControllerTest : public CocoaProfileTest {
void StartProfileChooserController() { void StartProfileChooserController() {
NSRect frame = [test_window() frame]; NSRect frame = [test_window() frame];
NSPoint point = NSMakePoint(NSMidX(frame), NSMidY(frame)); NSPoint point = NSMakePoint(NSMidX(frame), NSMidY(frame));
controller_.reset( controller_.reset([[ProfileChooserController alloc]
[[ProfileChooserController alloc] initWithBrowser:browser() initWithBrowser:browser()
anchoredAt:point]); anchoredAt:point
withMode:PROFILE_CHOOSER_VIEW]);
[controller_ showWindow:nil]; [controller_ showWindow:nil];
} }
......
...@@ -708,7 +708,7 @@ void BrowserWindowCocoa::ShowAvatarBubble(WebContents* web_contents, ...@@ -708,7 +708,7 @@ void BrowserWindowCocoa::ShowAvatarBubble(WebContents* web_contents,
void BrowserWindowCocoa::ShowAvatarBubbleFromAvatarButton( void BrowserWindowCocoa::ShowAvatarBubbleFromAvatarButton(
AvatarBubbleMode mode) { AvatarBubbleMode mode) {
AvatarBaseController* controller = [controller_ avatarButtonController]; AvatarBaseController* controller = [controller_ avatarButtonController];
[controller showAvatarBubble:[controller buttonView]]; [controller showAvatarBubble:[controller buttonView] withMode:mode];
} }
void BrowserWindowCocoa::ShowPasswordGenerationBubble( void BrowserWindowCocoa::ShowPasswordGenerationBubble(
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment