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

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

Issue 2490323002: [Mac] Anchor profile switcher to left side of avatar button in RTL (Closed)
Patch Set: Review comments Created 4 years, 1 month 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 "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"
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_manager.h" 12 #include "chrome/browser/profiles/profile_manager.h"
13 #include "chrome/browser/profiles/profile_metrics.h" 13 #include "chrome/browser/profiles/profile_metrics.h"
14 #include "chrome/browser/profiles/profile_window.h" 14 #include "chrome/browser/profiles/profile_window.h"
15 #include "chrome/browser/profiles/profiles_state.h" 15 #include "chrome/browser/profiles/profiles_state.h"
16 #include "chrome/browser/signin/chrome_signin_helper.h" 16 #include "chrome/browser/signin/chrome_signin_helper.h"
17 #include "chrome/browser/ui/browser.h" 17 #include "chrome/browser/ui/browser.h"
18 #include "chrome/browser/ui/browser_commands.h" 18 #include "chrome/browser/ui/browser_commands.h"
19 #include "chrome/browser/ui/browser_window.h" 19 #include "chrome/browser/ui/browser_window.h"
20 #import "chrome/browser/ui/cocoa/base_bubble_controller.h" 20 #import "chrome/browser/ui/cocoa/base_bubble_controller.h"
21 #import "chrome/browser/ui/cocoa/browser_window_controller.h" 21 #import "chrome/browser/ui/cocoa/browser_window_controller.h"
22 #include "chrome/browser/ui/cocoa/l10n_util.h"
22 #import "chrome/browser/ui/cocoa/profiles/avatar_menu_bubble_controller.h" 23 #import "chrome/browser/ui/cocoa/profiles/avatar_menu_bubble_controller.h"
23 #import "chrome/browser/ui/cocoa/profiles/profile_chooser_controller.h" 24 #import "chrome/browser/ui/cocoa/profiles/profile_chooser_controller.h"
24 #include "components/signin/core/common/profile_management_switches.h" 25 #include "components/signin/core/common/profile_management_switches.h"
25 #include "ui/base/cocoa/cocoa_base_utils.h" 26 #include "ui/base/cocoa/cocoa_base_utils.h"
26 27
27 // Space between the avatar icon and the avatar menu bubble. 28 // Space between the avatar icon and the avatar menu bubble.
28 const CGFloat kMenuYOffsetAdjust = 1.0; 29 const CGFloat kMenuYOffsetAdjust = 1.0;
29 // Offset needed to align the edge of the avatar bubble with the edge of the 30 // Offset needed to align the edge of the avatar bubble with the edge of the
30 // avatar button. 31 // avatar button.
31 const CGFloat kMenuXOffsetAdjust = 1.0; 32 const CGFloat kMenuXOffsetAdjust = 1.0;
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 NSWindowController* wc = 152 NSWindowController* wc =
152 [browser_->window()->GetNativeWindow() windowController]; 153 [browser_->window()->GetNativeWindow() windowController];
153 if ([wc isKindOfClass:[BrowserWindowController class]]) { 154 if ([wc isKindOfClass:[BrowserWindowController class]]) {
154 [static_cast<BrowserWindowController*>(wc) 155 [static_cast<BrowserWindowController*>(wc)
155 lockToolbarVisibilityForOwner:self 156 lockToolbarVisibilityForOwner:self
156 withAnimation:NO]; 157 withAnimation:NO];
157 } 158 }
158 159
159 // The new avatar bubble does not have an arrow, and it should be anchored 160 // The new avatar bubble does not have an arrow, and it should be anchored
160 // to the edge of the avatar button. 161 // to the edge of the avatar button.
161 int anchorX = NSMaxX([anchor bounds]) - kMenuXOffsetAdjust; 162 int anchorX = cocoa_l10n_util::ShouldDoExperimentalRTLLayout()
163 ? NSMinX([anchor bounds]) + kMenuXOffsetAdjust
164 : NSMaxX([anchor bounds]) - kMenuXOffsetAdjust;
162 NSPoint point = NSMakePoint(anchorX, 165 NSPoint point = NSMakePoint(anchorX,
163 NSMaxY([anchor bounds]) + kMenuYOffsetAdjust); 166 NSMaxY([anchor bounds]) + kMenuYOffsetAdjust);
164 point = [anchor convertPoint:point toView:nil]; 167 point = [anchor convertPoint:point toView:nil];
165 point = ui::ConvertPointFromWindowToScreen([anchor window], point); 168 point = ui::ConvertPointFromWindowToScreen([anchor window], point);
166 169
167 // |menuController_| will automatically release itself on close. 170 // |menuController_| will automatically release itself on close.
168 profiles::BubbleViewMode viewMode; 171 profiles::BubbleViewMode viewMode;
169 profiles::TutorialMode tutorialMode; 172 profiles::TutorialMode tutorialMode;
170 profiles::BubbleViewModeFromAvatarBubbleMode( 173 profiles::BubbleViewModeFromAvatarBubbleMode(
171 mode, &viewMode, &tutorialMode); 174 mode, &viewMode, &tutorialMode);
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 } 242 }
240 243
241 - (void)setErrorStatus:(BOOL)hasError { 244 - (void)setErrorStatus:(BOOL)hasError {
242 } 245 }
243 246
244 - (BaseBubbleController*)menuController { 247 - (BaseBubbleController*)menuController {
245 return menuController_; 248 return menuController_;
246 } 249 }
247 250
248 @end 251 @end
OLDNEW
« no previous file with comments | « chrome/browser/ui/cocoa/info_bubble_view.h ('k') | chrome/browser/ui/cocoa/profiles/profile_chooser_controller.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698