Commit 1574c57a authored by mlerman@chromium.org's avatar mlerman@chromium.org

Move profile_chooser enums to a constant place for mac and win.

This will affect the cocoa and views versions of the profile_chooser.


BUG=357693

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

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@272537 0039d316-1c4b-4281-b951-d872f2087c98
parent 8a838628
...@@ -122,10 +122,10 @@ class ProfileInfoUpdateObserver : public ProfileInfoCacheObserver { ...@@ -122,10 +122,10 @@ class ProfileInfoUpdateObserver : public ProfileInfoCacheObserver {
// |menuController_| will automatically release itself on close. // |menuController_| will automatically release itself on close.
if (switches::IsNewAvatarMenu()) { if (switches::IsNewAvatarMenu()) {
BubbleViewMode viewMode = profiles::BubbleViewMode viewMode =
mode == BrowserWindow::AVATAR_BUBBLE_MODE_DEFAULT ? mode == BrowserWindow::AVATAR_BUBBLE_MODE_DEFAULT ?
BUBBLE_VIEW_MODE_PROFILE_CHOOSER : profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER :
BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT; profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT;
menuController_ = menuController_ =
[[ProfileChooserController alloc] initWithBrowser:browser_ [[ProfileChooserController alloc] initWithBrowser:browser_
anchoredAt:point anchoredAt:point
......
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
#include <string> #include <string>
#include "base/memory/scoped_ptr.h" #include "base/memory/scoped_ptr.h"
#include "chrome/browser/ui/profile_chooser_constants.h"
#import "chrome/browser/ui/cocoa/base_bubble_controller.h" #import "chrome/browser/ui/cocoa/base_bubble_controller.h"
class AvatarMenu; class AvatarMenu;
...@@ -24,31 +25,7 @@ class WebContents; ...@@ -24,31 +25,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<NSTextViewDelegate> { @interface ProfileChooserController : BaseBubbleController<NSTextViewDelegate> {
@public
// Different views that can be displayed in the bubble.
enum BubbleViewMode {
// Shows a "fast profile switcher" view.
BUBBLE_VIEW_MODE_PROFILE_CHOOSER,
// Shows a list of accounts for the active user.
BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT,
// Shows a web view for primary sign in.
BUBBLE_VIEW_MODE_GAIA_SIGNIN,
// Shows a web view for adding secondary accounts.
BUBBLE_VIEW_MODE_GAIA_ADD_ACCOUNT,
// Shows a view for confirming account removal.
BUBBLE_VIEW_MODE_ACCOUNT_REMOVAL,
// Shows a view for ending new profile management preview.
BUBBLE_VIEW_MODE_END_PREVIEW
};
@private @private
enum TutorialMode {
TUTORIAL_MODE_NONE, // No tutorial card shown.
TUTORIAL_MODE_ENABLE_PREVIEW, // The enable-mirror-preview tutorial shown.
TUTORIAL_MODE_WELCOME, // The welcome-to-mirror tutorial shown.
TUTORIAL_MODE_SEND_FEEDBACK // The send-feedback tutorial shown.
};
// 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_;
...@@ -65,10 +42,10 @@ class WebContents; ...@@ -65,10 +42,10 @@ class WebContents;
std::string accountIdToRemove_; std::string accountIdToRemove_;
// Active view mode. // Active view mode.
BubbleViewMode viewMode_; profiles::BubbleViewMode viewMode_;
// The current tutorial mode. // The current tutorial mode.
TutorialMode tutorialMode_; profiles::TutorialMode tutorialMode_;
// List of the full, un-elided accounts for the active profile. The keys are // List of the full, un-elided accounts for the active profile. The keys are
// generated used to tag the UI buttons, and the values are the original // generated used to tag the UI buttons, and the values are the original
...@@ -84,13 +61,13 @@ class WebContents; ...@@ -84,13 +61,13 @@ class WebContents;
- (id)initWithBrowser:(Browser*)browser - (id)initWithBrowser:(Browser*)browser
anchoredAt:(NSPoint)point anchoredAt:(NSPoint)point
withMode:(BubbleViewMode)mode; withMode:(profiles::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:(profiles::BubbleViewMode)viewToDisplay;
// Returns the view currently displayed by the bubble. // Returns the view currently displayed by the bubble.
- (BubbleViewMode)viewMode; - (profiles::BubbleViewMode)viewMode;
// Switches to a given profile. |sender| is an ProfileChooserItemController. // Switches to a given profile. |sender| is an ProfileChooserItemController.
- (IBAction)switchToProfile:(id)sender; - (IBAction)switchToProfile:(id)sender;
...@@ -135,7 +112,7 @@ class WebContents; ...@@ -135,7 +112,7 @@ class WebContents;
@interface ProfileChooserController (ExposedForTesting) @interface ProfileChooserController (ExposedForTesting)
- (id)initWithBrowser:(Browser*)browser - (id)initWithBrowser:(Browser*)browser
anchoredAt:(NSPoint)point anchoredAt:(NSPoint)point
withMode:(BubbleViewMode)mode; withMode:(profiles::BubbleViewMode)mode;
@end @end
#endif // CHROME_BROWSER_UI_COCOA_PROFILES_PROFILE_CHOOSER_CONTROLLER_H_ #endif // CHROME_BROWSER_UI_COCOA_PROFILES_PROFILE_CHOOSER_CONTROLLER_H_
...@@ -278,28 +278,29 @@ class ActiveProfileObserverBridge : public AvatarMenuObserver, ...@@ -278,28 +278,29 @@ class ActiveProfileObserverBridge : public AvatarMenuObserver,
// Tokens can only be added by adding an account through the inline flow, // Tokens can only be added by adding an account through the inline flow,
// which is started from the account management view. Refresh it to show the // which is started from the account management view. Refresh it to show the
// update. // update.
BubbleViewMode viewMode = [controller_ viewMode]; profiles::BubbleViewMode viewMode = [controller_ viewMode];
if (viewMode == BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT || if (viewMode == profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT ||
viewMode == BUBBLE_VIEW_MODE_GAIA_SIGNIN || viewMode == profiles::BUBBLE_VIEW_MODE_GAIA_SIGNIN ||
viewMode == BUBBLE_VIEW_MODE_GAIA_ADD_ACCOUNT) { viewMode == profiles::BUBBLE_VIEW_MODE_GAIA_ADD_ACCOUNT) {
[controller_ [controller_ initMenuContentsWithView:
initMenuContentsWithView:BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT]; profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT];
} }
} }
virtual void OnRefreshTokenRevoked(const std::string& account_id) OVERRIDE { virtual void OnRefreshTokenRevoked(const std::string& account_id) OVERRIDE {
// Tokens can only be removed from the account management view. Refresh it // Tokens can only be removed from the account management view. Refresh it
// to show the update. // to show the update.
if ([controller_ viewMode] == BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT) if ([controller_ viewMode] == profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT)
[controller_ [controller_ initMenuContentsWithView:
initMenuContentsWithView:BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT]; profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT];
} }
// AvatarMenuObserver: // AvatarMenuObserver:
virtual void OnAvatarMenuChanged(AvatarMenu* avatar_menu) OVERRIDE { virtual void OnAvatarMenuChanged(AvatarMenu* avatar_menu) OVERRIDE {
// While the bubble is open, the avatar menu can only change from the // While the bubble is open, the avatar menu can only change from the
// profile chooser view by modifying the current profile's photo or name. // profile chooser view by modifying the current profile's photo or name.
[controller_ initMenuContentsWithView:BUBBLE_VIEW_MODE_PROFILE_CHOOSER]; [controller_
initMenuContentsWithView:profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER];
} }
// content::NotificationObserver: // content::NotificationObserver:
...@@ -663,7 +664,7 @@ class ActiveProfileObserverBridge : public AvatarMenuObserver, ...@@ -663,7 +664,7 @@ class ActiveProfileObserverBridge : public AvatarMenuObserver,
// using |linkMessageId|, and a left aligned button using |buttonMessageId|. // using |linkMessageId|, and a left aligned button using |buttonMessageId|.
// On click, the link would execute |linkAction|, and the button would execute // On click, the link would execute |linkAction|, and the button would execute
// |buttonAction|. It sets |tutorialMode_| to the given |mode|. // |buttonAction|. It sets |tutorialMode_| to the given |mode|.
- (NSView*)tutorialViewWithMode:(TutorialMode)mode - (NSView*)tutorialViewWithMode:(profiles::TutorialMode)mode
titleMessage:(int)titleMessageId titleMessage:(int)titleMessageId
contentMessage:(int)contentMessageId contentMessage:(int)contentMessageId
linkMessage:(int)linkMessageId linkMessage:(int)linkMessageId
...@@ -735,7 +736,7 @@ class ActiveProfileObserverBridge : public AvatarMenuObserver, ...@@ -735,7 +736,7 @@ class ActiveProfileObserverBridge : public AvatarMenuObserver,
@end @end
@implementation ProfileChooserController @implementation ProfileChooserController
- (BubbleViewMode) viewMode { - (profiles::BubbleViewMode) viewMode {
return viewMode_; return viewMode_;
} }
...@@ -758,11 +759,11 @@ class ActiveProfileObserverBridge : public AvatarMenuObserver, ...@@ -758,11 +759,11 @@ class ActiveProfileObserverBridge : public AvatarMenuObserver,
} }
- (IBAction)showAccountManagement:(id)sender { - (IBAction)showAccountManagement:(id)sender {
[self initMenuContentsWithView:BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT]; [self initMenuContentsWithView:profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT];
} }
- (IBAction)hideAccountManagement:(id)sender { - (IBAction)hideAccountManagement:(id)sender {
[self initMenuContentsWithView:BUBBLE_VIEW_MODE_PROFILE_CHOOSER]; [self initMenuContentsWithView:profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER];
} }
- (IBAction)lockProfile:(id)sender { - (IBAction)lockProfile:(id)sender {
...@@ -770,7 +771,7 @@ class ActiveProfileObserverBridge : public AvatarMenuObserver, ...@@ -770,7 +771,7 @@ class ActiveProfileObserverBridge : public AvatarMenuObserver,
} }
- (IBAction)showInlineSigninPage:(id)sender { - (IBAction)showInlineSigninPage:(id)sender {
[self initMenuContentsWithView:BUBBLE_VIEW_MODE_GAIA_SIGNIN]; [self initMenuContentsWithView:profiles::BUBBLE_VIEW_MODE_GAIA_SIGNIN];
} }
- (IBAction)showTabbedSigninPage:(id)sender { - (IBAction)showTabbedSigninPage:(id)sender {
...@@ -778,14 +779,15 @@ class ActiveProfileObserverBridge : public AvatarMenuObserver, ...@@ -778,14 +779,15 @@ class ActiveProfileObserverBridge : public AvatarMenuObserver,
} }
- (IBAction)addAccount:(id)sender { - (IBAction)addAccount:(id)sender {
[self initMenuContentsWithView:BUBBLE_VIEW_MODE_GAIA_ADD_ACCOUNT]; [self initMenuContentsWithView:profiles::BUBBLE_VIEW_MODE_GAIA_ADD_ACCOUNT];
} }
- (IBAction)navigateBackFromSigninPage:(id)sender { - (IBAction)navigateBackFromSigninPage:(id)sender {
std::string primaryAccount = SigninManagerFactory::GetForProfile( std::string primaryAccount = SigninManagerFactory::GetForProfile(
browser_->profile())->GetAuthenticatedUsername(); browser_->profile())->GetAuthenticatedUsername();
[self initMenuContentsWithView:primaryAccount.empty() ? [self initMenuContentsWithView:primaryAccount.empty() ?
BUBBLE_VIEW_MODE_PROFILE_CHOOSER : BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT]; profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER :
profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT];
} }
- (IBAction)showAccountRemovalView:(id)sender { - (IBAction)showAccountRemovalView:(id)sender {
...@@ -802,7 +804,7 @@ class ActiveProfileObserverBridge : public AvatarMenuObserver, ...@@ -802,7 +804,7 @@ class ActiveProfileObserverBridge : public AvatarMenuObserver,
accountIdToRemove_ = currentProfileAccounts_[tag]; accountIdToRemove_ = currentProfileAccounts_[tag];
} }
[self initMenuContentsWithView:BUBBLE_VIEW_MODE_ACCOUNT_REMOVAL]; [self initMenuContentsWithView:profiles::BUBBLE_VIEW_MODE_ACCOUNT_REMOVAL];
} }
- (IBAction)removeAccount:(id)sender { - (IBAction)removeAccount:(id)sender {
...@@ -811,7 +813,7 @@ class ActiveProfileObserverBridge : public AvatarMenuObserver, ...@@ -811,7 +813,7 @@ class ActiveProfileObserverBridge : public AvatarMenuObserver,
browser_->profile())->RevokeCredentials(accountIdToRemove_); browser_->profile())->RevokeCredentials(accountIdToRemove_);
accountIdToRemove_.clear(); accountIdToRemove_.clear();
[self initMenuContentsWithView:BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT]; [self initMenuContentsWithView:profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT];
} }
- (IBAction)openTutorialLearnMoreURL:(id)sender { - (IBAction)openTutorialLearnMoreURL:(id)sender {
...@@ -834,16 +836,16 @@ class ActiveProfileObserverBridge : public AvatarMenuObserver, ...@@ -834,16 +836,16 @@ class ActiveProfileObserverBridge : public AvatarMenuObserver,
// indeed shown for the maximum number of times. // indeed shown for the maximum number of times.
browser_->profile()->GetPrefs()->SetInteger( browser_->profile()->GetPrefs()->SetInteger(
prefs::kProfileAvatarTutorialShown, kProfileAvatarTutorialShowMax + 1); prefs::kProfileAvatarTutorialShown, kProfileAvatarTutorialShowMax + 1);
[self initMenuContentsWithView:BUBBLE_VIEW_MODE_PROFILE_CHOOSER]; [self initMenuContentsWithView:profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER];
} }
- (IBAction)showSendFeedbackTutorial:(id)sender { - (IBAction)showSendFeedbackTutorial:(id)sender {
tutorialMode_ = TUTORIAL_MODE_SEND_FEEDBACK; tutorialMode_ = profiles::TUTORIAL_MODE_SEND_FEEDBACK;
[self initMenuContentsWithView:BUBBLE_VIEW_MODE_PROFILE_CHOOSER]; [self initMenuContentsWithView:profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER];
} }
- (IBAction)showEndPreviewView:(id)sender { - (IBAction)showEndPreviewView:(id)sender {
[self initMenuContentsWithView:BUBBLE_VIEW_MODE_END_PREVIEW]; [self initMenuContentsWithView:profiles::BUBBLE_VIEW_MODE_END_PREVIEW];
} }
- (IBAction)sendFeedback:(id)sender { - (IBAction)sendFeedback:(id)sender {
...@@ -860,7 +862,7 @@ class ActiveProfileObserverBridge : public AvatarMenuObserver, ...@@ -860,7 +862,7 @@ class ActiveProfileObserverBridge : public AvatarMenuObserver,
- (id)initWithBrowser:(Browser*)browser - (id)initWithBrowser:(Browser*)browser
anchoredAt:(NSPoint)point anchoredAt:(NSPoint)point
withMode:(BubbleViewMode)mode { withMode:(profiles::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
...@@ -872,7 +874,7 @@ class ActiveProfileObserverBridge : public AvatarMenuObserver, ...@@ -872,7 +874,7 @@ class ActiveProfileObserverBridge : public AvatarMenuObserver,
anchoredAt:point])) { anchoredAt:point])) {
browser_ = browser; browser_ = browser;
viewMode_ = mode; viewMode_ = mode;
tutorialMode_ = TUTORIAL_MODE_NONE; tutorialMode_ = profiles::TUTORIAL_MODE_NONE;
observer_.reset(new ActiveProfileObserverBridge(self, browser_)); observer_.reset(new ActiveProfileObserverBridge(self, browser_));
avatarMenu_.reset(new AvatarMenu( avatarMenu_.reset(new AvatarMenu(
...@@ -893,26 +895,28 @@ class ActiveProfileObserverBridge : public AvatarMenuObserver, ...@@ -893,26 +895,28 @@ class ActiveProfileObserverBridge : public AvatarMenuObserver,
return self; return self;
} }
- (void)initMenuContentsWithView:(BubbleViewMode)viewToDisplay { - (void)initMenuContentsWithView:(profiles::BubbleViewMode)viewToDisplay {
viewMode_ = viewToDisplay; viewMode_ = viewToDisplay;
NSView* contentView = [[self window] contentView]; NSView* contentView = [[self window] contentView];
[contentView setSubviews:[NSArray array]]; [contentView setSubviews:[NSArray array]];
NSView* subView; NSView* subView;
switch (viewMode_) { switch (viewMode_) {
case BUBBLE_VIEW_MODE_GAIA_SIGNIN: case profiles::BUBBLE_VIEW_MODE_GAIA_SIGNIN:
case BUBBLE_VIEW_MODE_GAIA_ADD_ACCOUNT: case profiles::BUBBLE_VIEW_MODE_GAIA_ADD_ACCOUNT:
case profiles::BUBBLE_VIEW_MODE_GAIA_REAUTH:
subView = [self buildGaiaEmbeddedView]; subView = [self buildGaiaEmbeddedView];
break; break;
case BUBBLE_VIEW_MODE_ACCOUNT_REMOVAL: case profiles::BUBBLE_VIEW_MODE_ACCOUNT_REMOVAL:
subView = [self buildAccountRemovalView]; subView = [self buildAccountRemovalView];
break; break;
case BUBBLE_VIEW_MODE_END_PREVIEW: case profiles::BUBBLE_VIEW_MODE_END_PREVIEW:
subView = [self buildEndPreviewView]; subView = [self buildEndPreviewView];
break; break;
case BUBBLE_VIEW_MODE_PROFILE_CHOOSER: case profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER:
case BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT: case profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT:
subView = [self buildProfileChooserView]; subView = [self buildProfileChooserView];
break;
} }
[contentView addSubview:subView]; [contentView addSubview:subView];
...@@ -936,7 +940,7 @@ class ActiveProfileObserverBridge : public AvatarMenuObserver, ...@@ -936,7 +940,7 @@ class ActiveProfileObserverBridge : public AvatarMenuObserver,
for (int i = avatarMenu_->GetNumberOfItems() - 1; i >= 0; --i) { for (int i = avatarMenu_->GetNumberOfItems() - 1; i >= 0; --i) {
const AvatarMenu::Item& item = avatarMenu_->GetItemAt(i); const AvatarMenu::Item& item = avatarMenu_->GetItemAt(i);
if (item.active) { if (item.active) {
if (viewMode_ == BUBBLE_VIEW_MODE_PROFILE_CHOOSER) if (viewMode_ == profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER)
tutorialView = [self buildPreviewTutorialIfNeeded:item]; tutorialView = [self buildPreviewTutorialIfNeeded:item];
currentProfileView = [self createCurrentProfileView:item]; currentProfileView = [self createCurrentProfileView:item];
enableLock = item.signed_in; enableLock = item.signed_in;
...@@ -964,7 +968,7 @@ class ActiveProfileObserverBridge : public AvatarMenuObserver, ...@@ -964,7 +968,7 @@ class ActiveProfileObserverBridge : public AvatarMenuObserver,
yOffset = NSMaxY([separator frame]); yOffset = NSMaxY([separator frame]);
} }
if (viewMode_ == BUBBLE_VIEW_MODE_PROFILE_CHOOSER && if (viewMode_ == profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER &&
switches::IsFastUserSwitching()) { switches::IsFastUserSwitching()) {
// Other profiles switcher. The profiles have already been sorted // Other profiles switcher. The profiles have already been sorted
// by their y-coordinate, so they can be added in the existing order. // by their y-coordinate, so they can be added in the existing order.
...@@ -978,7 +982,7 @@ class ActiveProfileObserverBridge : public AvatarMenuObserver, ...@@ -978,7 +982,7 @@ class ActiveProfileObserverBridge : public AvatarMenuObserver,
[container addSubview:separator]; [container addSubview:separator];
yOffset = NSMaxY([separator frame]); yOffset = NSMaxY([separator frame]);
} }
} else if (viewMode_ == BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT) { } else if (viewMode_ == profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT) {
NSView* currentProfileAccountsView = [self createCurrentProfileAccountsView: NSView* currentProfileAccountsView = [self createCurrentProfileAccountsView:
NSMakeRect(0, yOffset, kFixedMenuWidth, 0)]; NSMakeRect(0, yOffset, kFixedMenuWidth, 0)];
[container addSubview:currentProfileAccountsView]; [container addSubview:currentProfileAccountsView];
...@@ -1003,7 +1007,7 @@ class ActiveProfileObserverBridge : public AvatarMenuObserver, ...@@ -1003,7 +1007,7 @@ class ActiveProfileObserverBridge : public AvatarMenuObserver,
[container addSubview:tutorialView]; [container addSubview:tutorialView];
yOffset = NSMaxY([tutorialView frame]); yOffset = NSMaxY([tutorialView frame]);
} else { } else {
tutorialMode_ = TUTORIAL_MODE_NONE; tutorialMode_ = profiles::TUTORIAL_MODE_NONE;
} }
[container setFrameSize:NSMakeSize(kFixedMenuWidth, yOffset)]; [container setFrameSize:NSMakeSize(kFixedMenuWidth, yOffset)];
...@@ -1012,7 +1016,7 @@ class ActiveProfileObserverBridge : public AvatarMenuObserver, ...@@ -1012,7 +1016,7 @@ class ActiveProfileObserverBridge : public AvatarMenuObserver,
- (NSView*)buildPreviewTutorialIfNeeded:(const AvatarMenu::Item&)item { - (NSView*)buildPreviewTutorialIfNeeded:(const AvatarMenu::Item&)item {
if (!switches::IsNewProfileManagement()) { if (!switches::IsNewProfileManagement()) {
return [self tutorialViewWithMode:TUTORIAL_MODE_ENABLE_PREVIEW return [self tutorialViewWithMode:profiles::TUTORIAL_MODE_ENABLE_PREVIEW
titleMessage:IDS_PROFILES_PREVIEW_TUTORIAL_TITLE titleMessage:IDS_PROFILES_PREVIEW_TUTORIAL_TITLE
contentMessage:IDS_PROFILES_PREVIEW_TUTORIAL_CONTENT_TEXT contentMessage:IDS_PROFILES_PREVIEW_TUTORIAL_CONTENT_TEXT
linkMessage:IDS_PROFILES_PROFILE_TUTORIAL_LEARN_MORE linkMessage:IDS_PROFILES_PROFILE_TUTORIAL_LEARN_MORE
...@@ -1025,8 +1029,8 @@ class ActiveProfileObserverBridge : public AvatarMenuObserver, ...@@ -1025,8 +1029,8 @@ class ActiveProfileObserverBridge : public AvatarMenuObserver,
if (!switches::IsNewProfileManagementPreviewEnabled()) if (!switches::IsNewProfileManagementPreviewEnabled())
return nil; return nil;
if (tutorialMode_ == TUTORIAL_MODE_SEND_FEEDBACK) { if (tutorialMode_ == profiles::TUTORIAL_MODE_SEND_FEEDBACK) {
return [self tutorialViewWithMode:TUTORIAL_MODE_SEND_FEEDBACK return [self tutorialViewWithMode:profiles::TUTORIAL_MODE_SEND_FEEDBACK
titleMessage:IDS_PROFILES_FEEDBACK_TUTORIAL_TITLE titleMessage:IDS_PROFILES_FEEDBACK_TUTORIAL_TITLE
contentMessage: contentMessage:
IDS_PROFILES_FEEDBACK_TUTORIAL_CONTENT_TEXT IDS_PROFILES_FEEDBACK_TUTORIAL_CONTENT_TEXT
...@@ -1043,14 +1047,14 @@ class ActiveProfileObserverBridge : public AvatarMenuObserver, ...@@ -1043,14 +1047,14 @@ class ActiveProfileObserverBridge : public AvatarMenuObserver,
if (showCount > kProfileAvatarTutorialShowMax) if (showCount > kProfileAvatarTutorialShowMax)
return nil; return nil;
if (tutorialMode_ != TUTORIAL_MODE_WELCOME) { if (tutorialMode_ != profiles::TUTORIAL_MODE_WELCOME) {
if (showCount == kProfileAvatarTutorialShowMax) if (showCount == kProfileAvatarTutorialShowMax)
return nil; return nil;
profile->GetPrefs()->SetInteger( profile->GetPrefs()->SetInteger(
prefs::kProfileAvatarTutorialShown, showCount + 1); prefs::kProfileAvatarTutorialShown, showCount + 1);
} }
return [self tutorialViewWithMode:TUTORIAL_MODE_WELCOME return [self tutorialViewWithMode:profiles::TUTORIAL_MODE_WELCOME
titleMessage:IDS_PROFILES_PREVIEW_ENABLED_TUTORIAL_TITLE titleMessage:IDS_PROFILES_PREVIEW_ENABLED_TUTORIAL_TITLE
contentMessage: contentMessage:
IDS_PROFILES_PREVIEW_ENABLED_TUTORIAL_CONTENT_TEXT IDS_PROFILES_PREVIEW_ENABLED_TUTORIAL_CONTENT_TEXT
...@@ -1060,7 +1064,7 @@ class ActiveProfileObserverBridge : public AvatarMenuObserver, ...@@ -1060,7 +1064,7 @@ class ActiveProfileObserverBridge : public AvatarMenuObserver,
buttonAction:@selector(dismissTutorial:)]; buttonAction:@selector(dismissTutorial:)];
} }
- (NSView*)tutorialViewWithMode:(TutorialMode)mode - (NSView*)tutorialViewWithMode:(profiles::TutorialMode)mode
titleMessage:(int)titleMessageId titleMessage:(int)titleMessageId
contentMessage:(int)contentMessageId contentMessage:(int)contentMessageId
linkMessage:(int)linkMessageId linkMessage:(int)linkMessageId
...@@ -1242,10 +1246,11 @@ class ActiveProfileObserverBridge : public AvatarMenuObserver, ...@@ -1242,10 +1246,11 @@ class ActiveProfileObserverBridge : public AvatarMenuObserver,
if (item.signed_in) { if (item.signed_in) {
if (switches::IsNewProfileManagement()) { if (switches::IsNewProfileManagement()) {
NSString* linkTitle = l10n_util::GetNSString( NSString* linkTitle = l10n_util::GetNSString(
viewMode_ == BUBBLE_VIEW_MODE_PROFILE_CHOOSER ? viewMode_ == profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER ?
IDS_PROFILES_PROFILE_MANAGE_ACCOUNTS_BUTTON : IDS_PROFILES_PROFILE_MANAGE_ACCOUNTS_BUTTON :
IDS_PROFILES_PROFILE_HIDE_MANAGE_ACCOUNTS_BUTTON); IDS_PROFILES_PROFILE_HIDE_MANAGE_ACCOUNTS_BUTTON);
SEL linkSelector = (viewMode_ == BUBBLE_VIEW_MODE_PROFILE_CHOOSER) ? SEL linkSelector =
(viewMode_ == profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER) ?
@selector(showAccountManagement:) : @selector(hideAccountManagement:); @selector(showAccountManagement:) : @selector(hideAccountManagement:);
link = [self linkButtonWithTitle:linkTitle link = [self linkButtonWithTitle:linkTitle
frameOrigin:rect.origin frameOrigin:rect.origin
...@@ -1439,7 +1444,8 @@ class ActiveProfileObserverBridge : public AvatarMenuObserver, ...@@ -1439,7 +1444,8 @@ class ActiveProfileObserverBridge : public AvatarMenuObserver,
[[NSView alloc] initWithFrame:NSZeroRect]); [[NSView alloc] initWithFrame:NSZeroRect]);
CGFloat yOffset = 0; CGFloat yOffset = 0;
bool addSecondaryAccount = viewMode_ == BUBBLE_VIEW_MODE_GAIA_ADD_ACCOUNT; bool addSecondaryAccount =
viewMode_ == profiles::BUBBLE_VIEW_MODE_GAIA_ADD_ACCOUNT;
signin::Source source = addSecondaryAccount ? signin::Source source = addSecondaryAccount ?
signin::SOURCE_AVATAR_BUBBLE_ADD_ACCOUNT : signin::SOURCE_AVATAR_BUBBLE_ADD_ACCOUNT :
signin::SOURCE_AVATAR_BUBBLE_SIGN_IN; signin::SOURCE_AVATAR_BUBBLE_SIGN_IN;
......
...@@ -68,7 +68,7 @@ class ProfileChooserControllerTest : public CocoaProfileTest { ...@@ -68,7 +68,7 @@ class ProfileChooserControllerTest : public CocoaProfileTest {
controller_.reset([[ProfileChooserController alloc] controller_.reset([[ProfileChooserController alloc]
initWithBrowser:browser() initWithBrowser:browser()
anchoredAt:point anchoredAt:point
withMode:BUBBLE_VIEW_MODE_PROFILE_CHOOSER]); withMode:profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER]);
[controller_ showWindow:nil]; [controller_ showWindow:nil];
} }
...@@ -378,7 +378,8 @@ TEST_F(ProfileChooserControllerTest, AccountManagementLayout) { ...@@ -378,7 +378,8 @@ TEST_F(ProfileChooserControllerTest, AccountManagementLayout) {
UpdateCredentials(kSecondaryEmail, kLoginToken); UpdateCredentials(kSecondaryEmail, kLoginToken);
StartProfileChooserController(); StartProfileChooserController();
[controller() initMenuContentsWithView:BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT]; [controller() initMenuContentsWithView:
profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT];
NSArray* subviews = [[[controller() window] contentView] subviews]; NSArray* subviews = [[[controller() window] contentView] subviews];
EXPECT_EQ(1U, [subviews count]); EXPECT_EQ(1U, [subviews count]);
......
// Copyright 2014 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_UI_PROFILE_CHOOSER_CONSTANTS_H_
#define CHROME_BROWSER_UI_PROFILE_CHOOSER_CONSTANTS_H_
namespace profiles {
// Different views that can be displayed in the profile chooser bubble.
enum BubbleViewMode {
// Shows a "fast profile switcher" view.
BUBBLE_VIEW_MODE_PROFILE_CHOOSER,
// Shows a list of accounts for the active user.
BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT,
// Shows a web view for primary sign in.
BUBBLE_VIEW_MODE_GAIA_SIGNIN,
// Shows a web view for adding secondary accounts.
BUBBLE_VIEW_MODE_GAIA_ADD_ACCOUNT,
// Shows a web view for reauthenticating an account.
BUBBLE_VIEW_MODE_GAIA_REAUTH,
// Shows a view for confirming account removal.
BUBBLE_VIEW_MODE_ACCOUNT_REMOVAL,
// Shows a view for ending new profile management preview.
BUBBLE_VIEW_MODE_END_PREVIEW,
};
// Tutorial modes that can be displayed in the profile chooser bubble.
enum TutorialMode {
TUTORIAL_MODE_NONE, // No tutorial card shown.
TUTORIAL_MODE_ENABLE_PREVIEW, // The enable-mirror-preview tutorial shown.
TUTORIAL_MODE_WELCOME, // The welcome-to-mirror tutorial shown.
TUTORIAL_MODE_SEND_FEEDBACK, // The send-feedback tutorial shown.
};
}; // namespace profiles
#endif // CHROME_BROWSER_UI_PROFILE_CHOOSER_CONSTANTS_H_
...@@ -2390,19 +2390,19 @@ void BrowserView::ShowAvatarBubbleFromAvatarButton(AvatarBubbleMode mode) { ...@@ -2390,19 +2390,19 @@ void BrowserView::ShowAvatarBubbleFromAvatarButton(AvatarBubbleMode mode) {
views::View::ConvertPointToScreen(button, &origin); views::View::ConvertPointToScreen(button, &origin);
gfx::Rect bounds(origin, size()); gfx::Rect bounds(origin, size());
ProfileChooserView::BubbleViewMode view_mode; profiles::BubbleViewMode view_mode;
switch (mode) { switch (mode) {
case AVATAR_BUBBLE_MODE_ACCOUNT_MANAGEMENT: case AVATAR_BUBBLE_MODE_ACCOUNT_MANAGEMENT:
view_mode = ProfileChooserView::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT; view_mode = profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT;
break; break;
case AVATAR_BUBBLE_MODE_SIGNIN: case AVATAR_BUBBLE_MODE_SIGNIN:
view_mode = ProfileChooserView::BUBBLE_VIEW_MODE_GAIA_SIGNIN; view_mode = profiles::BUBBLE_VIEW_MODE_GAIA_SIGNIN;
break; break;
case AVATAR_BUBBLE_MODE_REAUTH: case AVATAR_BUBBLE_MODE_REAUTH:
view_mode = ProfileChooserView::BUBBLE_VIEW_MODE_GAIA_REAUTH; view_mode = profiles::BUBBLE_VIEW_MODE_GAIA_REAUTH;
break; break;
default: default:
view_mode = ProfileChooserView::BUBBLE_VIEW_MODE_PROFILE_CHOOSER; view_mode = profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER;
break; break;
} }
......
...@@ -415,7 +415,7 @@ bool ProfileChooserView::close_on_deactivate_for_testing_ = true; ...@@ -415,7 +415,7 @@ bool ProfileChooserView::close_on_deactivate_for_testing_ = true;
// static // static
void ProfileChooserView::ShowBubble( void ProfileChooserView::ShowBubble(
BubbleViewMode view_mode, profiles::BubbleViewMode view_mode,
views::View* anchor_view, views::View* anchor_view,
views::BubbleBorder::Arrow arrow, views::BubbleBorder::Arrow arrow,
views::BubbleBorder::BubbleAlignment border_alignment, views::BubbleBorder::BubbleAlignment border_alignment,
...@@ -448,11 +448,11 @@ ProfileChooserView::ProfileChooserView(views::View* anchor_view, ...@@ -448,11 +448,11 @@ ProfileChooserView::ProfileChooserView(views::View* anchor_view,
views::BubbleBorder::Arrow arrow, views::BubbleBorder::Arrow arrow,
const gfx::Rect& anchor_rect, const gfx::Rect& anchor_rect,
Browser* browser, Browser* browser,
BubbleViewMode view_mode) profiles::BubbleViewMode view_mode)
: BubbleDelegateView(anchor_view, arrow), : BubbleDelegateView(anchor_view, arrow),
browser_(browser), browser_(browser),
view_mode_(view_mode), view_mode_(view_mode),
tutorial_mode_(TUTORIAL_MODE_NONE) { tutorial_mode_(profiles::TUTORIAL_MODE_NONE) {
// Reset the default margins inherited from the BubbleDelegateView. // Reset the default margins inherited from the BubbleDelegateView.
set_margins(gfx::Insets()); set_margins(gfx::Insets());
...@@ -499,15 +499,15 @@ void ProfileChooserView::ResetView() { ...@@ -499,15 +499,15 @@ void ProfileChooserView::ResetView() {
open_other_profile_indexes_map_.clear(); open_other_profile_indexes_map_.clear();
delete_account_button_map_.clear(); delete_account_button_map_.clear();
reauth_account_button_map_.clear(); reauth_account_button_map_.clear();
tutorial_mode_ = TUTORIAL_MODE_NONE; tutorial_mode_ = profiles::TUTORIAL_MODE_NONE;
} }
void ProfileChooserView::Init() { void ProfileChooserView::Init() {
// If view mode is PROFILE_CHOOSER but there is an auth error, force // If view mode is PROFILE_CHOOSER but there is an auth error, force
// ACCOUNT_MANAGEMENT mode. // ACCOUNT_MANAGEMENT mode.
if (view_mode_ == BUBBLE_VIEW_MODE_PROFILE_CHOOSER && if (view_mode_ == profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER &&
HasAuthError(browser_->profile())) { HasAuthError(browser_->profile())) {
view_mode_ = BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT; view_mode_ = profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT;
} }
ShowView(view_mode_, avatar_menu_.get()); ShowView(view_mode_, avatar_menu_.get());
...@@ -518,40 +518,40 @@ void ProfileChooserView::OnAvatarMenuChanged( ...@@ -518,40 +518,40 @@ void ProfileChooserView::OnAvatarMenuChanged(
// Refresh the view with the new menu. We can't just update the local copy // Refresh the view with the new menu. We can't just update the local copy
// as this may have been triggered by a sign out action, in which case // as this may have been triggered by a sign out action, in which case
// the view is being destroyed. // the view is being destroyed.
ShowView(BUBBLE_VIEW_MODE_PROFILE_CHOOSER, avatar_menu); ShowView(profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER, avatar_menu);
} }
void ProfileChooserView::OnRefreshTokenAvailable( void ProfileChooserView::OnRefreshTokenAvailable(
const std::string& account_id) { const std::string& account_id) {
// Refresh the account management view when a new account is added to the // Refresh the account management view when a new account is added to the
// profile. // profile.
if (view_mode_ == BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT || if (view_mode_ == profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT ||
view_mode_ == BUBBLE_VIEW_MODE_GAIA_SIGNIN || view_mode_ == profiles::BUBBLE_VIEW_MODE_GAIA_SIGNIN ||
view_mode_ == BUBBLE_VIEW_MODE_GAIA_ADD_ACCOUNT || view_mode_ == profiles::BUBBLE_VIEW_MODE_GAIA_ADD_ACCOUNT ||
view_mode_ == BUBBLE_VIEW_MODE_GAIA_REAUTH) { view_mode_ == profiles::BUBBLE_VIEW_MODE_GAIA_REAUTH) {
ShowView(BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT, avatar_menu_.get()); ShowView(profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT, avatar_menu_.get());
} }
} }
void ProfileChooserView::OnRefreshTokenRevoked(const std::string& account_id) { void ProfileChooserView::OnRefreshTokenRevoked(const std::string& account_id) {
// Refresh the account management view when an account is removed from the // Refresh the account management view when an account is removed from the
// profile. // profile.
if (view_mode_ == BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT) if (view_mode_ == profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT)
ShowView(BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT, avatar_menu_.get()); ShowView(profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT, avatar_menu_.get());
} }
void ProfileChooserView::ShowView(BubbleViewMode view_to_display, void ProfileChooserView::ShowView(profiles::BubbleViewMode view_to_display,
AvatarMenu* avatar_menu) { AvatarMenu* avatar_menu) {
// The account management view should only be displayed if the active profile // The account management view should only be displayed if the active profile
// is signed in. // is signed in.
if (view_to_display == BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT) { if (view_to_display == profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT) {
const AvatarMenu::Item& active_item = avatar_menu->GetItemAt( const AvatarMenu::Item& active_item = avatar_menu->GetItemAt(
avatar_menu->GetActiveProfileIndex()); avatar_menu->GetActiveProfileIndex());
DCHECK(active_item.signed_in); DCHECK(active_item.signed_in);
} }
// Records the last tutorial mode. // Records the last tutorial mode.
TutorialMode last_tutorial_mode = tutorial_mode_; profiles::TutorialMode last_tutorial_mode = tutorial_mode_;
ResetView(); ResetView();
RemoveAllChildViews(true); RemoveAllChildViews(true);
view_mode_ = view_to_display; view_mode_ = view_to_display;
...@@ -559,17 +559,17 @@ void ProfileChooserView::ShowView(BubbleViewMode view_to_display, ...@@ -559,17 +559,17 @@ void ProfileChooserView::ShowView(BubbleViewMode view_to_display,
views::GridLayout* layout; views::GridLayout* layout;
views::View* sub_view; views::View* sub_view;
switch (view_mode_) { switch (view_mode_) {
case BUBBLE_VIEW_MODE_GAIA_SIGNIN: case profiles::BUBBLE_VIEW_MODE_GAIA_SIGNIN:
case BUBBLE_VIEW_MODE_GAIA_ADD_ACCOUNT: case profiles::BUBBLE_VIEW_MODE_GAIA_ADD_ACCOUNT:
case BUBBLE_VIEW_MODE_GAIA_REAUTH: case profiles::BUBBLE_VIEW_MODE_GAIA_REAUTH:
layout = CreateSingleColumnLayout(this, kFixedGaiaViewWidth); layout = CreateSingleColumnLayout(this, kFixedGaiaViewWidth);
sub_view = CreateGaiaSigninView(); sub_view = CreateGaiaSigninView();
break; break;
case BUBBLE_VIEW_MODE_ACCOUNT_REMOVAL: case profiles::BUBBLE_VIEW_MODE_ACCOUNT_REMOVAL:
layout = CreateSingleColumnLayout(this, kFixedAccountRemovalViewWidth); layout = CreateSingleColumnLayout(this, kFixedAccountRemovalViewWidth);
sub_view = CreateAccountRemovalView(); sub_view = CreateAccountRemovalView();
break; break;
case BUBBLE_VIEW_MODE_END_PREVIEW: case profiles::BUBBLE_VIEW_MODE_END_PREVIEW:
layout = CreateSingleColumnLayout(this, kFixedEndPreviewViewWidth); layout = CreateSingleColumnLayout(this, kFixedEndPreviewViewWidth);
sub_view = CreateEndPreviewView(); sub_view = CreateEndPreviewView();
break; break;
...@@ -618,7 +618,7 @@ void ProfileChooserView::ButtonPressed(views::Button* sender, ...@@ -618,7 +618,7 @@ void ProfileChooserView::ButtonPressed(views::Button* sender,
ProfileMetrics::LogProfileUpgradeEnrollment( ProfileMetrics::LogProfileUpgradeEnrollment(
ProfileMetrics::PROFILE_ENROLLMENT_CLOSE_WELCOME_CARD); ProfileMetrics::PROFILE_ENROLLMENT_CLOSE_WELCOME_CARD);
ShowView(BUBBLE_VIEW_MODE_PROFILE_CHOOSER, avatar_menu_.get()); ShowView(profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER, avatar_menu_.get());
} else if (sender == tutorial_enable_new_profile_management_button_) { } else if (sender == tutorial_enable_new_profile_management_button_) {
ProfileMetrics::LogProfileUpgradeEnrollment( ProfileMetrics::LogProfileUpgradeEnrollment(
ProfileMetrics::PROFILE_ENROLLMENT_ACCEPT_NEW_PROFILE_MGMT); ProfileMetrics::PROFILE_ENROLLMENT_ACCEPT_NEW_PROFILE_MGMT);
...@@ -627,17 +627,18 @@ void ProfileChooserView::ButtonPressed(views::Button* sender, ...@@ -627,17 +627,18 @@ void ProfileChooserView::ButtonPressed(views::Button* sender,
RemoveAccount(); RemoveAccount();
} else if (sender == account_removal_cancel_button_) { } else if (sender == account_removal_cancel_button_) {
account_id_to_remove_.clear(); account_id_to_remove_.clear();
ShowView(BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT, avatar_menu_.get()); ShowView(profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT, avatar_menu_.get());
} else if (sender == gaia_signin_cancel_button_) { } else if (sender == gaia_signin_cancel_button_) {
std::string primary_account = std::string primary_account =
SigninManagerFactory::GetForProfile(browser_->profile())-> SigninManagerFactory::GetForProfile(browser_->profile())->
GetAuthenticatedUsername(); GetAuthenticatedUsername();
ShowView(primary_account.empty() ? BUBBLE_VIEW_MODE_PROFILE_CHOOSER : ShowView(primary_account.empty() ?
BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT, profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER :
profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT,
avatar_menu_.get()); avatar_menu_.get());
} else if (sender == question_mark_button_) { } else if (sender == question_mark_button_) {
tutorial_mode_ = TUTORIAL_MODE_SEND_FEEDBACK; tutorial_mode_ = profiles::TUTORIAL_MODE_SEND_FEEDBACK;
ShowView(BUBBLE_VIEW_MODE_PROFILE_CHOOSER, avatar_menu_.get()); ShowView(profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER, avatar_menu_.get());
} else if (sender == tutorial_send_feedback_button_) { } else if (sender == tutorial_send_feedback_button_) {
ProfileMetrics::LogProfileUpgradeEnrollment( ProfileMetrics::LogProfileUpgradeEnrollment(
ProfileMetrics::PROFILE_ENROLLMENT_SEND_FEEDBACK); ProfileMetrics::PROFILE_ENROLLMENT_SEND_FEEDBACK);
...@@ -647,8 +648,8 @@ void ProfileChooserView::ButtonPressed(views::Button* sender, ...@@ -647,8 +648,8 @@ void ProfileChooserView::ButtonPressed(views::Button* sender,
ProfileMetrics::PROFILE_ENROLLMENT_DISABLE_NEW_PROFILE_MGMT); ProfileMetrics::PROFILE_ENROLLMENT_DISABLE_NEW_PROFILE_MGMT);
profiles::DisableNewProfileManagementPreview(); profiles::DisableNewProfileManagementPreview();
} else if (sender == end_preview_cancel_button_) { } else if (sender == end_preview_cancel_button_) {
tutorial_mode_ = TUTORIAL_MODE_SEND_FEEDBACK; tutorial_mode_ = profiles::TUTORIAL_MODE_SEND_FEEDBACK;
ShowView(BUBBLE_VIEW_MODE_PROFILE_CHOOSER, avatar_menu_.get()); ShowView(profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER, avatar_menu_.get());
} else if (current_profile_photo_ && } else if (current_profile_photo_ &&
sender == current_profile_photo_->change_photo_button()) { sender == current_profile_photo_->change_photo_button()) {
avatar_menu_->EditProfile(avatar_menu_->GetActiveProfileIndex()); avatar_menu_->EditProfile(avatar_menu_->GetActiveProfileIndex());
...@@ -656,7 +657,7 @@ void ProfileChooserView::ButtonPressed(views::Button* sender, ...@@ -656,7 +657,7 @@ void ProfileChooserView::ButtonPressed(views::Button* sender,
// Only show the inline signin if the new UI flag is flipped. Otherwise, // Only show the inline signin if the new UI flag is flipped. Otherwise,
// use the tab signin page. // use the tab signin page.
if (switches::IsNewProfileManagement()) if (switches::IsNewProfileManagement())
ShowView(BUBBLE_VIEW_MODE_GAIA_SIGNIN, avatar_menu_.get()); ShowView(profiles::BUBBLE_VIEW_MODE_GAIA_SIGNIN, avatar_menu_.get());
else else
chrome::ShowBrowserSignin(browser_, signin::SOURCE_MENU); chrome::ShowBrowserSignin(browser_, signin::SOURCE_MENU);
} else { } else {
...@@ -675,11 +676,12 @@ void ProfileChooserView::ButtonPressed(views::Button* sender, ...@@ -675,11 +676,12 @@ void ProfileChooserView::ButtonPressed(views::Button* sender,
delete_account_button_map_.find(sender); delete_account_button_map_.find(sender);
if (account_match != delete_account_button_map_.end()) { if (account_match != delete_account_button_map_.end()) {
account_id_to_remove_ = account_match->second; account_id_to_remove_ = account_match->second;
ShowView(BUBBLE_VIEW_MODE_ACCOUNT_REMOVAL, avatar_menu_.get()); ShowView(profiles::BUBBLE_VIEW_MODE_ACCOUNT_REMOVAL,
avatar_menu_.get());
} else { } else {
account_match = reauth_account_button_map_.find(sender); account_match = reauth_account_button_map_.find(sender);
DCHECK(account_match != reauth_account_button_map_.end()); DCHECK(account_match != reauth_account_button_map_.end());
ShowView(BUBBLE_VIEW_MODE_GAIA_REAUTH, avatar_menu_.get()); ShowView(profiles::BUBBLE_VIEW_MODE_GAIA_REAUTH, avatar_menu_.get());
} }
} }
} }
...@@ -694,7 +696,7 @@ void ProfileChooserView::RemoveAccount() { ...@@ -694,7 +696,7 @@ void ProfileChooserView::RemoveAccount() {
oauth2_token_service->RevokeCredentials(account_id_to_remove_); oauth2_token_service->RevokeCredentials(account_id_to_remove_);
account_id_to_remove_.clear(); account_id_to_remove_.clear();
ShowView(BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT, avatar_menu_.get()); ShowView(profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT, avatar_menu_.get());
} }
void ProfileChooserView::LinkClicked(views::Link* sender, int event_flags) { void ProfileChooserView::LinkClicked(views::Link* sender, int event_flags) {
...@@ -703,12 +705,12 @@ void ProfileChooserView::LinkClicked(views::Link* sender, int event_flags) { ...@@ -703,12 +705,12 @@ void ProfileChooserView::LinkClicked(views::Link* sender, int event_flags) {
// depending on which view it is displayed. ShowView() will DCHECK if // depending on which view it is displayed. ShowView() will DCHECK if
// the account management view is displayed for non signed-in users. // the account management view is displayed for non signed-in users.
ShowView( ShowView(
view_mode_ == BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT ? view_mode_ == profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT ?
BUBBLE_VIEW_MODE_PROFILE_CHOOSER : profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER :
BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT, profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT,
avatar_menu_.get()); avatar_menu_.get());
} else if (sender == add_account_link_) { } else if (sender == add_account_link_) {
ShowView(BUBBLE_VIEW_MODE_GAIA_ADD_ACCOUNT, avatar_menu_.get()); ShowView(profiles::BUBBLE_VIEW_MODE_GAIA_ADD_ACCOUNT, avatar_menu_.get());
} else if (sender == tutorial_learn_more_link_) { } else if (sender == tutorial_learn_more_link_) {
ProfileMetrics::LogProfileUpgradeEnrollment( ProfileMetrics::LogProfileUpgradeEnrollment(
ProfileMetrics::PROFILE_ENROLLMENT_LAUNCH_LEARN_MORE); ProfileMetrics::PROFILE_ENROLLMENT_LAUNCH_LEARN_MORE);
...@@ -722,7 +724,7 @@ void ProfileChooserView::LinkClicked(views::Link* sender, int event_flags) { ...@@ -722,7 +724,7 @@ void ProfileChooserView::LinkClicked(views::Link* sender, int event_flags) {
chrome::Navigate(&params); chrome::Navigate(&params);
} else { } else {
DCHECK(sender == tutorial_end_preview_link_); DCHECK(sender == tutorial_end_preview_link_);
ShowView(BUBBLE_VIEW_MODE_END_PREVIEW, avatar_menu_.get()); ShowView(profiles::BUBBLE_VIEW_MODE_END_PREVIEW, avatar_menu_.get());
} }
} }
...@@ -762,7 +764,7 @@ bool ProfileChooserView::HandleKeyEvent(views::Textfield* sender, ...@@ -762,7 +764,7 @@ bool ProfileChooserView::HandleKeyEvent(views::Textfield* sender,
views::View* ProfileChooserView::CreateProfileChooserView( views::View* ProfileChooserView::CreateProfileChooserView(
AvatarMenu* avatar_menu, AvatarMenu* avatar_menu,
TutorialMode last_tutorial_mode) { profiles::TutorialMode last_tutorial_mode) {
// TODO(guohui, noms): the view should be customized based on whether new // TODO(guohui, noms): the view should be customized based on whether new
// profile management preview is enabled or not. // profile management preview is enabled or not.
...@@ -780,12 +782,13 @@ views::View* ProfileChooserView::CreateProfileChooserView( ...@@ -780,12 +782,13 @@ views::View* ProfileChooserView::CreateProfileChooserView(
if (item.active) { if (item.active) {
option_buttons_view = CreateOptionsView(item.signed_in); option_buttons_view = CreateOptionsView(item.signed_in);
current_profile_view = CreateCurrentProfileView(item, false); current_profile_view = CreateCurrentProfileView(item, false);
if (view_mode_ == BUBBLE_VIEW_MODE_PROFILE_CHOOSER) { if (view_mode_ == profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER) {
if (is_new_profile_management) { if (is_new_profile_management) {
tutorial_view = last_tutorial_mode == TUTORIAL_MODE_SEND_FEEDBACK ? tutorial_view =
last_tutorial_mode == profiles::TUTORIAL_MODE_SEND_FEEDBACK ?
CreateSendPreviewFeedbackView() : CreateSendPreviewFeedbackView() :
CreatePreviewEnabledTutorialView( CreatePreviewEnabledTutorialView(
item, last_tutorial_mode == TUTORIAL_MODE_PREVIEW_ENABLED); item, last_tutorial_mode == profiles::TUTORIAL_MODE_WELCOME);
} else { } else {
tutorial_view = CreateNewProfileManagementPreviewView(); tutorial_view = CreateNewProfileManagementPreviewView();
} }
...@@ -817,7 +820,7 @@ views::View* ProfileChooserView::CreateProfileChooserView( ...@@ -817,7 +820,7 @@ views::View* ProfileChooserView::CreateProfileChooserView(
layout->StartRow(1, 0); layout->StartRow(1, 0);
layout->AddView(current_profile_view); layout->AddView(current_profile_view);
if (view_mode_ == BUBBLE_VIEW_MODE_PROFILE_CHOOSER) { if (view_mode_ == profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER) {
layout->StartRow(1, 0); layout->StartRow(1, 0);
if (switches::IsFastUserSwitching()) if (switches::IsFastUserSwitching())
layout->AddView(CreateOtherProfilesView(other_profiles)); layout->AddView(CreateOtherProfilesView(other_profiles));
...@@ -862,7 +865,7 @@ views::View* ProfileChooserView::CreatePreviewEnabledTutorialView( ...@@ -862,7 +865,7 @@ views::View* ProfileChooserView::CreatePreviewEnabledTutorialView(
} }
return CreateTutorialView( return CreateTutorialView(
TUTORIAL_MODE_PREVIEW_ENABLED, profiles::TUTORIAL_MODE_WELCOME,
l10n_util::GetStringUTF16(IDS_PROFILES_PREVIEW_ENABLED_TUTORIAL_TITLE), l10n_util::GetStringUTF16(IDS_PROFILES_PREVIEW_ENABLED_TUTORIAL_TITLE),
l10n_util::GetStringUTF16( l10n_util::GetStringUTF16(
IDS_PROFILES_PREVIEW_ENABLED_TUTORIAL_CONTENT_TEXT), IDS_PROFILES_PREVIEW_ENABLED_TUTORIAL_CONTENT_TEXT),
...@@ -874,7 +877,7 @@ views::View* ProfileChooserView::CreatePreviewEnabledTutorialView( ...@@ -874,7 +877,7 @@ views::View* ProfileChooserView::CreatePreviewEnabledTutorialView(
views::View* ProfileChooserView::CreateSendPreviewFeedbackView() { views::View* ProfileChooserView::CreateSendPreviewFeedbackView() {
return CreateTutorialView( return CreateTutorialView(
TUTORIAL_MODE_SEND_FEEDBACK, profiles::TUTORIAL_MODE_SEND_FEEDBACK,
l10n_util::GetStringUTF16(IDS_PROFILES_FEEDBACK_TUTORIAL_TITLE), l10n_util::GetStringUTF16(IDS_PROFILES_FEEDBACK_TUTORIAL_TITLE),
l10n_util::GetStringUTF16( l10n_util::GetStringUTF16(
IDS_PROFILES_FEEDBACK_TUTORIAL_CONTENT_TEXT), IDS_PROFILES_FEEDBACK_TUTORIAL_CONTENT_TEXT),
...@@ -885,7 +888,7 @@ views::View* ProfileChooserView::CreateSendPreviewFeedbackView() { ...@@ -885,7 +888,7 @@ views::View* ProfileChooserView::CreateSendPreviewFeedbackView() {
} }
views::View* ProfileChooserView::CreateTutorialView( views::View* ProfileChooserView::CreateTutorialView(
TutorialMode tutorial_mode, profiles::TutorialMode tutorial_mode,
const base::string16& title_text, const base::string16& title_text,
const base::string16& content_text, const base::string16& content_text,
const base::string16& link_text, const base::string16& link_text,
...@@ -1031,7 +1034,7 @@ views::View* ProfileChooserView::CreateCurrentProfileView( ...@@ -1031,7 +1034,7 @@ views::View* ProfileChooserView::CreateCurrentProfileView(
layout->StartRow(1, 0); layout->StartRow(1, 0);
if (switches::IsNewProfileManagement()) { if (switches::IsNewProfileManagement()) {
base::string16 link_title = l10n_util::GetStringUTF16( base::string16 link_title = l10n_util::GetStringUTF16(
view_mode_ == BUBBLE_VIEW_MODE_PROFILE_CHOOSER ? view_mode_ == profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER ?
IDS_PROFILES_PROFILE_MANAGE_ACCOUNTS_BUTTON : IDS_PROFILES_PROFILE_MANAGE_ACCOUNTS_BUTTON :
IDS_PROFILES_PROFILE_HIDE_MANAGE_ACCOUNTS_BUTTON); IDS_PROFILES_PROFILE_HIDE_MANAGE_ACCOUNTS_BUTTON);
manage_accounts_link_ = CreateLink(link_title, this); manage_accounts_link_ = CreateLink(link_title, this);
...@@ -1263,19 +1266,19 @@ views::View* ProfileChooserView::CreateGaiaSigninView() { ...@@ -1263,19 +1266,19 @@ views::View* ProfileChooserView::CreateGaiaSigninView() {
int message_id; int message_id;
switch (view_mode_) { switch (view_mode_) {
case BUBBLE_VIEW_MODE_GAIA_SIGNIN: case profiles::BUBBLE_VIEW_MODE_GAIA_SIGNIN:
url = signin::GetPromoURL(signin::SOURCE_AVATAR_BUBBLE_SIGN_IN, url = signin::GetPromoURL(signin::SOURCE_AVATAR_BUBBLE_SIGN_IN,
false /* auto_close */, false /* auto_close */,
true /* is_constrained */); true /* is_constrained */);
message_id = IDS_PROFILES_GAIA_SIGNIN_TITLE; message_id = IDS_PROFILES_GAIA_SIGNIN_TITLE;
break; break;
case BUBBLE_VIEW_MODE_GAIA_ADD_ACCOUNT: case profiles::BUBBLE_VIEW_MODE_GAIA_ADD_ACCOUNT:
url = signin::GetPromoURL(signin::SOURCE_AVATAR_BUBBLE_ADD_ACCOUNT, url = signin::GetPromoURL(signin::SOURCE_AVATAR_BUBBLE_ADD_ACCOUNT,
false /* auto_close */, false /* auto_close */,
true /* is_constrained */); true /* is_constrained */);
message_id = IDS_PROFILES_GAIA_ADD_ACCOUNT_TITLE; message_id = IDS_PROFILES_GAIA_ADD_ACCOUNT_TITLE;
break; break;
case BUBBLE_VIEW_MODE_GAIA_REAUTH: { case profiles::BUBBLE_VIEW_MODE_GAIA_REAUTH: {
DCHECK(HasAuthError(browser_->profile())); DCHECK(HasAuthError(browser_->profile()));
url = signin::GetReauthURL(browser_->profile(), url = signin::GetReauthURL(browser_->profile(),
GetAuthErrorUsername(browser_->profile())); GetAuthErrorUsername(browser_->profile()));
...@@ -1363,7 +1366,7 @@ views::View* ProfileChooserView::CreateAccountRemovalView() { ...@@ -1363,7 +1366,7 @@ views::View* ProfileChooserView::CreateAccountRemovalView() {
views::View* ProfileChooserView::CreateNewProfileManagementPreviewView() { views::View* ProfileChooserView::CreateNewProfileManagementPreviewView() {
return CreateTutorialView( return CreateTutorialView(
TUTORIAL_MODE_ENABLE_PREVIEW, profiles::TUTORIAL_MODE_ENABLE_PREVIEW,
l10n_util::GetStringUTF16(IDS_PROFILES_PREVIEW_TUTORIAL_TITLE), l10n_util::GetStringUTF16(IDS_PROFILES_PREVIEW_TUTORIAL_TITLE),
l10n_util::GetStringUTF16(IDS_PROFILES_PREVIEW_TUTORIAL_CONTENT_TEXT), l10n_util::GetStringUTF16(IDS_PROFILES_PREVIEW_TUTORIAL_CONTENT_TEXT),
l10n_util::GetStringUTF16(IDS_PROFILES_PROFILE_TUTORIAL_LEARN_MORE), l10n_util::GetStringUTF16(IDS_PROFILES_PROFILE_TUTORIAL_LEARN_MORE),
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
#include "chrome/browser/profiles/avatar_menu.h" #include "chrome/browser/profiles/avatar_menu.h"
#include "chrome/browser/profiles/avatar_menu_observer.h" #include "chrome/browser/profiles/avatar_menu_observer.h"
#include "chrome/browser/ui/browser_window.h" #include "chrome/browser/ui/browser_window.h"
#include "chrome/browser/ui/profile_chooser_constants.h"
#include "google_apis/gaia/oauth2_token_service.h" #include "google_apis/gaia/oauth2_token_service.h"
#include "ui/views/bubble/bubble_delegate.h" #include "ui/views/bubble/bubble_delegate.h"
#include "ui/views/controls/button/button.h" #include "ui/views/controls/button/button.h"
...@@ -44,37 +45,12 @@ class ProfileChooserView : public views::BubbleDelegateView, ...@@ -44,37 +45,12 @@ class ProfileChooserView : public views::BubbleDelegateView,
public AvatarMenuObserver, public AvatarMenuObserver,
public OAuth2TokenService::Observer { public OAuth2TokenService::Observer {
public: public:
// Different views that can be displayed in the bubble.
enum BubbleViewMode {
// Shows a "fast profile switcher" view.
BUBBLE_VIEW_MODE_PROFILE_CHOOSER,
// Shows a list of accounts for the active user.
BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT,
// Shows a web view for primary sign in.
BUBBLE_VIEW_MODE_GAIA_SIGNIN,
// Shows a web view for adding secondary accounts.
BUBBLE_VIEW_MODE_GAIA_ADD_ACCOUNT,
// Shows a web view for reauthenticating an account.
BUBBLE_VIEW_MODE_GAIA_REAUTH,
// Shows a view for confirming account removal.
BUBBLE_VIEW_MODE_ACCOUNT_REMOVAL,
// Shows a view for ending new profile management preview.
BUBBLE_VIEW_MODE_END_PREVIEW
};
enum TutorialMode {
TUTORIAL_MODE_NONE, // No tutorial card shown.
TUTORIAL_MODE_ENABLE_PREVIEW, // The enable-mirror-preview tutorial shown.
TUTORIAL_MODE_PREVIEW_ENABLED, // The welcome-to-mirror tutorial shown.
TUTORIAL_MODE_SEND_FEEDBACK // The send-feedback tutorial shown.
};
// Shows the bubble if one is not already showing. This allows us to easily // Shows the bubble if one is not already showing. This allows us to easily
// make a button toggle the bubble on and off when clicked: we unconditionally // make a button toggle the bubble on and off when clicked: we unconditionally
// call this function when the button is clicked and if the bubble isn't // call this function when the button is clicked and if the bubble isn't
// showing it will appear while if it is showing, nothing will happen here and // showing it will appear while if it is showing, nothing will happen here and
// the existing bubble will auto-close due to focus loss. // the existing bubble will auto-close due to focus loss.
static void ShowBubble(BubbleViewMode view_mode, static void ShowBubble(profiles::BubbleViewMode view_mode,
views::View* anchor_view, views::View* anchor_view,
views::BubbleBorder::Arrow arrow, views::BubbleBorder::Arrow arrow,
views::BubbleBorder::BubbleAlignment border_alignment, views::BubbleBorder::BubbleAlignment border_alignment,
...@@ -102,7 +78,7 @@ class ProfileChooserView : public views::BubbleDelegateView, ...@@ -102,7 +78,7 @@ class ProfileChooserView : public views::BubbleDelegateView,
views::BubbleBorder::Arrow arrow, views::BubbleBorder::Arrow arrow,
const gfx::Rect& anchor_rect, const gfx::Rect& anchor_rect,
Browser* browser, Browser* browser,
BubbleViewMode view_mode); profiles::BubbleViewMode view_mode);
virtual ~ProfileChooserView(); virtual ~ProfileChooserView();
// views::BubbleDelegateView: // views::BubbleDelegateView:
...@@ -137,13 +113,13 @@ class ProfileChooserView : public views::BubbleDelegateView, ...@@ -137,13 +113,13 @@ class ProfileChooserView : public views::BubbleDelegateView,
void ResetView(); void ResetView();
// Shows the bubble with the |view_to_display|. // Shows the bubble with the |view_to_display|.
void ShowView(BubbleViewMode view_to_display, void ShowView(profiles::BubbleViewMode view_to_display,
AvatarMenu* avatar_menu); AvatarMenu* avatar_menu);
// Creates the profile chooser view. |tutorial_shown| indicates if the "mirror // Creates the profile chooser view. |tutorial_shown| indicates if the "mirror
// enabled" tutorial was shown or not in the last active view. // enabled" tutorial was shown or not in the last active view.
views::View* CreateProfileChooserView(AvatarMenu* avatar_menu, views::View* CreateProfileChooserView(AvatarMenu* avatar_menu,
TutorialMode last_tutorial_mode); profiles::TutorialMode last_tutorial_mode);
// Creates the main profile card for the profile |avatar_item|. |is_guest| // Creates the main profile card for the profile |avatar_item|. |is_guest|
// is used to determine whether to show any Sign in/Sign out/Manage accounts // is used to determine whether to show any Sign in/Sign out/Manage accounts
...@@ -194,7 +170,7 @@ class ProfileChooserView : public views::BubbleDelegateView, ...@@ -194,7 +170,7 @@ class ProfileChooserView : public views::BubbleDelegateView,
// sets |link| to point to the newly created link, |button| to the newly // sets |link| to point to the newly created link, |button| to the newly
// created button, and |tutorial_mode_| to the given |tutorial_mode|. // created button, and |tutorial_mode_| to the given |tutorial_mode|.
views::View* CreateTutorialView( views::View* CreateTutorialView(
TutorialMode tutorial_mode, profiles::TutorialMode tutorial_mode,
const base::string16& title_text, const base::string16& title_text,
const base::string16& content_text, const base::string16& content_text,
const base::string16& link_text, const base::string16& link_text,
...@@ -251,10 +227,10 @@ class ProfileChooserView : public views::BubbleDelegateView, ...@@ -251,10 +227,10 @@ class ProfileChooserView : public views::BubbleDelegateView,
std::string account_id_to_remove_; std::string account_id_to_remove_;
// Active view mode. // Active view mode.
BubbleViewMode view_mode_; profiles::BubbleViewMode view_mode_;
// The current tutorial mode. // The current tutorial mode.
TutorialMode tutorial_mode_; profiles::TutorialMode tutorial_mode_;
DISALLOW_COPY_AND_ASSIGN(ProfileChooserView); DISALLOW_COPY_AND_ASSIGN(ProfileChooserView);
}; };
......
...@@ -1283,6 +1283,7 @@ ...@@ -1283,6 +1283,7 @@
'browser/ui/prefs/prefs_tab_helper.cc', 'browser/ui/prefs/prefs_tab_helper.cc',
'browser/ui/prefs/prefs_tab_helper.h', 'browser/ui/prefs/prefs_tab_helper.h',
'browser/ui/process_singleton_dialog_linux.h', 'browser/ui/process_singleton_dialog_linux.h',
'browser/ui/profile_chooser_constants.h',
'browser/ui/profile_error_dialog.cc', 'browser/ui/profile_error_dialog.cc',
'browser/ui/profile_error_dialog.h', 'browser/ui/profile_error_dialog.h',
'browser/ui/protocol_dialog_delegate.h', 'browser/ui/protocol_dialog_delegate.h',
......
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