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 494 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
518 profiles::LockProfile(browser_->profile()); | 519 profiles::LockProfile(browser_->profile()); |
519 } else if (sender == add_account_button_) { | 520 } else if (sender == add_account_button_) { |
520 ShowView(BUBBLE_VIEW_MODE_GAIA_ADD_ACCOUNT, avatar_menu_.get()); | 521 ShowView(BUBBLE_VIEW_MODE_GAIA_ADD_ACCOUNT, avatar_menu_.get()); |
521 } else if (sender == tutorial_ok_button_) { | 522 } else if (sender == tutorial_ok_button_) { |
522 // If the user manually dismissed the tutorial, never show it again by | 523 // If the user manually dismissed the tutorial, never show it again by |
523 // setting the number of times shown to the maximum plus 1, so that later we | 524 // setting the number of times shown to the maximum plus 1, so that later we |
524 // could distinguish between the dismiss case and the case when the tutorial | 525 // could distinguish between the dismiss case and the case when the tutorial |
525 // is indeed shown for the maximum number of times. | 526 // is indeed shown for the maximum number of times. |
526 browser_->profile()->GetPrefs()->SetInteger( | 527 browser_->profile()->GetPrefs()->SetInteger( |
527 prefs::kProfileAvatarTutorialShown, kProfileAvatarTutorialShowMax + 1); | 528 prefs::kProfileAvatarTutorialShown, kProfileAvatarTutorialShowMax + 1); |
529 | |
530 ProfileMetrics:: | |
531 LogProfileMirrorEnrollment(ProfileMetrics::ENROLL_CLOSE_PROMO_CARD); | |
528 ShowView(BUBBLE_VIEW_MODE_PROFILE_CHOOSER, avatar_menu_.get()); | 532 ShowView(BUBBLE_VIEW_MODE_PROFILE_CHOOSER, avatar_menu_.get()); |
529 } else if (sender == tutorial_enable_new_profile_management_button_) { | 533 } else if (sender == tutorial_enable_new_profile_management_button_) { |
530 profiles::EnableNewProfileManagementPreview(); | 534 profiles::EnableNewProfileManagementPreview(); |
535 ProfileMetrics:: | |
536 LogProfileMirrorEnrollment(ProfileMetrics::ENROLL_ACCEPT_MIRROR); | |
531 } else if (sender == remove_account_and_relaunch_button_) { | 537 } else if (sender == remove_account_and_relaunch_button_) { |
532 RemoveAccount(); | 538 RemoveAccount(); |
533 } else if (sender == account_removal_cancel_button_) { | 539 } else if (sender == account_removal_cancel_button_) { |
534 account_id_to_remove_.clear(); | 540 account_id_to_remove_.clear(); |
535 ShowView(BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT, avatar_menu_.get()); | 541 ShowView(BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT, avatar_menu_.get()); |
536 } else if (sender == gaia_signin_cancel_button_) { | 542 } else if (sender == gaia_signin_cancel_button_) { |
537 std::string primary_account = | 543 std::string primary_account = |
538 SigninManagerFactory::GetForProfile(browser_->profile())-> | 544 SigninManagerFactory::GetForProfile(browser_->profile())-> |
539 GetAuthenticatedUsername(); | 545 GetAuthenticatedUsername(); |
540 ShowView(primary_account.empty() ? BUBBLE_VIEW_MODE_PROFILE_CHOOSER : | 546 ShowView(primary_account.empty() ? BUBBLE_VIEW_MODE_PROFILE_CHOOSER : |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
575 | 581 |
576 chrome::AttemptRestart(); | 582 chrome::AttemptRestart(); |
577 } | 583 } |
578 | 584 |
579 void ProfileChooserView::LinkClicked(views::Link* sender, int event_flags) { | 585 void ProfileChooserView::LinkClicked(views::Link* sender, int event_flags) { |
580 if (sender == manage_accounts_link_) { | 586 if (sender == manage_accounts_link_) { |
581 // ShowView() will DCHECK if this view is displayed for non signed-in users. | 587 // ShowView() will DCHECK if this view is displayed for non signed-in users. |
582 ShowView(BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT, avatar_menu_.get()); | 588 ShowView(BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT, avatar_menu_.get()); |
583 } else if (sender == tutorial_learn_more_link_) { | 589 } else if (sender == tutorial_learn_more_link_) { |
584 // TODO(guohui): update |learn_more_url| once it is decided. | 590 // TODO(guohui): update |learn_more_url| once it is decided. |
591 ProfileMetrics:: | |
592 LogProfileMirrorEnrollment(ProfileMetrics::ENROLL_LAUNCH_TUTORIAL); | |
585 const GURL lear_more_url("https://support.google.com/chrome/?hl=en#to"); | 593 const GURL lear_more_url("https://support.google.com/chrome/?hl=en#to"); |
586 chrome::NavigateParams params( | 594 chrome::NavigateParams params( |
587 browser_->profile(), | 595 browser_->profile(), |
588 lear_more_url, | 596 lear_more_url, |
589 content::PAGE_TRANSITION_LINK); | 597 content::PAGE_TRANSITION_LINK); |
590 params.disposition = NEW_FOREGROUND_TAB; | 598 params.disposition = NEW_FOREGROUND_TAB; |
591 chrome::Navigate(¶ms); | 599 chrome::Navigate(¶ms); |
592 } else { | 600 } else { |
593 DCHECK(sender == signin_current_profile_link_); | 601 DCHECK(sender == signin_current_profile_link_); |
594 ShowView(BUBBLE_VIEW_MODE_GAIA_SIGNIN, avatar_menu_.get()); | 602 ShowView(BUBBLE_VIEW_MODE_GAIA_SIGNIN, avatar_menu_.get()); |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
654 } else { | 662 } else { |
655 current_profile_view = CreateCurrentProfileEditableView(item); | 663 current_profile_view = CreateCurrentProfileEditableView(item); |
656 current_profile_accounts = CreateCurrentProfileAccountsView(item); | 664 current_profile_accounts = CreateCurrentProfileAccountsView(item); |
657 } | 665 } |
658 } else { | 666 } else { |
659 other_profiles.push_back(i); | 667 other_profiles.push_back(i); |
660 } | 668 } |
661 } | 669 } |
662 | 670 |
663 if (tutorial_view) { | 671 if (tutorial_view) { |
672 // Be sure not to track the tutorial display on View refresh, and only count | |
673 // the preview-promo view, not the welcome-enabled view. | |
674 if (tutorial_shown == FALSE && !switches::IsNewProfileManagement()) { | |
guohui
2014/04/25 14:46:50
Currently tutorial_shown only tracks the welcome-e
Mike Lerman
2014/04/28 14:53:11
Ok. I had put in the condition on tutorial_shown b
| |
675 ProfileMetrics:: | |
676 LogProfileMirrorEnrollment(ProfileMetrics::ENROLL_DISPLAY); | |
677 } | |
664 layout->StartRow(1, 0); | 678 layout->StartRow(1, 0); |
665 layout->AddView(tutorial_view); | 679 layout->AddView(tutorial_view); |
666 } | 680 } |
667 | 681 |
668 if (!current_profile_view) { | 682 if (!current_profile_view) { |
669 // Guest windows don't have an active profile. | 683 // Guest windows don't have an active profile. |
670 current_profile_view = CreateGuestProfileView(); | 684 current_profile_view = CreateGuestProfileView(); |
671 option_buttons_view = CreateOptionsView(false); | 685 option_buttons_view = CreateOptionsView(false); |
672 } | 686 } |
673 | 687 |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
742 layout->SetInsets(views::kButtonVEdgeMarginNew, | 756 layout->SetInsets(views::kButtonVEdgeMarginNew, |
743 views::kButtonHEdgeMarginNew, | 757 views::kButtonHEdgeMarginNew, |
744 views::kButtonVEdgeMarginNew, | 758 views::kButtonVEdgeMarginNew, |
745 views::kButtonHEdgeMarginNew); | 759 views::kButtonHEdgeMarginNew); |
746 | 760 |
747 // Adds title. | 761 // Adds title. |
748 views::Label* title_label = new views::Label(title_text); | 762 views::Label* title_label = new views::Label(title_text); |
749 title_label->SetHorizontalAlignment(gfx::ALIGN_LEFT); | 763 title_label->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
750 title_label->SetAutoColorReadabilityEnabled(false); | 764 title_label->SetAutoColorReadabilityEnabled(false); |
751 title_label->SetEnabledColor(SK_ColorWHITE); | 765 title_label->SetEnabledColor(SK_ColorWHITE); |
752 title_label ->SetFontList(ui::ResourceBundle::GetSharedInstance().GetFontList( | 766 title_label->SetFontList(ui::ResourceBundle::GetSharedInstance().GetFontList( |
753 ui::ResourceBundle::MediumFont)); | 767 ui::ResourceBundle::MediumFont)); |
754 layout->StartRow(1, 0); | 768 layout->StartRow(1, 0); |
755 layout->AddView(title_label); | 769 layout->AddView(title_label); |
756 | 770 |
757 // Adds body content. | 771 // Adds body content. |
758 views::Label* content_label = new views::Label(content_text); | 772 views::Label* content_label = new views::Label(content_text); |
759 content_label->SetMultiLine(true); | 773 content_label->SetMultiLine(true); |
760 content_label->SetHorizontalAlignment(gfx::ALIGN_LEFT); | 774 content_label->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
761 content_label->SetAutoColorReadabilityEnabled(false); | 775 content_label->SetAutoColorReadabilityEnabled(false); |
762 content_label->SetEnabledColor(profiles::kAvatarTutorialContentTextColor); | 776 content_label->SetEnabledColor(profiles::kAvatarTutorialContentTextColor); |
(...skipping 405 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1168 | 1182 |
1169 views::View* ProfileChooserView::CreateNewProfileManagementPreviewView() { | 1183 views::View* ProfileChooserView::CreateNewProfileManagementPreviewView() { |
1170 return CreateTutorialView( | 1184 return CreateTutorialView( |
1171 l10n_util::GetStringUTF16(IDS_PROFILES_PREVIEW_TUTORIAL_TITLE), | 1185 l10n_util::GetStringUTF16(IDS_PROFILES_PREVIEW_TUTORIAL_TITLE), |
1172 l10n_util::GetStringUTF16(IDS_PROFILES_PREVIEW_TUTORIAL_CONTENT_TEXT), | 1186 l10n_util::GetStringUTF16(IDS_PROFILES_PREVIEW_TUTORIAL_CONTENT_TEXT), |
1173 l10n_util::GetStringUTF16(IDS_PROFILES_PROFILE_TUTORIAL_LEARN_MORE), | 1187 l10n_util::GetStringUTF16(IDS_PROFILES_PROFILE_TUTORIAL_LEARN_MORE), |
1174 l10n_util::GetStringUTF16(IDS_PROFILES_TUTORIAL_TRY_BUTTON), | 1188 l10n_util::GetStringUTF16(IDS_PROFILES_TUTORIAL_TRY_BUTTON), |
1175 &tutorial_learn_more_link_, | 1189 &tutorial_learn_more_link_, |
1176 &tutorial_enable_new_profile_management_button_); | 1190 &tutorial_enable_new_profile_management_button_); |
1177 } | 1191 } |
OLD | NEW |