| OLD | NEW |
| 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/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 152 NSImage* OmniboxViewMac::ImageForResource(int resource_id) { | 152 NSImage* OmniboxViewMac::ImageForResource(int resource_id) { |
| 153 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); | 153 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); |
| 154 return rb.GetNativeImageNamed(resource_id).ToNSImage(); | 154 return rb.GetNativeImageNamed(resource_id).ToNSImage(); |
| 155 } | 155 } |
| 156 | 156 |
| 157 // static | 157 // static |
| 158 NSColor* OmniboxViewMac::SuggestTextColor() { | 158 NSColor* OmniboxViewMac::SuggestTextColor() { |
| 159 return [NSColor colorWithCalibratedWhite:0.0 alpha:0.5]; | 159 return [NSColor colorWithCalibratedWhite:0.0 alpha:0.5]; |
| 160 } | 160 } |
| 161 | 161 |
| 162 //static |
| 163 SkColor OmniboxViewMac::BaseTextColorSkia(bool in_dark_mode) { |
| 164 return in_dark_mode ? SkColorSetA(SK_ColorWHITE, 0x7F) |
| 165 : SkColorSetA(SK_ColorBLACK, 0x7F); |
| 166 } |
| 167 |
| 162 // static | 168 // static |
| 163 NSColor* OmniboxViewMac::BaseTextColor(bool inDarkMode) { | 169 NSColor* OmniboxViewMac::BaseTextColor(bool in_dark_mode) { |
| 164 if (!ui::MaterialDesignController::IsModeMaterial()) { | 170 if (!ui::MaterialDesignController::IsModeMaterial()) { |
| 165 return [NSColor darkGrayColor]; | 171 return [NSColor darkGrayColor]; |
| 166 } | 172 } |
| 167 return inDarkMode ? [NSColor colorWithCalibratedWhite:1 alpha:0.5] | 173 return skia::SkColorToCalibratedNSColor(BaseTextColorSkia(in_dark_mode)); |
| 168 : [NSColor colorWithCalibratedWhite:0 alpha:0.5]; | |
| 169 } | 174 } |
| 170 | 175 |
| 171 OmniboxViewMac::OmniboxViewMac(OmniboxEditController* controller, | 176 OmniboxViewMac::OmniboxViewMac(OmniboxEditController* controller, |
| 172 Profile* profile, | 177 Profile* profile, |
| 173 CommandUpdater* command_updater, | 178 CommandUpdater* command_updater, |
| 174 AutocompleteTextField* field) | 179 AutocompleteTextField* field) |
| 175 : OmniboxView( | 180 : OmniboxView( |
| 176 controller, | 181 controller, |
| 177 base::WrapUnique(new ChromeOmniboxClient(controller, profile))), | 182 base::WrapUnique(new ChromeOmniboxClient(controller, profile))), |
| 178 profile_(profile), | 183 profile_(profile), |
| (...skipping 929 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1108 | 1113 |
| 1109 NSUInteger OmniboxViewMac::GetTextLength() const { | 1114 NSUInteger OmniboxViewMac::GetTextLength() const { |
| 1110 return [field_ currentEditor] ? [[[field_ currentEditor] string] length] : | 1115 return [field_ currentEditor] ? [[[field_ currentEditor] string] length] : |
| 1111 [[field_ stringValue] length]; | 1116 [[field_ stringValue] length]; |
| 1112 } | 1117 } |
| 1113 | 1118 |
| 1114 bool OmniboxViewMac::IsCaretAtEnd() const { | 1119 bool OmniboxViewMac::IsCaretAtEnd() const { |
| 1115 const NSRange selection = GetSelectedRange(); | 1120 const NSRange selection = GetSelectedRange(); |
| 1116 return NSMaxRange(selection) == GetTextLength(); | 1121 return NSMaxRange(selection) == GetTextLength(); |
| 1117 } | 1122 } |
| OLD | NEW |