Index: chrome/browser/ui/cocoa/profiles/profile_chooser_controller.mm |
diff --git a/chrome/browser/ui/cocoa/profiles/profile_chooser_controller.mm b/chrome/browser/ui/cocoa/profiles/profile_chooser_controller.mm |
index 7ff7d0d19c86435755222c9dbc1325ac92a6d478..4e0bc668461ca9bb1cdfaa2bd921722560f49bcd 100644 |
--- a/chrome/browser/ui/cocoa/profiles/profile_chooser_controller.mm |
+++ b/chrome/browser/ui/cocoa/profiles/profile_chooser_controller.mm |
@@ -22,6 +22,7 @@ |
#include "chrome/browser/profiles/profile_window.h" |
#include "chrome/browser/profiles/profiles_state.h" |
#include "chrome/browser/signin/profile_oauth2_token_service_factory.h" |
+#include "chrome/browser/signin/signin_header_helper.h" |
#include "chrome/browser/signin/signin_manager_factory.h" |
#include "chrome/browser/signin/signin_promo.h" |
#include "chrome/browser/ui/browser.h" |
@@ -363,12 +364,14 @@ class ActiveProfileObserverBridge : public AvatarMenuObserver, |
base::scoped_nsobject<TransparentBackgroundButton> changePhotoButton_; |
// Used to display the "Change" button on hover. |
ui::ScopedCrTrackingArea trackingArea_; |
+ ProfileChooserController* controller_; |
} |
- (id)initWithFrame:(NSRect)frameRect |
avatarMenu:(AvatarMenu*)avatarMenu |
profileIcon:(const gfx::Image&)profileIcon |
- editingAllowed:(BOOL)editingAllowed; |
+ editingAllowed:(BOOL)editingAllowed |
+ withController:(ProfileChooserController*)controller; |
// Called when the "Change" button is clicked. |
- (void)editPhoto:(id)sender; |
@@ -389,9 +392,11 @@ class ActiveProfileObserverBridge : public AvatarMenuObserver, |
- (id)initWithFrame:(NSRect)frameRect |
avatarMenu:(AvatarMenu*)avatarMenu |
profileIcon:(const gfx::Image&)profileIcon |
- editingAllowed:(BOOL)editingAllowed { |
+ editingAllowed:(BOOL)editingAllowed |
+ withController:(ProfileChooserController*)controller { |
if ((self = [super initWithFrame:frameRect])) { |
avatarMenu_ = avatarMenu; |
+ controller_ = controller; |
[self setImage:CreateProfileImage( |
profileIcon, kLargeImageSide).ToNSImage()]; |
@@ -430,6 +435,8 @@ class ActiveProfileObserverBridge : public AvatarMenuObserver, |
- (void)editPhoto:(id)sender { |
avatarMenu_->EditProfile(avatarMenu_->GetActiveProfileIndex()); |
+ [controller_ |
+ postActionPerformed:ProfileMetrics::PROFILE_DESKTOP_MENU_EDIT_IMAGE]; |
} |
- (void)mouseEntered:(NSEvent*)event { |
@@ -457,12 +464,14 @@ class ActiveProfileObserverBridge : public AvatarMenuObserver, |
@private |
base::scoped_nsobject<NSTextField> profileNameTextField_; |
Profile* profile_; // Weak. |
+ ProfileChooserController* controller_; |
} |
- (id)initWithFrame:(NSRect)frameRect |
profile:(Profile*)profile |
profileName:(NSString*)profileName |
- editingAllowed:(BOOL)editingAllowed; |
+ editingAllowed:(BOOL)editingAllowed |
+ withController:(ProfileChooserController*)controller; |
// Called when the button is clicked. |
- (void)showEditableView:(id)sender; |
@@ -475,9 +484,11 @@ class ActiveProfileObserverBridge : public AvatarMenuObserver, |
- (id)initWithFrame:(NSRect)frameRect |
profile:(Profile*)profile |
profileName:(NSString*)profileName |
- editingAllowed:(BOOL)editingAllowed { |
+ editingAllowed:(BOOL)editingAllowed |
+ withController:(ProfileChooserController*)controller { |
if ((self = [super initWithFrame:frameRect])) { |
profile_ = profile; |
+ controller_ = controller; |
[self setBordered:NO]; |
[self setFont:[NSFont labelFontOfSize:kTitleFontSize]]; |
@@ -533,6 +544,8 @@ class ActiveProfileObserverBridge : public AvatarMenuObserver, |
// Empty profile names are not allowed, and are treated as a cancel. |
if ([text length] > 0) { |
profiles::UpdateProfileName(profile_, base::SysNSStringToUTF16(text)); |
+ [controller_ |
+ postActionPerformed:ProfileMetrics::PROFILE_DESKTOP_MENU_EDIT_NAME]; |
[self setTitle:text]; |
} |
[profileNameTextField_ setHidden:YES]; |
@@ -737,7 +750,6 @@ class ActiveProfileObserverBridge : public AvatarMenuObserver, |
- (NSButton*)accountButtonWithRect:(NSRect)rect |
title:(const std::string&)title |
tag:(int)tag; |
- |
@end |
@implementation ProfileChooserController |
@@ -773,6 +785,7 @@ class ActiveProfileObserverBridge : public AvatarMenuObserver, |
- (IBAction)lockProfile:(id)sender { |
profiles::LockProfile(browser_->profile()); |
+ [self postActionPerformed:ProfileMetrics::PROFILE_DESKTOP_MENU_LOCK]; |
} |
- (IBAction)showInlineSigninPage:(id)sender { |
@@ -785,6 +798,7 @@ class ActiveProfileObserverBridge : public AvatarMenuObserver, |
- (IBAction)addAccount:(id)sender { |
[self initMenuContentsWithView:profiles::BUBBLE_VIEW_MODE_GAIA_ADD_ACCOUNT]; |
+ [self postActionPerformed:ProfileMetrics::PROFILE_DESKTOP_MENU_ADD_ACCT]; |
} |
- (IBAction)navigateBackFromSigninPage:(id)sender { |
@@ -816,6 +830,7 @@ class ActiveProfileObserverBridge : public AvatarMenuObserver, |
DCHECK(!accountIdToRemove_.empty()); |
ProfileOAuth2TokenServiceFactory::GetPlatformSpecificForProfile( |
browser_->profile())->RevokeCredentials(accountIdToRemove_); |
+ [self postActionPerformed:ProfileMetrics::PROFILE_DESKTOP_MENU_REMOVE_ACCT]; |
accountIdToRemove_.clear(); |
[self initMenuContentsWithView:profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT]; |
@@ -875,7 +890,8 @@ class ActiveProfileObserverBridge : public AvatarMenuObserver, |
- (id)initWithBrowser:(Browser*)browser |
anchoredAt:(NSPoint)point |
- withMode:(profiles::BubbleViewMode)mode { |
+ withMode:(profiles::BubbleViewMode)mode |
+ withServiceType:(signin::GAIAServiceType)serviceType { |
base::scoped_nsobject<InfoBubbleWindow> window([[InfoBubbleWindow alloc] |
initWithContentRect:ui::kWindowSizeDeterminedLater |
styleMask:NSBorderlessWindowMask |
@@ -889,6 +905,7 @@ class ActiveProfileObserverBridge : public AvatarMenuObserver, |
viewMode_ = mode; |
tutorialMode_ = profiles::TUTORIAL_MODE_NONE; |
observer_.reset(new ActiveProfileObserverBridge(self, browser_)); |
+ serviceType_ = serviceType; |
avatarMenu_.reset(new AvatarMenu( |
&g_browser_process->profile_manager()->GetProfileInfoCache(), |
@@ -1031,7 +1048,7 @@ class ActiveProfileObserverBridge : public AvatarMenuObserver, |
} |
[container setFrameSize:NSMakeSize(kFixedMenuWidth, yOffset)]; |
- return container.autorelease();; |
+ return container.autorelease(); |
} |
- (NSView*)buildPreviewTutorialIfNeeded:(const AvatarMenu::Item&)item { |
@@ -1215,7 +1232,8 @@ class ActiveProfileObserverBridge : public AvatarMenuObserver, |
profile:browser_->profile() |
profileName:base::SysUTF16ToNSString( |
profiles::GetAvatarNameForProfile(browser_->profile())) |
- editingAllowed:editingAllowed]); |
+ editingAllowed:editingAllowed |
+ withController:self]); |
[container addSubview:profileName]; |
yOffset = NSMaxY([profileName frame]); |
@@ -1228,7 +1246,8 @@ class ActiveProfileObserverBridge : public AvatarMenuObserver, |
kLargeImageSide, kLargeImageSide) |
avatarMenu:avatarMenu_.get() |
profileIcon:item.icon |
- editingAllowed:!isGuestSession_]); |
+ editingAllowed:!isGuestSession_ |
+ withController:self]); |
[container addSubview:iconView]; |
yOffset = NSMaxY([iconView frame]); |
@@ -1719,4 +1738,9 @@ class ActiveProfileObserverBridge : public AvatarMenuObserver, |
return button.autorelease(); |
} |
+- (void)postActionPerformed:(ProfileMetrics::ProfileDesktopMenu)action { |
+ ProfileMetrics::LogProfileDesktopMenu(action, serviceType_); |
+ serviceType_ = signin::GAIA_SERVICE_TYPE_NONE; |
+} |
+ |
@end |