OLD | NEW |
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 "base/mac/foundation_util.h" | 7 #include "base/mac/foundation_util.h" |
8 #include "base/macros.h" | 8 #include "base/macros.h" |
9 #include "chrome/app/chrome_command_ids.h" | 9 #include "chrome/app/chrome_command_ids.h" |
10 #include "chrome/browser/browser_process.h" | 10 #include "chrome/browser/browser_process.h" |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
126 CHECK(button_.get()); // Subclasses must set this. | 126 CHECK(button_.get()); // Subclasses must set this. |
127 return button_.get(); | 127 return button_.get(); |
128 } | 128 } |
129 | 129 |
130 - (void)showAvatarBubbleAnchoredAt:(NSView*)anchor | 130 - (void)showAvatarBubbleAnchoredAt:(NSView*)anchor |
131 withMode:(BrowserWindow::AvatarBubbleMode)mode | 131 withMode:(BrowserWindow::AvatarBubbleMode)mode |
132 withServiceType:(signin::GAIAServiceType)serviceType | 132 withServiceType:(signin::GAIAServiceType)serviceType |
133 fromAccessPoint:(signin_metrics::AccessPoint)accessPoint { | 133 fromAccessPoint:(signin_metrics::AccessPoint)accessPoint { |
134 if (menuController_) { | 134 if (menuController_) { |
135 profiles::BubbleViewMode viewMode; | 135 profiles::BubbleViewMode viewMode; |
136 profiles::TutorialMode tutorialMode; | 136 profiles::BubbleViewModeFromAvatarBubbleMode(mode, &viewMode); |
137 profiles::BubbleViewModeFromAvatarBubbleMode( | 137 if (viewMode == profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER) { |
138 mode, &viewMode, &tutorialMode); | |
139 if (tutorialMode != profiles::TUTORIAL_MODE_NONE) { | |
140 ProfileChooserController* profileChooserController = | 138 ProfileChooserController* profileChooserController = |
141 base::mac::ObjCCastStrict<ProfileChooserController>( | 139 base::mac::ObjCCastStrict<ProfileChooserController>( |
142 menuController_); | 140 menuController_); |
143 [profileChooserController setTutorialMode:tutorialMode]; | |
144 [profileChooserController initMenuContentsWithView:viewMode]; | 141 [profileChooserController initMenuContentsWithView:viewMode]; |
145 } | 142 } |
146 return; | 143 return; |
147 } | 144 } |
148 | 145 |
149 DCHECK(chrome::IsCommandEnabled(browser_, IDC_SHOW_AVATAR_MENU)); | 146 DCHECK(chrome::IsCommandEnabled(browser_, IDC_SHOW_AVATAR_MENU)); |
150 | 147 |
151 NSWindowController* wc = | 148 NSWindowController* wc = |
152 [browser_->window()->GetNativeWindow() windowController]; | 149 [browser_->window()->GetNativeWindow() windowController]; |
153 if ([wc isKindOfClass:[BrowserWindowController class]]) { | 150 if ([wc isKindOfClass:[BrowserWindowController class]]) { |
154 [static_cast<BrowserWindowController*>(wc) | 151 [static_cast<BrowserWindowController*>(wc) |
155 lockToolbarVisibilityForOwner:self | 152 lockToolbarVisibilityForOwner:self |
156 withAnimation:NO]; | 153 withAnimation:NO]; |
157 } | 154 } |
158 | 155 |
159 // The new avatar bubble does not have an arrow, and it should be anchored | 156 // The new avatar bubble does not have an arrow, and it should be anchored |
160 // to the edge of the avatar button. | 157 // to the edge of the avatar button. |
161 int anchorX = cocoa_l10n_util::ShouldFlipWindowControlsInRTL() | 158 int anchorX = cocoa_l10n_util::ShouldFlipWindowControlsInRTL() |
162 ? NSMinX([anchor bounds]) + kMenuXOffsetAdjust | 159 ? NSMinX([anchor bounds]) + kMenuXOffsetAdjust |
163 : NSMaxX([anchor bounds]) - kMenuXOffsetAdjust; | 160 : NSMaxX([anchor bounds]) - kMenuXOffsetAdjust; |
164 NSPoint point = NSMakePoint(anchorX, | 161 NSPoint point = NSMakePoint(anchorX, |
165 NSMaxY([anchor bounds]) + kMenuYOffsetAdjust); | 162 NSMaxY([anchor bounds]) + kMenuYOffsetAdjust); |
166 point = [anchor convertPoint:point toView:nil]; | 163 point = [anchor convertPoint:point toView:nil]; |
167 point = ui::ConvertPointFromWindowToScreen([anchor window], point); | 164 point = ui::ConvertPointFromWindowToScreen([anchor window], point); |
168 | 165 |
169 // |menuController_| will automatically release itself on close. | 166 // |menuController_| will automatically release itself on close. |
170 profiles::BubbleViewMode viewMode; | 167 profiles::BubbleViewMode viewMode; |
171 profiles::TutorialMode tutorialMode; | 168 profiles::BubbleViewModeFromAvatarBubbleMode(mode, &viewMode); |
172 profiles::BubbleViewModeFromAvatarBubbleMode( | |
173 mode, &viewMode, &tutorialMode); | |
174 | 169 |
175 menuController_ = | 170 menuController_ = |
176 [[ProfileChooserController alloc] initWithBrowser:browser_ | 171 [[ProfileChooserController alloc] initWithBrowser:browser_ |
177 anchoredAt:point | 172 anchoredAt:point |
178 viewMode:viewMode | 173 viewMode:viewMode |
179 tutorialMode:tutorialMode | |
180 serviceType:serviceType | 174 serviceType:serviceType |
181 accessPoint:accessPoint]; | 175 accessPoint:accessPoint]; |
182 | 176 |
183 [[NSNotificationCenter defaultCenter] | 177 [[NSNotificationCenter defaultCenter] |
184 addObserver:self | 178 addObserver:self |
185 selector:@selector(bubbleWillClose:) | 179 selector:@selector(bubbleWillClose:) |
186 name:NSWindowWillCloseNotification | 180 name:NSWindowWillCloseNotification |
187 object:[menuController_ window]]; | 181 object:[menuController_ window]]; |
188 [menuController_ showWindow:self]; | 182 [menuController_ showWindow:self]; |
189 | 183 |
(...skipping 24 matching lines...) Expand all Loading... |
214 } | 208 } |
215 | 209 |
216 - (void)setErrorStatus:(BOOL)hasError { | 210 - (void)setErrorStatus:(BOOL)hasError { |
217 } | 211 } |
218 | 212 |
219 - (BaseBubbleController*)menuController { | 213 - (BaseBubbleController*)menuController { |
220 return menuController_; | 214 return menuController_; |
221 } | 215 } |
222 | 216 |
223 @end | 217 @end |
OLD | NEW |