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

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

Issue 227083007: UMA for New Profile Management. Track User-Menu Tutorial actions with Histograms. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Further clean up condition controlling OptionsView. 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 | 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"
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_commands.h" 21 #include "chrome/browser/ui/browser_commands.h"
21 #include "chrome/browser/ui/browser_dialogs.h" 22 #include "chrome/browser/ui/browser_dialogs.h"
22 #include "chrome/browser/ui/chrome_pages.h" 23 #include "chrome/browser/ui/chrome_pages.h"
23 #include "chrome/browser/ui/singleton_tabs.h" 24 #include "chrome/browser/ui/singleton_tabs.h"
(...skipping 512 matching lines...) Expand 10 before | Expand all | Expand 10 after
536 profiles::CloseGuestProfileWindows(); 537 profiles::CloseGuestProfileWindows();
537 } else if (sender == lock_button_) { 538 } else if (sender == lock_button_) {
538 profiles::LockProfile(browser_->profile()); 539 profiles::LockProfile(browser_->profile());
539 } else if (sender == tutorial_ok_button_) { 540 } else if (sender == tutorial_ok_button_) {
540 // If the user manually dismissed the tutorial, never show it again by 541 // If the user manually dismissed the tutorial, never show it again by
541 // setting the number of times shown to the maximum plus 1, so that later we 542 // setting the number of times shown to the maximum plus 1, so that later we
542 // could distinguish between the dismiss case and the case when the tutorial 543 // could distinguish between the dismiss case and the case when the tutorial
543 // is indeed shown for the maximum number of times. 544 // is indeed shown for the maximum number of times.
544 browser_->profile()->GetPrefs()->SetInteger( 545 browser_->profile()->GetPrefs()->SetInteger(
545 prefs::kProfileAvatarTutorialShown, kProfileAvatarTutorialShowMax + 1); 546 prefs::kProfileAvatarTutorialShown, kProfileAvatarTutorialShowMax + 1);
547
548 ProfileMetrics::LogProfileUpgradeEnrollment(
549 ProfileMetrics::PROFILE_ENROLLMENT_CLOSE_WELCOME_CARD);
546 ShowView(BUBBLE_VIEW_MODE_PROFILE_CHOOSER, avatar_menu_.get()); 550 ShowView(BUBBLE_VIEW_MODE_PROFILE_CHOOSER, avatar_menu_.get());
547 } else if (sender == tutorial_enable_new_profile_management_button_) { 551 } else if (sender == tutorial_enable_new_profile_management_button_) {
552 ProfileMetrics::LogProfileUpgradeEnrollment(
553 ProfileMetrics::PROFILE_ENROLLMENT_ACCEPT_NEW_PROFILE_MGMT);
548 profiles::EnableNewProfileManagementPreview(); 554 profiles::EnableNewProfileManagementPreview();
549 } else if (sender == remove_account_and_relaunch_button_) { 555 } else if (sender == remove_account_and_relaunch_button_) {
550 RemoveAccount(); 556 RemoveAccount();
551 } else if (sender == account_removal_cancel_button_) { 557 } else if (sender == account_removal_cancel_button_) {
552 account_id_to_remove_.clear(); 558 account_id_to_remove_.clear();
553 ShowView(BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT, avatar_menu_.get()); 559 ShowView(BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT, avatar_menu_.get());
554 } else if (sender == gaia_signin_cancel_button_) { 560 } else if (sender == gaia_signin_cancel_button_) {
555 std::string primary_account = 561 std::string primary_account =
556 SigninManagerFactory::GetForProfile(browser_->profile())-> 562 SigninManagerFactory::GetForProfile(browser_->profile())->
557 GetAuthenticatedUsername(); 563 GetAuthenticatedUsername();
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
612 // depending on which view it is displayed. ShowView() will DCHECK if 618 // depending on which view it is displayed. ShowView() will DCHECK if
613 // the account management view is displayed for non signed-in users. 619 // the account management view is displayed for non signed-in users.
614 ShowView( 620 ShowView(
615 view_mode_ == BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT ? 621 view_mode_ == BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT ?
616 BUBBLE_VIEW_MODE_PROFILE_CHOOSER : 622 BUBBLE_VIEW_MODE_PROFILE_CHOOSER :
617 BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT, 623 BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT,
618 avatar_menu_.get()); 624 avatar_menu_.get());
619 } else if (sender == add_account_link_) { 625 } else if (sender == add_account_link_) {
620 ShowView(BUBBLE_VIEW_MODE_GAIA_ADD_ACCOUNT, avatar_menu_.get()); 626 ShowView(BUBBLE_VIEW_MODE_GAIA_ADD_ACCOUNT, avatar_menu_.get());
621 } else if (sender == tutorial_learn_more_link_) { 627 } else if (sender == tutorial_learn_more_link_) {
628 ProfileMetrics::LogProfileUpgradeEnrollment(
629 ProfileMetrics::PROFILE_ENROLLMENT_LAUNCH_LEARN_MORE);
622 // TODO(guohui): update |learn_more_url| once it is decided. 630 // TODO(guohui): update |learn_more_url| once it is decided.
623 const GURL lear_more_url("https://support.google.com/chrome/?hl=en#to"); 631 const GURL lear_more_url("https://support.google.com/chrome/?hl=en#to");
624 chrome::NavigateParams params( 632 chrome::NavigateParams params(
625 browser_->profile(), 633 browser_->profile(),
626 lear_more_url, 634 lear_more_url,
627 content::PAGE_TRANSITION_LINK); 635 content::PAGE_TRANSITION_LINK);
628 params.disposition = NEW_FOREGROUND_TAB; 636 params.disposition = NEW_FOREGROUND_TAB;
629 chrome::Navigate(&params); 637 chrome::Navigate(&params);
630 } else { 638 } else {
631 DCHECK(sender == tutorial_end_preview_link_); 639 DCHECK(sender == tutorial_end_preview_link_);
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
681 views::View* current_profile_accounts = NULL; 689 views::View* current_profile_accounts = NULL;
682 views::View* option_buttons_view = NULL; 690 views::View* option_buttons_view = NULL;
683 bool is_new_profile_management = switches::IsNewProfileManagement(); 691 bool is_new_profile_management = switches::IsNewProfileManagement();
684 for (size_t i = 0; i < avatar_menu->GetNumberOfItems(); ++i) { 692 for (size_t i = 0; i < avatar_menu->GetNumberOfItems(); ++i) {
685 const AvatarMenu::Item& item = avatar_menu->GetItemAt(i); 693 const AvatarMenu::Item& item = avatar_menu->GetItemAt(i);
686 if (item.active) { 694 if (item.active) {
687 option_buttons_view = CreateOptionsView(item.signed_in); 695 option_buttons_view = CreateOptionsView(item.signed_in);
688 current_profile_view = CreateCurrentProfileView(item, false); 696 current_profile_view = CreateCurrentProfileView(item, false);
689 if (view_mode_ == BUBBLE_VIEW_MODE_PROFILE_CHOOSER) { 697 if (view_mode_ == BUBBLE_VIEW_MODE_PROFILE_CHOOSER) {
690 if (is_new_profile_management) { 698 if (is_new_profile_management) {
691 tutorial_view = last_tutorial_mode == TUTORIAL_MODE_SEND_FEEDBACK ? 699 tutorial_view = tutorial_mode_ == TUTORIAL_MODE_SEND_FEEDBACK ?
692 CreateSendPreviewFeedbackView() : 700 CreateSendPreviewFeedbackView() :
693 CreatePreviewEnabledTutorialView( 701 CreatePreviewEnabledTutorialView(
694 item, last_tutorial_mode == TUTORIAL_MODE_PREVIEW_ENABLED); 702 item, tutorial_mode_ == TUTORIAL_MODE_PREVIEW_ENABLED);
695 } else { 703 } else {
696 tutorial_view = CreateNewProfileManagementPreviewView(); 704 tutorial_view = CreateNewProfileManagementPreviewView();
697 } 705 }
698 } else { 706 } else {
699 current_profile_accounts = CreateCurrentProfileAccountsView(item); 707 current_profile_accounts = CreateCurrentProfileAccountsView(item);
700 } 708 }
701 } else { 709 } else {
702 other_profiles.push_back(i); 710 other_profiles.push_back(i);
703 } 711 }
704 } 712 }
705 713
706 if (tutorial_view) { 714 if (tutorial_view) {
715 // Be sure not to track the tutorial display on View refresh, and only count
716 // the preview-promo view, shown when New Profile Management is off.
717 if (tutorial_mode_ != last_tutorial_mode && !is_new_profile_management) {
718 ProfileMetrics::LogProfileUpgradeEnrollment(
719 ProfileMetrics::PROFILE_ENROLLMENT_SHOW_PREVIEW_PROMO);
720 }
707 layout->StartRow(1, 0); 721 layout->StartRow(1, 0);
708 layout->AddView(tutorial_view); 722 layout->AddView(tutorial_view);
709 } 723 }
710 724
711 if (!current_profile_view) { 725 if (!current_profile_view) {
712 // Guest windows don't have an active profile. 726 // Guest windows don't have an active profile.
713 current_profile_view = CreateGuestProfileView(); 727 current_profile_view = CreateGuestProfileView();
714 option_buttons_view = CreateOptionsView(false); 728 option_buttons_view = CreateOptionsView(false);
715 } 729 }
716 730
717 layout->StartRow(1, 0); 731 layout->StartRow(1, 0);
718 layout->AddView(current_profile_view); 732 layout->AddView(current_profile_view);
719 733
720 if (view_mode_ == BUBBLE_VIEW_MODE_PROFILE_CHOOSER) { 734 if (view_mode_ == BUBBLE_VIEW_MODE_PROFILE_CHOOSER) {
721 layout->StartRow(1, 0); 735 layout->StartRow(1, 0);
722 if (switches::IsFastUserSwitching()) 736 if (switches::IsFastUserSwitching())
723 layout->AddView(CreateOtherProfilesView(other_profiles)); 737 layout->AddView(CreateOtherProfilesView(other_profiles));
724 } else { 738 } else {
725 DCHECK(current_profile_accounts); 739 DCHECK(current_profile_accounts);
726 layout->StartRow(0, 0); 740 layout->StartRow(0, 0);
727 layout->AddView(new views::Separator(views::Separator::HORIZONTAL)); 741 layout->AddView(new views::Separator(views::Separator::HORIZONTAL));
728 layout->StartRow(1, 0); 742 layout->StartRow(1, 0);
729 layout->AddView(current_profile_accounts); 743 layout->AddView(current_profile_accounts);
730 } 744 }
731 745
732 layout->StartRow(0, 0); 746 layout->StartRow(0, 0);
733 layout->AddView(new views::Separator(views::Separator::HORIZONTAL)); 747 layout->AddView(new views::Separator(views::Separator::HORIZONTAL));
734 748
735 // Option buttons. Only available with the new profile management flag. 749 // Option buttons. Only available with the new profile management flag.
736 if (switches::IsNewProfileManagement()) { 750 if (option_buttons_view) {
737 layout->StartRow(0, 0); 751 layout->StartRow(0, 0);
738 layout->AddView(option_buttons_view); 752 layout->AddView(option_buttons_view);
739 } 753 }
740 754
741 return view; 755 return view;
742 } 756 }
743 757
744 views::View* ProfileChooserView::CreatePreviewEnabledTutorialView( 758 views::View* ProfileChooserView::CreatePreviewEnabledTutorialView(
745 const AvatarMenu::Item& current_avatar_item, 759 const AvatarMenu::Item& current_avatar_item,
746 bool tutorial_shown) { 760 bool tutorial_shown) {
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
802 layout->SetInsets(views::kButtonVEdgeMarginNew, 816 layout->SetInsets(views::kButtonVEdgeMarginNew,
803 views::kButtonHEdgeMarginNew, 817 views::kButtonHEdgeMarginNew,
804 views::kButtonVEdgeMarginNew, 818 views::kButtonVEdgeMarginNew,
805 views::kButtonHEdgeMarginNew); 819 views::kButtonHEdgeMarginNew);
806 820
807 // Adds title. 821 // Adds title.
808 views::Label* title_label = new views::Label(title_text); 822 views::Label* title_label = new views::Label(title_text);
809 title_label->SetHorizontalAlignment(gfx::ALIGN_LEFT); 823 title_label->SetHorizontalAlignment(gfx::ALIGN_LEFT);
810 title_label->SetAutoColorReadabilityEnabled(false); 824 title_label->SetAutoColorReadabilityEnabled(false);
811 title_label->SetEnabledColor(SK_ColorWHITE); 825 title_label->SetEnabledColor(SK_ColorWHITE);
812 title_label ->SetFontList(ui::ResourceBundle::GetSharedInstance().GetFontList( 826 title_label->SetFontList(ui::ResourceBundle::GetSharedInstance().GetFontList(
813 ui::ResourceBundle::MediumFont)); 827 ui::ResourceBundle::MediumFont));
814 layout->StartRow(1, 0); 828 layout->StartRow(1, 0);
815 layout->AddView(title_label); 829 layout->AddView(title_label);
816 830
817 // Adds body content. 831 // Adds body content.
818 views::Label* content_label = new views::Label(content_text); 832 views::Label* content_label = new views::Label(content_text);
819 content_label->SetMultiLine(true); 833 content_label->SetMultiLine(true);
820 content_label->SetHorizontalAlignment(gfx::ALIGN_LEFT); 834 content_label->SetHorizontalAlignment(gfx::ALIGN_LEFT);
821 content_label->SetAutoColorReadabilityEnabled(false); 835 content_label->SetAutoColorReadabilityEnabled(false);
822 content_label->SetEnabledColor(profiles::kAvatarTutorialContentTextColor); 836 content_label->SetEnabledColor(profiles::kAvatarTutorialContentTextColor);
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
988 layout->StartRow(1, 0); 1002 layout->StartRow(1, 0);
989 layout->AddView(new views::Separator(views::Separator::HORIZONTAL)); 1003 layout->AddView(new views::Separator(views::Separator::HORIZONTAL));
990 layout->StartRow(1, 0); 1004 layout->StartRow(1, 0);
991 layout->AddView(button); 1005 layout->AddView(button);
992 } 1006 }
993 1007
994 return view; 1008 return view;
995 } 1009 }
996 1010
997 views::View* ProfileChooserView::CreateOptionsView(bool enable_lock) { 1011 views::View* ProfileChooserView::CreateOptionsView(bool enable_lock) {
1012 if (!switches::IsNewProfileManagement())
1013 return NULL;
1014
998 views::View* view = new views::View(); 1015 views::View* view = new views::View();
999 views::GridLayout* layout; 1016 views::GridLayout* layout;
1000 1017
1001 // Only signed-in users have the ability to lock. 1018 // Only signed-in users have the ability to lock.
1002 if (enable_lock) { 1019 if (enable_lock) {
1003 layout = new views::GridLayout(view); 1020 layout = new views::GridLayout(view);
1004 views::ColumnSet* columns = layout->AddColumnSet(0); 1021 views::ColumnSet* columns = layout->AddColumnSet(0);
1005 int width_of_lock_button = 1022 int width_of_lock_button =
1006 2 * views::kUnrelatedControlLargeHorizontalSpacing + 12; 1023 2 * views::kUnrelatedControlLargeHorizontalSpacing + 12;
1007 int width_of_users_button = kFixedMenuWidth - width_of_lock_button; 1024 int width_of_users_button = kFixedMenuWidth - width_of_lock_button;
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after
1254 this, l10n_util::GetStringUTF16(IDS_PROFILES_END_PREVIEW_AND_RELAUNCH)); 1271 this, l10n_util::GetStringUTF16(IDS_PROFILES_END_PREVIEW_AND_RELAUNCH));
1255 end_preview_and_relaunch_button_->SetHorizontalAlignment( 1272 end_preview_and_relaunch_button_->SetHorizontalAlignment(
1256 gfx::ALIGN_CENTER); 1273 gfx::ALIGN_CENTER);
1257 layout->StartRowWithPadding( 1274 layout->StartRowWithPadding(
1258 1, 0, 0, views::kUnrelatedControlVerticalSpacing); 1275 1, 0, 0, views::kUnrelatedControlVerticalSpacing);
1259 layout->AddView(end_preview_and_relaunch_button_); 1276 layout->AddView(end_preview_and_relaunch_button_);
1260 1277
1261 return view; 1278 return view;
1262 } 1279 }
1263 1280
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698