| 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/app/vector_icons/vector_icons.h" | 9 #include "chrome/app/vector_icons/vector_icons.h" |
| 10 #include "chrome/browser/browser_process.h" | 10 #include "chrome/browser/browser_process.h" |
| 11 #include "chrome/browser/profiles/profile_attributes_entry.h" | 11 #include "chrome/browser/profiles/profile_attributes_entry.h" |
| 12 #include "chrome/browser/profiles/profile_attributes_storage.h" | 12 #include "chrome/browser/profiles/profile_attributes_storage.h" |
| 13 #include "chrome/browser/profiles/profile_manager.h" | 13 #include "chrome/browser/profiles/profile_manager.h" |
| 14 #include "chrome/browser/profiles/profiles_state.h" | 14 #include "chrome/browser/profiles/profiles_state.h" |
| 15 #import "chrome/browser/themes/theme_properties.h" | 15 #import "chrome/browser/themes/theme_properties.h" |
| 16 #include "chrome/browser/themes/theme_service.h" | 16 #include "chrome/browser/themes/theme_service.h" |
| 17 #include "chrome/browser/themes/theme_service_factory.h" | 17 #include "chrome/browser/themes/theme_service_factory.h" |
| 18 #include "chrome/browser/ui/browser.h" | 18 #include "chrome/browser/ui/browser.h" |
| 19 #include "chrome/browser/ui/browser_window.h" | 19 #include "chrome/browser/ui/browser_window.h" |
| 20 #import "chrome/browser/ui/cocoa/browser_window_controller.h" | 20 #import "chrome/browser/ui/cocoa/browser_window_controller.h" |
| 21 #include "chrome/browser/ui/cocoa/l10n_util.h" | |
| 22 #import "chrome/browser/ui/cocoa/profiles/avatar_button.h" | 21 #import "chrome/browser/ui/cocoa/profiles/avatar_button.h" |
| 23 #include "chrome/grit/generated_resources.h" | 22 #include "chrome/grit/generated_resources.h" |
| 24 #include "chrome/grit/theme_resources.h" | 23 #include "chrome/grit/theme_resources.h" |
| 25 #include "components/signin/core/common/profile_management_switches.h" | 24 #include "components/signin/core/common/profile_management_switches.h" |
| 26 #include "skia/ext/skia_utils_mac.h" | 25 #include "skia/ext/skia_utils_mac.h" |
| 27 #import "ui/base/cocoa/appkit_utils.h" | 26 #import "ui/base/cocoa/appkit_utils.h" |
| 28 #include "ui/base/l10n/l10n_util_mac.h" | 27 #include "ui/base/l10n/l10n_util_mac.h" |
| 29 #include "ui/base/material_design/material_design_controller.h" | 28 #include "ui/base/material_design/material_design_controller.h" |
| 30 #include "ui/gfx/color_palette.h" | 29 #include "ui/gfx/color_palette.h" |
| 31 #include "ui/gfx/image/image_skia_util_mac.h" | 30 #include "ui/gfx/image/image_skia_util_mac.h" |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 179 | 178 |
| 180 [avatarButton setWantsLayer:YES]; | 179 [avatarButton setWantsLayer:YES]; |
| 181 [self setView:avatarButton]; | 180 [self setView:avatarButton]; |
| 182 | 181 |
| 183 [avatarButton setBezelStyle:NSShadowlessSquareBezelStyle]; | 182 [avatarButton setBezelStyle:NSShadowlessSquareBezelStyle]; |
| 184 [avatarButton setButtonType:NSMomentaryChangeButton]; | 183 [avatarButton setButtonType:NSMomentaryChangeButton]; |
| 185 if (switches::IsMaterialDesignUserMenu()) | 184 if (switches::IsMaterialDesignUserMenu()) |
| 186 [[avatarButton cell] setHighlightsBy:NSNoCellMask]; | 185 [[avatarButton cell] setHighlightsBy:NSNoCellMask]; |
| 187 [avatarButton setBordered:YES]; | 186 [avatarButton setBordered:YES]; |
| 188 | 187 |
| 189 if (cocoa_l10n_util::ShouldFlipWindowControlsInRTL()) | |
| 190 [avatarButton setAutoresizingMask:NSViewMaxXMargin | NSViewMinYMargin]; | |
| 191 else | |
| 192 [avatarButton setAutoresizingMask:NSViewMinXMargin | NSViewMinYMargin]; | |
| 193 [avatarButton setTarget:self]; | 188 [avatarButton setTarget:self]; |
| 194 [avatarButton setAction:@selector(buttonClicked:)]; | 189 [avatarButton setAction:@selector(buttonClicked:)]; |
| 195 [avatarButton setRightAction:@selector(buttonClicked:)]; | 190 [avatarButton setRightAction:@selector(buttonClicked:)]; |
| 196 | 191 |
| 197 // Check if the account already has an authentication or sync error and | 192 // Check if the account already has an authentication or sync error and |
| 198 // initialize the avatar button UI. | 193 // initialize the avatar button UI. |
| 199 hasError_ = profileObserver_->HasAvatarError(); | 194 hasError_ = profileObserver_->HasAvatarError(); |
| 200 [self updateAvatarButtonAndLayoutParent:NO]; | 195 [self updateAvatarButtonAndLayoutParent:NO]; |
| 201 | 196 |
| 202 window_ = window; | 197 window_ = window; |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 344 } | 339 } |
| 345 | 340 |
| 346 - (void)bubbleWillClose:(NSNotification*)notif { | 341 - (void)bubbleWillClose:(NSNotification*)notif { |
| 347 AvatarButton* button = base::mac::ObjCCastStrict<AvatarButton>(button_); | 342 AvatarButton* button = base::mac::ObjCCastStrict<AvatarButton>(button_); |
| 348 [button setIsActive:NO]; | 343 [button setIsActive:NO]; |
| 349 [self updateAvatarButtonAndLayoutParent:NO]; | 344 [self updateAvatarButtonAndLayoutParent:NO]; |
| 350 [super bubbleWillClose:notif]; | 345 [super bubbleWillClose:notif]; |
| 351 } | 346 } |
| 352 | 347 |
| 353 @end | 348 @end |
| OLD | NEW |