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 {
// |menuController_| will automatically release itself on close.
if (switches::IsNewAvatarMenu()) {
BubbleViewMode viewMode =
profiles::BubbleViewMode viewMode =
mode == BrowserWindow::AVATAR_BUBBLE_MODE_DEFAULT ?
BUBBLE_VIEW_MODE_PROFILE_CHOOSER :
BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT;
profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER :
profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT;
menuController_ =
[[ProfileChooserController alloc] initWithBrowser:browser_
anchoredAt:point
......
......@@ -10,6 +10,7 @@
#include <string>
#include "base/memory/scoped_ptr.h"
#include "chrome/browser/ui/profile_chooser_constants.h"
#import "chrome/browser/ui/cocoa/base_bubble_controller.h"
class AvatarMenu;
......@@ -24,31 +25,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<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
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.
scoped_ptr<AvatarMenu> avatarMenu_;
......@@ -65,10 +42,10 @@ class WebContents;
std::string accountIdToRemove_;
// Active view mode.
BubbleViewMode viewMode_;
profiles::BubbleViewMode viewMode_;
// The current tutorial mode.
TutorialMode tutorialMode_;
profiles::TutorialMode tutorialMode_;
// 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
......@@ -84,13 +61,13 @@ class WebContents;
- (id)initWithBrowser:(Browser*)browser
anchoredAt:(NSPoint)point
withMode:(BubbleViewMode)mode;
withMode:(profiles::BubbleViewMode)mode;
// 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.
- (BubbleViewMode)viewMode;
- (profiles::BubbleViewMode)viewMode;
// Switches to a given profile. |sender| is an ProfileChooserItemController.
- (IBAction)switchToProfile:(id)sender;
......@@ -135,7 +112,7 @@ class WebContents;
@interface ProfileChooserController (ExposedForTesting)
- (id)initWithBrowser:(Browser*)browser
anchoredAt:(NSPoint)point
withMode:(BubbleViewMode)mode;
withMode:(profiles::BubbleViewMode)mode;
@end
#endif // CHROME_BROWSER_UI_COCOA_PROFILES_PROFILE_CHOOSER_CONTROLLER_H_
......@@ -68,7 +68,7 @@ class ProfileChooserControllerTest : public CocoaProfileTest {
controller_.reset([[ProfileChooserController alloc]
initWithBrowser:browser()
anchoredAt:point
withMode:BUBBLE_VIEW_MODE_PROFILE_CHOOSER]);
withMode:profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER]);
[controller_ showWindow:nil];
}
......@@ -378,7 +378,8 @@ TEST_F(ProfileChooserControllerTest, AccountManagementLayout) {
UpdateCredentials(kSecondaryEmail, kLoginToken);
StartProfileChooserController();
[controller() initMenuContentsWithView:BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT];
[controller() initMenuContentsWithView:
profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT];
NSArray* subviews = [[[controller() window] contentView] subviews];
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) {
views::View::ConvertPointToScreen(button, &origin);
gfx::Rect bounds(origin, size());
ProfileChooserView::BubbleViewMode view_mode;
profiles::BubbleViewMode view_mode;
switch (mode) {
case AVATAR_BUBBLE_MODE_ACCOUNT_MANAGEMENT:
view_mode = ProfileChooserView::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT;
view_mode = profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT;
break;
case AVATAR_BUBBLE_MODE_SIGNIN:
view_mode = ProfileChooserView::BUBBLE_VIEW_MODE_GAIA_SIGNIN;
view_mode = profiles::BUBBLE_VIEW_MODE_GAIA_SIGNIN;
break;
case AVATAR_BUBBLE_MODE_REAUTH:
view_mode = ProfileChooserView::BUBBLE_VIEW_MODE_GAIA_REAUTH;
view_mode = profiles::BUBBLE_VIEW_MODE_GAIA_REAUTH;
break;
default:
view_mode = ProfileChooserView::BUBBLE_VIEW_MODE_PROFILE_CHOOSER;
view_mode = profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER;
break;
}
......
......@@ -11,6 +11,7 @@
#include "chrome/browser/profiles/avatar_menu.h"
#include "chrome/browser/profiles/avatar_menu_observer.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 "ui/views/bubble/bubble_delegate.h"
#include "ui/views/controls/button/button.h"
......@@ -44,37 +45,12 @@ class ProfileChooserView : public views::BubbleDelegateView,
public AvatarMenuObserver,
public OAuth2TokenService::Observer {
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
// 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
// showing it will appear while if it is showing, nothing will happen here and
// 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::BubbleBorder::Arrow arrow,
views::BubbleBorder::BubbleAlignment border_alignment,
......@@ -102,7 +78,7 @@ class ProfileChooserView : public views::BubbleDelegateView,
views::BubbleBorder::Arrow arrow,
const gfx::Rect& anchor_rect,
Browser* browser,
BubbleViewMode view_mode);
profiles::BubbleViewMode view_mode);
virtual ~ProfileChooserView();
// views::BubbleDelegateView:
......@@ -137,13 +113,13 @@ class ProfileChooserView : public views::BubbleDelegateView,
void ResetView();
// Shows the bubble with the |view_to_display|.
void ShowView(BubbleViewMode view_to_display,
void ShowView(profiles::BubbleViewMode view_to_display,
AvatarMenu* avatar_menu);
// Creates the profile chooser view. |tutorial_shown| indicates if the "mirror
// enabled" tutorial was shown or not in the last active view.
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|
// is used to determine whether to show any Sign in/Sign out/Manage accounts
......@@ -194,7 +170,7 @@ class ProfileChooserView : public views::BubbleDelegateView,
// sets |link| to point to the newly created link, |button| to the newly
// created button, and |tutorial_mode_| to the given |tutorial_mode|.
views::View* CreateTutorialView(
TutorialMode tutorial_mode,
profiles::TutorialMode tutorial_mode,
const base::string16& title_text,
const base::string16& content_text,
const base::string16& link_text,
......@@ -251,10 +227,10 @@ class ProfileChooserView : public views::BubbleDelegateView,
std::string account_id_to_remove_;
// Active view mode.
BubbleViewMode view_mode_;
profiles::BubbleViewMode view_mode_;
// The current tutorial mode.
TutorialMode tutorial_mode_;
profiles::TutorialMode tutorial_mode_;
DISALLOW_COPY_AND_ASSIGN(ProfileChooserView);
};
......
......@@ -1283,6 +1283,7 @@
'browser/ui/prefs/prefs_tab_helper.cc',
'browser/ui/prefs/prefs_tab_helper.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.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