| 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/profiles/profiles_state.h" | 9 #include "chrome/browser/profiles/profiles_state.h" |
| 10 #include "chrome/browser/themes/theme_service.h" | 10 #include "chrome/browser/themes/theme_service.h" |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 113 - (void)dealloc; | 113 - (void)dealloc; |
| 114 - (void)themeDidChangeNotification:(NSNotification*)aNotification; | 114 - (void)themeDidChangeNotification:(NSNotification*)aNotification; |
| 115 @end | 115 @end |
| 116 | 116 |
| 117 @implementation AvatarButtonController | 117 @implementation AvatarButtonController |
| 118 | 118 |
| 119 - (id)initWithBrowser:(Browser*)browser { | 119 - (id)initWithBrowser:(Browser*)browser { |
| 120 if ((self = [super initWithBrowser:browser])) { | 120 if ((self = [super initWithBrowser:browser])) { |
| 121 ThemeService* themeService = | 121 ThemeService* themeService = |
| 122 ThemeServiceFactory::GetForProfile(browser->profile()); | 122 ThemeServiceFactory::GetForProfile(browser->profile()); |
| 123 isThemedWindow_ = !themeService->UsingNativeTheme(); | 123 isThemedWindow_ = !themeService->UsingSystemTheme(); |
| 124 | 124 |
| 125 HoverImageButton* hoverButton = | 125 HoverImageButton* hoverButton = |
| 126 [[HoverImageButton alloc] initWithFrame:NSZeroRect]; | 126 [[HoverImageButton alloc] initWithFrame:NSZeroRect]; |
| 127 [hoverButton setDefaultImage:GetImageFromResourceID( | 127 [hoverButton setDefaultImage:GetImageFromResourceID( |
| 128 IDR_AVATAR_MAC_BUTTON_DROPARROW)]; | 128 IDR_AVATAR_MAC_BUTTON_DROPARROW)]; |
| 129 [hoverButton setHoverImage:GetImageFromResourceID( | 129 [hoverButton setHoverImage:GetImageFromResourceID( |
| 130 IDR_AVATAR_MAC_BUTTON_DROPARROW_HOVER)]; | 130 IDR_AVATAR_MAC_BUTTON_DROPARROW_HOVER)]; |
| 131 [hoverButton setPressedImage:GetImageFromResourceID( | 131 [hoverButton setPressedImage:GetImageFromResourceID( |
| 132 IDR_AVATAR_MAC_BUTTON_DROPARROW_PRESSED)]; | 132 IDR_AVATAR_MAC_BUTTON_DROPARROW_PRESSED)]; |
| 133 | 133 |
| (...skipping 28 matching lines...) Expand all Loading... |
| 162 | 162 |
| 163 - (void)dealloc { | 163 - (void)dealloc { |
| 164 [[NSNotificationCenter defaultCenter] removeObserver:self]; | 164 [[NSNotificationCenter defaultCenter] removeObserver:self]; |
| 165 [super dealloc]; | 165 [super dealloc]; |
| 166 } | 166 } |
| 167 | 167 |
| 168 - (void)themeDidChangeNotification:(NSNotification*)aNotification { | 168 - (void)themeDidChangeNotification:(NSNotification*)aNotification { |
| 169 // Redraw the button if the window has switched between themed and native. | 169 // Redraw the button if the window has switched between themed and native. |
| 170 ThemeService* themeService = | 170 ThemeService* themeService = |
| 171 ThemeServiceFactory::GetForProfile(browser_->profile()); | 171 ThemeServiceFactory::GetForProfile(browser_->profile()); |
| 172 BOOL updatedIsThemedWindow = !themeService->UsingNativeTheme(); | 172 BOOL updatedIsThemedWindow = !themeService->UsingSystemTheme(); |
| 173 if (isThemedWindow_ != updatedIsThemedWindow) { | 173 if (isThemedWindow_ != updatedIsThemedWindow) { |
| 174 isThemedWindow_ = updatedIsThemedWindow; | 174 isThemedWindow_ = updatedIsThemedWindow; |
| 175 [[button_ cell] setIsThemedWindow:isThemedWindow_]; | 175 [[button_ cell] setIsThemedWindow:isThemedWindow_]; |
| 176 [self updateAvatarButtonAndLayoutParent:YES]; | 176 [self updateAvatarButtonAndLayoutParent:YES]; |
| 177 } | 177 } |
| 178 } | 178 } |
| 179 | 179 |
| 180 - (void)updateAvatarButtonAndLayoutParent:(BOOL)layoutParent { | 180 - (void)updateAvatarButtonAndLayoutParent:(BOOL)layoutParent { |
| 181 // The button text has a black foreground and a white drop shadow for regular | 181 // The button text has a black foreground and a white drop shadow for regular |
| 182 // windows, and a light text with a dark drop shadow for guest windows | 182 // windows, and a light text with a dark drop shadow for guest windows |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 222 if (layoutParent) { | 222 if (layoutParent) { |
| 223 // Because the width of the button might have changed, the parent browser | 223 // Because the width of the button might have changed, the parent browser |
| 224 // frame needs to recalculate the button bounds and redraw it. | 224 // frame needs to recalculate the button bounds and redraw it. |
| 225 [[BrowserWindowController | 225 [[BrowserWindowController |
| 226 browserWindowControllerForWindow:browser_->window()->GetNativeWindow()] | 226 browserWindowControllerForWindow:browser_->window()->GetNativeWindow()] |
| 227 layoutSubviews]; | 227 layoutSubviews]; |
| 228 } | 228 } |
| 229 } | 229 } |
| 230 | 230 |
| 231 @end | 231 @end |
| OLD | NEW |