| 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_button_controller.h" | 5 #import "chrome/browser/ui/cocoa/profiles/avatar_button_controller.h" |
| 6 | 6 |
| 7 #include "base/mac/foundation_util.h" | 7 #include "base/mac/foundation_util.h" |
| 8 #include "base/strings/sys_string_conversions.h" | 8 #include "base/strings/sys_string_conversions.h" |
| 9 #include "chrome/browser/browser_process.h" | 9 #include "chrome/browser/browser_process.h" |
| 10 #include "chrome/browser/profiles/profile_attributes_entry.h" | 10 #include "chrome/browser/profiles/profile_attributes_entry.h" |
| 11 #include "chrome/browser/profiles/profile_attributes_storage.h" | 11 #include "chrome/browser/profiles/profile_attributes_storage.h" |
| 12 #include "chrome/browser/profiles/profile_manager.h" | 12 #include "chrome/browser/profiles/profile_manager.h" |
| 13 #include "chrome/browser/profiles/profiles_state.h" | 13 #include "chrome/browser/profiles/profiles_state.h" |
| 14 #include "chrome/browser/themes/theme_service.h" | 14 #include "chrome/browser/themes/theme_service.h" |
| 15 #include "chrome/browser/themes/theme_service_factory.h" | 15 #include "chrome/browser/themes/theme_service_factory.h" |
| 16 #include "chrome/browser/ui/browser.h" | 16 #include "chrome/browser/ui/browser.h" |
| 17 #include "chrome/browser/ui/browser_window.h" | 17 #include "chrome/browser/ui/browser_window.h" |
| 18 #import "chrome/browser/ui/cocoa/browser_window_controller.h" | 18 #import "chrome/browser/ui/cocoa/browser_window_controller.h" |
| 19 #include "chrome/browser/ui/cocoa/l10n_util.h" |
| 19 #import "chrome/browser/ui/cocoa/profiles/avatar_button.h" | 20 #import "chrome/browser/ui/cocoa/profiles/avatar_button.h" |
| 20 #include "chrome/grit/generated_resources.h" | 21 #include "chrome/grit/generated_resources.h" |
| 21 #include "chrome/grit/theme_resources.h" | 22 #include "chrome/grit/theme_resources.h" |
| 22 #include "components/signin/core/common/profile_management_switches.h" | 23 #include "components/signin/core/common/profile_management_switches.h" |
| 23 #include "skia/ext/skia_utils_mac.h" | 24 #include "skia/ext/skia_utils_mac.h" |
| 24 #import "ui/base/cocoa/appkit_utils.h" | 25 #import "ui/base/cocoa/appkit_utils.h" |
| 25 #include "ui/base/l10n/l10n_util_mac.h" | 26 #include "ui/base/l10n/l10n_util_mac.h" |
| 26 #include "ui/base/material_design/material_design_controller.h" | 27 #include "ui/base/material_design/material_design_controller.h" |
| 27 #include "ui/base/nine_image_painter_factory.h" | 28 #include "ui/base/nine_image_painter_factory.h" |
| 28 #include "ui/base/resource/resource_bundle.h" | 29 #include "ui/base/resource/resource_bundle.h" |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 212 | 213 |
| 213 [avatarButton setWantsLayer:YES]; | 214 [avatarButton setWantsLayer:YES]; |
| 214 [self setView:avatarButton]; | 215 [self setView:avatarButton]; |
| 215 | 216 |
| 216 [avatarButton setBezelStyle:NSShadowlessSquareBezelStyle]; | 217 [avatarButton setBezelStyle:NSShadowlessSquareBezelStyle]; |
| 217 [avatarButton setButtonType:NSMomentaryChangeButton]; | 218 [avatarButton setButtonType:NSMomentaryChangeButton]; |
| 218 if (switches::IsMaterialDesignUserMenu()) | 219 if (switches::IsMaterialDesignUserMenu()) |
| 219 [[avatarButton cell] setHighlightsBy:NSNoCellMask]; | 220 [[avatarButton cell] setHighlightsBy:NSNoCellMask]; |
| 220 [avatarButton setBordered:YES]; | 221 [avatarButton setBordered:YES]; |
| 221 | 222 |
| 222 [avatarButton setAutoresizingMask:NSViewMinXMargin | NSViewMinYMargin]; | 223 if (cocoa_l10n_util::ExperimentalMacRTLIsEnabled()) |
| 224 [avatarButton setAutoresizingMask:NSViewMaxXMargin | NSViewMinYMargin]; |
| 225 else |
| 226 [avatarButton setAutoresizingMask:NSViewMinXMargin | NSViewMinYMargin]; |
| 223 [avatarButton setTarget:self]; | 227 [avatarButton setTarget:self]; |
| 224 [avatarButton setAction:@selector(buttonClicked:)]; | 228 [avatarButton setAction:@selector(buttonClicked:)]; |
| 225 [avatarButton setRightAction:@selector(buttonRightClicked:)]; | 229 [avatarButton setRightAction:@selector(buttonRightClicked:)]; |
| 226 | 230 |
| 227 // Check if the account already has an authentication or sync error and | 231 // Check if the account already has an authentication or sync error and |
| 228 // initialize the avatar button UI. | 232 // initialize the avatar button UI. |
| 229 hasError_ = profileObserver_->HasAvatarError(); | 233 hasError_ = profileObserver_->HasAvatarError(); |
| 230 [self updateAvatarButtonAndLayoutParent:NO]; | 234 [self updateAvatarButtonAndLayoutParent:NO]; |
| 231 | 235 |
| 232 NSNotificationCenter* center = [NSNotificationCenter defaultCenter]; | 236 NSNotificationCenter* center = [NSNotificationCenter defaultCenter]; |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 357 layoutSubviews]; | 361 layoutSubviews]; |
| 358 } | 362 } |
| 359 } | 363 } |
| 360 | 364 |
| 361 - (void)setErrorStatus:(BOOL)hasError { | 365 - (void)setErrorStatus:(BOOL)hasError { |
| 362 hasError_ = hasError; | 366 hasError_ = hasError; |
| 363 [self updateAvatarButtonAndLayoutParent:YES]; | 367 [self updateAvatarButtonAndLayoutParent:YES]; |
| 364 } | 368 } |
| 365 | 369 |
| 366 @end | 370 @end |
| OLD | NEW |