Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(58)

Side by Side Diff: chrome/browser/ui/cocoa/profiles/avatar_button_controller.mm

Issue 2369663002: [Material][Mac] Update User Account Button (Closed)
Patch Set: Added back the MD checks and non MD stuff Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #include "chrome/browser/ui/cocoa/l10n_util.h"
20 #import "chrome/browser/ui/cocoa/profiles/avatar_button.h" 20 #import "chrome/browser/ui/cocoa/profiles/avatar_button.h"
21 #include "chrome/grit/generated_resources.h" 21 #include "chrome/grit/generated_resources.h"
22 #import "chrome/browser/themes/theme_properties.h"
22 #include "chrome/grit/theme_resources.h" 23 #include "chrome/grit/theme_resources.h"
23 #include "components/signin/core/common/profile_management_switches.h" 24 #include "components/signin/core/common/profile_management_switches.h"
24 #include "skia/ext/skia_utils_mac.h" 25 #include "skia/ext/skia_utils_mac.h"
25 #import "ui/base/cocoa/appkit_utils.h" 26 #import "ui/base/cocoa/appkit_utils.h"
26 #include "ui/base/l10n/l10n_util_mac.h" 27 #include "ui/base/l10n/l10n_util_mac.h"
27 #include "ui/base/material_design/material_design_controller.h" 28 #include "ui/base/material_design/material_design_controller.h"
28 #include "ui/base/nine_image_painter_factory.h" 29 #include "ui/base/nine_image_painter_factory.h"
29 #include "ui/base/resource/resource_bundle.h" 30 #include "ui/base/resource/resource_bundle.h"
30 #include "ui/gfx/color_palette.h" 31 #include "ui/gfx/color_palette.h"
31 #include "ui/gfx/image/image_skia_operations.h" 32 #include "ui/gfx/image/image_skia_operations.h"
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 } 245 }
245 return self; 246 return self;
246 } 247 }
247 248
248 - (void)dealloc { 249 - (void)dealloc {
249 [[NSNotificationCenter defaultCenter] removeObserver:self]; 250 [[NSNotificationCenter defaultCenter] removeObserver:self];
250 [super dealloc]; 251 [super dealloc];
251 } 252 }
252 253
253 - (void)themeDidChangeNotification:(NSNotification*)aNotification { 254 - (void)themeDidChangeNotification:(NSNotification*)aNotification {
254 // Redraw the button if the window has switched between themed and native. 255 // Redraw the button if the window has switched between themed and native
256 // or if we're in MD design.
255 ThemeService* themeService = 257 ThemeService* themeService =
256 ThemeServiceFactory::GetForProfile(browser_->profile()); 258 ThemeServiceFactory::GetForProfile(browser_->profile());
257 BOOL updatedIsThemedWindow = !themeService->UsingSystemTheme(); 259 BOOL updatedIsThemedWindow = !themeService->UsingSystemTheme();
258 if (isThemedWindow_ != updatedIsThemedWindow) { 260 if (isThemedWindow_ != updatedIsThemedWindow ||
261 ui::MaterialDesignController::IsModeMaterial()) {
259 isThemedWindow_ = updatedIsThemedWindow; 262 isThemedWindow_ = updatedIsThemedWindow;
260 [[button_ cell] setIsThemedWindow:isThemedWindow_]; 263 [[button_ cell] setIsThemedWindow:isThemedWindow_];
261 [self updateAvatarButtonAndLayoutParent:YES]; 264 [self updateAvatarButtonAndLayoutParent:YES];
262 } 265 }
263 } 266 }
264 267
265 - (void)updateAvatarButtonAndLayoutParent:(BOOL)layoutParent { 268 - (void)updateAvatarButtonAndLayoutParent:(BOOL)layoutParent {
266 // The button text has a black foreground and a white drop shadow for regular 269 // The button text has a black foreground and a white drop shadow for regular
267 // windows, and a light text with a dark drop shadow for guest windows 270 // windows, and a light text with a dark drop shadow for guest windows
268 // which are themed with a dark background. If we're using MD, then there 271 // which are themed with a dark background. If we're using MD, then there
269 // should be no drop shadows. 272 // should be no drop shadows.
270 BOOL isMaterial = ui::MaterialDesignController::IsModeMaterial(); 273 BOOL isMaterial = ui::MaterialDesignController::IsModeMaterial();
271 274
272 NSColor* foregroundColor; 275 NSColor* foregroundColor;
273 if (browser_->profile()->IsGuestSession() && isMaterial) 276 if (isMaterial) {
274 foregroundColor = [NSColor colorWithCalibratedWhite:1.0 alpha:0.9]; 277 const ui::ThemeProvider* theme =
275 else if (!isThemedWindow_) 278 &ThemeService::GetThemeProviderForProfile(browser_->profile());
276 foregroundColor = [NSColor blackColor]; 279 foregroundColor = theme ? theme->GetNSColor(ThemeProperties::COLOR_TAB_TEXT)
277 else 280 : [NSColor blackColor];
278 foregroundColor = [NSColor blackColor]; 281 } else {
282 foregroundColor = browser_->profile()->IsGuestSession()
283 ? [NSColor colorWithCalibratedWhite:1.0 alpha:0.9]
284 : [NSColor blackColor];
285 }
279 286
280 ProfileAttributesStorage& storage = 287 ProfileAttributesStorage& storage =
281 g_browser_process->profile_manager()->GetProfileAttributesStorage(); 288 g_browser_process->profile_manager()->GetProfileAttributesStorage();
282 // If there is a single local profile, then use the generic avatar button 289 // If there is a single local profile, then use the generic avatar button
283 // instead of the profile name. Never use the generic button if the active 290 // instead of the profile name. Never use the generic button if the active
284 // profile is Guest. 291 // profile is Guest.
285 bool useGenericButton = 292 bool useGenericButton =
286 !browser_->profile()->IsGuestSession() && 293 !browser_->profile()->IsGuestSession() &&
287 storage.GetNumberOfProfiles() == 1 && 294 storage.GetNumberOfProfiles() == 1 &&
288 !storage.GetAllProfilesAttributes().front()->IsAuthenticated(); 295 !storage.GetAllProfilesAttributes().front()->IsAuthenticated();
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
382 layoutSubviews]; 389 layoutSubviews];
383 } 390 }
384 } 391 }
385 392
386 - (void)setErrorStatus:(BOOL)hasError { 393 - (void)setErrorStatus:(BOOL)hasError {
387 hasError_ = hasError; 394 hasError_ = hasError;
388 [self updateAvatarButtonAndLayoutParent:YES]; 395 [self updateAvatarButtonAndLayoutParent:YES];
389 } 396 }
390 397
391 @end 398 @end
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698