| 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_icon_controller.h" | 5 #import "chrome/browser/ui/cocoa/profiles/avatar_icon_controller.h" |
| 6 | 6 |
| 7 #include "base/strings/sys_string_conversions.h" | 7 #include "base/strings/sys_string_conversions.h" |
| 8 #include "chrome/browser/browser_process.h" | 8 #include "chrome/browser/browser_process.h" |
| 9 #include "chrome/browser/profiles/profile.h" | 9 #include "chrome/browser/profiles/profile.h" |
| 10 #include "chrome/browser/profiles/profile_avatar_icon_util.h" | 10 #include "chrome/browser/profiles/profile_avatar_icon_util.h" |
| 11 #include "chrome/browser/profiles/profile_info_cache.h" | 11 #include "chrome/browser/profiles/profile_info_cache.h" |
| 12 #include "chrome/browser/profiles/profile_manager.h" | 12 #include "chrome/browser/profiles/profile_manager.h" |
| 13 #include "chrome/browser/ui/browser.h" | 13 #include "chrome/browser/ui/browser.h" |
| 14 #include "chrome/browser/ui/browser_window.h" | 14 #include "chrome/browser/ui/browser_window.h" |
| 15 #import "chrome/browser/ui/cocoa/browser_window_controller.h" | 15 #import "chrome/browser/ui/cocoa/browser_window_controller.h" |
| 16 #import "chrome/browser/ui/cocoa/nsview_additions.h" | |
| 17 #import "chrome/browser/ui/cocoa/profiles/avatar_label_button.h" | 16 #import "chrome/browser/ui/cocoa/profiles/avatar_label_button.h" |
| 18 #include "grit/generated_resources.h" | 17 #include "grit/generated_resources.h" |
| 19 #include "grit/theme_resources.h" | 18 #include "grit/theme_resources.h" |
| 20 #include "ui/base/l10n/l10n_util_mac.h" | 19 #include "ui/base/l10n/l10n_util_mac.h" |
| 21 #include "ui/base/resource/resource_bundle.h" | 20 #include "ui/base/resource/resource_bundle.h" |
| 22 #include "ui/gfx/image/image.h" | 21 #include "ui/gfx/image/image.h" |
| 23 #include "ui/gfx/scoped_ns_graphics_context_save_gstate_mac.h" | 22 #include "ui/gfx/scoped_ns_graphics_context_save_gstate_mac.h" |
| 24 | 23 |
| 25 namespace { | 24 namespace { |
| 26 | 25 |
| (...skipping 26 matching lines...) Expand all Loading... |
| 53 | 52 |
| 54 @implementation AvatarIconController | 53 @implementation AvatarIconController |
| 55 | 54 |
| 56 - (id)initWithBrowser:(Browser*)browser { | 55 - (id)initWithBrowser:(Browser*)browser { |
| 57 if ((self = [super initWithBrowser:browser])) { | 56 if ((self = [super initWithBrowser:browser])) { |
| 58 browser_ = browser; | 57 browser_ = browser; |
| 59 | 58 |
| 60 base::scoped_nsobject<NSView> container( | 59 base::scoped_nsobject<NSView> container( |
| 61 [[NSView alloc] initWithFrame:NSMakeRect( | 60 [[NSView alloc] initWithFrame:NSMakeRect( |
| 62 0, 0, profiles::kAvatarIconWidth, profiles::kAvatarIconHeight)]); | 61 0, 0, profiles::kAvatarIconWidth, profiles::kAvatarIconHeight)]); |
| 63 [container cr_setWantsLayer:YES]; | 62 [container setWantsLayer:YES]; |
| 64 [self setView:container]; | 63 [self setView:container]; |
| 65 | 64 |
| 66 button_.reset([[NSButton alloc] initWithFrame:NSMakeRect( | 65 button_.reset([[NSButton alloc] initWithFrame:NSMakeRect( |
| 67 0, 0, profiles::kAvatarIconWidth, profiles::kAvatarIconHeight)]); | 66 0, 0, profiles::kAvatarIconWidth, profiles::kAvatarIconHeight)]); |
| 68 NSButtonCell* cell = [button_ cell]; | 67 NSButtonCell* cell = [button_ cell]; |
| 69 [button_ setButtonType:NSMomentaryLightButton]; | 68 [button_ setButtonType:NSMomentaryLightButton]; |
| 70 | 69 |
| 71 [button_ setImagePosition:NSImageOnly]; | 70 [button_ setImagePosition:NSImageOnly]; |
| 72 [cell setImageScaling:NSImageScaleProportionallyDown]; | 71 [cell setImageScaling:NSImageScaleProportionallyDown]; |
| 73 [cell setImagePosition:NSImageBelow]; | 72 [cell setImagePosition:NSImageBelow]; |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 233 // needs to be adjusted. Since the fullscreen button is positioned by | 232 // needs to be adjusted. Since the fullscreen button is positioned by |
| 234 // FramedBrowserWindow using private APIs, the easiest way to update the | 233 // FramedBrowserWindow using private APIs, the easiest way to update the |
| 235 // position of the button is through this private API. Resizing the window | 234 // position of the button is through this private API. Resizing the window |
| 236 // also works, but invoking |-display| does not. | 235 // also works, but invoking |-display| does not. |
| 237 NSView* themeFrame = [[[wc window] contentView] superview]; | 236 NSView* themeFrame = [[[wc window] contentView] superview]; |
| 238 if ([themeFrame respondsToSelector:@selector(_tileTitlebarAndRedisplay:)]) | 237 if ([themeFrame respondsToSelector:@selector(_tileTitlebarAndRedisplay:)]) |
| 239 [themeFrame _tileTitlebarAndRedisplay:YES]; | 238 [themeFrame _tileTitlebarAndRedisplay:YES]; |
| 240 } | 239 } |
| 241 | 240 |
| 242 @end | 241 @end |
| OLD | NEW |