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

Unified 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 side-by-side diff with in-line comments
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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/cocoa/chrome_browser_window.mm
diff --git a/chrome/browser/ui/cocoa/chrome_browser_window.mm b/chrome/browser/ui/cocoa/chrome_browser_window.mm
index a16401952aed3928ff0c96510b5eec449ac1c579..4f12cda64c98aba999a2426561aefb03589afbcf 100644
--- a/chrome/browser/ui/cocoa/chrome_browser_window.mm
+++ b/chrome/browser/ui/cocoa/chrome_browser_window.mm
@@ -5,6 +5,7 @@
#import "chrome/browser/ui/cocoa/chrome_browser_window.h"
#include "base/logging.h"
+#include "chrome/browser/themes/theme_properties.h"
#import "chrome/browser/ui/cocoa/themed_window.h"
#include "ui/base/theme_provider.h"
@@ -31,4 +32,52 @@
return [delegate themeImagePositionForAlignment:alignment];
}
+- (BOOL)inIncognitoMode {
+ const ui::ThemeProvider* themeProvider = [self themeProvider];
+ return themeProvider && themeProvider->InIncognitoMode();
+}
+
+- (BOOL)inIncognitoModeWithSystemTheme {
+ const ui::ThemeProvider* themeProvider = [self themeProvider];
+ return themeProvider && themeProvider->InIncognitoMode() &&
+ themeProvider->UsingSystemTheme();
+}
+
+- (BOOL)hasDarkTheme {
+ // If a system theme, return YES if Incognito.
+ const ui::ThemeProvider* themeProvider = [self themeProvider];
+ if (!themeProvider) {
+ return NO;
+ } else if (themeProvider->UsingSystemTheme()) {
+ return themeProvider->InIncognitoMode();
+ }
+
+ // If the custom theme has a custom toolbar color, return YES if it's
+ // dark.
+ if (themeProvider->HasCustomColor(ThemeProperties::COLOR_TOOLBAR)) {
+ NSColor* theColor =
+ themeProvider->GetNSColor(ThemeProperties::COLOR_TOOLBAR);
+ theColor =
+ [theColor colorUsingColorSpaceName:NSCalibratedWhiteColorSpace];
+ if (theColor != nil) {
+ // The white componement cutoff is an empirical value.
+ return [theColor whiteComponent] < 0.7;
+ }
+ }
+
+ // If the custom theme has a custom tab text color, assume that a light
+ // color means a dark tab background image, and therefore a dark theme.
+ if (themeProvider->HasCustomColor(ThemeProperties::COLOR_TAB_TEXT)) {
+ NSColor* theColor =
+ themeProvider->GetNSColor(ThemeProperties::COLOR_TAB_TEXT);
+ theColor =
+ [theColor colorUsingColorSpaceName:NSCalibratedWhiteColorSpace];
+ if (theColor != nil) {
+ return [theColor whiteComponent] >= 0.7;
+ }
+ }
+
+ return NO;
+}
+
@end
« 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