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

Side by Side Diff: chrome/browser/ui/cocoa/profiles/profile_chooser_controller.mm

Issue 308433002: Desktop Menu UMA for Mac (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 6 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
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 #import <Cocoa/Cocoa.h> 5 #import <Cocoa/Cocoa.h>
6 6
7 #import "chrome/browser/ui/cocoa/profiles/profile_chooser_controller.h" 7 #import "chrome/browser/ui/cocoa/profiles/profile_chooser_controller.h"
8 8
9 #include "base/mac/bundle_locations.h" 9 #include "base/mac/bundle_locations.h"
10 #include "base/prefs/pref_service.h" 10 #include "base/prefs/pref_service.h"
11 #include "base/strings/sys_string_conversions.h" 11 #include "base/strings/sys_string_conversions.h"
12 #include "base/strings/utf_string_conversions.h" 12 #include "base/strings/utf_string_conversions.h"
13 #include "chrome/browser/browser_process.h" 13 #include "chrome/browser/browser_process.h"
14 #include "chrome/browser/chrome_notification_types.h" 14 #include "chrome/browser/chrome_notification_types.h"
15 #include "chrome/browser/lifetime/application_lifetime.h" 15 #include "chrome/browser/lifetime/application_lifetime.h"
16 #include "chrome/browser/profiles/avatar_menu.h" 16 #include "chrome/browser/profiles/avatar_menu.h"
17 #include "chrome/browser/profiles/avatar_menu_observer.h" 17 #include "chrome/browser/profiles/avatar_menu_observer.h"
18 #include "chrome/browser/profiles/profile_avatar_icon_util.h" 18 #include "chrome/browser/profiles/profile_avatar_icon_util.h"
19 #include "chrome/browser/profiles/profile_info_cache.h" 19 #include "chrome/browser/profiles/profile_info_cache.h"
20 #include "chrome/browser/profiles/profile_manager.h" 20 #include "chrome/browser/profiles/profile_manager.h"
21 #include "chrome/browser/profiles/profile_metrics.h" 21 #include "chrome/browser/profiles/profile_metrics.h"
22 #include "chrome/browser/profiles/profile_window.h" 22 #include "chrome/browser/profiles/profile_window.h"
23 #include "chrome/browser/profiles/profiles_state.h" 23 #include "chrome/browser/profiles/profiles_state.h"
24 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" 24 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h"
25 #include "chrome/browser/signin/signin_header_helper.h"
25 #include "chrome/browser/signin/signin_manager_factory.h" 26 #include "chrome/browser/signin/signin_manager_factory.h"
26 #include "chrome/browser/signin/signin_promo.h" 27 #include "chrome/browser/signin/signin_promo.h"
27 #include "chrome/browser/ui/browser.h" 28 #include "chrome/browser/ui/browser.h"
28 #include "chrome/browser/ui/browser_commands.h" 29 #include "chrome/browser/ui/browser_commands.h"
29 #include "chrome/browser/ui/browser_dialogs.h" 30 #include "chrome/browser/ui/browser_dialogs.h"
30 #include "chrome/browser/ui/browser_window.h" 31 #include "chrome/browser/ui/browser_window.h"
31 #include "chrome/browser/ui/chrome_pages.h" 32 #include "chrome/browser/ui/chrome_pages.h"
32 #include "chrome/browser/ui/chrome_style.h" 33 #include "chrome/browser/ui/chrome_style.h"
33 #import "chrome/browser/ui/cocoa/hyperlink_text_view.h" 34 #import "chrome/browser/ui/cocoa/hyperlink_text_view.h"
34 #import "chrome/browser/ui/cocoa/info_bubble_view.h" 35 #import "chrome/browser/ui/cocoa/info_bubble_view.h"
(...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after
423 [path addClip]; 424 [path addClip];
424 [self.image drawAtPoint:bounds.origin 425 [self.image drawAtPoint:bounds.origin
425 fromRect:bounds 426 fromRect:bounds
426 operation:NSCompositeSourceOver 427 operation:NSCompositeSourceOver
427 fraction:1.0]; 428 fraction:1.0];
428 429
429 } 430 }
430 431
431 - (void)editPhoto:(id)sender { 432 - (void)editPhoto:(id)sender {
432 avatarMenu_->EditProfile(avatarMenu_->GetActiveProfileIndex()); 433 avatarMenu_->EditProfile(avatarMenu_->GetActiveProfileIndex());
434 [self postActionPerformed:ProfileMetrics::PROFILE_DESKTOP_MENU_EDIT_IMAGE];
433 } 435 }
434 436
435 - (void)mouseEntered:(NSEvent*)event { 437 - (void)mouseEntered:(NSEvent*)event {
436 [changePhotoButton_ setHidden:NO]; 438 [changePhotoButton_ setHidden:NO];
437 } 439 }
438 440
439 - (void)mouseExited:(NSEvent*)event { 441 - (void)mouseExited:(NSEvent*)event {
440 [changePhotoButton_ setHidden:YES]; 442 [changePhotoButton_ setHidden:YES];
441 } 443 }
442 444
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
526 return self; 528 return self;
527 } 529 }
528 530
529 // NSTextField objects send an NSNotification to a delegate if 531 // NSTextField objects send an NSNotification to a delegate if
530 // it implements this method: 532 // it implements this method:
531 - (void)controlTextDidEndEditing:(NSNotification *)obj { 533 - (void)controlTextDidEndEditing:(NSNotification *)obj {
532 NSString* text = [profileNameTextField_ stringValue]; 534 NSString* text = [profileNameTextField_ stringValue];
533 // Empty profile names are not allowed, and are treated as a cancel. 535 // Empty profile names are not allowed, and are treated as a cancel.
534 if ([text length] > 0) { 536 if ([text length] > 0) {
535 profiles::UpdateProfileName(profile_, base::SysNSStringToUTF16(text)); 537 profiles::UpdateProfileName(profile_, base::SysNSStringToUTF16(text));
538 [self postActionPerformed:ProfileMetrics::PROFILE_DESKTOP_MENU_EDIT_NAME];
536 [self setTitle:text]; 539 [self setTitle:text];
537 } 540 }
538 [profileNameTextField_ setHidden:YES]; 541 [profileNameTextField_ setHidden:YES];
539 [profileNameTextField_ resignFirstResponder]; 542 [profileNameTextField_ resignFirstResponder];
540 } 543 }
541 544
542 - (void)showEditableView:(id)sender { 545 - (void)showEditableView:(id)sender {
543 [profileNameTextField_ setHidden:NO]; 546 [profileNameTextField_ setHidden:NO];
544 [profileNameTextField_ becomeFirstResponder]; 547 [profileNameTextField_ becomeFirstResponder];
545 } 548 }
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
731 - (NSButton*)linkButtonWithTitle:(NSString*)title 734 - (NSButton*)linkButtonWithTitle:(NSString*)title
732 frameOrigin:(NSPoint)frameOrigin 735 frameOrigin:(NSPoint)frameOrigin
733 action:(SEL)action; 736 action:(SEL)action;
734 737
735 // Creates an email account button with |title| and a remove icon. |tag| 738 // Creates an email account button with |title| and a remove icon. |tag|
736 // indicates which account the button refers to. 739 // indicates which account the button refers to.
737 - (NSButton*)accountButtonWithRect:(NSRect)rect 740 - (NSButton*)accountButtonWithRect:(NSRect)rect
738 title:(const std::string&)title 741 title:(const std::string&)title
739 tag:(int)tag; 742 tag:(int)tag;
740 743
744 // Clean-up done after an action was performed in the ProfileChooser.
745 - (void)postActionPerformed:(ProfileMetrics::ProfileDesktopMenu)action;
Scott Hess - ex-Googler 2014/05/30 04:09:27 I think it's weird to have this down here though i
Mike Lerman 2014/05/30 17:46:25 Done... I guess... since there's nothing for me to
746
741 @end 747 @end
742 748
743 @implementation ProfileChooserController 749 @implementation ProfileChooserController
744 - (profiles::BubbleViewMode) viewMode { 750 - (profiles::BubbleViewMode) viewMode {
745 return viewMode_; 751 return viewMode_;
746 } 752 }
747 753
748 - (IBAction)switchToProfile:(id)sender { 754 - (IBAction)switchToProfile:(id)sender {
749 // Check the event flags to see if a new window should be created. 755 // Check the event flags to see if a new window should be created.
750 bool alwaysCreate = ui::WindowOpenDispositionFromNSEvent( 756 bool alwaysCreate = ui::WindowOpenDispositionFromNSEvent(
(...skipping 15 matching lines...) Expand all
766 - (IBAction)showAccountManagement:(id)sender { 772 - (IBAction)showAccountManagement:(id)sender {
767 [self initMenuContentsWithView:profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT]; 773 [self initMenuContentsWithView:profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT];
768 } 774 }
769 775
770 - (IBAction)hideAccountManagement:(id)sender { 776 - (IBAction)hideAccountManagement:(id)sender {
771 [self initMenuContentsWithView:profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER]; 777 [self initMenuContentsWithView:profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER];
772 } 778 }
773 779
774 - (IBAction)lockProfile:(id)sender { 780 - (IBAction)lockProfile:(id)sender {
775 profiles::LockProfile(browser_->profile()); 781 profiles::LockProfile(browser_->profile());
782 [self postActionPerformed:ProfileMetrics::PROFILE_DESKTOP_MENU_LOCK];
776 } 783 }
777 784
778 - (IBAction)showInlineSigninPage:(id)sender { 785 - (IBAction)showInlineSigninPage:(id)sender {
779 [self initMenuContentsWithView:profiles::BUBBLE_VIEW_MODE_GAIA_SIGNIN]; 786 [self initMenuContentsWithView:profiles::BUBBLE_VIEW_MODE_GAIA_SIGNIN];
780 } 787 }
781 788
782 - (IBAction)showTabbedSigninPage:(id)sender { 789 - (IBAction)showTabbedSigninPage:(id)sender {
783 chrome::ShowBrowserSignin(browser_, signin::SOURCE_MENU); 790 chrome::ShowBrowserSignin(browser_, signin::SOURCE_MENU);
784 } 791 }
785 792
786 - (IBAction)addAccount:(id)sender { 793 - (IBAction)addAccount:(id)sender {
787 [self initMenuContentsWithView:profiles::BUBBLE_VIEW_MODE_GAIA_ADD_ACCOUNT]; 794 [self initMenuContentsWithView:profiles::BUBBLE_VIEW_MODE_GAIA_ADD_ACCOUNT];
795 [self postActionPerformed:ProfileMetrics::PROFILE_DESKTOP_MENU_ADD_ACCT];
788 } 796 }
789 797
790 - (IBAction)navigateBackFromSigninPage:(id)sender { 798 - (IBAction)navigateBackFromSigninPage:(id)sender {
791 std::string primaryAccount = SigninManagerFactory::GetForProfile( 799 std::string primaryAccount = SigninManagerFactory::GetForProfile(
792 browser_->profile())->GetAuthenticatedUsername(); 800 browser_->profile())->GetAuthenticatedUsername();
793 [self initMenuContentsWithView:primaryAccount.empty() ? 801 [self initMenuContentsWithView:primaryAccount.empty() ?
794 profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER : 802 profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER :
795 profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT]; 803 profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT];
796 } 804 }
797 805
(...skipping 11 matching lines...) Expand all
809 accountIdToRemove_ = currentProfileAccounts_[tag]; 817 accountIdToRemove_ = currentProfileAccounts_[tag];
810 } 818 }
811 819
812 [self initMenuContentsWithView:profiles::BUBBLE_VIEW_MODE_ACCOUNT_REMOVAL]; 820 [self initMenuContentsWithView:profiles::BUBBLE_VIEW_MODE_ACCOUNT_REMOVAL];
813 } 821 }
814 822
815 - (IBAction)removeAccount:(id)sender { 823 - (IBAction)removeAccount:(id)sender {
816 DCHECK(!accountIdToRemove_.empty()); 824 DCHECK(!accountIdToRemove_.empty());
817 ProfileOAuth2TokenServiceFactory::GetPlatformSpecificForProfile( 825 ProfileOAuth2TokenServiceFactory::GetPlatformSpecificForProfile(
818 browser_->profile())->RevokeCredentials(accountIdToRemove_); 826 browser_->profile())->RevokeCredentials(accountIdToRemove_);
827 [self postActionPerformed:ProfileMetrics::PROFILE_DESKTOP_MENU_REMOVE_ACCT];
819 accountIdToRemove_.clear(); 828 accountIdToRemove_.clear();
820 829
821 [self initMenuContentsWithView:profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT]; 830 [self initMenuContentsWithView:profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT];
822 } 831 }
823 832
824 - (IBAction)openTutorialLearnMoreURL:(id)sender { 833 - (IBAction)openTutorialLearnMoreURL:(id)sender {
825 ProfileMetrics::LogProfileUpgradeEnrollment( 834 ProfileMetrics::LogProfileUpgradeEnrollment(
826 ProfileMetrics::PROFILE_ENROLLMENT_LAUNCH_LEARN_MORE); 835 ProfileMetrics::PROFILE_ENROLLMENT_LAUNCH_LEARN_MORE);
827 // TODO(guohui): update |learnMoreUrl| once it is decided. 836 // TODO(guohui): update |learnMoreUrl| once it is decided.
828 const GURL learnMoreUrl("https://support.google.com/chrome/?hl=en#to"); 837 const GURL learnMoreUrl("https://support.google.com/chrome/?hl=en#to");
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
868 - (IBAction)endPreviewAndRelaunch:(id)sender { 877 - (IBAction)endPreviewAndRelaunch:(id)sender {
869 profiles::DisableNewProfileManagementPreview(); 878 profiles::DisableNewProfileManagementPreview();
870 } 879 }
871 880
872 - (void)cleanUpEmbeddedViewContents { 881 - (void)cleanUpEmbeddedViewContents {
873 webContents_.reset(); 882 webContents_.reset();
874 } 883 }
875 884
876 - (id)initWithBrowser:(Browser*)browser 885 - (id)initWithBrowser:(Browser*)browser
877 anchoredAt:(NSPoint)point 886 anchoredAt:(NSPoint)point
878 withMode:(profiles::BubbleViewMode)mode { 887 withMode:(profiles::BubbleViewMode)mode
888 withServiceType:(signin::GAIAServiceType)GAIAServiceType {
879 base::scoped_nsobject<InfoBubbleWindow> window([[InfoBubbleWindow alloc] 889 base::scoped_nsobject<InfoBubbleWindow> window([[InfoBubbleWindow alloc]
880 initWithContentRect:ui::kWindowSizeDeterminedLater 890 initWithContentRect:ui::kWindowSizeDeterminedLater
881 styleMask:NSBorderlessWindowMask 891 styleMask:NSBorderlessWindowMask
882 backing:NSBackingStoreBuffered 892 backing:NSBackingStoreBuffered
883 defer:NO]); 893 defer:NO]);
884 894
885 if ((self = [super initWithWindow:window 895 if ((self = [super initWithWindow:window
886 parentWindow:browser->window()->GetNativeWindow() 896 parentWindow:browser->window()->GetNativeWindow()
887 anchoredAt:point])) { 897 anchoredAt:point])) {
888 browser_ = browser; 898 browser_ = browser;
889 viewMode_ = mode; 899 viewMode_ = mode;
890 tutorialMode_ = profiles::TUTORIAL_MODE_NONE; 900 tutorialMode_ = profiles::TUTORIAL_MODE_NONE;
891 observer_.reset(new ActiveProfileObserverBridge(self, browser_)); 901 observer_.reset(new ActiveProfileObserverBridge(self, browser_));
902 GAIAServiceType_ = GAIAServiceType;
892 903
893 avatarMenu_.reset(new AvatarMenu( 904 avatarMenu_.reset(new AvatarMenu(
894 &g_browser_process->profile_manager()->GetProfileInfoCache(), 905 &g_browser_process->profile_manager()->GetProfileInfoCache(),
895 observer_.get(), 906 observer_.get(),
896 browser_)); 907 browser_));
897 avatarMenu_->RebuildMenu(); 908 avatarMenu_->RebuildMenu();
898 909
899 // Guest profiles do not have a token service. 910 // Guest profiles do not have a token service.
900 isGuestSession_ = browser_->profile()->IsGuestSession(); 911 isGuestSession_ = browser_->profile()->IsGuestSession();
901 912
(...skipping 810 matching lines...) Expand 10 before | Expand all | Expand 10 after
1712 [deleteButton setPressedImage:rb->GetNativeImageNamed( 1723 [deleteButton setPressedImage:rb->GetNativeImageNamed(
1713 IDR_CLOSE_1_P).ToNSImage()]; 1724 IDR_CLOSE_1_P).ToNSImage()];
1714 [deleteButton setTarget:self]; 1725 [deleteButton setTarget:self];
1715 [deleteButton setAction:@selector(showAccountRemovalView:)]; 1726 [deleteButton setAction:@selector(showAccountRemovalView:)];
1716 [deleteButton setTag:tag]; 1727 [deleteButton setTag:tag];
1717 1728
1718 [button addSubview:deleteButton]; 1729 [button addSubview:deleteButton];
1719 return button.autorelease(); 1730 return button.autorelease();
1720 } 1731 }
1721 1732
1733 - (void)postActionPerformed:(ProfileMetrics::ProfileDesktopMenu)action {
1734 ProfileMetrics::LogProfileDesktopMenu(action, GAIAServiceType_);
1735 GAIAServiceType_ = signin::GAIA_SERVICE_TYPE_NONE;
1736 }
1737
1722 @end 1738 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698