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

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

Issue 297803007: Move profile_chooser enums to a constant place for mac and win. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Unit tests need love too Created 6 years, 7 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
« no previous file with comments | « chrome/browser/ui/views/profiles/profile_chooser_view.h ('k') | chrome/chrome_browser_ui.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 395 matching lines...) Expand 10 before | Expand all | Expand 10 after
406 }; 406 };
407 407
408 // ProfileChooserView --------------------------------------------------------- 408 // ProfileChooserView ---------------------------------------------------------
409 409
410 // static 410 // static
411 ProfileChooserView* ProfileChooserView::profile_bubble_ = NULL; 411 ProfileChooserView* ProfileChooserView::profile_bubble_ = NULL;
412 bool ProfileChooserView::close_on_deactivate_for_testing_ = true; 412 bool ProfileChooserView::close_on_deactivate_for_testing_ = true;
413 413
414 // static 414 // static
415 void ProfileChooserView::ShowBubble( 415 void ProfileChooserView::ShowBubble(
416 BubbleViewMode view_mode, 416 profiles::BubbleViewMode view_mode,
417 views::View* anchor_view, 417 views::View* anchor_view,
418 views::BubbleBorder::Arrow arrow, 418 views::BubbleBorder::Arrow arrow,
419 views::BubbleBorder::BubbleAlignment border_alignment, 419 views::BubbleBorder::BubbleAlignment border_alignment,
420 const gfx::Rect& anchor_rect, 420 const gfx::Rect& anchor_rect,
421 Browser* browser) { 421 Browser* browser) {
422 if (IsShowing()) 422 if (IsShowing())
423 return; 423 return;
424 424
425 profile_bubble_ = new ProfileChooserView(anchor_view, arrow, anchor_rect, 425 profile_bubble_ = new ProfileChooserView(anchor_view, arrow, anchor_rect,
426 browser, view_mode); 426 browser, view_mode);
(...skipping 12 matching lines...) Expand all
439 // static 439 // static
440 void ProfileChooserView::Hide() { 440 void ProfileChooserView::Hide() {
441 if (IsShowing()) 441 if (IsShowing())
442 profile_bubble_->GetWidget()->Close(); 442 profile_bubble_->GetWidget()->Close();
443 } 443 }
444 444
445 ProfileChooserView::ProfileChooserView(views::View* anchor_view, 445 ProfileChooserView::ProfileChooserView(views::View* anchor_view,
446 views::BubbleBorder::Arrow arrow, 446 views::BubbleBorder::Arrow arrow,
447 const gfx::Rect& anchor_rect, 447 const gfx::Rect& anchor_rect,
448 Browser* browser, 448 Browser* browser,
449 BubbleViewMode view_mode) 449 profiles::BubbleViewMode view_mode)
450 : BubbleDelegateView(anchor_view, arrow), 450 : BubbleDelegateView(anchor_view, arrow),
451 browser_(browser), 451 browser_(browser),
452 view_mode_(view_mode), 452 view_mode_(view_mode),
453 tutorial_mode_(TUTORIAL_MODE_NONE) { 453 tutorial_mode_(profiles::TUTORIAL_MODE_NONE) {
454 // Reset the default margins inherited from the BubbleDelegateView. 454 // Reset the default margins inherited from the BubbleDelegateView.
455 set_margins(gfx::Insets()); 455 set_margins(gfx::Insets());
456 456
457 ResetView(); 457 ResetView();
458 458
459 avatar_menu_.reset(new AvatarMenu( 459 avatar_menu_.reset(new AvatarMenu(
460 &g_browser_process->profile_manager()->GetProfileInfoCache(), 460 &g_browser_process->profile_manager()->GetProfileInfoCache(),
461 this, 461 this,
462 browser_)); 462 browser_));
463 avatar_menu_->RebuildMenu(); 463 avatar_menu_->RebuildMenu();
(...skipping 26 matching lines...) Expand all
490 tutorial_end_preview_link_ = NULL; 490 tutorial_end_preview_link_ = NULL;
491 tutorial_send_feedback_button_ = NULL; 491 tutorial_send_feedback_button_ = NULL;
492 end_preview_and_relaunch_button_ = NULL; 492 end_preview_and_relaunch_button_ = NULL;
493 end_preview_cancel_button_ = NULL; 493 end_preview_cancel_button_ = NULL;
494 remove_account_button_ = NULL; 494 remove_account_button_ = NULL;
495 account_removal_cancel_button_ = NULL; 495 account_removal_cancel_button_ = NULL;
496 gaia_signin_cancel_button_ = NULL; 496 gaia_signin_cancel_button_ = NULL;
497 open_other_profile_indexes_map_.clear(); 497 open_other_profile_indexes_map_.clear();
498 delete_account_button_map_.clear(); 498 delete_account_button_map_.clear();
499 reauth_account_button_map_.clear(); 499 reauth_account_button_map_.clear();
500 tutorial_mode_ = TUTORIAL_MODE_NONE; 500 tutorial_mode_ = profiles::TUTORIAL_MODE_NONE;
501 } 501 }
502 502
503 void ProfileChooserView::Init() { 503 void ProfileChooserView::Init() {
504 // If view mode is PROFILE_CHOOSER but there is an auth error, force 504 // If view mode is PROFILE_CHOOSER but there is an auth error, force
505 // ACCOUNT_MANAGEMENT mode. 505 // ACCOUNT_MANAGEMENT mode.
506 if (view_mode_ == BUBBLE_VIEW_MODE_PROFILE_CHOOSER && 506 if (view_mode_ == profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER &&
507 HasAuthError(browser_->profile())) { 507 HasAuthError(browser_->profile())) {
508 view_mode_ = BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT; 508 view_mode_ = profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT;
509 } 509 }
510 510
511 ShowView(view_mode_, avatar_menu_.get()); 511 ShowView(view_mode_, avatar_menu_.get());
512 } 512 }
513 513
514 void ProfileChooserView::OnAvatarMenuChanged( 514 void ProfileChooserView::OnAvatarMenuChanged(
515 AvatarMenu* avatar_menu) { 515 AvatarMenu* avatar_menu) {
516 // Refresh the view with the new menu. We can't just update the local copy 516 // Refresh the view with the new menu. We can't just update the local copy
517 // as this may have been triggered by a sign out action, in which case 517 // as this may have been triggered by a sign out action, in which case
518 // the view is being destroyed. 518 // the view is being destroyed.
519 ShowView(BUBBLE_VIEW_MODE_PROFILE_CHOOSER, avatar_menu); 519 ShowView(profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER, avatar_menu);
520 } 520 }
521 521
522 void ProfileChooserView::OnRefreshTokenAvailable( 522 void ProfileChooserView::OnRefreshTokenAvailable(
523 const std::string& account_id) { 523 const std::string& account_id) {
524 // Refresh the account management view when a new account is added to the 524 // Refresh the account management view when a new account is added to the
525 // profile. 525 // profile.
526 if (view_mode_ == BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT || 526 if (view_mode_ == profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT ||
527 view_mode_ == BUBBLE_VIEW_MODE_GAIA_SIGNIN || 527 view_mode_ == profiles::BUBBLE_VIEW_MODE_GAIA_SIGNIN ||
528 view_mode_ == BUBBLE_VIEW_MODE_GAIA_ADD_ACCOUNT || 528 view_mode_ == profiles::BUBBLE_VIEW_MODE_GAIA_ADD_ACCOUNT ||
529 view_mode_ == BUBBLE_VIEW_MODE_GAIA_REAUTH) { 529 view_mode_ == profiles::BUBBLE_VIEW_MODE_GAIA_REAUTH) {
530 ShowView(BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT, avatar_menu_.get()); 530 ShowView(profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT, avatar_menu_.get());
531 } 531 }
532 } 532 }
533 533
534 void ProfileChooserView::OnRefreshTokenRevoked(const std::string& account_id) { 534 void ProfileChooserView::OnRefreshTokenRevoked(const std::string& account_id) {
535 // Refresh the account management view when an account is removed from the 535 // Refresh the account management view when an account is removed from the
536 // profile. 536 // profile.
537 if (view_mode_ == BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT) 537 if (view_mode_ == profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT)
538 ShowView(BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT, avatar_menu_.get()); 538 ShowView(profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT, avatar_menu_.get());
539 } 539 }
540 540
541 void ProfileChooserView::ShowView(BubbleViewMode view_to_display, 541 void ProfileChooserView::ShowView(profiles::BubbleViewMode view_to_display,
542 AvatarMenu* avatar_menu) { 542 AvatarMenu* avatar_menu) {
543 // The account management view should only be displayed if the active profile 543 // The account management view should only be displayed if the active profile
544 // is signed in. 544 // is signed in.
545 if (view_to_display == BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT) { 545 if (view_to_display == profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT) {
546 const AvatarMenu::Item& active_item = avatar_menu->GetItemAt( 546 const AvatarMenu::Item& active_item = avatar_menu->GetItemAt(
547 avatar_menu->GetActiveProfileIndex()); 547 avatar_menu->GetActiveProfileIndex());
548 DCHECK(active_item.signed_in); 548 DCHECK(active_item.signed_in);
549 } 549 }
550 550
551 // Records the last tutorial mode. 551 // Records the last tutorial mode.
552 TutorialMode last_tutorial_mode = tutorial_mode_; 552 profiles::TutorialMode last_tutorial_mode = tutorial_mode_;
553 ResetView(); 553 ResetView();
554 RemoveAllChildViews(true); 554 RemoveAllChildViews(true);
555 view_mode_ = view_to_display; 555 view_mode_ = view_to_display;
556 556
557 views::GridLayout* layout; 557 views::GridLayout* layout;
558 views::View* sub_view; 558 views::View* sub_view;
559 switch (view_mode_) { 559 switch (view_mode_) {
560 case BUBBLE_VIEW_MODE_GAIA_SIGNIN: 560 case profiles::BUBBLE_VIEW_MODE_GAIA_SIGNIN:
561 case BUBBLE_VIEW_MODE_GAIA_ADD_ACCOUNT: 561 case profiles::BUBBLE_VIEW_MODE_GAIA_ADD_ACCOUNT:
562 case BUBBLE_VIEW_MODE_GAIA_REAUTH: 562 case profiles::BUBBLE_VIEW_MODE_GAIA_REAUTH:
563 layout = CreateSingleColumnLayout(this, kFixedGaiaViewWidth); 563 layout = CreateSingleColumnLayout(this, kFixedGaiaViewWidth);
564 sub_view = CreateGaiaSigninView(); 564 sub_view = CreateGaiaSigninView();
565 break; 565 break;
566 case BUBBLE_VIEW_MODE_ACCOUNT_REMOVAL: 566 case profiles::BUBBLE_VIEW_MODE_ACCOUNT_REMOVAL:
567 layout = CreateSingleColumnLayout(this, kFixedAccountRemovalViewWidth); 567 layout = CreateSingleColumnLayout(this, kFixedAccountRemovalViewWidth);
568 sub_view = CreateAccountRemovalView(); 568 sub_view = CreateAccountRemovalView();
569 break; 569 break;
570 case BUBBLE_VIEW_MODE_END_PREVIEW: 570 case profiles::BUBBLE_VIEW_MODE_END_PREVIEW:
571 layout = CreateSingleColumnLayout(this, kFixedEndPreviewViewWidth); 571 layout = CreateSingleColumnLayout(this, kFixedEndPreviewViewWidth);
572 sub_view = CreateEndPreviewView(); 572 sub_view = CreateEndPreviewView();
573 break; 573 break;
574 default: 574 default:
575 layout = CreateSingleColumnLayout(this, kFixedMenuWidth); 575 layout = CreateSingleColumnLayout(this, kFixedMenuWidth);
576 sub_view = CreateProfileChooserView(avatar_menu, last_tutorial_mode); 576 sub_view = CreateProfileChooserView(avatar_menu, last_tutorial_mode);
577 } 577 }
578 sub_view->set_background(views::Background::CreateSolidBackground( 578 sub_view->set_background(views::Background::CreateSolidBackground(
579 GetNativeTheme()->GetSystemColor( 579 GetNativeTheme()->GetSystemColor(
580 ui::NativeTheme::kColorId_DialogBackground))); 580 ui::NativeTheme::kColorId_DialogBackground)));
(...skipping 28 matching lines...) Expand all
609 } else if (sender == tutorial_ok_button_) { 609 } else if (sender == tutorial_ok_button_) {
610 // If the user manually dismissed the tutorial, never show it again by 610 // If the user manually dismissed the tutorial, never show it again by
611 // setting the number of times shown to the maximum plus 1, so that later we 611 // setting the number of times shown to the maximum plus 1, so that later we
612 // could distinguish between the dismiss case and the case when the tutorial 612 // could distinguish between the dismiss case and the case when the tutorial
613 // is indeed shown for the maximum number of times. 613 // is indeed shown for the maximum number of times.
614 browser_->profile()->GetPrefs()->SetInteger( 614 browser_->profile()->GetPrefs()->SetInteger(
615 prefs::kProfileAvatarTutorialShown, kProfileAvatarTutorialShowMax + 1); 615 prefs::kProfileAvatarTutorialShown, kProfileAvatarTutorialShowMax + 1);
616 616
617 ProfileMetrics::LogProfileUpgradeEnrollment( 617 ProfileMetrics::LogProfileUpgradeEnrollment(
618 ProfileMetrics::PROFILE_ENROLLMENT_CLOSE_WELCOME_CARD); 618 ProfileMetrics::PROFILE_ENROLLMENT_CLOSE_WELCOME_CARD);
619 ShowView(BUBBLE_VIEW_MODE_PROFILE_CHOOSER, avatar_menu_.get()); 619 ShowView(profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER, avatar_menu_.get());
620 } else if (sender == tutorial_enable_new_profile_management_button_) { 620 } else if (sender == tutorial_enable_new_profile_management_button_) {
621 ProfileMetrics::LogProfileUpgradeEnrollment( 621 ProfileMetrics::LogProfileUpgradeEnrollment(
622 ProfileMetrics::PROFILE_ENROLLMENT_ACCEPT_NEW_PROFILE_MGMT); 622 ProfileMetrics::PROFILE_ENROLLMENT_ACCEPT_NEW_PROFILE_MGMT);
623 profiles::EnableNewProfileManagementPreview(); 623 profiles::EnableNewProfileManagementPreview();
624 } else if (sender == remove_account_button_) { 624 } else if (sender == remove_account_button_) {
625 RemoveAccount(); 625 RemoveAccount();
626 } else if (sender == account_removal_cancel_button_) { 626 } else if (sender == account_removal_cancel_button_) {
627 account_id_to_remove_.clear(); 627 account_id_to_remove_.clear();
628 ShowView(BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT, avatar_menu_.get()); 628 ShowView(profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT, avatar_menu_.get());
629 } else if (sender == gaia_signin_cancel_button_) { 629 } else if (sender == gaia_signin_cancel_button_) {
630 std::string primary_account = 630 std::string primary_account =
631 SigninManagerFactory::GetForProfile(browser_->profile())-> 631 SigninManagerFactory::GetForProfile(browser_->profile())->
632 GetAuthenticatedUsername(); 632 GetAuthenticatedUsername();
633 ShowView(primary_account.empty() ? BUBBLE_VIEW_MODE_PROFILE_CHOOSER : 633 ShowView(primary_account.empty() ?
634 BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT, 634 profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER :
635 profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT,
635 avatar_menu_.get()); 636 avatar_menu_.get());
636 } else if (sender == question_mark_button_) { 637 } else if (sender == question_mark_button_) {
637 tutorial_mode_ = TUTORIAL_MODE_SEND_FEEDBACK; 638 tutorial_mode_ = profiles::TUTORIAL_MODE_SEND_FEEDBACK;
638 ShowView(BUBBLE_VIEW_MODE_PROFILE_CHOOSER, avatar_menu_.get()); 639 ShowView(profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER, avatar_menu_.get());
639 } else if (sender == tutorial_send_feedback_button_) { 640 } else if (sender == tutorial_send_feedback_button_) {
640 ProfileMetrics::LogProfileUpgradeEnrollment( 641 ProfileMetrics::LogProfileUpgradeEnrollment(
641 ProfileMetrics::PROFILE_ENROLLMENT_SEND_FEEDBACK); 642 ProfileMetrics::PROFILE_ENROLLMENT_SEND_FEEDBACK);
642 chrome::OpenFeedbackDialog(browser_); 643 chrome::OpenFeedbackDialog(browser_);
643 } else if (sender == end_preview_and_relaunch_button_) { 644 } else if (sender == end_preview_and_relaunch_button_) {
644 ProfileMetrics::LogProfileUpgradeEnrollment( 645 ProfileMetrics::LogProfileUpgradeEnrollment(
645 ProfileMetrics::PROFILE_ENROLLMENT_DISABLE_NEW_PROFILE_MGMT); 646 ProfileMetrics::PROFILE_ENROLLMENT_DISABLE_NEW_PROFILE_MGMT);
646 profiles::DisableNewProfileManagementPreview(); 647 profiles::DisableNewProfileManagementPreview();
647 } else if (sender == end_preview_cancel_button_) { 648 } else if (sender == end_preview_cancel_button_) {
648 tutorial_mode_ = TUTORIAL_MODE_SEND_FEEDBACK; 649 tutorial_mode_ = profiles::TUTORIAL_MODE_SEND_FEEDBACK;
649 ShowView(BUBBLE_VIEW_MODE_PROFILE_CHOOSER, avatar_menu_.get()); 650 ShowView(profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER, avatar_menu_.get());
650 } else if (current_profile_photo_ && 651 } else if (current_profile_photo_ &&
651 sender == current_profile_photo_->change_photo_button()) { 652 sender == current_profile_photo_->change_photo_button()) {
652 avatar_menu_->EditProfile(avatar_menu_->GetActiveProfileIndex()); 653 avatar_menu_->EditProfile(avatar_menu_->GetActiveProfileIndex());
653 } else if (sender == signin_current_profile_link_) { 654 } else if (sender == signin_current_profile_link_) {
654 // Only show the inline signin if the new UI flag is flipped. Otherwise, 655 // Only show the inline signin if the new UI flag is flipped. Otherwise,
655 // use the tab signin page. 656 // use the tab signin page.
656 if (switches::IsNewProfileManagement()) 657 if (switches::IsNewProfileManagement())
657 ShowView(BUBBLE_VIEW_MODE_GAIA_SIGNIN, avatar_menu_.get()); 658 ShowView(profiles::BUBBLE_VIEW_MODE_GAIA_SIGNIN, avatar_menu_.get());
658 else 659 else
659 chrome::ShowBrowserSignin(browser_, signin::SOURCE_MENU); 660 chrome::ShowBrowserSignin(browser_, signin::SOURCE_MENU);
660 } else { 661 } else {
661 // Either one of the "other profiles", or one of the profile accounts 662 // Either one of the "other profiles", or one of the profile accounts
662 // buttons was pressed. 663 // buttons was pressed.
663 ButtonIndexes::const_iterator profile_match = 664 ButtonIndexes::const_iterator profile_match =
664 open_other_profile_indexes_map_.find(sender); 665 open_other_profile_indexes_map_.find(sender);
665 if (profile_match != open_other_profile_indexes_map_.end()) { 666 if (profile_match != open_other_profile_indexes_map_.end()) {
666 avatar_menu_->SwitchToProfile( 667 avatar_menu_->SwitchToProfile(
667 profile_match->second, 668 profile_match->second,
668 ui::DispositionFromEventFlags(event.flags()) == NEW_WINDOW, 669 ui::DispositionFromEventFlags(event.flags()) == NEW_WINDOW,
669 ProfileMetrics::SWITCH_PROFILE_ICON); 670 ProfileMetrics::SWITCH_PROFILE_ICON);
670 } else { 671 } else {
671 // This was a profile accounts button. 672 // This was a profile accounts button.
672 AccountButtonIndexes::const_iterator account_match = 673 AccountButtonIndexes::const_iterator account_match =
673 delete_account_button_map_.find(sender); 674 delete_account_button_map_.find(sender);
674 if (account_match != delete_account_button_map_.end()) { 675 if (account_match != delete_account_button_map_.end()) {
675 account_id_to_remove_ = account_match->second; 676 account_id_to_remove_ = account_match->second;
676 ShowView(BUBBLE_VIEW_MODE_ACCOUNT_REMOVAL, avatar_menu_.get()); 677 ShowView(profiles::BUBBLE_VIEW_MODE_ACCOUNT_REMOVAL,
678 avatar_menu_.get());
677 } else { 679 } else {
678 account_match = reauth_account_button_map_.find(sender); 680 account_match = reauth_account_button_map_.find(sender);
679 DCHECK(account_match != reauth_account_button_map_.end()); 681 DCHECK(account_match != reauth_account_button_map_.end());
680 ShowView(BUBBLE_VIEW_MODE_GAIA_REAUTH, avatar_menu_.get()); 682 ShowView(profiles::BUBBLE_VIEW_MODE_GAIA_REAUTH, avatar_menu_.get());
681 } 683 }
682 } 684 }
683 } 685 }
684 } 686 }
685 687
686 void ProfileChooserView::RemoveAccount() { 688 void ProfileChooserView::RemoveAccount() {
687 DCHECK(!account_id_to_remove_.empty()); 689 DCHECK(!account_id_to_remove_.empty());
688 MutableProfileOAuth2TokenService* oauth2_token_service = 690 MutableProfileOAuth2TokenService* oauth2_token_service =
689 ProfileOAuth2TokenServiceFactory::GetPlatformSpecificForProfile( 691 ProfileOAuth2TokenServiceFactory::GetPlatformSpecificForProfile(
690 browser_->profile()); 692 browser_->profile());
691 if (oauth2_token_service) 693 if (oauth2_token_service)
692 oauth2_token_service->RevokeCredentials(account_id_to_remove_); 694 oauth2_token_service->RevokeCredentials(account_id_to_remove_);
693 account_id_to_remove_.clear(); 695 account_id_to_remove_.clear();
694 696
695 ShowView(BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT, avatar_menu_.get()); 697 ShowView(profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT, avatar_menu_.get());
696 } 698 }
697 699
698 void ProfileChooserView::LinkClicked(views::Link* sender, int event_flags) { 700 void ProfileChooserView::LinkClicked(views::Link* sender, int event_flags) {
699 if (sender == manage_accounts_link_) { 701 if (sender == manage_accounts_link_) {
700 // This link can either mean show/hide the account management view, 702 // This link can either mean show/hide the account management view,
701 // depending on which view it is displayed. ShowView() will DCHECK if 703 // depending on which view it is displayed. ShowView() will DCHECK if
702 // the account management view is displayed for non signed-in users. 704 // the account management view is displayed for non signed-in users.
703 ShowView( 705 ShowView(
704 view_mode_ == BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT ? 706 view_mode_ == profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT ?
705 BUBBLE_VIEW_MODE_PROFILE_CHOOSER : 707 profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER :
706 BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT, 708 profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT,
707 avatar_menu_.get()); 709 avatar_menu_.get());
708 } else if (sender == add_account_link_) { 710 } else if (sender == add_account_link_) {
709 ShowView(BUBBLE_VIEW_MODE_GAIA_ADD_ACCOUNT, avatar_menu_.get()); 711 ShowView(profiles::BUBBLE_VIEW_MODE_GAIA_ADD_ACCOUNT, avatar_menu_.get());
710 } else if (sender == tutorial_learn_more_link_) { 712 } else if (sender == tutorial_learn_more_link_) {
711 ProfileMetrics::LogProfileUpgradeEnrollment( 713 ProfileMetrics::LogProfileUpgradeEnrollment(
712 ProfileMetrics::PROFILE_ENROLLMENT_LAUNCH_LEARN_MORE); 714 ProfileMetrics::PROFILE_ENROLLMENT_LAUNCH_LEARN_MORE);
713 // TODO(guohui): update |learn_more_url| once it is decided. 715 // TODO(guohui): update |learn_more_url| once it is decided.
714 const GURL lear_more_url("https://support.google.com/chrome/?hl=en#to"); 716 const GURL lear_more_url("https://support.google.com/chrome/?hl=en#to");
715 chrome::NavigateParams params( 717 chrome::NavigateParams params(
716 browser_->profile(), 718 browser_->profile(),
717 lear_more_url, 719 lear_more_url,
718 content::PAGE_TRANSITION_LINK); 720 content::PAGE_TRANSITION_LINK);
719 params.disposition = NEW_FOREGROUND_TAB; 721 params.disposition = NEW_FOREGROUND_TAB;
720 chrome::Navigate(&params); 722 chrome::Navigate(&params);
721 } else { 723 } else {
722 DCHECK(sender == tutorial_end_preview_link_); 724 DCHECK(sender == tutorial_end_preview_link_);
723 ShowView(BUBBLE_VIEW_MODE_END_PREVIEW, avatar_menu_.get()); 725 ShowView(profiles::BUBBLE_VIEW_MODE_END_PREVIEW, avatar_menu_.get());
724 } 726 }
725 } 727 }
726 728
727 void ProfileChooserView::StyledLabelLinkClicked( 729 void ProfileChooserView::StyledLabelLinkClicked(
728 const gfx::Range& range, int event_flags) { 730 const gfx::Range& range, int event_flags) {
729 chrome::ShowSettings(browser_); 731 chrome::ShowSettings(browser_);
730 } 732 }
731 733
732 bool ProfileChooserView::HandleKeyEvent(views::Textfield* sender, 734 bool ProfileChooserView::HandleKeyEvent(views::Textfield* sender,
733 const ui::KeyEvent& key_event) { 735 const ui::KeyEvent& key_event) {
(...skipping 19 matching lines...) Expand all
753 755
754 profiles::UpdateProfileName(profile, new_profile_name); 756 profiles::UpdateProfileName(profile, new_profile_name);
755 current_profile_name_->ShowReadOnlyView(); 757 current_profile_name_->ShowReadOnlyView();
756 return true; 758 return true;
757 } 759 }
758 return false; 760 return false;
759 } 761 }
760 762
761 views::View* ProfileChooserView::CreateProfileChooserView( 763 views::View* ProfileChooserView::CreateProfileChooserView(
762 AvatarMenu* avatar_menu, 764 AvatarMenu* avatar_menu,
763 TutorialMode last_tutorial_mode) { 765 profiles::TutorialMode last_tutorial_mode) {
764 // TODO(guohui, noms): the view should be customized based on whether new 766 // TODO(guohui, noms): the view should be customized based on whether new
765 // profile management preview is enabled or not. 767 // profile management preview is enabled or not.
766 768
767 views::View* view = new views::View(); 769 views::View* view = new views::View();
768 views::GridLayout* layout = CreateSingleColumnLayout(view, kFixedMenuWidth); 770 views::GridLayout* layout = CreateSingleColumnLayout(view, kFixedMenuWidth);
769 // Separate items into active and alternatives. 771 // Separate items into active and alternatives.
770 Indexes other_profiles; 772 Indexes other_profiles;
771 views::View* tutorial_view = NULL; 773 views::View* tutorial_view = NULL;
772 views::View* current_profile_view = NULL; 774 views::View* current_profile_view = NULL;
773 views::View* current_profile_accounts = NULL; 775 views::View* current_profile_accounts = NULL;
774 views::View* option_buttons_view = NULL; 776 views::View* option_buttons_view = NULL;
775 bool is_new_profile_management = switches::IsNewProfileManagement(); 777 bool is_new_profile_management = switches::IsNewProfileManagement();
776 for (size_t i = 0; i < avatar_menu->GetNumberOfItems(); ++i) { 778 for (size_t i = 0; i < avatar_menu->GetNumberOfItems(); ++i) {
777 const AvatarMenu::Item& item = avatar_menu->GetItemAt(i); 779 const AvatarMenu::Item& item = avatar_menu->GetItemAt(i);
778 if (item.active) { 780 if (item.active) {
779 option_buttons_view = CreateOptionsView(item.signed_in); 781 option_buttons_view = CreateOptionsView(item.signed_in);
780 current_profile_view = CreateCurrentProfileView(item, false); 782 current_profile_view = CreateCurrentProfileView(item, false);
781 if (view_mode_ == BUBBLE_VIEW_MODE_PROFILE_CHOOSER) { 783 if (view_mode_ == profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER) {
782 if (is_new_profile_management) { 784 if (is_new_profile_management) {
783 tutorial_view = last_tutorial_mode == TUTORIAL_MODE_SEND_FEEDBACK ? 785 tutorial_view =
786 last_tutorial_mode == profiles::TUTORIAL_MODE_SEND_FEEDBACK ?
784 CreateSendPreviewFeedbackView() : 787 CreateSendPreviewFeedbackView() :
785 CreatePreviewEnabledTutorialView( 788 CreatePreviewEnabledTutorialView(
786 item, last_tutorial_mode == TUTORIAL_MODE_PREVIEW_ENABLED); 789 item, last_tutorial_mode == profiles::TUTORIAL_MODE_WELCOME);
787 } else { 790 } else {
788 tutorial_view = CreateNewProfileManagementPreviewView(); 791 tutorial_view = CreateNewProfileManagementPreviewView();
789 } 792 }
790 } else { 793 } else {
791 current_profile_accounts = CreateCurrentProfileAccountsView(item); 794 current_profile_accounts = CreateCurrentProfileAccountsView(item);
792 } 795 }
793 } else { 796 } else {
794 other_profiles.push_back(i); 797 other_profiles.push_back(i);
795 } 798 }
796 } 799 }
(...skipping 11 matching lines...) Expand all
808 811
809 if (!current_profile_view) { 812 if (!current_profile_view) {
810 // Guest windows don't have an active profile. 813 // Guest windows don't have an active profile.
811 current_profile_view = CreateGuestProfileView(); 814 current_profile_view = CreateGuestProfileView();
812 option_buttons_view = CreateOptionsView(false); 815 option_buttons_view = CreateOptionsView(false);
813 } 816 }
814 817
815 layout->StartRow(1, 0); 818 layout->StartRow(1, 0);
816 layout->AddView(current_profile_view); 819 layout->AddView(current_profile_view);
817 820
818 if (view_mode_ == BUBBLE_VIEW_MODE_PROFILE_CHOOSER) { 821 if (view_mode_ == profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER) {
819 layout->StartRow(1, 0); 822 layout->StartRow(1, 0);
820 if (switches::IsFastUserSwitching()) 823 if (switches::IsFastUserSwitching())
821 layout->AddView(CreateOtherProfilesView(other_profiles)); 824 layout->AddView(CreateOtherProfilesView(other_profiles));
822 } else { 825 } else {
823 DCHECK(current_profile_accounts); 826 DCHECK(current_profile_accounts);
824 layout->StartRow(0, 0); 827 layout->StartRow(0, 0);
825 layout->AddView(new views::Separator(views::Separator::HORIZONTAL)); 828 layout->AddView(new views::Separator(views::Separator::HORIZONTAL));
826 layout->StartRow(1, 0); 829 layout->StartRow(1, 0);
827 layout->AddView(current_profile_accounts); 830 layout->AddView(current_profile_accounts);
828 } 831 }
(...skipping 24 matching lines...) Expand all
853 return NULL; 856 return NULL;
854 857
855 if (!tutorial_shown) { 858 if (!tutorial_shown) {
856 if (show_count == kProfileAvatarTutorialShowMax) 859 if (show_count == kProfileAvatarTutorialShowMax)
857 return NULL; 860 return NULL;
858 profile->GetPrefs()->SetInteger( 861 profile->GetPrefs()->SetInteger(
859 prefs::kProfileAvatarTutorialShown, show_count + 1); 862 prefs::kProfileAvatarTutorialShown, show_count + 1);
860 } 863 }
861 864
862 return CreateTutorialView( 865 return CreateTutorialView(
863 TUTORIAL_MODE_PREVIEW_ENABLED, 866 profiles::TUTORIAL_MODE_WELCOME,
864 l10n_util::GetStringUTF16(IDS_PROFILES_PREVIEW_ENABLED_TUTORIAL_TITLE), 867 l10n_util::GetStringUTF16(IDS_PROFILES_PREVIEW_ENABLED_TUTORIAL_TITLE),
865 l10n_util::GetStringUTF16( 868 l10n_util::GetStringUTF16(
866 IDS_PROFILES_PREVIEW_ENABLED_TUTORIAL_CONTENT_TEXT), 869 IDS_PROFILES_PREVIEW_ENABLED_TUTORIAL_CONTENT_TEXT),
867 l10n_util::GetStringUTF16(IDS_PROFILES_PROFILE_TUTORIAL_LEARN_MORE), 870 l10n_util::GetStringUTF16(IDS_PROFILES_PROFILE_TUTORIAL_LEARN_MORE),
868 l10n_util::GetStringUTF16(IDS_PROFILES_TUTORIAL_OK_BUTTON), 871 l10n_util::GetStringUTF16(IDS_PROFILES_TUTORIAL_OK_BUTTON),
869 &tutorial_learn_more_link_, 872 &tutorial_learn_more_link_,
870 &tutorial_ok_button_); 873 &tutorial_ok_button_);
871 } 874 }
872 875
873 views::View* ProfileChooserView::CreateSendPreviewFeedbackView() { 876 views::View* ProfileChooserView::CreateSendPreviewFeedbackView() {
874 return CreateTutorialView( 877 return CreateTutorialView(
875 TUTORIAL_MODE_SEND_FEEDBACK, 878 profiles::TUTORIAL_MODE_SEND_FEEDBACK,
876 l10n_util::GetStringUTF16(IDS_PROFILES_FEEDBACK_TUTORIAL_TITLE), 879 l10n_util::GetStringUTF16(IDS_PROFILES_FEEDBACK_TUTORIAL_TITLE),
877 l10n_util::GetStringUTF16( 880 l10n_util::GetStringUTF16(
878 IDS_PROFILES_FEEDBACK_TUTORIAL_CONTENT_TEXT), 881 IDS_PROFILES_FEEDBACK_TUTORIAL_CONTENT_TEXT),
879 l10n_util::GetStringUTF16(IDS_PROFILES_END_PREVIEW), 882 l10n_util::GetStringUTF16(IDS_PROFILES_END_PREVIEW),
880 l10n_util::GetStringUTF16(IDS_PROFILES_SEND_FEEDBACK_BUTTON), 883 l10n_util::GetStringUTF16(IDS_PROFILES_SEND_FEEDBACK_BUTTON),
881 &tutorial_end_preview_link_, 884 &tutorial_end_preview_link_,
882 &tutorial_send_feedback_button_); 885 &tutorial_send_feedback_button_);
883 } 886 }
884 887
885 views::View* ProfileChooserView::CreateTutorialView( 888 views::View* ProfileChooserView::CreateTutorialView(
886 TutorialMode tutorial_mode, 889 profiles::TutorialMode tutorial_mode,
887 const base::string16& title_text, 890 const base::string16& title_text,
888 const base::string16& content_text, 891 const base::string16& content_text,
889 const base::string16& link_text, 892 const base::string16& link_text,
890 const base::string16& button_text, 893 const base::string16& button_text,
891 views::Link** link, 894 views::Link** link,
892 views::LabelButton** button) { 895 views::LabelButton** button) {
893 tutorial_mode_ = tutorial_mode; 896 tutorial_mode_ = tutorial_mode;
894 897
895 views::View* view = new views::View(); 898 views::View* view = new views::View();
896 view->set_background(views::Background::CreateSolidBackground( 899 view->set_background(views::Background::CreateSolidBackground(
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
1022 layout->AddView(current_profile_name_); 1025 layout->AddView(current_profile_name_);
1023 1026
1024 if (is_guest) 1027 if (is_guest)
1025 return view; 1028 return view;
1026 1029
1027 // The available links depend on the type of profile that is active. 1030 // The available links depend on the type of profile that is active.
1028 if (avatar_item.signed_in) { 1031 if (avatar_item.signed_in) {
1029 layout->StartRow(1, 0); 1032 layout->StartRow(1, 0);
1030 if (switches::IsNewProfileManagement()) { 1033 if (switches::IsNewProfileManagement()) {
1031 base::string16 link_title = l10n_util::GetStringUTF16( 1034 base::string16 link_title = l10n_util::GetStringUTF16(
1032 view_mode_ == BUBBLE_VIEW_MODE_PROFILE_CHOOSER ? 1035 view_mode_ == profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER ?
1033 IDS_PROFILES_PROFILE_MANAGE_ACCOUNTS_BUTTON : 1036 IDS_PROFILES_PROFILE_MANAGE_ACCOUNTS_BUTTON :
1034 IDS_PROFILES_PROFILE_HIDE_MANAGE_ACCOUNTS_BUTTON); 1037 IDS_PROFILES_PROFILE_HIDE_MANAGE_ACCOUNTS_BUTTON);
1035 manage_accounts_link_ = CreateLink(link_title, this); 1038 manage_accounts_link_ = CreateLink(link_title, this);
1036 manage_accounts_link_->SetHorizontalAlignment(gfx::ALIGN_CENTER); 1039 manage_accounts_link_->SetHorizontalAlignment(gfx::ALIGN_CENTER);
1037 layout->AddView(manage_accounts_link_); 1040 layout->AddView(manage_accounts_link_);
1038 } else { 1041 } else {
1039 views::Label* email_label = new views::Label(avatar_item.sync_state); 1042 views::Label* email_label = new views::Label(avatar_item.sync_state);
1040 email_label->SetHorizontalAlignment(gfx::ALIGN_CENTER); 1043 email_label->SetHorizontalAlignment(gfx::ALIGN_CENTER);
1041 layout->AddView(email_label); 1044 layout->AddView(email_label);
1042 } 1045 }
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
1254 email_button->AddChildView(reauth_button); 1257 email_button->AddChildView(reauth_button);
1255 reauth_account_button_map_[reauth_button] = account; 1258 reauth_account_button_map_[reauth_button] = account;
1256 } 1259 }
1257 } 1260 }
1258 1261
1259 views::View* ProfileChooserView::CreateGaiaSigninView() { 1262 views::View* ProfileChooserView::CreateGaiaSigninView() {
1260 GURL url; 1263 GURL url;
1261 int message_id; 1264 int message_id;
1262 1265
1263 switch (view_mode_) { 1266 switch (view_mode_) {
1264 case BUBBLE_VIEW_MODE_GAIA_SIGNIN: 1267 case profiles::BUBBLE_VIEW_MODE_GAIA_SIGNIN:
1265 url = signin::GetPromoURL(signin::SOURCE_AVATAR_BUBBLE_SIGN_IN, 1268 url = signin::GetPromoURL(signin::SOURCE_AVATAR_BUBBLE_SIGN_IN,
1266 false /* auto_close */, 1269 false /* auto_close */,
1267 true /* is_constrained */); 1270 true /* is_constrained */);
1268 message_id = IDS_PROFILES_GAIA_SIGNIN_TITLE; 1271 message_id = IDS_PROFILES_GAIA_SIGNIN_TITLE;
1269 break; 1272 break;
1270 case BUBBLE_VIEW_MODE_GAIA_ADD_ACCOUNT: 1273 case profiles::BUBBLE_VIEW_MODE_GAIA_ADD_ACCOUNT:
1271 url = signin::GetPromoURL(signin::SOURCE_AVATAR_BUBBLE_ADD_ACCOUNT, 1274 url = signin::GetPromoURL(signin::SOURCE_AVATAR_BUBBLE_ADD_ACCOUNT,
1272 false /* auto_close */, 1275 false /* auto_close */,
1273 true /* is_constrained */); 1276 true /* is_constrained */);
1274 message_id = IDS_PROFILES_GAIA_ADD_ACCOUNT_TITLE; 1277 message_id = IDS_PROFILES_GAIA_ADD_ACCOUNT_TITLE;
1275 break; 1278 break;
1276 case BUBBLE_VIEW_MODE_GAIA_REAUTH: { 1279 case profiles::BUBBLE_VIEW_MODE_GAIA_REAUTH: {
1277 DCHECK(HasAuthError(browser_->profile())); 1280 DCHECK(HasAuthError(browser_->profile()));
1278 url = signin::GetReauthURL(browser_->profile(), 1281 url = signin::GetReauthURL(browser_->profile(),
1279 GetAuthErrorUsername(browser_->profile())); 1282 GetAuthErrorUsername(browser_->profile()));
1280 message_id = IDS_PROFILES_GAIA_REAUTH_TITLE; 1283 message_id = IDS_PROFILES_GAIA_REAUTH_TITLE;
1281 break; 1284 break;
1282 } 1285 }
1283 default: 1286 default:
1284 NOTREACHED() << "Called with invalid mode=" << view_mode_; 1287 NOTREACHED() << "Called with invalid mode=" << view_mode_;
1285 return NULL; 1288 return NULL;
1286 } 1289 }
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
1354 } 1357 }
1355 1358
1356 TitleCard* title_card = new TitleCard(IDS_PROFILES_ACCOUNT_REMOVAL_TITLE, 1359 TitleCard* title_card = new TitleCard(IDS_PROFILES_ACCOUNT_REMOVAL_TITLE,
1357 this, &account_removal_cancel_button_); 1360 this, &account_removal_cancel_button_);
1358 return TitleCard::AddPaddedTitleCard(view, title_card, 1361 return TitleCard::AddPaddedTitleCard(view, title_card,
1359 kFixedAccountRemovalViewWidth); 1362 kFixedAccountRemovalViewWidth);
1360 } 1363 }
1361 1364
1362 views::View* ProfileChooserView::CreateNewProfileManagementPreviewView() { 1365 views::View* ProfileChooserView::CreateNewProfileManagementPreviewView() {
1363 return CreateTutorialView( 1366 return CreateTutorialView(
1364 TUTORIAL_MODE_ENABLE_PREVIEW, 1367 profiles::TUTORIAL_MODE_ENABLE_PREVIEW,
1365 l10n_util::GetStringUTF16(IDS_PROFILES_PREVIEW_TUTORIAL_TITLE), 1368 l10n_util::GetStringUTF16(IDS_PROFILES_PREVIEW_TUTORIAL_TITLE),
1366 l10n_util::GetStringUTF16(IDS_PROFILES_PREVIEW_TUTORIAL_CONTENT_TEXT), 1369 l10n_util::GetStringUTF16(IDS_PROFILES_PREVIEW_TUTORIAL_CONTENT_TEXT),
1367 l10n_util::GetStringUTF16(IDS_PROFILES_PROFILE_TUTORIAL_LEARN_MORE), 1370 l10n_util::GetStringUTF16(IDS_PROFILES_PROFILE_TUTORIAL_LEARN_MORE),
1368 l10n_util::GetStringUTF16(IDS_PROFILES_TUTORIAL_TRY_BUTTON), 1371 l10n_util::GetStringUTF16(IDS_PROFILES_TUTORIAL_TRY_BUTTON),
1369 &tutorial_learn_more_link_, 1372 &tutorial_learn_more_link_,
1370 &tutorial_enable_new_profile_management_button_); 1373 &tutorial_enable_new_profile_management_button_);
1371 } 1374 }
1372 1375
1373 views::View* ProfileChooserView::CreateEndPreviewView() { 1376 views::View* ProfileChooserView::CreateEndPreviewView() {
1374 views::View* view = new views::View(); 1377 views::View* view = new views::View();
(...skipping 24 matching lines...) Expand all
1399 layout->StartRowWithPadding( 1402 layout->StartRowWithPadding(
1400 1, 0, 0, views::kUnrelatedControlVerticalSpacing); 1403 1, 0, 0, views::kUnrelatedControlVerticalSpacing);
1401 layout->AddView(end_preview_and_relaunch_button_); 1404 layout->AddView(end_preview_and_relaunch_button_);
1402 1405
1403 TitleCard* title_card = new TitleCard( 1406 TitleCard* title_card = new TitleCard(
1404 IDS_PROFILES_END_PREVIEW, this, &end_preview_cancel_button_); 1407 IDS_PROFILES_END_PREVIEW, this, &end_preview_cancel_button_);
1405 return TitleCard::AddPaddedTitleCard( 1408 return TitleCard::AddPaddedTitleCard(
1406 view, title_card, kFixedAccountRemovalViewWidth); 1409 view, title_card, kFixedAccountRemovalViewWidth);
1407 } 1410 }
1408 1411
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/profiles/profile_chooser_view.h ('k') | chrome/chrome_browser_ui.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698