| OLD | NEW |
| 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" |
| 11 #include "chrome/browser/profiles/profile_avatar_icon_util.h" | 11 #include "chrome/browser/profiles/profile_avatar_icon_util.h" |
| 12 #include "chrome/browser/profiles/profile_info_cache.h" | 12 #include "chrome/browser/profiles/profile_info_cache.h" |
| 13 #include "chrome/browser/profiles/profile_manager.h" | 13 #include "chrome/browser/profiles/profile_manager.h" |
| 14 #include "chrome/browser/profiles/profile_metrics.h" |
| 14 #include "chrome/browser/profiles/profile_window.h" | 15 #include "chrome/browser/profiles/profile_window.h" |
| 15 #include "chrome/browser/profiles/profiles_state.h" | 16 #include "chrome/browser/profiles/profiles_state.h" |
| 16 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" | 17 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" |
| 17 #include "chrome/browser/signin/signin_manager_factory.h" | 18 #include "chrome/browser/signin/signin_manager_factory.h" |
| 18 #include "chrome/browser/signin/signin_promo.h" | 19 #include "chrome/browser/signin/signin_promo.h" |
| 19 #include "chrome/browser/ui/browser.h" | 20 #include "chrome/browser/ui/browser.h" |
| 20 #include "chrome/browser/ui/browser_dialogs.h" | 21 #include "chrome/browser/ui/browser_dialogs.h" |
| 21 #include "chrome/browser/ui/chrome_pages.h" | 22 #include "chrome/browser/ui/chrome_pages.h" |
| 22 #include "chrome/browser/ui/singleton_tabs.h" | 23 #include "chrome/browser/ui/singleton_tabs.h" |
| 23 #include "chrome/browser/ui/views/profiles/user_manager_view.h" | 24 #include "chrome/browser/ui/views/profiles/user_manager_view.h" |
| (...skipping 498 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 522 profiles::ShowUserManagerMaybeWithTutorial(browser_->profile()); | 523 profiles::ShowUserManagerMaybeWithTutorial(browser_->profile()); |
| 523 } else if (sender == lock_button_) { | 524 } else if (sender == lock_button_) { |
| 524 profiles::LockProfile(browser_->profile()); | 525 profiles::LockProfile(browser_->profile()); |
| 525 } else if (sender == tutorial_ok_button_) { | 526 } else if (sender == tutorial_ok_button_) { |
| 526 // If the user manually dismissed the tutorial, never show it again by | 527 // If the user manually dismissed the tutorial, never show it again by |
| 527 // setting the number of times shown to the maximum plus 1, so that later we | 528 // setting the number of times shown to the maximum plus 1, so that later we |
| 528 // could distinguish between the dismiss case and the case when the tutorial | 529 // could distinguish between the dismiss case and the case when the tutorial |
| 529 // is indeed shown for the maximum number of times. | 530 // is indeed shown for the maximum number of times. |
| 530 browser_->profile()->GetPrefs()->SetInteger( | 531 browser_->profile()->GetPrefs()->SetInteger( |
| 531 prefs::kProfileAvatarTutorialShown, kProfileAvatarTutorialShowMax + 1); | 532 prefs::kProfileAvatarTutorialShown, kProfileAvatarTutorialShowMax + 1); |
| 533 |
| 534 ProfileMetrics::LogProfileMirrorEnrollment( |
| 535 ProfileMetrics::PROFILE_ENROLLMENT_CLOSE_WELCOME_CARD); |
| 532 ShowView(BUBBLE_VIEW_MODE_PROFILE_CHOOSER, avatar_menu_.get()); | 536 ShowView(BUBBLE_VIEW_MODE_PROFILE_CHOOSER, avatar_menu_.get()); |
| 533 } else if (sender == tutorial_enable_new_profile_management_button_) { | 537 } else if (sender == tutorial_enable_new_profile_management_button_) { |
| 538 ProfileMetrics::LogProfileMirrorEnrollment( |
| 539 ProfileMetrics::PROFILE_ENROLLMENT_ACCEPT_NEW_PROFILE_MGMT); |
| 534 profiles::EnableNewProfileManagementPreview(); | 540 profiles::EnableNewProfileManagementPreview(); |
| 535 } else if (sender == remove_account_and_relaunch_button_) { | 541 } else if (sender == remove_account_and_relaunch_button_) { |
| 536 RemoveAccount(); | 542 RemoveAccount(); |
| 537 } else if (sender == account_removal_cancel_button_) { | 543 } else if (sender == account_removal_cancel_button_) { |
| 538 account_id_to_remove_.clear(); | 544 account_id_to_remove_.clear(); |
| 539 ShowView(BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT, avatar_menu_.get()); | 545 ShowView(BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT, avatar_menu_.get()); |
| 540 } else if (sender == gaia_signin_cancel_button_) { | 546 } else if (sender == gaia_signin_cancel_button_) { |
| 541 std::string primary_account = | 547 std::string primary_account = |
| 542 SigninManagerFactory::GetForProfile(browser_->profile())-> | 548 SigninManagerFactory::GetForProfile(browser_->profile())-> |
| 543 GetAuthenticatedUsername(); | 549 GetAuthenticatedUsername(); |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 589 // the account management view is displayed for non signed-in users. | 595 // the account management view is displayed for non signed-in users. |
| 590 ShowView( | 596 ShowView( |
| 591 view_mode_ == BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT ? | 597 view_mode_ == BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT ? |
| 592 BUBBLE_VIEW_MODE_PROFILE_CHOOSER : | 598 BUBBLE_VIEW_MODE_PROFILE_CHOOSER : |
| 593 BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT, | 599 BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT, |
| 594 avatar_menu_.get()); | 600 avatar_menu_.get()); |
| 595 } else if (sender == add_account_link_) { | 601 } else if (sender == add_account_link_) { |
| 596 ShowView(BUBBLE_VIEW_MODE_GAIA_ADD_ACCOUNT, avatar_menu_.get()); | 602 ShowView(BUBBLE_VIEW_MODE_GAIA_ADD_ACCOUNT, avatar_menu_.get()); |
| 597 } else { | 603 } else { |
| 598 DCHECK(sender == tutorial_learn_more_link_); | 604 DCHECK(sender == tutorial_learn_more_link_); |
| 605 ProfileMetrics::LogProfileMirrorEnrollment( |
| 606 ProfileMetrics::PROFILE_ENROLLMENT_LAUNCH_LEARN_MORE); |
| 599 // TODO(guohui): update |learn_more_url| once it is decided. | 607 // TODO(guohui): update |learn_more_url| once it is decided. |
| 600 const GURL lear_more_url("https://support.google.com/chrome/?hl=en#to"); | 608 const GURL lear_more_url("https://support.google.com/chrome/?hl=en#to"); |
| 601 chrome::NavigateParams params( | 609 chrome::NavigateParams params( |
| 602 browser_->profile(), | 610 browser_->profile(), |
| 603 lear_more_url, | 611 lear_more_url, |
| 604 content::PAGE_TRANSITION_LINK); | 612 content::PAGE_TRANSITION_LINK); |
| 605 params.disposition = NEW_FOREGROUND_TAB; | 613 params.disposition = NEW_FOREGROUND_TAB; |
| 606 chrome::Navigate(¶ms); | 614 chrome::Navigate(¶ms); |
| 607 } | 615 } |
| 608 } | 616 } |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 665 CreateNewProfileManagementPreviewView(); | 673 CreateNewProfileManagementPreviewView(); |
| 666 } else { | 674 } else { |
| 667 current_profile_accounts = CreateCurrentProfileAccountsView(item); | 675 current_profile_accounts = CreateCurrentProfileAccountsView(item); |
| 668 } | 676 } |
| 669 } else { | 677 } else { |
| 670 other_profiles.push_back(i); | 678 other_profiles.push_back(i); |
| 671 } | 679 } |
| 672 } | 680 } |
| 673 | 681 |
| 674 if (tutorial_view) { | 682 if (tutorial_view) { |
| 683 // Be sure not to track the tutorial display on View refresh, and only count |
| 684 // the preview-promo view, not the welcome-enabled view. |
| 685 if (!tutorial_shown && !switches::IsNewProfileManagement()) { |
| 686 ProfileMetrics::LogProfileMirrorEnrollment( |
| 687 ProfileMetrics::PROFILE_ENROLLMENT_SHOW_PREVIEW_PROMO); |
| 688 } |
| 675 layout->StartRow(1, 0); | 689 layout->StartRow(1, 0); |
| 676 layout->AddView(tutorial_view); | 690 layout->AddView(tutorial_view); |
| 677 } | 691 } |
| 678 | 692 |
| 679 if (!current_profile_view) { | 693 if (!current_profile_view) { |
| 680 // Guest windows don't have an active profile. | 694 // Guest windows don't have an active profile. |
| 681 current_profile_view = CreateGuestProfileView(); | 695 current_profile_view = CreateGuestProfileView(); |
| 682 option_buttons_view = CreateOptionsView(false); | 696 option_buttons_view = CreateOptionsView(false); |
| 683 } | 697 } |
| 684 | 698 |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 721 // Do not show the tutorial if user has dismissed it. | 735 // Do not show the tutorial if user has dismissed it. |
| 722 if (show_count > kProfileAvatarTutorialShowMax) | 736 if (show_count > kProfileAvatarTutorialShowMax) |
| 723 return NULL; | 737 return NULL; |
| 724 | 738 |
| 725 if (!tutorial_shown) { | 739 if (!tutorial_shown) { |
| 726 if (show_count == kProfileAvatarTutorialShowMax) | 740 if (show_count == kProfileAvatarTutorialShowMax) |
| 727 return NULL; | 741 return NULL; |
| 728 profile->GetPrefs()->SetInteger( | 742 profile->GetPrefs()->SetInteger( |
| 729 prefs::kProfileAvatarTutorialShown, show_count + 1); | 743 prefs::kProfileAvatarTutorialShown, show_count + 1); |
| 730 } | 744 } |
| 731 tutorial_showing_ = true; | |
| 732 | 745 |
| 733 return CreateTutorialView( | 746 return CreateTutorialView( |
| 734 l10n_util::GetStringUTF16(IDS_PROFILES_PREVIEW_ENABLED_TUTORIAL_TITLE), | 747 l10n_util::GetStringUTF16(IDS_PROFILES_PREVIEW_ENABLED_TUTORIAL_TITLE), |
| 735 l10n_util::GetStringUTF16( | 748 l10n_util::GetStringUTF16( |
| 736 IDS_PROFILES_PREVIEW_ENABLED_TUTORIAL_CONTENT_TEXT), | 749 IDS_PROFILES_PREVIEW_ENABLED_TUTORIAL_CONTENT_TEXT), |
| 737 l10n_util::GetStringUTF16(IDS_PROFILES_PROFILE_TUTORIAL_LEARN_MORE), | 750 l10n_util::GetStringUTF16(IDS_PROFILES_PROFILE_TUTORIAL_LEARN_MORE), |
| 738 l10n_util::GetStringUTF16(IDS_PROFILES_TUTORIAL_OK_BUTTON), | 751 l10n_util::GetStringUTF16(IDS_PROFILES_TUTORIAL_OK_BUTTON), |
| 739 &tutorial_learn_more_link_, | 752 &tutorial_learn_more_link_, |
| 740 &tutorial_ok_button_); | 753 &tutorial_ok_button_); |
| 741 } | 754 } |
| 742 | 755 |
| 743 views::View* ProfileChooserView::CreateTutorialView( | 756 views::View* ProfileChooserView::CreateTutorialView( |
| 744 const base::string16& title_text, | 757 const base::string16& title_text, |
| 745 const base::string16& content_text, | 758 const base::string16& content_text, |
| 746 const base::string16& link_text, | 759 const base::string16& link_text, |
| 747 const base::string16& button_text, | 760 const base::string16& button_text, |
| 748 views::Link** link, | 761 views::Link** link, |
| 749 views::LabelButton** button) { | 762 views::LabelButton** button) { |
| 763 tutorial_showing_ = true; |
| 764 |
| 750 views::View* view = new views::View(); | 765 views::View* view = new views::View(); |
| 751 view->set_background(views::Background::CreateSolidBackground( | 766 view->set_background(views::Background::CreateSolidBackground( |
| 752 profiles::kAvatarTutorialBackgroundColor)); | 767 profiles::kAvatarTutorialBackgroundColor)); |
| 753 views::GridLayout* layout = CreateSingleColumnLayout(view, | 768 views::GridLayout* layout = CreateSingleColumnLayout(view, |
| 754 kFixedMenuWidth - 2 * views::kButtonHEdgeMarginNew); | 769 kFixedMenuWidth - 2 * views::kButtonHEdgeMarginNew); |
| 755 layout->SetInsets(views::kButtonVEdgeMarginNew, | 770 layout->SetInsets(views::kButtonVEdgeMarginNew, |
| 756 views::kButtonHEdgeMarginNew, | 771 views::kButtonHEdgeMarginNew, |
| 757 views::kButtonVEdgeMarginNew, | 772 views::kButtonVEdgeMarginNew, |
| 758 views::kButtonHEdgeMarginNew); | 773 views::kButtonHEdgeMarginNew); |
| 759 | 774 |
| 760 // Adds title. | 775 // Adds title. |
| 761 views::Label* title_label = new views::Label(title_text); | 776 views::Label* title_label = new views::Label(title_text); |
| 762 title_label->SetHorizontalAlignment(gfx::ALIGN_LEFT); | 777 title_label->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
| 763 title_label->SetAutoColorReadabilityEnabled(false); | 778 title_label->SetAutoColorReadabilityEnabled(false); |
| 764 title_label->SetEnabledColor(SK_ColorWHITE); | 779 title_label->SetEnabledColor(SK_ColorWHITE); |
| 765 title_label ->SetFontList(ui::ResourceBundle::GetSharedInstance().GetFontList( | 780 title_label->SetFontList(ui::ResourceBundle::GetSharedInstance().GetFontList( |
| 766 ui::ResourceBundle::MediumFont)); | 781 ui::ResourceBundle::MediumFont)); |
| 767 layout->StartRow(1, 0); | 782 layout->StartRow(1, 0); |
| 768 layout->AddView(title_label); | 783 layout->AddView(title_label); |
| 769 | 784 |
| 770 // Adds body content. | 785 // Adds body content. |
| 771 views::Label* content_label = new views::Label(content_text); | 786 views::Label* content_label = new views::Label(content_text); |
| 772 content_label->SetMultiLine(true); | 787 content_label->SetMultiLine(true); |
| 773 content_label->SetHorizontalAlignment(gfx::ALIGN_LEFT); | 788 content_label->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
| 774 content_label->SetAutoColorReadabilityEnabled(false); | 789 content_label->SetAutoColorReadabilityEnabled(false); |
| 775 content_label->SetEnabledColor(profiles::kAvatarTutorialContentTextColor); | 790 content_label->SetEnabledColor(profiles::kAvatarTutorialContentTextColor); |
| (...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1148 | 1163 |
| 1149 views::View* ProfileChooserView::CreateNewProfileManagementPreviewView() { | 1164 views::View* ProfileChooserView::CreateNewProfileManagementPreviewView() { |
| 1150 return CreateTutorialView( | 1165 return CreateTutorialView( |
| 1151 l10n_util::GetStringUTF16(IDS_PROFILES_PREVIEW_TUTORIAL_TITLE), | 1166 l10n_util::GetStringUTF16(IDS_PROFILES_PREVIEW_TUTORIAL_TITLE), |
| 1152 l10n_util::GetStringUTF16(IDS_PROFILES_PREVIEW_TUTORIAL_CONTENT_TEXT), | 1167 l10n_util::GetStringUTF16(IDS_PROFILES_PREVIEW_TUTORIAL_CONTENT_TEXT), |
| 1153 l10n_util::GetStringUTF16(IDS_PROFILES_PROFILE_TUTORIAL_LEARN_MORE), | 1168 l10n_util::GetStringUTF16(IDS_PROFILES_PROFILE_TUTORIAL_LEARN_MORE), |
| 1154 l10n_util::GetStringUTF16(IDS_PROFILES_TUTORIAL_TRY_BUTTON), | 1169 l10n_util::GetStringUTF16(IDS_PROFILES_TUTORIAL_TRY_BUTTON), |
| 1155 &tutorial_learn_more_link_, | 1170 &tutorial_learn_more_link_, |
| 1156 &tutorial_enable_new_profile_management_button_); | 1171 &tutorial_enable_new_profile_management_button_); |
| 1157 } | 1172 } |
| OLD | NEW |