| 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 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 NSColor* HostTextColor(bool in_dark_mode) { | 91 NSColor* HostTextColor(bool in_dark_mode) { |
| 92 if (!ui::MaterialDesignController::IsModeMaterial()) { | 92 if (!ui::MaterialDesignController::IsModeMaterial()) { |
| 93 return [NSColor blackColor]; | 93 return [NSColor blackColor]; |
| 94 } | 94 } |
| 95 return in_dark_mode ? [NSColor whiteColor] : [NSColor blackColor]; | 95 return in_dark_mode ? [NSColor whiteColor] : [NSColor blackColor]; |
| 96 } | 96 } |
| 97 NSColor* SecureSchemeColor(bool in_dark_mode) { | 97 NSColor* SecureSchemeColor(bool in_dark_mode) { |
| 98 if (!ui::MaterialDesignController::IsModeMaterial()) { | 98 if (!ui::MaterialDesignController::IsModeMaterial()) { |
| 99 return ColorWithRGBBytes(0x07, 0x95, 0x00); | 99 return ColorWithRGBBytes(0x07, 0x95, 0x00); |
| 100 } | 100 } |
| 101 return in_dark_mode ? [NSColor colorWithCalibratedWhite:1 alpha:0.5] | 101 return in_dark_mode |
| 102 : skia::SkColorToCalibratedNSColor(gfx::kGoogleGreen700); | 102 ? skia::SkColorToSRGBNSColor(SkColorSetA(SK_ColorWHITE, 0x7F)) |
| 103 : skia::SkColorToSRGBNSColor(gfx::kGoogleGreen700); |
| 103 } | 104 } |
| 104 NSColor* SecurityWarningSchemeColor(bool in_dark_mode) { | 105 NSColor* SecurityWarningSchemeColor(bool in_dark_mode) { |
| 105 return in_dark_mode ? [NSColor colorWithCalibratedWhite:1 alpha:0.5] | 106 return in_dark_mode |
| 106 : skia::SkColorToCalibratedNSColor(gfx::kGoogleYellow700); | 107 ? skia::SkColorToSRGBNSColor(SkColorSetA(SK_ColorWHITE, 0x7F)) |
| 108 : skia::SkColorToSRGBNSColor(gfx::kGoogleYellow700); |
| 107 } | 109 } |
| 108 NSColor* SecurityErrorSchemeColor(bool in_dark_mode) { | 110 NSColor* SecurityErrorSchemeColor(bool in_dark_mode) { |
| 109 if (!ui::MaterialDesignController::IsModeMaterial()) { | 111 if (!ui::MaterialDesignController::IsModeMaterial()) { |
| 110 return ColorWithRGBBytes(0xa2, 0x00, 0x00); | 112 return ColorWithRGBBytes(0xa2, 0x00, 0x00); |
| 111 } | 113 } |
| 112 return in_dark_mode ? [NSColor colorWithCalibratedWhite:1 alpha:0.5] | 114 return in_dark_mode |
| 113 : skia::SkColorToCalibratedNSColor(gfx::kGoogleRed700); | 115 ? skia::SkColorToSRGBNSColor(SkColorSetA(SK_ColorWHITE, 0x7F)) |
| 116 : skia::SkColorToSRGBNSColor(gfx::kGoogleRed700); |
| 114 } | 117 } |
| 115 | 118 |
| 116 const char kOmniboxViewMacStateKey[] = "OmniboxViewMacState"; | 119 const char kOmniboxViewMacStateKey[] = "OmniboxViewMacState"; |
| 117 | 120 |
| 118 // Store's the model and view state across tab switches. | 121 // Store's the model and view state across tab switches. |
| 119 struct OmniboxViewMacState : public base::SupportsUserData::Data { | 122 struct OmniboxViewMacState : public base::SupportsUserData::Data { |
| 120 OmniboxViewMacState(const OmniboxEditModel::State model_state, | 123 OmniboxViewMacState(const OmniboxEditModel::State model_state, |
| 121 const bool has_focus, | 124 const bool has_focus, |
| 122 const NSRange& selection) | 125 const NSRange& selection) |
| 123 : model_state(model_state), | 126 : model_state(model_state), |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 165 SkColor OmniboxViewMac::BaseTextColorSkia(bool in_dark_mode) { | 168 SkColor OmniboxViewMac::BaseTextColorSkia(bool in_dark_mode) { |
| 166 return in_dark_mode ? SkColorSetA(SK_ColorWHITE, 0x7F) | 169 return in_dark_mode ? SkColorSetA(SK_ColorWHITE, 0x7F) |
| 167 : SkColorSetA(SK_ColorBLACK, 0x7F); | 170 : SkColorSetA(SK_ColorBLACK, 0x7F); |
| 168 } | 171 } |
| 169 | 172 |
| 170 // static | 173 // static |
| 171 NSColor* OmniboxViewMac::BaseTextColor(bool in_dark_mode) { | 174 NSColor* OmniboxViewMac::BaseTextColor(bool in_dark_mode) { |
| 172 if (!ui::MaterialDesignController::IsModeMaterial()) { | 175 if (!ui::MaterialDesignController::IsModeMaterial()) { |
| 173 return [NSColor darkGrayColor]; | 176 return [NSColor darkGrayColor]; |
| 174 } | 177 } |
| 175 return skia::SkColorToCalibratedNSColor(BaseTextColorSkia(in_dark_mode)); | 178 return skia::SkColorToSRGBNSColor(BaseTextColorSkia(in_dark_mode)); |
| 176 } | 179 } |
| 177 | 180 |
| 178 OmniboxViewMac::OmniboxViewMac(OmniboxEditController* controller, | 181 OmniboxViewMac::OmniboxViewMac(OmniboxEditController* controller, |
| 179 Profile* profile, | 182 Profile* profile, |
| 180 CommandUpdater* command_updater, | 183 CommandUpdater* command_updater, |
| 181 AutocompleteTextField* field) | 184 AutocompleteTextField* field) |
| 182 : OmniboxView( | 185 : OmniboxView( |
| 183 controller, | 186 controller, |
| 184 base::WrapUnique(new ChromeOmniboxClient(controller, profile))), | 187 base::WrapUnique(new ChromeOmniboxClient(controller, profile))), |
| 185 profile_(profile), | 188 profile_(profile), |
| (...skipping 947 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1133 | 1136 |
| 1134 NSUInteger OmniboxViewMac::GetTextLength() const { | 1137 NSUInteger OmniboxViewMac::GetTextLength() const { |
| 1135 return [field_ currentEditor] ? [[[field_ currentEditor] string] length] : | 1138 return [field_ currentEditor] ? [[[field_ currentEditor] string] length] : |
| 1136 [[field_ stringValue] length]; | 1139 [[field_ stringValue] length]; |
| 1137 } | 1140 } |
| 1138 | 1141 |
| 1139 bool OmniboxViewMac::IsCaretAtEnd() const { | 1142 bool OmniboxViewMac::IsCaretAtEnd() const { |
| 1140 const NSRange selection = GetSelectedRange(); | 1143 const NSRange selection = GetSelectedRange(); |
| 1141 return NSMaxRange(selection) == GetTextLength(); | 1144 return NSMaxRange(selection) == GetTextLength(); |
| 1142 } | 1145 } |
| OLD | NEW |