| 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 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 177 [avatarButton setCell:cell.get()]; | 176 [avatarButton setCell:cell.get()]; |
| 178 | 177 |
| 179 [avatarButton setWantsLayer:YES]; | 178 [avatarButton setWantsLayer:YES]; |
| 180 [self setView:avatarButton]; | 179 [self setView:avatarButton]; |
| 181 | 180 |
| 182 [avatarButton setBezelStyle:NSShadowlessSquareBezelStyle]; | 181 [avatarButton setBezelStyle:NSShadowlessSquareBezelStyle]; |
| 183 [avatarButton setButtonType:NSMomentaryChangeButton]; | 182 [avatarButton setButtonType:NSMomentaryChangeButton]; |
| 184 [[avatarButton cell] setHighlightsBy:NSNoCellMask]; | 183 [[avatarButton cell] setHighlightsBy:NSNoCellMask]; |
| 185 [avatarButton setBordered:YES]; | 184 [avatarButton setBordered:YES]; |
| 186 | 185 |
| 187 if (cocoa_l10n_util::ShouldFlipWindowControlsInRTL()) | |
| 188 [avatarButton setAutoresizingMask:NSViewMaxXMargin | NSViewMinYMargin]; | |
| 189 else | |
| 190 [avatarButton setAutoresizingMask:NSViewMinXMargin | NSViewMinYMargin]; | |
| 191 [avatarButton setTarget:self]; | 186 [avatarButton setTarget:self]; |
| 192 [avatarButton setAction:@selector(buttonClicked:)]; | 187 [avatarButton setAction:@selector(buttonClicked:)]; |
| 193 [avatarButton setRightAction:@selector(buttonClicked:)]; | 188 [avatarButton setRightAction:@selector(buttonClicked:)]; |
| 194 | 189 |
| 195 // Check if the account already has an authentication or sync error and | 190 // Check if the account already has an authentication or sync error and |
| 196 // initialize the avatar button UI. | 191 // initialize the avatar button UI. |
| 197 hasError_ = profileObserver_->HasAvatarError(); | 192 hasError_ = profileObserver_->HasAvatarError(); |
| 198 [self updateAvatarButtonAndLayoutParent:NO]; | 193 [self updateAvatarButtonAndLayoutParent:NO]; |
| 199 | 194 |
| 200 window_ = window; | 195 window_ = window; |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 342 } | 337 } |
| 343 | 338 |
| 344 - (void)bubbleWillClose:(NSNotification*)notif { | 339 - (void)bubbleWillClose:(NSNotification*)notif { |
| 345 AvatarButton* button = base::mac::ObjCCastStrict<AvatarButton>(button_); | 340 AvatarButton* button = base::mac::ObjCCastStrict<AvatarButton>(button_); |
| 346 [button setIsActive:NO]; | 341 [button setIsActive:NO]; |
| 347 [self updateAvatarButtonAndLayoutParent:NO]; | 342 [self updateAvatarButtonAndLayoutParent:NO]; |
| 348 [super bubbleWillClose:notif]; | 343 [super bubbleWillClose:notif]; |
| 349 } | 344 } |
| 350 | 345 |
| 351 @end | 346 @end |
| OLD | NEW |