| 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 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 } | 102 } |
| 103 return in_dark_mode ? [NSColor whiteColor] : [NSColor blackColor]; | 103 return in_dark_mode ? [NSColor whiteColor] : [NSColor blackColor]; |
| 104 } | 104 } |
| 105 NSColor* SecureSchemeColor(bool in_dark_mode) { | 105 NSColor* SecureSchemeColor(bool in_dark_mode) { |
| 106 if (!ui::MaterialDesignController::IsModeMaterial()) { | 106 if (!ui::MaterialDesignController::IsModeMaterial()) { |
| 107 return ColorWithRGBBytes(0x07, 0x95, 0x00); | 107 return ColorWithRGBBytes(0x07, 0x95, 0x00); |
| 108 } | 108 } |
| 109 return in_dark_mode ? skia::SkColorToSRGBNSColor(SK_ColorWHITE) | 109 return in_dark_mode ? skia::SkColorToSRGBNSColor(SK_ColorWHITE) |
| 110 : skia::SkColorToSRGBNSColor(gfx::kGoogleGreen700); | 110 : skia::SkColorToSRGBNSColor(gfx::kGoogleGreen700); |
| 111 } | 111 } |
| 112 NSColor* SecurityWarningSchemeColor(bool in_dark_mode) { | |
| 113 return in_dark_mode | |
| 114 ? skia::SkColorToSRGBNSColor(SkColorSetA(SK_ColorWHITE, 0x7F)) | |
| 115 : skia::SkColorToSRGBNSColor(gfx::kGoogleYellow700); | |
| 116 } | |
| 117 NSColor* SecurityErrorSchemeColor(bool in_dark_mode) { | 112 NSColor* SecurityErrorSchemeColor(bool in_dark_mode) { |
| 118 if (!ui::MaterialDesignController::IsModeMaterial()) { | 113 if (!ui::MaterialDesignController::IsModeMaterial()) { |
| 119 return ColorWithRGBBytes(0xa2, 0x00, 0x00); | 114 return ColorWithRGBBytes(0xa2, 0x00, 0x00); |
| 120 } | 115 } |
| 121 return in_dark_mode | 116 return in_dark_mode |
| 122 ? skia::SkColorToSRGBNSColor(SkColorSetA(SK_ColorWHITE, 0x7F)) | 117 ? skia::SkColorToSRGBNSColor(SkColorSetA(SK_ColorWHITE, 0x7F)) |
| 123 : skia::SkColorToSRGBNSColor(gfx::kGoogleRed700); | 118 : skia::SkColorToSRGBNSColor(gfx::kGoogleRed700); |
| 124 } | 119 } |
| 125 | 120 |
| 126 const char kOmniboxViewMacStateKey[] = "OmniboxViewMacState"; | 121 const char kOmniboxViewMacStateKey[] = "OmniboxViewMacState"; |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 188 | 183 |
| 189 // static | 184 // static |
| 190 NSColor* OmniboxViewMac::GetSecureTextColor( | 185 NSColor* OmniboxViewMac::GetSecureTextColor( |
| 191 security_state::SecurityStateModel::SecurityLevel security_level, | 186 security_state::SecurityStateModel::SecurityLevel security_level, |
| 192 bool in_dark_mode) { | 187 bool in_dark_mode) { |
| 193 if (security_level == security_state::SecurityStateModel::EV_SECURE || | 188 if (security_level == security_state::SecurityStateModel::EV_SECURE || |
| 194 security_level == security_state::SecurityStateModel::SECURE) { | 189 security_level == security_state::SecurityStateModel::SECURE) { |
| 195 return SecureSchemeColor(in_dark_mode); | 190 return SecureSchemeColor(in_dark_mode); |
| 196 } | 191 } |
| 197 | 192 |
| 198 if (security_level == security_state::SecurityStateModel::SECURITY_ERROR) | 193 DCHECK_EQ(security_state::SecurityStateModel::SECURITY_ERROR, |
| 199 return SecurityErrorSchemeColor(in_dark_mode); | |
| 200 | |
| 201 DCHECK_EQ(security_state::SecurityStateModel::SECURITY_WARNING, | |
| 202 security_level); | 194 security_level); |
| 203 return SecurityWarningSchemeColor(in_dark_mode); | 195 return SecurityErrorSchemeColor(in_dark_mode); |
| 204 } | 196 } |
| 205 | 197 |
| 206 OmniboxViewMac::OmniboxViewMac(OmniboxEditController* controller, | 198 OmniboxViewMac::OmniboxViewMac(OmniboxEditController* controller, |
| 207 Profile* profile, | 199 Profile* profile, |
| 208 CommandUpdater* command_updater, | 200 CommandUpdater* command_updater, |
| 209 AutocompleteTextField* field) | 201 AutocompleteTextField* field) |
| 210 : OmniboxView( | 202 : OmniboxView( |
| 211 controller, | 203 controller, |
| 212 base::WrapUnique(new ChromeOmniboxClient(controller, profile))), | 204 base::WrapUnique(new ChromeOmniboxClient(controller, profile))), |
| 213 profile_(profile), | 205 profile_(profile), |
| (...skipping 921 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1135 display_text); | 1127 display_text); |
| 1136 NSDictionary* notification_info = @{ | 1128 NSDictionary* notification_info = @{ |
| 1137 NSAccessibilityAnnouncementKey : announcement, | 1129 NSAccessibilityAnnouncementKey : announcement, |
| 1138 NSAccessibilityPriorityKey : @(NSAccessibilityPriorityHigh) | 1130 NSAccessibilityPriorityKey : @(NSAccessibilityPriorityHigh) |
| 1139 }; | 1131 }; |
| 1140 NSAccessibilityPostNotificationWithUserInfo( | 1132 NSAccessibilityPostNotificationWithUserInfo( |
| 1141 [field_ window], | 1133 [field_ window], |
| 1142 NSAccessibilityAnnouncementRequestedNotification, | 1134 NSAccessibilityAnnouncementRequestedNotification, |
| 1143 notification_info); | 1135 notification_info); |
| 1144 } | 1136 } |
| OLD | NEW |