diff options
author | guohui@chromium.org <guohui@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-04-14 18:33:24 +0000 |
---|---|---|
committer | guohui@chromium.org <guohui@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-04-14 18:33:24 +0000 |
commit | 379903224afd83422601c9c037267fd54fb72844 (patch) | |
tree | 56526c02a0f23be34844d41036b1fde1991b3b2a | |
parent | 1200e7e53f1a133481b82287dd88393f473227c3 (diff) | |
download | chromium_src-379903224afd83422601c9c037267fd54fb72844.zip chromium_src-379903224afd83422601c9c037267fd54fb72844.tar.gz chromium_src-379903224afd83422601c9c037267fd54fb72844.tar.bz2 |
Hook all preview tutorials together
This CL hooks all preview tutorial together, including the mirror preview tutorial, user manager tutorial and 'you are all set' avatar tutorial.
See mock 3-5 at https://docs.google.com/a/google.com/presentation/d/1UMAexroivw01osOXpnEqbQcE3FMyDkc9eZoIszm4DP4/edit#slide=id.g12716c613_09
snapshot at https://x20web.corp.google.com/users/gu/guohui/www/preview_hooked.png
BUG=358265
Review URL: https://codereview.chromium.org/226363009
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@263677 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/ui/views/frame/browser_view.cc | 13 | ||||
-rw-r--r-- | chrome/browser/ui/views/profiles/avatar_menu_button.cc | 7 | ||||
-rw-r--r-- | chrome/browser/ui/views/profiles/profile_chooser_view.cc | 206 | ||||
-rw-r--r-- | chrome/browser/ui/views/profiles/profile_chooser_view.h | 20 | ||||
-rw-r--r-- | chrome/common/profile_management_switches.cc | 16 | ||||
-rw-r--r-- | chrome/common/profile_management_switches.h | 10 |
6 files changed, 130 insertions, 142 deletions
diff --git a/chrome/browser/ui/views/frame/browser_view.cc b/chrome/browser/ui/views/frame/browser_view.cc index 4bc2151..7bca2bc 100644 --- a/chrome/browser/ui/views/frame/browser_view.cc +++ b/chrome/browser/ui/views/frame/browser_view.cc @@ -2455,15 +2455,10 @@ void BrowserView::ShowAvatarBubbleFromAvatarButton(AvatarBubbleMode mode) { views::View::ConvertPointToScreen(button, &origin); gfx::Rect bounds(origin, size()); - ProfileChooserView::BubbleViewMode view_mode; - if (mode == BrowserWindow::AVATAR_BUBBLE_MODE_ACCOUNT_MANAGEMENT) { - view_mode = ProfileChooserView::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT; - } else if (switches::IsNewProfileManagement()) { - view_mode = ProfileChooserView::BUBBLE_VIEW_MODE_PROFILE_CHOOSER; - } else { - view_mode = - ProfileChooserView::BUBBLE_VIEW_MODE_NEW_PROFILE_MANAGEMENT_PREVIEW; - } + ProfileChooserView::BubbleViewMode view_mode = + (mode == BrowserWindow::AVATAR_BUBBLE_MODE_ACCOUNT_MANAGEMENT) ? + ProfileChooserView::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT : + ProfileChooserView::BUBBLE_VIEW_MODE_PROFILE_CHOOSER; ProfileChooserView::ShowBubble( view_mode, button, views::BubbleBorder::TOP_RIGHT, views::BubbleBorder::ALIGN_EDGE_TO_ANCHOR_EDGE, bounds, browser()); diff --git a/chrome/browser/ui/views/profiles/avatar_menu_button.cc b/chrome/browser/ui/views/profiles/avatar_menu_button.cc index 15b511f..b2b1d53 100644 --- a/chrome/browser/ui/views/profiles/avatar_menu_button.cc +++ b/chrome/browser/ui/views/profiles/avatar_menu_button.cc @@ -105,16 +105,11 @@ void AvatarMenuButton::ShowAvatarBubble() { gfx::Rect bounds(origin, size()); views::BubbleBorder::Arrow arrow = button_on_right_ ? views::BubbleBorder::TOP_RIGHT : views::BubbleBorder::TOP_LEFT; - if (switches::IsNewProfileManagement()) { + if (switches::IsNewAvatarMenu()) { ProfileChooserView::ShowBubble( ProfileChooserView::BUBBLE_VIEW_MODE_PROFILE_CHOOSER, this, arrow, views::BubbleBorder::ALIGN_ARROW_TO_MID_ANCHOR, bounds, browser_); - } else if (switches::IsNewAvatarMenu()) { - ProfileChooserView::ShowBubble( - ProfileChooserView::BUBBLE_VIEW_MODE_NEW_PROFILE_MANAGEMENT_PREVIEW, - this, arrow, views::BubbleBorder::ALIGN_ARROW_TO_MID_ANCHOR, bounds, - browser_); } else { AvatarMenuBubbleView::ShowBubble( this, arrow, views::BubbleBorder::ALIGN_ARROW_TO_MID_ANCHOR, bounds, diff --git a/chrome/browser/ui/views/profiles/profile_chooser_view.cc b/chrome/browser/ui/views/profiles/profile_chooser_view.cc index c867337..eb811cf 100644 --- a/chrome/browser/ui/views/profiles/profile_chooser_view.cc +++ b/chrome/browser/ui/views/profiles/profile_chooser_view.cc @@ -355,16 +355,13 @@ void ProfileChooserView::ShowBubble( views::BubbleBorder::BubbleAlignment border_alignment, const gfx::Rect& anchor_rect, Browser* browser) { - profile_bubble_ = new ProfileChooserView( - anchor_view, arrow, anchor_rect, browser); + profile_bubble_ = new ProfileChooserView(anchor_view, arrow, anchor_rect, + browser, view_mode); views::BubbleDelegateView::CreateBubble(profile_bubble_); profile_bubble_->set_close_on_deactivate(close_on_deactivate_for_testing_); profile_bubble_->SetAlignment(border_alignment); profile_bubble_->GetWidget()->Show(); profile_bubble_->SetArrowPaintType(views::BubbleBorder::PAINT_NONE); - - if (view_mode != BUBBLE_VIEW_MODE_PROFILE_CHOOSER) - profile_bubble_->ShowView(view_mode, profile_bubble_->avatar_menu_.get()); } // static @@ -381,10 +378,11 @@ void ProfileChooserView::Hide() { ProfileChooserView::ProfileChooserView(views::View* anchor_view, views::BubbleBorder::Arrow arrow, const gfx::Rect& anchor_rect, - Browser* browser) + Browser* browser, + BubbleViewMode view_mode) : BubbleDelegateView(anchor_view, arrow), browser_(browser), - view_mode_(BUBBLE_VIEW_MODE_PROFILE_CHOOSER), + view_mode_(view_mode), tutorial_showing_(false) { // Reset the default margins inherited from the BubbleDelegateView. set_margins(gfx::Insets()); @@ -433,7 +431,7 @@ void ProfileChooserView::ResetView() { } void ProfileChooserView::Init() { - ShowView(BUBBLE_VIEW_MODE_PROFILE_CHOOSER, avatar_menu_.get()); + ShowView(view_mode_, avatar_menu_.get()); } void ProfileChooserView::OnAvatarMenuChanged( @@ -472,101 +470,32 @@ void ProfileChooserView::ShowView(BubbleViewMode view_to_display, DCHECK(active_item.signed_in); } - // Records if the tutorial card is currently shown before resetting the view. + // Records if the "mirror enabled" tutorial card is currently shown before + // resetting the view. bool tutorial_shown = tutorial_showing_; ResetView(); RemoveAllChildViews(true); view_mode_ = view_to_display; - if (view_mode_ == BUBBLE_VIEW_MODE_GAIA_SIGNIN || - view_mode_ == BUBBLE_VIEW_MODE_GAIA_ADD_ACCOUNT || - view_mode_ == BUBBLE_VIEW_MODE_ACCOUNT_REMOVAL || - view_mode_ == BUBBLE_VIEW_MODE_NEW_PROFILE_MANAGEMENT_PREVIEW) { - views::GridLayout* layout; - views::View* sub_view; - switch (view_mode_) { - case BUBBLE_VIEW_MODE_GAIA_SIGNIN: - case BUBBLE_VIEW_MODE_GAIA_ADD_ACCOUNT: - layout = CreateSingleColumnLayout(this, kFixedGaiaViewWidth); - sub_view = CreateGaiaSigninView( - view_mode_ == BUBBLE_VIEW_MODE_GAIA_ADD_ACCOUNT); - break; - case BUBBLE_VIEW_MODE_ACCOUNT_REMOVAL: - layout = CreateSingleColumnLayout(this, kFixedAccountRemovalViewWidth); - sub_view = CreateAccountRemovalView(); - break; - case BUBBLE_VIEW_MODE_NEW_PROFILE_MANAGEMENT_PREVIEW: - layout = CreateSingleColumnLayout(this, kFixedMenuWidth); - sub_view = CreateNewProfileManagementPreviewView(); - break; - default: - NOTREACHED(); - return; - } - layout->StartRow(1, 0); - layout->AddView(sub_view); - Layout(); - if (GetBubbleFrameView()) - SizeToContents(); - return; - } - - views::GridLayout* layout = CreateSingleColumnLayout(this, kFixedMenuWidth); - // Separate items into active and alternatives. - Indexes other_profiles; - views::View* tutorial_view = NULL; - views::View* current_profile_view = NULL; - views::View* current_profile_accounts = NULL; - views::View* option_buttons_view = NULL; - for (size_t i = 0; i < avatar_menu->GetNumberOfItems(); ++i) { - const AvatarMenu::Item& item = avatar_menu->GetItemAt(i); - if (item.active) { - option_buttons_view = CreateOptionsView(item.signed_in); - if (view_to_display == BUBBLE_VIEW_MODE_PROFILE_CHOOSER) { - tutorial_view = CreatePreviewEnabledTutorialView(item, tutorial_shown); - current_profile_view = CreateCurrentProfileView(item, false); - } else { - current_profile_view = CreateCurrentProfileEditableView(item); - current_profile_accounts = CreateCurrentProfileAccountsView(item); - } - } else { - other_profiles.push_back(i); - } - } - - if (tutorial_view) { - layout->StartRow(1, 0); - layout->AddView(tutorial_view); - } - - if (!current_profile_view) { - // Guest windows don't have an active profile. - current_profile_view = CreateGuestProfileView(); - option_buttons_view = CreateOptionsView(false); + views::GridLayout* layout; + views::View* sub_view; + switch (view_mode_) { + case BUBBLE_VIEW_MODE_GAIA_SIGNIN: + case BUBBLE_VIEW_MODE_GAIA_ADD_ACCOUNT: + layout = CreateSingleColumnLayout(this, kFixedGaiaViewWidth); + sub_view = CreateGaiaSigninView( + view_mode_ == BUBBLE_VIEW_MODE_GAIA_ADD_ACCOUNT); + break; + case BUBBLE_VIEW_MODE_ACCOUNT_REMOVAL: + layout = CreateSingleColumnLayout(this, kFixedAccountRemovalViewWidth); + sub_view = CreateAccountRemovalView(); + break; + default: + layout = CreateSingleColumnLayout(this, kFixedMenuWidth); + sub_view = CreateProfileChooserView(avatar_menu, tutorial_shown); } - layout->StartRow(1, 0); - layout->AddView(current_profile_view); - - if (view_to_display == BUBBLE_VIEW_MODE_PROFILE_CHOOSER) { - layout->StartRow(1, 0); - if (switches::IsFastUserSwitching()) - layout->AddView(CreateOtherProfilesView(other_profiles)); - } else { - DCHECK(current_profile_accounts); - layout->StartRow(0, 0); - layout->AddView(new views::Separator(views::Separator::HORIZONTAL)); - layout->StartRow(1, 0); - layout->AddView(current_profile_accounts); - } - - layout->StartRow(0, 0); - layout->AddView(new views::Separator(views::Separator::HORIZONTAL)); - - // Action buttons. - layout->StartRow(0, 0); - layout->AddView(option_buttons_view); - + layout->AddView(sub_view); Layout(); if (GetBubbleFrameView()) SizeToContents(); @@ -702,10 +631,77 @@ bool ProfileChooserView::HandleKeyEvent(views::Textfield* sender, return false; } +views::View* ProfileChooserView::CreateProfileChooserView( + AvatarMenu* avatar_menu, bool tutorial_shown) { + // TODO(guohui, noms): the view should be customized based on whether new + // profile management preview is enabled or not. + + views::View* view = new views::View(); + views::GridLayout* layout = CreateSingleColumnLayout(view, kFixedMenuWidth); + // Separate items into active and alternatives. + Indexes other_profiles; + views::View* tutorial_view = NULL; + views::View* current_profile_view = NULL; + views::View* current_profile_accounts = NULL; + views::View* option_buttons_view = NULL; + for (size_t i = 0; i < avatar_menu->GetNumberOfItems(); ++i) { + const AvatarMenu::Item& item = avatar_menu->GetItemAt(i); + if (item.active) { + option_buttons_view = CreateOptionsView(item.signed_in); + if (view_mode_ == BUBBLE_VIEW_MODE_PROFILE_CHOOSER) { + tutorial_view = switches::IsNewProfileManagement() ? + CreatePreviewEnabledTutorialView(item, tutorial_shown) : + CreateNewProfileManagementPreviewView(); + current_profile_view = CreateCurrentProfileView(item, false); + } else { + current_profile_view = CreateCurrentProfileEditableView(item); + current_profile_accounts = CreateCurrentProfileAccountsView(item); + } + } else { + other_profiles.push_back(i); + } + } + + if (tutorial_view) { + layout->StartRow(1, 0); + layout->AddView(tutorial_view); + } + + if (!current_profile_view) { + // Guest windows don't have an active profile. + current_profile_view = CreateGuestProfileView(); + option_buttons_view = CreateOptionsView(false); + } + + layout->StartRow(1, 0); + layout->AddView(current_profile_view); + + if (view_mode_ == BUBBLE_VIEW_MODE_PROFILE_CHOOSER) { + layout->StartRow(1, 0); + if (switches::IsFastUserSwitching()) + layout->AddView(CreateOtherProfilesView(other_profiles)); + } else { + DCHECK(current_profile_accounts); + layout->StartRow(0, 0); + layout->AddView(new views::Separator(views::Separator::HORIZONTAL)); + layout->StartRow(1, 0); + layout->AddView(current_profile_accounts); + } + + layout->StartRow(0, 0); + layout->AddView(new views::Separator(views::Separator::HORIZONTAL)); + + // Action buttons. + layout->StartRow(0, 0); + layout->AddView(option_buttons_view); + + return view; +} + views::View* ProfileChooserView::CreatePreviewEnabledTutorialView( const AvatarMenu::Item& current_avatar_item, bool tutorial_shown) { - if (!current_avatar_item.signed_in) + if (!switches::IsNewProfileManagementPreviewEnabled()) return NULL; Profile* profile = browser_->profile(); @@ -1172,23 +1168,13 @@ views::View* ProfileChooserView::CreateAccountRemovalView() { } views::View* ProfileChooserView::CreateNewProfileManagementPreviewView() { - views::View* view = new views::View(); - views::GridLayout* layout = CreateSingleColumnLayout(view, kFixedMenuWidth); - - // Adds tutorial card. - layout->StartRow(1, 0); - layout->AddView(CreateTutorialView( + return CreateTutorialView( l10n_util::GetStringUTF16(IDS_PROFILES_PREVIEW_TUTORIAL_TITLE), l10n_util::GetStringUTF16(IDS_PROFILES_PREVIEW_TUTORIAL_CONTENT_TEXT), l10n_util::GetStringUTF16(IDS_PROFILES_PROFILE_TUTORIAL_LEARN_MORE), l10n_util::GetStringUTF16(IDS_PROFILES_TUTORIAL_TRY_BUTTON), &tutorial_learn_more_link_, - &tutorial_enable_new_profile_management_button_)); - - // TODO(guohui, noms): adds the current account card and fast profile switcher - // card. - - return view; + &tutorial_enable_new_profile_management_button_); } void ProfileChooserView::EnableNewProfileManagementPreview() { @@ -1203,5 +1189,5 @@ void ProfileChooserView::EnableNewProfileManagementPreview() { CommandLine::ForCurrentProcess()->AppendSwitch( switches::kNewProfileManagement); - chrome::ShowUserManager(base::FilePath()); + chrome::ShowUserManagerWithTutorial(profiles::USER_MANAGER_TUTORIAL_OVERVIEW); } diff --git a/chrome/browser/ui/views/profiles/profile_chooser_view.h b/chrome/browser/ui/views/profiles/profile_chooser_view.h index 872bdd3..90c1d36 100644 --- a/chrome/browser/ui/views/profiles/profile_chooser_view.h +++ b/chrome/browser/ui/views/profiles/profile_chooser_view.h @@ -57,10 +57,7 @@ class ProfileChooserView : public views::BubbleDelegateView, // 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 fast profile switcher view with a tutorial card that prompts the - // user to preview new profile management. - BUBBLE_VIEW_MODE_NEW_PROFILE_MANAGEMENT_PREVIEW + BUBBLE_VIEW_MODE_ACCOUNT_REMOVAL }; // Shows the bubble if one is not already showing. This allows us to easily @@ -95,7 +92,8 @@ class ProfileChooserView : public views::BubbleDelegateView, ProfileChooserView(views::View* anchor_view, views::BubbleBorder::Arrow arrow, const gfx::Rect& anchor_rect, - Browser* browser); + Browser* browser, + BubbleViewMode view_mode); virtual ~ProfileChooserView(); // views::BubbleDelegateView: @@ -133,10 +131,15 @@ class ProfileChooserView : public views::BubbleDelegateView, void ResetView(); - // Shows either the profile chooser or the account management views. + // Shows the bubble with the |view_to_display|. void ShowView(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, + bool tutorial_shown); + // 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 // links. @@ -166,9 +169,8 @@ class ProfileChooserView : public views::BubbleDelegateView, // Removes the currently selected account and attempts to restart Chrome. void RemoveAccount(); - // Creates an avatar bubble view that shows a redesigned avatar menu with the - // same functionality as the old one, plus a tutorial card at the top - // prompting the user to try out the new profile management UI. + // Creates a a tutorial card at the top prompting the user to try out the new + // profile management UI. views::View* CreateNewProfileManagementPreviewView(); // Creates a tutorial card shown when new profile management preview is diff --git a/chrome/common/profile_management_switches.cc b/chrome/common/profile_management_switches.cc index a7fcd31..1c83744 100644 --- a/chrome/common/profile_management_switches.cc +++ b/chrome/common/profile_management_switches.cc @@ -49,14 +49,20 @@ bool IsGoogleProfileInfo() { return CheckProfileManagementFlag(switches::kGoogleProfileInfo, true); } +bool IsNewProfileManagement() { + return CheckProfileManagementFlag(switches::kNewProfileManagement, true); +} + bool IsNewAvatarMenu() { - return - CommandLine::ForCurrentProcess()->HasSwitch(switches::kNewAvatarMenu) || - IsNewProfileManagement(); + bool is_new_avatar_menu = + CommandLine::ForCurrentProcess()->HasSwitch(switches::kNewAvatarMenu); + return is_new_avatar_menu || IsNewProfileManagement(); } -bool IsNewProfileManagement() { - return CheckProfileManagementFlag(switches::kNewProfileManagement, true); +bool IsNewProfileManagementPreviewEnabled() { + bool is_new_avatar_menu = + CommandLine::ForCurrentProcess()->HasSwitch(switches::kNewAvatarMenu); + return is_new_avatar_menu && IsNewProfileManagement(); } bool IsFastUserSwitching() { diff --git a/chrome/common/profile_management_switches.h b/chrome/common/profile_management_switches.h index 9fc5b0e..e05bb1b 100644 --- a/chrome/common/profile_management_switches.h +++ b/chrome/common/profile_management_switches.h @@ -17,13 +17,17 @@ bool IsEnableWebBasedSignin(); // Enables using GAIA information to populate profile name and icon. bool IsGoogleProfileInfo(); -// Shows the new avatar menu. -bool IsNewAvatarMenu(); - // Use new profile management system, including profile sign-out and new // choosers. bool IsNewProfileManagement(); +// Whether the new avatar menu is enabled, either because new profile management +// is enabled or because the new profile management preview UI is enabled. +bool IsNewAvatarMenu(); + +// Whether the new profile management preview has been enabled. +bool IsNewProfileManagementPreviewEnabled(); + // Checks whether the flag for fast user switching is enabled. bool IsFastUserSwitching(); |