| 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 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 NSColor* HostTextColor(bool in_dark_mode) { | 95 NSColor* HostTextColor(bool in_dark_mode) { |
| 96 if (!ui::MaterialDesignController::IsModeMaterial()) { | 96 if (!ui::MaterialDesignController::IsModeMaterial()) { |
| 97 return [NSColor blackColor]; | 97 return [NSColor blackColor]; |
| 98 } | 98 } |
| 99 return in_dark_mode ? [NSColor whiteColor] : [NSColor blackColor]; | 99 return in_dark_mode ? [NSColor whiteColor] : [NSColor blackColor]; |
| 100 } | 100 } |
| 101 NSColor* SecureSchemeColor(bool in_dark_mode) { | 101 NSColor* SecureSchemeColor(bool in_dark_mode) { |
| 102 if (!ui::MaterialDesignController::IsModeMaterial()) { | 102 if (!ui::MaterialDesignController::IsModeMaterial()) { |
| 103 return ColorWithRGBBytes(0x07, 0x95, 0x00); | 103 return ColorWithRGBBytes(0x07, 0x95, 0x00); |
| 104 } | 104 } |
| 105 return in_dark_mode ? [NSColor colorWithCalibratedWhite:1 alpha:0.5] | 105 return in_dark_mode |
| 106 : skia::SkColorToCalibratedNSColor(gfx::kGoogleGreen700); | 106 ? skia::SkColorToSRGBNSColor(SkColorSetA(SK_ColorWHITE, 0x7F)) |
| 107 : skia::SkColorToSRGBNSColor(gfx::kGoogleGreen700); |
| 107 } | 108 } |
| 108 NSColor* SecurityWarningSchemeColor(bool in_dark_mode) { | 109 NSColor* SecurityWarningSchemeColor(bool in_dark_mode) { |
| 109 return in_dark_mode ? [NSColor colorWithCalibratedWhite:1 alpha:0.5] | 110 return in_dark_mode |
| 110 : skia::SkColorToCalibratedNSColor(gfx::kGoogleYellow700); | 111 ? skia::SkColorToSRGBNSColor(SkColorSetA(SK_ColorWHITE, 0x7F)) |
| 112 : skia::SkColorToSRGBNSColor(gfx::kGoogleYellow700); |
| 111 } | 113 } |
| 112 NSColor* SecurityErrorSchemeColor(bool in_dark_mode) { | 114 NSColor* SecurityErrorSchemeColor(bool in_dark_mode) { |
| 113 if (!ui::MaterialDesignController::IsModeMaterial()) { | 115 if (!ui::MaterialDesignController::IsModeMaterial()) { |
| 114 return ColorWithRGBBytes(0xa2, 0x00, 0x00); | 116 return ColorWithRGBBytes(0xa2, 0x00, 0x00); |
| 115 } | 117 } |
| 116 return in_dark_mode ? [NSColor colorWithCalibratedWhite:1 alpha:0.5] | 118 return in_dark_mode |
| 117 : skia::SkColorToCalibratedNSColor(gfx::kGoogleRed700); | 119 ? skia::SkColorToSRGBNSColor(SkColorSetA(SK_ColorWHITE, 0x7F)) |
| 120 : skia::SkColorToSRGBNSColor(gfx::kGoogleRed700); |
| 118 } | 121 } |
| 119 | 122 |
| 120 const char kOmniboxViewMacStateKey[] = "OmniboxViewMacState"; | 123 const char kOmniboxViewMacStateKey[] = "OmniboxViewMacState"; |
| 121 | 124 |
| 122 // Store's the model and view state across tab switches. | 125 // Store's the model and view state across tab switches. |
| 123 struct OmniboxViewMacState : public base::SupportsUserData::Data { | 126 struct OmniboxViewMacState : public base::SupportsUserData::Data { |
| 124 OmniboxViewMacState(const OmniboxEditModel::State model_state, | 127 OmniboxViewMacState(const OmniboxEditModel::State model_state, |
| 125 const bool has_focus, | 128 const bool has_focus, |
| 126 const NSRange& selection) | 129 const NSRange& selection) |
| 127 : model_state(model_state), | 130 : model_state(model_state), |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 169 SkColor OmniboxViewMac::BaseTextColorSkia(bool in_dark_mode) { | 172 SkColor OmniboxViewMac::BaseTextColorSkia(bool in_dark_mode) { |
| 170 return in_dark_mode ? SkColorSetA(SK_ColorWHITE, 0x7F) | 173 return in_dark_mode ? SkColorSetA(SK_ColorWHITE, 0x7F) |
| 171 : SkColorSetA(SK_ColorBLACK, 0x7F); | 174 : SkColorSetA(SK_ColorBLACK, 0x7F); |
| 172 } | 175 } |
| 173 | 176 |
| 174 // static | 177 // static |
| 175 NSColor* OmniboxViewMac::BaseTextColor(bool in_dark_mode) { | 178 NSColor* OmniboxViewMac::BaseTextColor(bool in_dark_mode) { |
| 176 if (!ui::MaterialDesignController::IsModeMaterial()) { | 179 if (!ui::MaterialDesignController::IsModeMaterial()) { |
| 177 return [NSColor darkGrayColor]; | 180 return [NSColor darkGrayColor]; |
| 178 } | 181 } |
| 179 return skia::SkColorToCalibratedNSColor(BaseTextColorSkia(in_dark_mode)); | 182 return skia::SkColorToSRGBNSColor(BaseTextColorSkia(in_dark_mode)); |
| 180 } | 183 } |
| 181 | 184 |
| 182 // static | 185 // static |
| 183 NSColor* OmniboxViewMac::GetSecureTextColor( | 186 NSColor* OmniboxViewMac::GetSecureTextColor( |
| 184 security_state::SecurityStateModel::SecurityLevel security_level, | 187 security_state::SecurityStateModel::SecurityLevel security_level, |
| 185 bool in_dark_mode) { | 188 bool in_dark_mode) { |
| 186 if (security_level == security_state::SecurityStateModel::EV_SECURE || | 189 if (security_level == security_state::SecurityStateModel::EV_SECURE || |
| 187 security_level == security_state::SecurityStateModel::SECURE) { | 190 security_level == security_state::SecurityStateModel::SECURE) { |
| 188 return SecureSchemeColor(in_dark_mode); | 191 return SecureSchemeColor(in_dark_mode); |
| 189 } | 192 } |
| (...skipping 962 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1152 display_text); | 1155 display_text); |
| 1153 NSDictionary* notification_info = @{ | 1156 NSDictionary* notification_info = @{ |
| 1154 NSAccessibilityAnnouncementKey : announcement, | 1157 NSAccessibilityAnnouncementKey : announcement, |
| 1155 NSAccessibilityPriorityKey : @(NSAccessibilityPriorityHigh) | 1158 NSAccessibilityPriorityKey : @(NSAccessibilityPriorityHigh) |
| 1156 }; | 1159 }; |
| 1157 NSAccessibilityPostNotificationWithUserInfo( | 1160 NSAccessibilityPostNotificationWithUserInfo( |
| 1158 [field_ window], | 1161 [field_ window], |
| 1159 NSAccessibilityAnnouncementRequestedNotification, | 1162 NSAccessibilityAnnouncementRequestedNotification, |
| 1160 notification_info); | 1163 notification_info); |
| 1161 } | 1164 } |
| OLD | NEW |