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

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

Issue 288493008: UMA Metrics for the user menu, including vasquette-detection (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Removing forward declarations of enums. 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_metrics.h"
15 #include "chrome/browser/profiles/profile_window.h" 15 #include "chrome/browser/profiles/profile_window.h"
16 #include "chrome/browser/profiles/profiles_state.h" 16 #include "chrome/browser/profiles/profiles_state.h"
17 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" 17 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h"
18 #include "chrome/browser/signin/signin_header_helper.h"
18 #include "chrome/browser/signin/signin_manager_factory.h" 19 #include "chrome/browser/signin/signin_manager_factory.h"
19 #include "chrome/browser/signin/signin_promo.h" 20 #include "chrome/browser/signin/signin_promo.h"
20 #include "chrome/browser/ui/browser.h" 21 #include "chrome/browser/ui/browser.h"
21 #include "chrome/browser/ui/browser_commands.h" 22 #include "chrome/browser/ui/browser_commands.h"
22 #include "chrome/browser/ui/browser_dialogs.h" 23 #include "chrome/browser/ui/browser_dialogs.h"
23 #include "chrome/browser/ui/chrome_pages.h" 24 #include "chrome/browser/ui/chrome_pages.h"
24 #include "chrome/browser/ui/singleton_tabs.h" 25 #include "chrome/browser/ui/singleton_tabs.h"
25 #include "chrome/browser/ui/views/profiles/user_manager_view.h" 26 #include "chrome/browser/ui/views/profiles/user_manager_view.h"
26 #include "chrome/common/pref_names.h" 27 #include "chrome/common/pref_names.h"
27 #include "chrome/common/url_constants.h" 28 #include "chrome/common/url_constants.h"
(...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after
407 408
408 // ProfileChooserView --------------------------------------------------------- 409 // ProfileChooserView ---------------------------------------------------------
409 410
410 // static 411 // static
411 ProfileChooserView* ProfileChooserView::profile_bubble_ = NULL; 412 ProfileChooserView* ProfileChooserView::profile_bubble_ = NULL;
412 bool ProfileChooserView::close_on_deactivate_for_testing_ = true; 413 bool ProfileChooserView::close_on_deactivate_for_testing_ = true;
413 414
414 // static 415 // static
415 void ProfileChooserView::ShowBubble( 416 void ProfileChooserView::ShowBubble(
416 BubbleViewMode view_mode, 417 BubbleViewMode view_mode,
418 signin::GAIAServiceType service_type,
417 views::View* anchor_view, 419 views::View* anchor_view,
418 views::BubbleBorder::Arrow arrow, 420 views::BubbleBorder::Arrow arrow,
419 views::BubbleBorder::BubbleAlignment border_alignment, 421 views::BubbleBorder::BubbleAlignment border_alignment,
420 const gfx::Rect& anchor_rect, 422 const gfx::Rect& anchor_rect,
421 Browser* browser) { 423 Browser* browser) {
422 if (IsShowing()) 424 if (IsShowing())
423 return; 425 return;
424 426
425 profile_bubble_ = new ProfileChooserView(anchor_view, arrow, anchor_rect, 427 profile_bubble_ = new ProfileChooserView(anchor_view, arrow, anchor_rect,
426 browser, view_mode); 428 browser, view_mode, service_type);
427 views::BubbleDelegateView::CreateBubble(profile_bubble_); 429 views::BubbleDelegateView::CreateBubble(profile_bubble_);
428 profile_bubble_->set_close_on_deactivate(close_on_deactivate_for_testing_); 430 profile_bubble_->set_close_on_deactivate(close_on_deactivate_for_testing_);
429 profile_bubble_->SetAlignment(border_alignment); 431 profile_bubble_->SetAlignment(border_alignment);
430 profile_bubble_->GetWidget()->Show(); 432 profile_bubble_->GetWidget()->Show();
431 profile_bubble_->SetArrowPaintType(views::BubbleBorder::PAINT_NONE); 433 profile_bubble_->SetArrowPaintType(views::BubbleBorder::PAINT_NONE);
432 } 434 }
433 435
434 // static 436 // static
435 bool ProfileChooserView::IsShowing() { 437 bool ProfileChooserView::IsShowing() {
436 return profile_bubble_ != NULL; 438 return profile_bubble_ != NULL;
437 } 439 }
438 440
439 // static 441 // static
440 void ProfileChooserView::Hide() { 442 void ProfileChooserView::Hide() {
441 if (IsShowing()) 443 if (IsShowing())
442 profile_bubble_->GetWidget()->Close(); 444 profile_bubble_->GetWidget()->Close();
443 } 445 }
444 446
445 ProfileChooserView::ProfileChooserView(views::View* anchor_view, 447 ProfileChooserView::ProfileChooserView(views::View* anchor_view,
446 views::BubbleBorder::Arrow arrow, 448 views::BubbleBorder::Arrow arrow,
447 const gfx::Rect& anchor_rect, 449 const gfx::Rect& anchor_rect,
448 Browser* browser, 450 Browser* browser,
449 BubbleViewMode view_mode) 451 BubbleViewMode view_mode,
452 signin::GAIAServiceType service_type)
450 : BubbleDelegateView(anchor_view, arrow), 453 : BubbleDelegateView(anchor_view, arrow),
451 browser_(browser), 454 browser_(browser),
455 tutorial_mode_(TUTORIAL_MODE_NONE),
452 view_mode_(view_mode), 456 view_mode_(view_mode),
453 tutorial_mode_(TUTORIAL_MODE_NONE) { 457 gaia_service_type_(service_type) {
454 // Reset the default margins inherited from the BubbleDelegateView. 458 // Reset the default margins inherited from the BubbleDelegateView.
455 set_margins(gfx::Insets()); 459 set_margins(gfx::Insets());
456 460
457 ResetView(); 461 ResetView();
458 462
459 avatar_menu_.reset(new AvatarMenu( 463 avatar_menu_.reset(new AvatarMenu(
460 &g_browser_process->profile_manager()->GetProfileInfoCache(), 464 &g_browser_process->profile_manager()->GetProfileInfoCache(),
461 this, 465 this,
462 browser_)); 466 browser_));
463 avatar_menu_->RebuildMenu(); 467 avatar_menu_->RebuildMenu();
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
599 if (sender->parent()) 603 if (sender->parent())
600 sender->SetEnabled(false); 604 sender->SetEnabled(false);
601 605
602 if (sender == users_button_) { 606 if (sender == users_button_) {
603 profiles::ShowUserManagerMaybeWithTutorial(browser_->profile()); 607 profiles::ShowUserManagerMaybeWithTutorial(browser_->profile());
604 // If this is a guest session, also close all the guest browser windows. 608 // If this is a guest session, also close all the guest browser windows.
605 if (browser_->profile()->IsGuestSession()) 609 if (browser_->profile()->IsGuestSession())
606 profiles::CloseGuestProfileWindows(); 610 profiles::CloseGuestProfileWindows();
607 } else if (sender == lock_button_) { 611 } else if (sender == lock_button_) {
608 profiles::LockProfile(browser_->profile()); 612 profiles::LockProfile(browser_->profile());
613 PostActionPerformed(ProfileMetrics::PROFILE_DESKTOP_MENU_LOCK);
609 } else if (sender == tutorial_ok_button_) { 614 } else if (sender == tutorial_ok_button_) {
610 // If the user manually dismissed the tutorial, never show it again by 615 // 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 616 // 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 617 // could distinguish between the dismiss case and the case when the tutorial
613 // is indeed shown for the maximum number of times. 618 // is indeed shown for the maximum number of times.
614 browser_->profile()->GetPrefs()->SetInteger( 619 browser_->profile()->GetPrefs()->SetInteger(
615 prefs::kProfileAvatarTutorialShown, kProfileAvatarTutorialShowMax + 1); 620 prefs::kProfileAvatarTutorialShown, kProfileAvatarTutorialShowMax + 1);
616 621
617 ProfileMetrics::LogProfileUpgradeEnrollment( 622 ProfileMetrics::LogProfileUpgradeEnrollment(
618 ProfileMetrics::PROFILE_ENROLLMENT_CLOSE_WELCOME_CARD); 623 ProfileMetrics::PROFILE_ENROLLMENT_CLOSE_WELCOME_CARD);
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
681 } 686 }
682 } 687 }
683 } 688 }
684 } 689 }
685 690
686 void ProfileChooserView::RemoveAccount() { 691 void ProfileChooserView::RemoveAccount() {
687 DCHECK(!account_id_to_remove_.empty()); 692 DCHECK(!account_id_to_remove_.empty());
688 MutableProfileOAuth2TokenService* oauth2_token_service = 693 MutableProfileOAuth2TokenService* oauth2_token_service =
689 ProfileOAuth2TokenServiceFactory::GetPlatformSpecificForProfile( 694 ProfileOAuth2TokenServiceFactory::GetPlatformSpecificForProfile(
690 browser_->profile()); 695 browser_->profile());
691 if (oauth2_token_service) 696 if (oauth2_token_service) {
692 oauth2_token_service->RevokeCredentials(account_id_to_remove_); 697 oauth2_token_service->RevokeCredentials(account_id_to_remove_);
698 PostActionPerformed(ProfileMetrics::PROFILE_DESKTOP_MENU_REMOVE_ACCT);
699 }
693 account_id_to_remove_.clear(); 700 account_id_to_remove_.clear();
694 701
695 ShowView(BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT, avatar_menu_.get()); 702 ShowView(BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT, avatar_menu_.get());
696 } 703 }
697 704
698 void ProfileChooserView::LinkClicked(views::Link* sender, int event_flags) { 705 void ProfileChooserView::LinkClicked(views::Link* sender, int event_flags) {
699 if (sender == manage_accounts_link_) { 706 if (sender == manage_accounts_link_) {
700 // This link can either mean show/hide the account management view, 707 // This link can either mean show/hide the account management view,
701 // depending on which view it is displayed. ShowView() will DCHECK if 708 // depending on which view it is displayed. ShowView() will DCHECK if
702 // the account management view is displayed for non signed-in users. 709 // the account management view is displayed for non signed-in users.
703 ShowView( 710 ShowView(
704 view_mode_ == BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT ? 711 view_mode_ == BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT ?
705 BUBBLE_VIEW_MODE_PROFILE_CHOOSER : 712 BUBBLE_VIEW_MODE_PROFILE_CHOOSER :
706 BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT, 713 BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT,
707 avatar_menu_.get()); 714 avatar_menu_.get());
708 } else if (sender == add_account_link_) { 715 } else if (sender == add_account_link_) {
709 ShowView(BUBBLE_VIEW_MODE_GAIA_ADD_ACCOUNT, avatar_menu_.get()); 716 ShowView(BUBBLE_VIEW_MODE_GAIA_ADD_ACCOUNT, avatar_menu_.get());
717 PostActionPerformed(ProfileMetrics::PROFILE_DESKTOP_MENU_ADD_ACCT);
710 } else if (sender == tutorial_learn_more_link_) { 718 } else if (sender == tutorial_learn_more_link_) {
711 ProfileMetrics::LogProfileUpgradeEnrollment( 719 ProfileMetrics::LogProfileUpgradeEnrollment(
712 ProfileMetrics::PROFILE_ENROLLMENT_LAUNCH_LEARN_MORE); 720 ProfileMetrics::PROFILE_ENROLLMENT_LAUNCH_LEARN_MORE);
713 // TODO(guohui): update |learn_more_url| once it is decided. 721 // TODO(guohui): update |learn_more_url| once it is decided.
714 const GURL lear_more_url("https://support.google.com/chrome/?hl=en#to"); 722 const GURL lear_more_url("https://support.google.com/chrome/?hl=en#to");
715 chrome::NavigateParams params( 723 chrome::NavigateParams params(
716 browser_->profile(), 724 browser_->profile(),
717 lear_more_url, 725 lear_more_url,
718 content::PAGE_TRANSITION_LINK); 726 content::PAGE_TRANSITION_LINK);
719 params.disposition = NEW_FOREGROUND_TAB; 727 params.disposition = NEW_FOREGROUND_TAB;
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
751 if (profile->IsManaged()) 759 if (profile->IsManaged())
752 return true; 760 return true;
753 761
754 profiles::UpdateProfileName(profile, new_profile_name); 762 profiles::UpdateProfileName(profile, new_profile_name);
755 current_profile_name_->ShowReadOnlyView(); 763 current_profile_name_->ShowReadOnlyView();
756 return true; 764 return true;
757 } 765 }
758 return false; 766 return false;
759 } 767 }
760 768
769 void ProfileChooserView::PostActionPerformed(
770 ProfileMetrics::ProfileDesktopMenu action_performed) {
771 ProfileMetrics::LogProfileDesktopMenu(action_performed, gaia_service_type_);
sky 2014/05/23 20:41:42 nit: indentation is off (should be 2 spaces, not 4
Mike Lerman 2014/05/26 12:55:24 Done.
772 gaia_service_type_ = signin::GAIA_SERVICE_TYPE_NONE;
773 }
774
761 views::View* ProfileChooserView::CreateProfileChooserView( 775 views::View* ProfileChooserView::CreateProfileChooserView(
762 AvatarMenu* avatar_menu, 776 AvatarMenu* avatar_menu,
763 TutorialMode last_tutorial_mode) { 777 TutorialMode last_tutorial_mode) {
764 // TODO(guohui, noms): the view should be customized based on whether new 778 // TODO(guohui, noms): the view should be customized based on whether new
765 // profile management preview is enabled or not. 779 // profile management preview is enabled or not.
766 780
767 views::View* view = new views::View(); 781 views::View* view = new views::View();
768 views::GridLayout* layout = CreateSingleColumnLayout(view, kFixedMenuWidth); 782 views::GridLayout* layout = CreateSingleColumnLayout(view, kFixedMenuWidth);
769 // Separate items into active and alternatives. 783 // Separate items into active and alternatives.
770 Indexes other_profiles; 784 Indexes other_profiles;
(...skipping 628 matching lines...) Expand 10 before | Expand all | Expand 10 after
1399 layout->StartRowWithPadding( 1413 layout->StartRowWithPadding(
1400 1, 0, 0, views::kUnrelatedControlVerticalSpacing); 1414 1, 0, 0, views::kUnrelatedControlVerticalSpacing);
1401 layout->AddView(end_preview_and_relaunch_button_); 1415 layout->AddView(end_preview_and_relaunch_button_);
1402 1416
1403 TitleCard* title_card = new TitleCard( 1417 TitleCard* title_card = new TitleCard(
1404 IDS_PROFILES_END_PREVIEW, this, &end_preview_cancel_button_); 1418 IDS_PROFILES_END_PREVIEW, this, &end_preview_cancel_button_);
1405 return TitleCard::AddPaddedTitleCard( 1419 return TitleCard::AddPaddedTitleCard(
1406 view, title_card, kFixedAccountRemovalViewWidth); 1420 view, title_card, kFixedAccountRemovalViewWidth);
1407 } 1421 }
1408 1422
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698