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

Unified Diff: chrome/browser/ui/cocoa/location_bar/autocomplete_text_field.mm

Issue 1866523002: [Mac] Update location bar colors when change themes in Material Design. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Clean up for review. Created 4 years, 8 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
Index: chrome/browser/ui/cocoa/location_bar/autocomplete_text_field.mm
diff --git a/chrome/browser/ui/cocoa/location_bar/autocomplete_text_field.mm b/chrome/browser/ui/cocoa/location_bar/autocomplete_text_field.mm
index 46e0d5d69280e46b5f63974a9eeaee85140ff97a..36b9a024ad561c5de3a1eac6b1a9db6e8777a9e6 100644
--- a/chrome/browser/ui/cocoa/location_bar/autocomplete_text_field.mm
+++ b/chrome/browser/ui/cocoa/location_bar/autocomplete_text_field.mm
@@ -12,6 +12,7 @@
#import "chrome/browser/ui/cocoa/location_bar/autocomplete_text_field_cell.h"
#import "chrome/browser/ui/cocoa/location_bar/autocomplete_text_field_editor.h"
#import "chrome/browser/ui/cocoa/location_bar/location_bar_decoration.h"
+#include "chrome/browser/ui/cocoa/omnibox/omnibox_view_mac.h"
#import "chrome/browser/ui/cocoa/toolbar/toolbar_controller.h"
#import "chrome/browser/ui/cocoa/url_drop_target.h"
#import "chrome/browser/ui/cocoa/view_id_util.h"
@@ -376,6 +377,20 @@ const CGFloat kAnimationDuration = 0.2;
[self setNeedsDisplay];
}
+- (void)updateColorsToMatchTheme {
+ if (![[self window] inIncognitoMode]) {
+ return;
+ }
+
+ // Invert the textfield's colors when Material Design and Incognito and not
+ // a custom theme.
+ bool inDarkMode = [[self window] inIncognitoModeWithSystemTheme];
+ [self setBackgroundColor:
+ inDarkMode ? [NSColor colorWithCalibratedWhite:115 / 255. alpha:1]
+ : [NSColor whiteColor]];
+ [self setTextColor:OmniboxViewMac::BaseTextColor(inDarkMode)];
+}
+
- (void)viewDidMoveToWindow {
if (![self window]) {
return;
@@ -387,15 +402,8 @@ const CGFloat kAnimationDuration = 0.2;
BrowserWindowController* browserWindowController =
[BrowserWindowController browserWindowControllerForView:self];
[[browserWindowController toolbarController] locationBarWasAddedToWindow];
- }
- // Invert the textfield's colors when Material Design and Incognito and not
- // a custom theme.
- if (ui::MaterialDesignController::IsModeMaterial() &&
- [[self window] inIncognitoModeWithSystemTheme]) {
- [self setTextColor:[NSColor whiteColor]];
- [self setBackgroundColor:
- [NSColor colorWithCalibratedWhite:115 / 255. alpha:1]];
+ [self updateColorsToMatchTheme];
}
NSNotificationCenter* nc = [NSNotificationCenter defaultCenter];
@@ -528,6 +536,19 @@ const CGFloat kAnimationDuration = 0.2;
return VIEW_ID_OMNIBOX;
}
+// ThemedWindowDrawing implementation.
+
+- (void)windowDidChangeTheme {
+ if (!ui::MaterialDesignController::IsModeMaterial()) {
+ return;
+ }
+
+ [self updateColorsToMatchTheme];
+}
+
+- (void)windowDidChangeActive {
+}
+
@end
namespace autocomplete_text_field {

Powered by Google App Engine
This is Rietveld 408576698