| Index: chrome/browser/ui/cocoa/location_bar/autocomplete_text_field_editor.mm
|
| diff --git a/chrome/browser/ui/cocoa/location_bar/autocomplete_text_field_editor.mm b/chrome/browser/ui/cocoa/location_bar/autocomplete_text_field_editor.mm
|
| index 86303014acea83a5152c4932743979a40ed20563..ea6c9090e213bd016cf868434c9b9544cd772db7 100644
|
| --- a/chrome/browser/ui/cocoa/location_bar/autocomplete_text_field_editor.mm
|
| +++ b/chrome/browser/ui/cocoa/location_bar/autocomplete_text_field_editor.mm
|
| @@ -69,29 +69,40 @@ BOOL ThePasteboardIsTooDamnBig() {
|
| return self;
|
| }
|
|
|
| -- (void)viewDidMoveToWindow {
|
| - // Only care about landing in a window when in Material Design mode.
|
| - if (![self window] || !ui::MaterialDesignController::IsModeMaterial()) {
|
| - return;
|
| - }
|
| -
|
| - // Only care about Incognito mode with a non-custom theme.
|
| - if (![[self window] inIncognitoModeWithSystemTheme]) {
|
| +- (void)updateColorsToMatchTheme {
|
| + if (![[self window] inIncognitoMode]) {
|
| return;
|
| }
|
|
|
| + bool inDarkMode = [[self window] inIncognitoModeWithSystemTheme];
|
| // Draw a light insertion point for MD Incognito.
|
| - [self setInsertionPointColor:
|
| - [NSColor colorWithCalibratedWhite:1 alpha:0.75]];
|
| - // In MD Incognito the text is light gray against a dark background. When
|
| - // selected, the light gray text against the selection color is illegible.
|
| - // Rather than tweak or change the selection color, make the text black when
|
| - // selected.
|
| + NSColor* insertionPointColor =
|
| + inDarkMode ? [NSColor colorWithCalibratedWhite:1 alpha:0.75]
|
| + : [NSColor blackColor];
|
| + [self setInsertionPointColor:insertionPointColor];
|
| +
|
| NSColor* textSelectionColor = [NSColor selectedTextBackgroundColor];
|
| - [self setSelectedTextAttributes:@{
|
| - NSForegroundColorAttributeName : [NSColor blackColor],
|
| - NSBackgroundColorAttributeName : textSelectionColor
|
| - }];
|
| + if (inDarkMode) {
|
| + // In MD Incognito the text is light gray against a dark background. When
|
| + // selected, the light gray text against the selection color is illegible.
|
| + // Rather than tweak or change the selection color, make the text black when
|
| + // selected.
|
| + [self setSelectedTextAttributes:@{
|
| + NSForegroundColorAttributeName : [NSColor blackColor],
|
| + NSBackgroundColorAttributeName : textSelectionColor
|
| + }];
|
| + } else {
|
| + [self setSelectedTextAttributes:@{
|
| + NSBackgroundColorAttributeName : textSelectionColor
|
| + }];
|
| + }
|
| +}
|
| +
|
| +- (void)viewDidMoveToWindow {
|
| + // Only care about landing in a window when in Material Design mode.
|
| + if ([self window] && ui::MaterialDesignController::IsModeMaterial()) {
|
| + [self updateColorsToMatchTheme];
|
| + }
|
| }
|
|
|
| // If the entire field is selected, drag the same data as would be
|
| @@ -570,4 +581,16 @@ BOOL ThePasteboardIsTooDamnBig() {
|
| observer->OnDidDrawRect();
|
| }
|
|
|
| +// ThemedWindowDrawing implementation.
|
| +
|
| +- (void)windowDidChangeTheme {
|
| + if (!ui::MaterialDesignController::IsModeMaterial()) {
|
| + return;
|
| + }
|
| + [self updateColorsToMatchTheme];
|
| +}
|
| +
|
| +- (void)windowDidChangeActive {
|
| +}
|
| +
|
| @end
|
|
|