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

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

Issue 308433002: Desktop Menu UMA for Mac (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rename variables; subViews to access profileChooserController for UMA 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 "chrome/browser/ui/cocoa/profiles/avatar_base_controller.h" 5 #import "chrome/browser/ui/cocoa/profiles/avatar_base_controller.h"
6 6
7 #include "chrome/app/chrome_command_ids.h" 7 #include "chrome/app/chrome_command_ids.h"
8 #include "chrome/browser/browser_process.h" 8 #include "chrome/browser/browser_process.h"
9 #include "chrome/browser/profiles/profile_info_cache_observer.h" 9 #include "chrome/browser/profiles/profile_info_cache_observer.h"
10 #include "chrome/browser/profiles/profile_avatar_icon_util.h" 10 #include "chrome/browser/profiles/profile_avatar_icon_util.h"
11 #include "chrome/browser/profiles/profile_manager.h" 11 #include "chrome/browser/profiles/profile_manager.h"
12 #include "chrome/browser/profiles/profile_metrics.h" 12 #include "chrome/browser/profiles/profile_metrics.h"
13 #include "chrome/browser/signin/signin_header_helper.h"
13 #include "chrome/browser/ui/browser.h" 14 #include "chrome/browser/ui/browser.h"
14 #include "chrome/browser/ui/browser_commands.h" 15 #include "chrome/browser/ui/browser_commands.h"
15 #include "chrome/browser/ui/browser_window.h" 16 #include "chrome/browser/ui/browser_window.h"
16 #import "chrome/browser/ui/cocoa/base_bubble_controller.h" 17 #import "chrome/browser/ui/cocoa/base_bubble_controller.h"
17 #import "chrome/browser/ui/cocoa/browser_window_controller.h" 18 #import "chrome/browser/ui/cocoa/browser_window_controller.h"
18 #import "chrome/browser/ui/cocoa/profiles/avatar_menu_bubble_controller.h" 19 #import "chrome/browser/ui/cocoa/profiles/avatar_menu_bubble_controller.h"
19 #import "chrome/browser/ui/cocoa/profiles/profile_chooser_controller.h" 20 #import "chrome/browser/ui/cocoa/profiles/profile_chooser_controller.h"
20 #include "components/signin/core/common/profile_management_switches.h" 21 #include "components/signin/core/common/profile_management_switches.h"
21 #include "ui/base/resource/resource_bundle.h" 22 #include "ui/base/resource/resource_bundle.h"
22 23
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 object:[menuController_ window]]; 92 object:[menuController_ window]];
92 [super dealloc]; 93 [super dealloc];
93 } 94 }
94 95
95 - (NSButton*)buttonView { 96 - (NSButton*)buttonView {
96 CHECK(button_.get()); // Subclasses must set this. 97 CHECK(button_.get()); // Subclasses must set this.
97 return button_.get(); 98 return button_.get();
98 } 99 }
99 100
100 - (void)showAvatarBubble:(NSView*)anchor 101 - (void)showAvatarBubble:(NSView*)anchor
101 withMode:(BrowserWindow::AvatarBubbleMode)mode { 102 withMode:(BrowserWindow::AvatarBubbleMode)mode
103 withServiceType:(signin::GAIAServiceType)serviceType {
102 if (menuController_) 104 if (menuController_)
103 return; 105 return;
104 106
105 DCHECK(chrome::IsCommandEnabled(browser_, IDC_SHOW_AVATAR_MENU)); 107 DCHECK(chrome::IsCommandEnabled(browser_, IDC_SHOW_AVATAR_MENU));
106 108
107 NSWindowController* wc = 109 NSWindowController* wc =
108 [browser_->window()->GetNativeWindow() windowController]; 110 [browser_->window()->GetNativeWindow() windowController];
109 if ([wc isKindOfClass:[BrowserWindowController class]]) { 111 if ([wc isKindOfClass:[BrowserWindowController class]]) {
110 [static_cast<BrowserWindowController*>(wc) 112 [static_cast<BrowserWindowController*>(wc)
111 lockBarVisibilityForOwner:self withAnimation:NO delay:NO]; 113 lockBarVisibilityForOwner:self withAnimation:NO delay:NO];
(...skipping 10 matching lines...) Expand all
122 124
123 // |menuController_| will automatically release itself on close. 125 // |menuController_| will automatically release itself on close.
124 if (switches::IsNewAvatarMenu()) { 126 if (switches::IsNewAvatarMenu()) {
125 profiles::BubbleViewMode viewMode = 127 profiles::BubbleViewMode viewMode =
126 mode == BrowserWindow::AVATAR_BUBBLE_MODE_DEFAULT ? 128 mode == BrowserWindow::AVATAR_BUBBLE_MODE_DEFAULT ?
127 profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER : 129 profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER :
128 profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT; 130 profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT;
129 menuController_ = 131 menuController_ =
130 [[ProfileChooserController alloc] initWithBrowser:browser_ 132 [[ProfileChooserController alloc] initWithBrowser:browser_
131 anchoredAt:point 133 anchoredAt:point
132 withMode:viewMode]; 134 withMode:viewMode
135 withServiceType:serviceType];
133 } else { 136 } else {
134 menuController_ = 137 menuController_ =
135 [[AvatarMenuBubbleController alloc] initWithBrowser:browser_ 138 [[AvatarMenuBubbleController alloc] initWithBrowser:browser_
136 anchoredAt:point]; 139 anchoredAt:point];
137 } 140 }
138 141
139 [[NSNotificationCenter defaultCenter] 142 [[NSNotificationCenter defaultCenter]
140 addObserver:self 143 addObserver:self
141 selector:@selector(bubbleWillClose:) 144 selector:@selector(bubbleWillClose:)
142 name:NSWindowWillCloseNotification 145 name:NSWindowWillCloseNotification
143 object:[menuController_ window]]; 146 object:[menuController_ window]];
144 [menuController_ showWindow:self]; 147 [menuController_ showWindow:self];
145 148
146 ProfileMetrics::LogProfileOpenMethod(ProfileMetrics::ICON_AVATAR_BUBBLE); 149 ProfileMetrics::LogProfileOpenMethod(ProfileMetrics::ICON_AVATAR_BUBBLE);
147 } 150 }
148 151
149 - (IBAction)buttonClicked:(id)sender { 152 - (IBAction)buttonClicked:(id)sender {
150 DCHECK_EQ(sender, button_.get()); 153 DCHECK_EQ(sender, button_.get());
151 [self showAvatarBubble:button_ 154 [self showAvatarBubble:button_
152 withMode:BrowserWindow::AVATAR_BUBBLE_MODE_DEFAULT]; 155 withMode:BrowserWindow::AVATAR_BUBBLE_MODE_DEFAULT
156 withServiceType:signin::GAIA_SERVICE_TYPE_NONE];
153 } 157 }
154 158
155 - (void)bubbleWillClose:(NSNotification*)notif { 159 - (void)bubbleWillClose:(NSNotification*)notif {
156 NSWindowController* wc = 160 NSWindowController* wc =
157 [browser_->window()->GetNativeWindow() windowController]; 161 [browser_->window()->GetNativeWindow() windowController];
158 if ([wc isKindOfClass:[BrowserWindowController class]]) { 162 if ([wc isKindOfClass:[BrowserWindowController class]]) {
159 [static_cast<BrowserWindowController*>(wc) 163 [static_cast<BrowserWindowController*>(wc)
160 releaseBarVisibilityForOwner:self withAnimation:YES delay:NO]; 164 releaseBarVisibilityForOwner:self withAnimation:YES delay:NO];
161 } 165 }
162 menuController_ = nil; 166 menuController_ = nil;
163 } 167 }
164 168
165 - (void)updateAvatarButtonAndLayoutParent:(BOOL)layoutParent { 169 - (void)updateAvatarButtonAndLayoutParent:(BOOL)layoutParent {
166 NOTREACHED(); 170 NOTREACHED();
167 } 171 }
168 172
169 - (BaseBubbleController*)menuController { 173 - (BaseBubbleController*)menuController {
170 return menuController_; 174 return menuController_;
171 } 175 }
172 176
173 @end 177 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698