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 @@
#import "base/mac/scoped_nsobject.h"
#include "base/memory/scoped_ptr.h"
#include "chrome/browser/ui/browser_window.h"
@class BaseBubbleController;
class Browser;
......@@ -38,8 +39,9 @@ class ProfileInfoUpdateObserver;
// Designated initializer.
- (id)initWithBrowser:(Browser*)browser;
// Shows the avatar bubble.
- (void)showAvatarBubble:(NSView*)anchor;
// Shows the avatar bubble in the given mode.
- (void)showAvatarBubble:(NSView*)anchor
withMode:(BrowserWindow::AvatarBubbleMode)mode;
@end
......
......@@ -97,7 +97,8 @@ class ProfileInfoUpdateObserver : public ProfileInfoCacheObserver {
return button_.get();
}
- (void)showAvatarBubble:(NSView*)anchor {
- (void)showAvatarBubble:(NSView*)anchor
withMode:(BrowserWindow::AvatarBubbleMode)mode {
if (menuController_)
return;
......@@ -121,9 +122,14 @@ class ProfileInfoUpdateObserver : public ProfileInfoCacheObserver {
// |menuController_| will automatically release itself on close.
if (switches::IsNewProfileManagement()) {
BubbleViewMode viewMode =
mode == BrowserWindow::AVATAR_BUBBLE_MODE_DEFAULT ?
PROFILE_CHOOSER_VIEW :
ACCOUNT_MANAGEMENT_VIEW;
menuController_ =
[[ProfileChooserController alloc] initWithBrowser:browser_
anchoredAt:point];
anchoredAt:point
withMode:viewMode];
} else {
menuController_ =
[[AvatarMenuBubbleController alloc] initWithBrowser:browser_
......@@ -142,7 +148,8 @@ class ProfileInfoUpdateObserver : public ProfileInfoCacheObserver {
- (IBAction)buttonClicked:(id)sender {
DCHECK_EQ(sender, button_.get());
[self showAvatarBubble:button_];
[self showAvatarBubble:button_
withMode:BrowserWindow::AVATAR_BUBBLE_MODE_DEFAULT];
}
- (void)bubbleWillClose:(NSNotification*)notif {
......
......@@ -23,7 +23,7 @@ class WebContents;
// 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.
@interface ProfileChooserController : BaseBubbleController {
@private
@public
// Different views that can be displayed in the bubble.
enum BubbleViewMode {
PROFILE_CHOOSER_VIEW, // Shows a "fast profile switcher" view.
......@@ -32,6 +32,7 @@ class WebContents;
GAIA_ADD_ACCOUNT_VIEW // Shows a web view for adding secondary accounts.
};
@private
// The menu that contains the data from the backend.
scoped_ptr<AvatarMenu> avatarMenu_;
......@@ -60,7 +61,9 @@ class WebContents;
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|.
- (void)initMenuContentsWithView:(BubbleViewMode)viewToDisplay;
......@@ -96,7 +99,9 @@ class WebContents;
// Testing API /////////////////////////////////////////////////////////////////
@interface ProfileChooserController (ExposedForTesting)
- (id)initWithBrowser:(Browser*)browser anchoredAt:(NSPoint)point;
- (id)initWithBrowser:(Browser*)browser
anchoredAt:(NSPoint)point
withMode:(BubbleViewMode)mode;
@end
#endif // CHROME_BROWSER_UI_COCOA_BROWSER_PROFILE_CHOOSER_CONTROLLER_H_
......@@ -627,7 +627,9 @@ class ActiveProfileObserverBridge : public AvatarMenuObserver,
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]
initWithContentRect:ui::kWindowSizeDeterminedLater
styleMask:NSBorderlessWindowMask
......@@ -638,7 +640,7 @@ class ActiveProfileObserverBridge : public AvatarMenuObserver,
parentWindow:browser->window()->GetNativeWindow()
anchoredAt:point])) {
browser_ = browser;
viewMode_ = PROFILE_CHOOSER_VIEW;
viewMode_ = mode;
tutorialShowing_ = false;
observer_.reset(new ActiveProfileObserverBridge(self, browser_));
......
......@@ -65,9 +65,10 @@ class ProfileChooserControllerTest : public CocoaProfileTest {
void StartProfileChooserController() {
NSRect frame = [test_window() frame];
NSPoint point = NSMakePoint(NSMidX(frame), NSMidY(frame));
controller_.reset(
[[ProfileChooserController alloc] initWithBrowser:browser()
anchoredAt:point]);
controller_.reset([[ProfileChooserController alloc]
initWithBrowser:browser()
anchoredAt:point
withMode:PROFILE_CHOOSER_VIEW]);
[controller_ showWindow:nil];
}
......
......@@ -708,7 +708,7 @@ void BrowserWindowCocoa::ShowAvatarBubble(WebContents* web_contents,
void BrowserWindowCocoa::ShowAvatarBubbleFromAvatarButton(
AvatarBubbleMode mode) {
AvatarBaseController* controller = [controller_ avatarButtonController];
[controller showAvatarBubble:[controller buttonView]];
[controller showAvatarBubble:[controller buttonView] withMode:mode];
}
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