Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(364)

Side by Side Diff: chrome/browser/ui/views/profiles/profile_chooser_view.cc

Issue 471023003: Make sure the new confirmation bubble is always shown upon signin (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebased Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/ui/views/profiles/profile_chooser_view.h" 5 #include "chrome/browser/ui/views/profiles/profile_chooser_view.h"
6 6
7 #include "base/prefs/pref_service.h" 7 #include "base/prefs/pref_service.h"
8 #include "base/strings/utf_string_conversions.h" 8 #include "base/strings/utf_string_conversions.h"
9 #include "chrome/browser/browser_process.h" 9 #include "chrome/browser/browser_process.h"
10 #include "chrome/browser/lifetime/application_lifetime.h" 10 #include "chrome/browser/lifetime/application_lifetime.h"
(...skipping 439 matching lines...) Expand 10 before | Expand all | Expand 10 after
450 450
451 // ProfileChooserView --------------------------------------------------------- 451 // ProfileChooserView ---------------------------------------------------------
452 452
453 // static 453 // static
454 ProfileChooserView* ProfileChooserView::profile_bubble_ = NULL; 454 ProfileChooserView* ProfileChooserView::profile_bubble_ = NULL;
455 bool ProfileChooserView::close_on_deactivate_for_testing_ = true; 455 bool ProfileChooserView::close_on_deactivate_for_testing_ = true;
456 456
457 // static 457 // static
458 void ProfileChooserView::ShowBubble( 458 void ProfileChooserView::ShowBubble(
459 profiles::BubbleViewMode view_mode, 459 profiles::BubbleViewMode view_mode,
460 profiles::TutorialMode tutorial_mode,
460 const signin::ManageAccountsParams& manage_accounts_params, 461 const signin::ManageAccountsParams& manage_accounts_params,
461 views::View* anchor_view, 462 views::View* anchor_view,
462 views::BubbleBorder::Arrow arrow, 463 views::BubbleBorder::Arrow arrow,
463 views::BubbleBorder::BubbleAlignment border_alignment, 464 views::BubbleBorder::BubbleAlignment border_alignment,
464 Browser* browser) { 465 Browser* browser) {
465 if (IsShowing()) 466 if (IsShowing()) {
467 if (tutorial_mode != profiles::TUTORIAL_MODE_NONE) {
468 profile_bubble_->tutorial_mode_ = tutorial_mode;
469 profile_bubble_->ShowView(view_mode, profile_bubble_->avatar_menu_.get());
470 }
466 return; 471 return;
472 }
467 473
468 profile_bubble_ = new ProfileChooserView(anchor_view, arrow, browser, 474 profile_bubble_ = new ProfileChooserView(anchor_view, arrow, browser,
469 view_mode, manage_accounts_params.service_type); 475 view_mode, tutorial_mode, manage_accounts_params.service_type);
470 views::BubbleDelegateView::CreateBubble(profile_bubble_); 476 views::BubbleDelegateView::CreateBubble(profile_bubble_);
471 profile_bubble_->set_close_on_deactivate(close_on_deactivate_for_testing_); 477 profile_bubble_->set_close_on_deactivate(close_on_deactivate_for_testing_);
472 profile_bubble_->SetAlignment(border_alignment); 478 profile_bubble_->SetAlignment(border_alignment);
473 profile_bubble_->GetWidget()->Show(); 479 profile_bubble_->GetWidget()->Show();
474 profile_bubble_->SetArrowPaintType(views::BubbleBorder::PAINT_NONE); 480 profile_bubble_->SetArrowPaintType(views::BubbleBorder::PAINT_NONE);
475 } 481 }
476 482
477 // static 483 // static
478 bool ProfileChooserView::IsShowing() { 484 bool ProfileChooserView::IsShowing() {
479 return profile_bubble_ != NULL; 485 return profile_bubble_ != NULL;
480 } 486 }
481 487
482 // static 488 // static
483 void ProfileChooserView::Hide() { 489 void ProfileChooserView::Hide() {
484 if (IsShowing()) 490 if (IsShowing())
485 profile_bubble_->GetWidget()->Close(); 491 profile_bubble_->GetWidget()->Close();
486 } 492 }
487 493
488 ProfileChooserView::ProfileChooserView(views::View* anchor_view, 494 ProfileChooserView::ProfileChooserView(views::View* anchor_view,
489 views::BubbleBorder::Arrow arrow, 495 views::BubbleBorder::Arrow arrow,
490 Browser* browser, 496 Browser* browser,
491 profiles::BubbleViewMode view_mode, 497 profiles::BubbleViewMode view_mode,
498 profiles::TutorialMode tutorial_mode,
492 signin::GAIAServiceType service_type) 499 signin::GAIAServiceType service_type)
493 : BubbleDelegateView(anchor_view, arrow), 500 : BubbleDelegateView(anchor_view, arrow),
494 browser_(browser), 501 browser_(browser),
495 view_mode_(view_mode), 502 view_mode_(view_mode),
496 tutorial_mode_(profiles::TUTORIAL_MODE_NONE), 503 tutorial_mode_(tutorial_mode),
497 gaia_service_type_(service_type) { 504 gaia_service_type_(service_type) {
498 // Reset the default margins inherited from the BubbleDelegateView. 505 // Reset the default margins inherited from the BubbleDelegateView.
499 // Add a small bottom inset so that the bubble's rounded corners show up. 506 // Add a small bottom inset so that the bubble's rounded corners show up.
500 set_margins(gfx::Insets(0, 0, 1, 0)); 507 set_margins(gfx::Insets(0, 0, 1, 0));
501 set_background(views::Background::CreateSolidBackground( 508 set_background(views::Background::CreateSolidBackground(
502 GetNativeTheme()->GetSystemColor( 509 GetNativeTheme()->GetSystemColor(
503 ui::NativeTheme::kColorId_DialogBackground))); 510 ui::NativeTheme::kColorId_DialogBackground)));
504 ResetView(); 511 ResetView();
505 512
506 avatar_menu_.reset(new AvatarMenu( 513 avatar_menu_.reset(new AvatarMenu(
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
538 gaia_signin_cancel_button_ = NULL; 545 gaia_signin_cancel_button_ = NULL;
539 remove_account_button_ = NULL; 546 remove_account_button_ = NULL;
540 account_removal_cancel_button_ = NULL; 547 account_removal_cancel_button_ = NULL;
541 add_person_button_ = NULL; 548 add_person_button_ = NULL;
542 disconnect_button_ = NULL; 549 disconnect_button_ = NULL;
543 switch_user_cancel_button_ = NULL; 550 switch_user_cancel_button_ = NULL;
544 tutorial_sync_settings_ok_button_ = NULL; 551 tutorial_sync_settings_ok_button_ = NULL;
545 tutorial_sync_settings_link_ = NULL; 552 tutorial_sync_settings_link_ = NULL;
546 tutorial_see_whats_new_button_ = NULL; 553 tutorial_see_whats_new_button_ = NULL;
547 tutorial_not_you_link_ = NULL; 554 tutorial_not_you_link_ = NULL;
548 tutorial_mode_ = profiles::TUTORIAL_MODE_NONE;
549 } 555 }
550 556
551 void ProfileChooserView::Init() { 557 void ProfileChooserView::Init() {
552 // If view mode is PROFILE_CHOOSER but there is an auth error, force 558 // If view mode is PROFILE_CHOOSER but there is an auth error, force
553 // ACCOUNT_MANAGEMENT mode. 559 // ACCOUNT_MANAGEMENT mode.
554 if (view_mode_ == profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER && 560 if (view_mode_ == profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER &&
555 HasAuthError(browser_->profile()) && 561 HasAuthError(browser_->profile()) &&
556 switches::IsEnableAccountConsistency() && 562 switches::IsEnableAccountConsistency() &&
557 avatar_menu_->GetItemAt(avatar_menu_->GetActiveProfileIndex()). 563 avatar_menu_->GetItemAt(avatar_menu_->GetActiveProfileIndex()).
558 signed_in) { 564 signed_in) {
(...skipping 14 matching lines...) Expand all
573 579
574 // Refresh the view with the new menu. We can't just update the local copy 580 // Refresh the view with the new menu. We can't just update the local copy
575 // as this may have been triggered by a sign out action, in which case 581 // as this may have been triggered by a sign out action, in which case
576 // the view is being destroyed. 582 // the view is being destroyed.
577 ShowView(profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER, avatar_menu); 583 ShowView(profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER, avatar_menu);
578 } 584 }
579 585
580 void ProfileChooserView::OnRefreshTokenAvailable( 586 void ProfileChooserView::OnRefreshTokenAvailable(
581 const std::string& account_id) { 587 const std::string& account_id) {
582 if (view_mode_ == profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT || 588 if (view_mode_ == profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT ||
583 view_mode_ == profiles::BUBBLE_VIEW_MODE_GAIA_SIGNIN ||
584 view_mode_ == profiles::BUBBLE_VIEW_MODE_GAIA_ADD_ACCOUNT || 589 view_mode_ == profiles::BUBBLE_VIEW_MODE_GAIA_ADD_ACCOUNT ||
585 view_mode_ == profiles::BUBBLE_VIEW_MODE_GAIA_REAUTH) { 590 view_mode_ == profiles::BUBBLE_VIEW_MODE_GAIA_REAUTH) {
586 if (view_mode_ == profiles::BUBBLE_VIEW_MODE_GAIA_SIGNIN)
587 tutorial_mode_ = profiles::TUTORIAL_MODE_CONFIRM_SIGNIN;
588 // The account management UI is only available through the 591 // The account management UI is only available through the
589 // --enable-account-consistency flag. 592 // --enable-account-consistency flag.
590 ShowView(switches::IsEnableAccountConsistency() ? 593 ShowView(switches::IsEnableAccountConsistency() ?
591 profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT : 594 profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT :
592 profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER, avatar_menu_.get()); 595 profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER, avatar_menu_.get());
593 } 596 }
594 } 597 }
595 598
596 void ProfileChooserView::OnRefreshTokenRevoked(const std::string& account_id) { 599 void ProfileChooserView::OnRefreshTokenRevoked(const std::string& account_id) {
597 // Refresh the account management view when an account is removed from the 600 // Refresh the account management view when an account is removed from the
(...skipping 13 matching lines...) Expand all
611 DCHECK(active_item.signed_in); 614 DCHECK(active_item.signed_in);
612 } 615 }
613 616
614 if (browser_->profile()->IsSupervised() && 617 if (browser_->profile()->IsSupervised() &&
615 (view_to_display == profiles::BUBBLE_VIEW_MODE_GAIA_ADD_ACCOUNT || 618 (view_to_display == profiles::BUBBLE_VIEW_MODE_GAIA_ADD_ACCOUNT ||
616 view_to_display == profiles::BUBBLE_VIEW_MODE_ACCOUNT_REMOVAL)) { 619 view_to_display == profiles::BUBBLE_VIEW_MODE_ACCOUNT_REMOVAL)) {
617 LOG(WARNING) << "Supervised user attempted to add/remove account"; 620 LOG(WARNING) << "Supervised user attempted to add/remove account";
618 return; 621 return;
619 } 622 }
620 623
621 // Records the last tutorial mode.
622 profiles::TutorialMode last_tutorial_mode = tutorial_mode_;
623 ResetView(); 624 ResetView();
624 RemoveAllChildViews(true); 625 RemoveAllChildViews(true);
625 view_mode_ = view_to_display; 626 view_mode_ = view_to_display;
626 627
627 views::GridLayout* layout; 628 views::GridLayout* layout;
628 views::View* sub_view; 629 views::View* sub_view;
629 switch (view_mode_) { 630 switch (view_mode_) {
630 case profiles::BUBBLE_VIEW_MODE_GAIA_SIGNIN: 631 case profiles::BUBBLE_VIEW_MODE_GAIA_SIGNIN:
631 case profiles::BUBBLE_VIEW_MODE_GAIA_ADD_ACCOUNT: 632 case profiles::BUBBLE_VIEW_MODE_GAIA_ADD_ACCOUNT:
632 case profiles::BUBBLE_VIEW_MODE_GAIA_REAUTH: 633 case profiles::BUBBLE_VIEW_MODE_GAIA_REAUTH:
633 layout = CreateSingleColumnLayout(this, kFixedGaiaViewWidth); 634 layout = CreateSingleColumnLayout(this, kFixedGaiaViewWidth);
634 sub_view = CreateGaiaSigninView(); 635 sub_view = CreateGaiaSigninView();
635 break; 636 break;
636 case profiles::BUBBLE_VIEW_MODE_ACCOUNT_REMOVAL: 637 case profiles::BUBBLE_VIEW_MODE_ACCOUNT_REMOVAL:
637 layout = CreateSingleColumnLayout(this, kFixedAccountRemovalViewWidth); 638 layout = CreateSingleColumnLayout(this, kFixedAccountRemovalViewWidth);
638 sub_view = CreateAccountRemovalView(); 639 sub_view = CreateAccountRemovalView();
639 break; 640 break;
640 case profiles::BUBBLE_VIEW_MODE_SWITCH_USER: 641 case profiles::BUBBLE_VIEW_MODE_SWITCH_USER:
641 layout = CreateSingleColumnLayout(this, kFixedSwitchUserViewWidth); 642 layout = CreateSingleColumnLayout(this, kFixedSwitchUserViewWidth);
642 sub_view = CreateSwitchUserView(); 643 sub_view = CreateSwitchUserView();
643 ProfileMetrics::LogProfileNewAvatarMenuNotYou( 644 ProfileMetrics::LogProfileNewAvatarMenuNotYou(
644 ProfileMetrics::PROFILE_AVATAR_MENU_NOT_YOU_VIEW); 645 ProfileMetrics::PROFILE_AVATAR_MENU_NOT_YOU_VIEW);
645 break; 646 break;
646 default: 647 default:
647 layout = CreateSingleColumnLayout(this, kFixedMenuWidth); 648 layout = CreateSingleColumnLayout(this, kFixedMenuWidth);
648 sub_view = CreateProfileChooserView(avatar_menu, last_tutorial_mode); 649 sub_view = CreateProfileChooserView(avatar_menu);
649 } 650 }
650 layout->StartRow(1, 0); 651 layout->StartRow(1, 0);
651 layout->AddView(sub_view); 652 layout->AddView(sub_view);
652 Layout(); 653 Layout();
653 if (GetBubbleFrameView()) 654 if (GetBubbleFrameView())
654 SizeToContents(); 655 SizeToContents();
655 } 656 }
656 657
657 void ProfileChooserView::WindowClosing() { 658 void ProfileChooserView::WindowClosing() {
658 DCHECK_EQ(profile_bubble_, this); 659 DCHECK_EQ(profile_bubble_, this);
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
832 833
833 profiles::UpdateProfileName(profile, new_profile_name); 834 profiles::UpdateProfileName(profile, new_profile_name);
834 PostActionPerformed(ProfileMetrics::PROFILE_DESKTOP_MENU_EDIT_NAME); 835 PostActionPerformed(ProfileMetrics::PROFILE_DESKTOP_MENU_EDIT_NAME);
835 current_profile_name_->ShowReadOnlyView(); 836 current_profile_name_->ShowReadOnlyView();
836 return true; 837 return true;
837 } 838 }
838 return false; 839 return false;
839 } 840 }
840 841
841 views::View* ProfileChooserView::CreateProfileChooserView( 842 views::View* ProfileChooserView::CreateProfileChooserView(
842 AvatarMenu* avatar_menu, 843 AvatarMenu* avatar_menu) {
843 profiles::TutorialMode last_tutorial_mode) {
844 // TODO(guohui, noms): the view should be customized based on whether new 844 // TODO(guohui, noms): the view should be customized based on whether new
845 // profile management preview is enabled or not. 845 // profile management preview is enabled or not.
846 846
847 views::View* view = new views::View(); 847 views::View* view = new views::View();
848 views::GridLayout* layout = CreateSingleColumnLayout(view, kFixedMenuWidth); 848 views::GridLayout* layout = CreateSingleColumnLayout(view, kFixedMenuWidth);
849 // Separate items into active and alternatives. 849 // Separate items into active and alternatives.
850 Indexes other_profiles; 850 Indexes other_profiles;
851 views::View* tutorial_view = NULL; 851 views::View* tutorial_view = NULL;
852 views::View* current_profile_view = NULL; 852 views::View* current_profile_view = NULL;
853 views::View* current_profile_accounts = NULL; 853 views::View* current_profile_accounts = NULL;
854 views::View* option_buttons_view = NULL; 854 views::View* option_buttons_view = NULL;
855 for (size_t i = 0; i < avatar_menu->GetNumberOfItems(); ++i) { 855 for (size_t i = 0; i < avatar_menu->GetNumberOfItems(); ++i) {
856 const AvatarMenu::Item& item = avatar_menu->GetItemAt(i); 856 const AvatarMenu::Item& item = avatar_menu->GetItemAt(i);
857 if (item.active) { 857 if (item.active) {
858 option_buttons_view = CreateOptionsView( 858 option_buttons_view = CreateOptionsView(
859 switches::IsNewProfileManagement() && item.signed_in); 859 switches::IsNewProfileManagement() && item.signed_in);
860 current_profile_view = CreateCurrentProfileView(item, false); 860 current_profile_view = CreateCurrentProfileView(item, false);
861 if (view_mode_ == profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER) { 861 if (view_mode_ == profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER) {
862 switch (last_tutorial_mode) { 862 switch (tutorial_mode_) {
863 case profiles::TUTORIAL_MODE_NONE: 863 case profiles::TUTORIAL_MODE_NONE:
864 case profiles::TUTORIAL_MODE_WELCOME_UPGRADE: 864 case profiles::TUTORIAL_MODE_WELCOME_UPGRADE:
865 tutorial_view = CreateWelcomeUpgradeTutorialViewIfNeeded( 865 tutorial_view = CreateWelcomeUpgradeTutorialViewIfNeeded(
866 last_tutorial_mode == profiles::TUTORIAL_MODE_WELCOME_UPGRADE, 866 tutorial_mode_ == profiles::TUTORIAL_MODE_WELCOME_UPGRADE,
867 item); 867 item);
868 break; 868 break;
869 case profiles::TUTORIAL_MODE_CONFIRM_SIGNIN: 869 case profiles::TUTORIAL_MODE_CONFIRM_SIGNIN:
870 tutorial_view = CreateSigninConfirmationView(); 870 tutorial_view = CreateSigninConfirmationView();
871 break; 871 break;
872 case profiles::TUTORIAL_MODE_SHOW_ERROR: 872 case profiles::TUTORIAL_MODE_SHOW_ERROR:
873 // TODO(guohui): not implemented yet. 873 // TODO(guohui): not implemented yet.
874 NOTREACHED(); 874 NOTREACHED();
875 } 875 }
876 } else { 876 } else {
877 current_profile_accounts = CreateCurrentProfileAccountsView(item); 877 current_profile_accounts = CreateCurrentProfileAccountsView(item);
878 } 878 }
879 } else { 879 } else {
880 other_profiles.push_back(i); 880 other_profiles.push_back(i);
881 } 881 }
882 } 882 }
883 883
884 if (tutorial_view) { 884 if (tutorial_view) {
885 // TODO(mlerman): update UMA stats for the new tutorial. 885 // TODO(mlerman): update UMA stats for the new tutorial.
886 layout->StartRow(1, 0); 886 layout->StartRow(1, 0);
887 layout->AddView(tutorial_view); 887 layout->AddView(tutorial_view);
888 } else {
889 tutorial_mode_ = profiles::TUTORIAL_MODE_NONE;
888 } 890 }
889 891
890 if (!current_profile_view) { 892 if (!current_profile_view) {
891 // Guest windows don't have an active profile. 893 // Guest windows don't have an active profile.
892 current_profile_view = CreateGuestProfileView(); 894 current_profile_view = CreateGuestProfileView();
893 option_buttons_view = CreateOptionsView(false); 895 option_buttons_view = CreateOptionsView(false);
894 } 896 }
895 897
896 layout->StartRow(1, 0); 898 layout->StartRow(1, 0);
897 layout->AddView(current_profile_view); 899 layout->AddView(current_profile_view);
(...skipping 626 matching lines...) Expand 10 before | Expand all | Expand 10 after
1524 IncognitoModePrefs::GetAvailability(browser_->profile()->GetPrefs()) != 1526 IncognitoModePrefs::GetAvailability(browser_->profile()->GetPrefs()) !=
1525 IncognitoModePrefs::DISABLED; 1527 IncognitoModePrefs::DISABLED;
1526 return incognito_available && !browser_->profile()->IsGuestSession(); 1528 return incognito_available && !browser_->profile()->IsGuestSession();
1527 } 1529 }
1528 1530
1529 void ProfileChooserView::PostActionPerformed( 1531 void ProfileChooserView::PostActionPerformed(
1530 ProfileMetrics::ProfileDesktopMenu action_performed) { 1532 ProfileMetrics::ProfileDesktopMenu action_performed) {
1531 ProfileMetrics::LogProfileDesktopMenu(action_performed, gaia_service_type_); 1533 ProfileMetrics::LogProfileDesktopMenu(action_performed, gaia_service_type_);
1532 gaia_service_type_ = signin::GAIA_SERVICE_TYPE_NONE; 1534 gaia_service_type_ = signin::GAIA_SERVICE_TYPE_NONE;
1533 } 1535 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/profiles/profile_chooser_view.h ('k') | chrome/browser/ui/webui/signin/inline_login_handler_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698