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

Side by Side Diff: chrome/browser/ui/cocoa/omnibox/omnibox_view_mac.mm

Issue 1718563002: Convert location bar decorations to Material Design (Mac). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@md_toolbar
Patch Set: Fix issue from browser test. 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/ui/cocoa/omnibox/omnibox_view_mac.h" 5 #include "chrome/browser/ui/cocoa/omnibox/omnibox_view_mac.h"
6 6
7 #include <Carbon/Carbon.h> // kVK_Return 7 #include <Carbon/Carbon.h> // kVK_Return
8 8
9 #include "base/mac/foundation_util.h" 9 #include "base/mac/foundation_util.h"
10 #include "base/metrics/histogram.h" 10 #include "base/metrics/histogram.h"
(...skipping 13 matching lines...) Expand all
24 #include "chrome/grit/generated_resources.h" 24 #include "chrome/grit/generated_resources.h"
25 #include "components/omnibox/browser/autocomplete_input.h" 25 #include "components/omnibox/browser/autocomplete_input.h"
26 #include "components/omnibox/browser/autocomplete_match.h" 26 #include "components/omnibox/browser/autocomplete_match.h"
27 #include "components/omnibox/browser/omnibox_edit_controller.h" 27 #include "components/omnibox/browser/omnibox_edit_controller.h"
28 #include "components/omnibox/browser/omnibox_field_trial.h" 28 #include "components/omnibox/browser/omnibox_field_trial.h"
29 #include "components/omnibox/browser/omnibox_popup_model.h" 29 #include "components/omnibox/browser/omnibox_popup_model.h"
30 #include "components/security_state/security_state_model.h" 30 #include "components/security_state/security_state_model.h"
31 #include "components/toolbar/toolbar_model.h" 31 #include "components/toolbar/toolbar_model.h"
32 #include "content/public/browser/web_contents.h" 32 #include "content/public/browser/web_contents.h"
33 #include "extensions/common/constants.h" 33 #include "extensions/common/constants.h"
34 #import "skia/ext/skia_utils_mac.h"
34 #import "third_party/mozilla/NSPasteboard+Utils.h" 35 #import "third_party/mozilla/NSPasteboard+Utils.h"
35 #include "ui/base/clipboard/clipboard.h" 36 #include "ui/base/clipboard/clipboard.h"
36 #import "ui/base/cocoa/cocoa_base_utils.h" 37 #import "ui/base/cocoa/cocoa_base_utils.h"
37 #include "ui/base/material_design/material_design_controller.h" 38 #include "ui/base/material_design/material_design_controller.h"
38 #include "ui/base/resource/resource_bundle.h" 39 #include "ui/base/resource/resource_bundle.h"
40 #include "ui/gfx/color_palette.h"
39 #include "ui/gfx/font.h" 41 #include "ui/gfx/font.h"
40 #include "ui/gfx/font_list.h" 42 #include "ui/gfx/font_list.h"
41 #include "ui/gfx/geometry/rect.h" 43 #include "ui/gfx/geometry/rect.h"
42 44
43 using content::WebContents; 45 using content::WebContents;
44 46
45 // Focus-handling between |field_| and model() is a bit subtle. 47 // Focus-handling between |field_| and model() is a bit subtle.
46 // Other platforms detect change of focus, which is inconvenient 48 // Other platforms detect change of focus, which is inconvenient
47 // without subclassing NSTextField (even with a subclass, the use of a 49 // without subclassing NSTextField (even with a subclass, the use of a
48 // field editor may complicate things). 50 // field editor may complicate things).
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 blue:static_cast<float>(bb)/255.0 83 blue:static_cast<float>(bb)/255.0
82 alpha:1.0]; 84 alpha:1.0];
83 } 85 }
84 86
85 NSColor* HostTextColor(bool inDarkMode) { 87 NSColor* HostTextColor(bool inDarkMode) {
86 if (!ui::MaterialDesignController::IsModeMaterial()) { 88 if (!ui::MaterialDesignController::IsModeMaterial()) {
87 return [NSColor blackColor]; 89 return [NSColor blackColor];
88 } 90 }
89 return inDarkMode ? [NSColor whiteColor] : [NSColor blackColor]; 91 return inDarkMode ? [NSColor whiteColor] : [NSColor blackColor];
90 } 92 }
91 NSColor* BaseTextColor(bool inDarkMode) {
92 if (!ui::MaterialDesignController::IsModeMaterial()) {
93 return [NSColor darkGrayColor];
94 }
95 return inDarkMode ? [NSColor colorWithCalibratedWhite:1 alpha:0.5] :
96 [NSColor colorWithCalibratedWhite:0 alpha:0.5];
97 }
98 NSColor* SecureSchemeColor(bool inDarkMode) { 93 NSColor* SecureSchemeColor(bool inDarkMode) {
99 if (!ui::MaterialDesignController::IsModeMaterial()) { 94 if (!ui::MaterialDesignController::IsModeMaterial()) {
100 return ColorWithRGBBytes(0x07, 0x95, 0x00); 95 return ColorWithRGBBytes(0x07, 0x95, 0x00);
101 } 96 }
102 return inDarkMode ? [NSColor colorWithCalibratedWhite:1 alpha:0.5] : 97 return inDarkMode ? [NSColor colorWithCalibratedWhite:1 alpha:0.5] :
103 ColorWithRGBBytes(0x0B, 0x80, 0x43); 98 skia::SkColorToCalibratedNSColor(gfx::kGoogleGreen700);
104 } 99 }
105 NSColor* SecurityWarningSchemeColor(bool inDarkMode) { 100 NSColor* SecurityWarningSchemeColor(bool inDarkMode) {
106 return inDarkMode ? [NSColor colorWithCalibratedWhite:1 alpha:0.5] : 101 return inDarkMode ? [NSColor colorWithCalibratedWhite:1 alpha:0.5] :
107 ColorWithRGBBytes(0xF0, 0x93, 0x00); 102 skia::SkColorToCalibratedNSColor(gfx::kGoogleYellow700);
108 } 103 }
109 NSColor* SecurityErrorSchemeColor(bool inDarkMode) { 104 NSColor* SecurityErrorSchemeColor(bool inDarkMode) {
110 if (!ui::MaterialDesignController::IsModeMaterial()) { 105 if (!ui::MaterialDesignController::IsModeMaterial()) {
111 return ColorWithRGBBytes(0xa2, 0x00, 0x00); 106 return ColorWithRGBBytes(0xa2, 0x00, 0x00);
112 } 107 }
113 return inDarkMode ? [NSColor colorWithCalibratedWhite:1 alpha:0.5] : 108 return inDarkMode ? [NSColor colorWithCalibratedWhite:1 alpha:0.5] :
114 ColorWithRGBBytes(0xC5, 0x39, 0x29); 109 skia::SkColorToCalibratedNSColor(gfx::kGoogleRed700);
115 } 110 }
116 111
117 const char kOmniboxViewMacStateKey[] = "OmniboxViewMacState"; 112 const char kOmniboxViewMacStateKey[] = "OmniboxViewMacState";
118 113
119 // Store's the model and view state across tab switches. 114 // Store's the model and view state across tab switches.
120 struct OmniboxViewMacState : public base::SupportsUserData::Data { 115 struct OmniboxViewMacState : public base::SupportsUserData::Data {
121 OmniboxViewMacState(const OmniboxEditModel::State model_state, 116 OmniboxViewMacState(const OmniboxEditModel::State model_state,
122 const bool has_focus, 117 const bool has_focus,
123 const NSRange& selection) 118 const NSRange& selection)
124 : model_state(model_state), 119 : model_state(model_state),
(...skipping 30 matching lines...) Expand all
155 NSImage* OmniboxViewMac::ImageForResource(int resource_id) { 150 NSImage* OmniboxViewMac::ImageForResource(int resource_id) {
156 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); 151 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
157 return rb.GetNativeImageNamed(resource_id).ToNSImage(); 152 return rb.GetNativeImageNamed(resource_id).ToNSImage();
158 } 153 }
159 154
160 // static 155 // static
161 NSColor* OmniboxViewMac::SuggestTextColor() { 156 NSColor* OmniboxViewMac::SuggestTextColor() {
162 return [NSColor colorWithCalibratedWhite:0.0 alpha:0.5]; 157 return [NSColor colorWithCalibratedWhite:0.0 alpha:0.5];
163 } 158 }
164 159
160 // static
161 NSColor* OmniboxViewMac::BaseTextColor(bool inDarkMode) {
162 if (!ui::MaterialDesignController::IsModeMaterial()) {
163 return [NSColor darkGrayColor];
164 }
165 return inDarkMode ? [NSColor colorWithCalibratedWhite:1 alpha:0.5]
166 : [NSColor colorWithCalibratedWhite:0 alpha:0.5];
167 }
168
165 OmniboxViewMac::OmniboxViewMac(OmniboxEditController* controller, 169 OmniboxViewMac::OmniboxViewMac(OmniboxEditController* controller,
166 Profile* profile, 170 Profile* profile,
167 CommandUpdater* command_updater, 171 CommandUpdater* command_updater,
168 AutocompleteTextField* field) 172 AutocompleteTextField* field)
169 : OmniboxView( 173 : OmniboxView(
170 controller, 174 controller,
171 make_scoped_ptr(new ChromeOmniboxClient(controller, profile))), 175 make_scoped_ptr(new ChromeOmniboxClient(controller, profile))),
172 profile_(profile), 176 profile_(profile),
173 popup_view_(new OmniboxPopupViewMac(this, model(), field)), 177 popup_view_(new OmniboxPopupViewMac(this, model(), field)),
174 field_(field), 178 field_(field),
(...skipping 922 matching lines...) Expand 10 before | Expand all | Expand 10 after
1097 1101
1098 NSUInteger OmniboxViewMac::GetTextLength() const { 1102 NSUInteger OmniboxViewMac::GetTextLength() const {
1099 return [field_ currentEditor] ? [[[field_ currentEditor] string] length] : 1103 return [field_ currentEditor] ? [[[field_ currentEditor] string] length] :
1100 [[field_ stringValue] length]; 1104 [[field_ stringValue] length];
1101 } 1105 }
1102 1106
1103 bool OmniboxViewMac::IsCaretAtEnd() const { 1107 bool OmniboxViewMac::IsCaretAtEnd() const {
1104 const NSRange selection = GetSelectedRange(); 1108 const NSRange selection = GetSelectedRange();
1105 return NSMaxRange(selection) == GetTextLength(); 1109 return NSMaxRange(selection) == GetTextLength();
1106 } 1110 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/cocoa/omnibox/omnibox_view_mac.h ('k') | chrome/browser/ui/cocoa/toolbar/toolbar_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698