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

Unified Diff: chrome/browser/ui/cocoa/location_bar/autocomplete_text_field.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
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 7f2938cf2eb04ee8b69604e638ba5be926b660fb..5087453f323047a4b245edf5d0713aa1838bd88e 100644
--- a/chrome/browser/ui/cocoa/location_bar/autocomplete_text_field.mm
+++ b/chrome/browser/ui/cocoa/location_bar/autocomplete_text_field.mm
@@ -7,6 +7,7 @@
#include "base/logging.h"
#import "base/mac/mac_util.h"
#import "base/mac/sdk_forward_declarations.h"
+#include "chrome/browser/themes/theme_service.h"
#import "chrome/browser/ui/cocoa/browser_window_controller.h"
#import "chrome/browser/ui/cocoa/location_bar/autocomplete_text_field_cell.h"
#import "chrome/browser/ui/cocoa/location_bar/autocomplete_text_field_editor.h"
@@ -14,6 +15,7 @@
#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"
+#include "ui/base/material_design/material_design_controller.h"
#include "ui/gfx/scoped_ns_graphics_context_save_gstate_mac.h"
namespace {
@@ -363,23 +365,34 @@ const CGFloat kAnimationDuration = 0.2;
}
- (void)viewDidMoveToWindow {
- if ([self window]) {
- NSNotificationCenter* nc = [NSNotificationCenter defaultCenter];
- [nc addObserver:self
- selector:@selector(windowDidResignKey:)
- name:NSWindowDidResignKeyNotification
- object:[self window]];
- [nc addObserver:self
- selector:@selector(windowDidResize:)
- name:NSWindowDidResizeNotification
- object:[self window]];
- // Only register for drops if not in a popup window. Lazily create the
- // drop handler when the type of window is known.
- BrowserWindowController* windowController =
- [BrowserWindowController browserWindowControllerForView:self];
- if ([windowController isTabbedWindow])
- dropHandler_.reset([[URLDropTargetHandler alloc] initWithView:self]);
+ if (![self window]) {
+ return;
+ }
+
+ // 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]];
}
+
+ NSNotificationCenter* nc = [NSNotificationCenter defaultCenter];
+ [nc addObserver:self
+ selector:@selector(windowDidResignKey:)
+ name:NSWindowDidResignKeyNotification
+ object:[self window]];
+ [nc addObserver:self
+ selector:@selector(windowDidResize:)
+ name:NSWindowDidResizeNotification
+ object:[self window]];
+ // Only register for drops if not in a popup window. Lazily create the
+ // drop handler when the type of window is known.
+ BrowserWindowController* windowController =
+ [BrowserWindowController browserWindowControllerForView:self];
+ if ([windowController isTabbedWindow])
+ dropHandler_.reset([[URLDropTargetHandler alloc] initWithView:self]);
}
// NSTextField becomes first responder by installing a "field editor"
« no previous file with comments | « chrome/browser/ui/cocoa/chrome_browser_window.mm ('k') | chrome/browser/ui/cocoa/location_bar/autocomplete_text_field_cell.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698