| 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
|
|
|