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

Side by Side Diff: chrome/browser/ui/cocoa/chrome_browser_window.mm

Issue 1680773006: Implement Material Design for Mac toolbar. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@md_master
Patch Set: Change button hover and pressed styles. Created 4 years, 9 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 | chrome/browser/ui/cocoa/location_bar/autocomplete_text_field.mm » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/chrome_browser_window.h" 5 #import "chrome/browser/ui/cocoa/chrome_browser_window.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "chrome/browser/themes/theme_properties.h"
8 #import "chrome/browser/ui/cocoa/themed_window.h" 9 #import "chrome/browser/ui/cocoa/themed_window.h"
9 #include "ui/base/theme_provider.h" 10 #include "ui/base/theme_provider.h"
10 11
11 @implementation ChromeBrowserWindow 12 @implementation ChromeBrowserWindow
12 13
13 - (const ui::ThemeProvider*)themeProvider { 14 - (const ui::ThemeProvider*)themeProvider {
14 id delegate = [self delegate]; 15 id delegate = [self delegate];
15 if (![delegate respondsToSelector:@selector(themeProvider)]) 16 if (![delegate respondsToSelector:@selector(themeProvider)])
16 return NULL; 17 return NULL;
17 return [delegate themeProvider]; 18 return [delegate themeProvider];
18 } 19 }
19 20
20 - (ThemedWindowStyle)themedWindowStyle { 21 - (ThemedWindowStyle)themedWindowStyle {
21 id delegate = [self delegate]; 22 id delegate = [self delegate];
22 if (![delegate respondsToSelector:@selector(themedWindowStyle)]) 23 if (![delegate respondsToSelector:@selector(themedWindowStyle)])
23 return THEMED_NORMAL; 24 return THEMED_NORMAL;
24 return [delegate themedWindowStyle]; 25 return [delegate themedWindowStyle];
25 } 26 }
26 27
27 - (NSPoint)themeImagePositionForAlignment:(ThemeImageAlignment)alignment { 28 - (NSPoint)themeImagePositionForAlignment:(ThemeImageAlignment)alignment {
28 id delegate = [self delegate]; 29 id delegate = [self delegate];
29 if (![delegate respondsToSelector:@selector(themeImagePositionForAlignment:)]) 30 if (![delegate respondsToSelector:@selector(themeImagePositionForAlignment:)])
30 return NSZeroPoint; 31 return NSZeroPoint;
31 return [delegate themeImagePositionForAlignment:alignment]; 32 return [delegate themeImagePositionForAlignment:alignment];
32 } 33 }
33 34
35 - (BOOL)inIncognitoMode {
36 const ui::ThemeProvider* themeProvider = [self themeProvider];
37 return themeProvider && themeProvider->InIncognitoMode();
38 }
39
40 - (BOOL)inIncognitoModeWithSystemTheme {
41 const ui::ThemeProvider* themeProvider = [self themeProvider];
42 return themeProvider && themeProvider->InIncognitoMode() &&
43 themeProvider->UsingSystemTheme();
44 }
45
46 - (BOOL)hasDarkTheme {
47 // If a system theme, return YES if Incognito.
48 const ui::ThemeProvider* themeProvider = [self themeProvider];
49 if (!themeProvider) {
50 return NO;
51 } else if (themeProvider->UsingSystemTheme()) {
52 return themeProvider->InIncognitoMode();
53 }
54
55 // If the custom theme has a custom toolbar color, return YES if it's
56 // dark.
57 if (themeProvider->HasCustomColor(ThemeProperties::COLOR_TOOLBAR)) {
58 NSColor* theColor =
59 themeProvider->GetNSColor(ThemeProperties::COLOR_TOOLBAR);
60 theColor =
61 [theColor colorUsingColorSpaceName:NSCalibratedWhiteColorSpace];
62 if (theColor != nil) {
63 // The white componement cutoff is an empirical value.
64 return [theColor whiteComponent] < 0.7;
65 }
66 }
67
68 // If the custom theme has a custom tab text color, assume that a light
69 // color means a dark tab background image, and therefore a dark theme.
70 if (themeProvider->HasCustomColor(ThemeProperties::COLOR_TAB_TEXT)) {
71 NSColor* theColor =
72 themeProvider->GetNSColor(ThemeProperties::COLOR_TAB_TEXT);
73 theColor =
74 [theColor colorUsingColorSpaceName:NSCalibratedWhiteColorSpace];
75 if (theColor != nil) {
76 return [theColor whiteComponent] >= 0.7;
77 }
78 }
79
80 return NO;
81 }
82
34 @end 83 @end
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/ui/cocoa/location_bar/autocomplete_text_field.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698