Index: chrome/browser/ui/views/profiles/profile_chooser_view.cc |
diff --git a/chrome/browser/ui/views/profiles/profile_chooser_view.cc b/chrome/browser/ui/views/profiles/profile_chooser_view.cc |
index a38ad3591343d4faecf60918e4ccb06da8bf8b74..27d9686be11cf48875fa17fc91ebd40eb3cd502d 100644 |
--- a/chrome/browser/ui/views/profiles/profile_chooser_view.cc |
+++ b/chrome/browser/ui/views/profiles/profile_chooser_view.cc |
@@ -27,6 +27,7 @@ |
#include "chrome/browser/ui/chrome_pages.h" |
#include "chrome/browser/ui/singleton_tabs.h" |
#include "chrome/browser/ui/user_manager.h" |
+#include "chrome/browser/ui/views/profiles/signin_view_controller.h" |
#include "chrome/browser/ui/views/profiles/user_manager_view.h" |
#include "chrome/browser/ui/webui/signin/login_ui_service.h" |
#include "chrome/browser/ui/webui/signin/login_ui_service_factory.h" |
@@ -79,9 +80,7 @@ namespace { |
const int kFixedMenuWidth = 250; |
const int kButtonHeight = 32; |
-const int kPasswordCombinedFixedGaiaViewHeight = 440; |
const int kPasswordCombinedFixedGaiaViewWidth = 360; |
-const int kFixedGaiaViewHeight = 512; |
const int kFixedGaiaViewWidth = 448; |
const int kFixedAccountRemovalViewWidth = 280; |
const int kFixedSwitchUserViewWidth = 320; |
@@ -594,7 +593,7 @@ gfx::ImageSkia CreateBadgeForProfile(Profile* profile) { |
// ProfileChooserView --------------------------------------------------------- |
// static |
-ProfileChooserView* ProfileChooserView::profile_bubble_ = NULL; |
+ProfileChooserView* ProfileChooserView::profile_bubble_ = nullptr; |
bool ProfileChooserView::close_on_deactivate_for_testing_ = true; |
// static |
@@ -617,7 +616,7 @@ void ProfileChooserView::ShowBubble( |
if (IsShowing()) { |
if (tutorial_mode != profiles::TUTORIAL_MODE_NONE) { |
profile_bubble_->tutorial_mode_ = tutorial_mode; |
- profile_bubble_->ShowView(view_mode, profile_bubble_->avatar_menu_.get()); |
+ profile_bubble_->ShowViewFromMode(view_mode); |
} |
return; |
} |
@@ -719,7 +718,7 @@ void ProfileChooserView::Init() { |
AddAccelerator(ui::Accelerator(ui::VKEY_DOWN, ui::EF_NONE)); |
AddAccelerator(ui::Accelerator(ui::VKEY_UP, ui::EF_NONE)); |
- ShowView(view_mode_, avatar_menu_.get()); |
+ ShowViewFromMode(view_mode_); |
} |
void ProfileChooserView::OnNativeThemeChanged( |
@@ -753,9 +752,9 @@ void ProfileChooserView::OnRefreshTokenAvailable( |
view_mode_ == profiles::BUBBLE_VIEW_MODE_GAIA_REAUTH) { |
// The account management UI is only available through the |
// --enable-account-consistency flag. |
- ShowView(switches::IsEnableAccountConsistency() ? |
+ ShowViewFromMode(switches::IsEnableAccountConsistency() ? |
profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT : |
- profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER, avatar_menu_.get()); |
+ profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER); |
} |
} |
@@ -763,7 +762,7 @@ void ProfileChooserView::OnRefreshTokenRevoked(const std::string& account_id) { |
// Refresh the account management view when an account is removed from the |
// profile. |
if (view_mode_ == profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT) |
- ShowView(profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT, avatar_menu_.get()); |
+ ShowViewFromMode(profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT); |
} |
void ProfileChooserView::ShowView(profiles::BubbleViewMode view_to_display, |
@@ -798,6 +797,7 @@ void ProfileChooserView::ShowView(profiles::BubbleViewMode view_to_display, |
const int width = switches::UsePasswordSeparatedSigninFlow() |
? kFixedGaiaViewWidth : kPasswordCombinedFixedGaiaViewWidth; |
layout = CreateSingleColumnLayout(this, width); |
+ DCHECK(!switches::UsePasswordSeparatedSigninFlow()); |
sub_view = CreateGaiaSigninView(&view_to_focus); |
break; |
} |
@@ -831,6 +831,24 @@ void ProfileChooserView::ShowView(profiles::BubbleViewMode view_to_display, |
view_to_focus->RequestFocus(); |
} |
+void ProfileChooserView::ShowViewFromMode(profiles::BubbleViewMode mode) { |
+ if (SigninViewController::ShouldShowModalSigninForMode(mode)) { |
+ BrowserWindow::AvatarBubbleMode converted_mode = |
+ BrowserWindow::AVATAR_BUBBLE_MODE_DEFAULT; |
+ if (mode == profiles::BUBBLE_VIEW_MODE_GAIA_SIGNIN) { |
+ converted_mode = BrowserWindow::AVATAR_BUBBLE_MODE_SIGNIN; |
+ } else if (mode == profiles::BUBBLE_VIEW_MODE_GAIA_ADD_ACCOUNT) { |
+ converted_mode = BrowserWindow::AVATAR_BUBBLE_MODE_ADD_ACCOUNT; |
+ } else if (mode == profiles::BUBBLE_VIEW_MODE_GAIA_REAUTH) { |
+ converted_mode = BrowserWindow::AVATAR_BUBBLE_MODE_REAUTH; |
+ } |
+ |
+ browser_->window()->ShowModalSigninWindow(converted_mode); |
+ } else { |
+ ShowView(mode, avatar_menu_.get()); |
+ } |
+} |
+ |
void ProfileChooserView::WindowClosing() { |
DCHECK_EQ(profile_bubble_, this); |
profile_bubble_ = NULL; |
@@ -882,7 +900,7 @@ void ProfileChooserView::ButtonPressed(views::Button* sender, |
profiles::LockProfile(browser_->profile()); |
PostActionPerformed(ProfileMetrics::PROFILE_DESKTOP_MENU_LOCK); |
} else if (sender == auth_error_email_button_) { |
- ShowView(profiles::BUBBLE_VIEW_MODE_GAIA_REAUTH, avatar_menu_.get()); |
+ ShowViewFromMode(profiles::BUBBLE_VIEW_MODE_GAIA_REAUTH); |
} else if (sender == tutorial_sync_settings_ok_button_) { |
LoginUIServiceFactory::GetForProfile(browser_->profile())-> |
SyncConfirmationUIClosed(false /* configure_sync_first */); |
@@ -903,7 +921,7 @@ void ProfileChooserView::ButtonPressed(views::Button* sender, |
RemoveAccount(); |
} else if (sender == account_removal_cancel_button_) { |
account_id_to_remove_.clear(); |
- ShowView(profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT, avatar_menu_.get()); |
+ ShowViewFromMode(profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT); |
} else if (sender == gaia_signin_cancel_button_) { |
// The account management view is only available with the |
// --enable-account-consistency flag. |
@@ -911,14 +929,14 @@ void ProfileChooserView::ButtonPressed(views::Button* sender, |
SigninManagerFactory::GetForProfile(browser_->profile())-> |
IsAuthenticated() && |
switches::IsEnableAccountConsistency(); |
- ShowView(account_management_available ? |
+ ShowViewFromMode(account_management_available ? |
profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT : |
- profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER, avatar_menu_.get()); |
+ profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER); |
} else if (sender == current_profile_photo_) { |
avatar_menu_->EditProfile(avatar_menu_->GetActiveProfileIndex()); |
PostActionPerformed(ProfileMetrics::PROFILE_DESKTOP_MENU_EDIT_IMAGE); |
} else if (sender == signin_current_profile_link_) { |
- ShowView(profiles::BUBBLE_VIEW_MODE_GAIA_SIGNIN, avatar_menu_.get()); |
+ ShowViewFromMode(profiles::BUBBLE_VIEW_MODE_GAIA_SIGNIN); |
} else if (sender == add_person_button_) { |
ProfileMetrics::LogProfileNewAvatarMenuNotYou( |
ProfileMetrics::PROFILE_AVATAR_MENU_NOT_YOU_ADD_PERSON); |
@@ -930,7 +948,7 @@ void ProfileChooserView::ButtonPressed(views::Button* sender, |
ProfileMetrics::PROFILE_AVATAR_MENU_NOT_YOU_DISCONNECT); |
chrome::ShowSettings(browser_); |
} else if (sender == switch_user_cancel_button_) { |
- ShowView(profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER, avatar_menu_.get()); |
+ ShowViewFromMode(profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER); |
ProfileMetrics::LogProfileNewAvatarMenuNotYou( |
ProfileMetrics::PROFILE_AVATAR_MENU_NOT_YOU_BACK); |
} else { |
@@ -949,12 +967,11 @@ void ProfileChooserView::ButtonPressed(views::Button* sender, |
delete_account_button_map_.find(sender); |
if (account_match != delete_account_button_map_.end()) { |
account_id_to_remove_ = account_match->second; |
- ShowView(profiles::BUBBLE_VIEW_MODE_ACCOUNT_REMOVAL, |
- avatar_menu_.get()); |
+ ShowViewFromMode(profiles::BUBBLE_VIEW_MODE_ACCOUNT_REMOVAL); |
} else { |
account_match = reauth_account_button_map_.find(sender); |
DCHECK(account_match != reauth_account_button_map_.end()); |
- ShowView(profiles::BUBBLE_VIEW_MODE_GAIA_REAUTH, avatar_menu_.get()); |
+ ShowViewFromMode(profiles::BUBBLE_VIEW_MODE_GAIA_REAUTH); |
} |
} |
} |
@@ -970,7 +987,7 @@ void ProfileChooserView::RemoveAccount() { |
} |
account_id_to_remove_.clear(); |
- ShowView(profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT, avatar_menu_.get()); |
+ ShowViewFromMode(profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT); |
} |
void ProfileChooserView::LinkClicked(views::Link* sender, int event_flags) { |
@@ -978,13 +995,12 @@ void ProfileChooserView::LinkClicked(views::Link* sender, int event_flags) { |
// This link can either mean show/hide the account management view, |
// depending on which view it is displayed. ShowView() will DCHECK if |
// the account management view is displayed for non signed-in users. |
- ShowView( |
+ ShowViewFromMode( |
view_mode_ == profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT ? |
profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER : |
- profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT, |
- avatar_menu_.get()); |
+ profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT); |
} else if (sender == add_account_link_) { |
- ShowView(profiles::BUBBLE_VIEW_MODE_GAIA_ADD_ACCOUNT, avatar_menu_.get()); |
+ ShowViewFromMode(profiles::BUBBLE_VIEW_MODE_GAIA_ADD_ACCOUNT); |
PostActionPerformed(ProfileMetrics::PROFILE_DESKTOP_MENU_ADD_ACCT); |
} else if (sender == tutorial_sync_settings_link_) { |
LoginUIServiceFactory::GetForProfile(browser_->profile())-> |
@@ -995,7 +1011,7 @@ void ProfileChooserView::LinkClicked(views::Link* sender, int event_flags) { |
} else if (sender == tutorial_not_you_link_) { |
ProfileMetrics::LogProfileNewAvatarMenuUpgrade( |
ProfileMetrics::PROFILE_AVATAR_MENU_UPGRADE_NOT_YOU); |
- ShowView(profiles::BUBBLE_VIEW_MODE_SWITCH_USER, avatar_menu_.get()); |
+ ShowViewFromMode(profiles::BUBBLE_VIEW_MODE_SWITCH_USER); |
} else { |
DCHECK(sender == tutorial_learn_more_link_); |
signin_ui_util::ShowSigninErrorLearnMorePage(browser_->profile()); |
@@ -1153,7 +1169,7 @@ void ProfileChooserView::DismissTutorial() { |
} |
tutorial_mode_ = profiles::TUTORIAL_MODE_NONE; |
- ShowView(profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER, avatar_menu_.get()); |
+ ShowViewFromMode(profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER); |
} |
views::View* ProfileChooserView::CreateTutorialViewIfNeeded( |
@@ -1620,27 +1636,18 @@ void ProfileChooserView::CreateAccountButton(views::GridLayout* layout, |
views::View* ProfileChooserView::CreateGaiaSigninView( |
views::View** signin_content_view) { |
- GURL url; |
- int message_id; |
+ views::WebView* web_view = SigninViewController::CreateGaiaWebView( |
+ this, view_mode_, browser_->profile()); |
+ int message_id; |
switch (view_mode_) { |
case profiles::BUBBLE_VIEW_MODE_GAIA_SIGNIN: |
- url = signin::GetPromoURL(signin_metrics::SOURCE_AVATAR_BUBBLE_SIGN_IN, |
- false /* auto_close */, |
- true /* is_constrained */); |
message_id = IDS_PROFILES_GAIA_SIGNIN_TITLE; |
break; |
case profiles::BUBBLE_VIEW_MODE_GAIA_ADD_ACCOUNT: |
- url = signin::GetPromoURL( |
- signin_metrics::SOURCE_AVATAR_BUBBLE_ADD_ACCOUNT, |
- false /* auto_close */, |
- true /* is_constrained */); |
message_id = IDS_PROFILES_GAIA_ADD_ACCOUNT_TITLE; |
break; |
case profiles::BUBBLE_VIEW_MODE_GAIA_REAUTH: { |
- DCHECK(HasAuthError(browser_->profile())); |
- url = signin::GetReauthURL(browser_->profile(), |
- GetAuthErrorAccountId(browser_->profile())); |
message_id = IDS_PROFILES_GAIA_REAUTH_TITLE; |
break; |
} |
@@ -1649,31 +1656,9 @@ views::View* ProfileChooserView::CreateGaiaSigninView( |
return NULL; |
} |
- // Adds Gaia signin webview. |
- const gfx::Size pref_size = switches::UsePasswordSeparatedSigninFlow() |
- ? gfx::Size(kFixedGaiaViewWidth, kFixedGaiaViewHeight) |
- : gfx::Size(kPasswordCombinedFixedGaiaViewWidth, |
- kPasswordCombinedFixedGaiaViewHeight); |
- Profile* profile = browser_->profile(); |
- views::WebView* web_view = new views::WebView(profile); |
- web_view->LoadInitialURL(url); |
- web_view->GetWebContents()->SetDelegate(this); |
- web_view->SetPreferredSize(pref_size); |
- content::RenderWidgetHostView* rwhv = |
- web_view->GetWebContents()->GetRenderWidgetHostView(); |
- if (rwhv) |
- rwhv->SetBackgroundColor(profiles::kAvatarBubbleGaiaBackgroundColor); |
- |
if (signin_content_view) |
*signin_content_view = web_view; |
- if (switches::UsePasswordSeparatedSigninFlow()) { |
- gaia_signin_cancel_button_ = CreateBackButton(this); |
- HostView* host = new HostView(); |
- host->Initialize(gaia_signin_cancel_button_, web_view); |
- return host; |
- } |
- |
TitleCard* title_card = new TitleCard(l10n_util::GetStringUTF16(message_id), |
this, |
&gaia_signin_cancel_button_); |