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 12 matching lines...) Expand all Loading... |
23 #include "chrome/browser/ui/omnibox/chrome_omnibox_client.h" | 23 #include "chrome/browser/ui/omnibox/chrome_omnibox_client.h" |
24 #include "chrome/browser/ui/omnibox/clipboard_utils.h" | 24 #include "chrome/browser/ui/omnibox/clipboard_utils.h" |
25 #include "chrome/grit/generated_resources.h" | 25 #include "chrome/grit/generated_resources.h" |
26 #include "chrome/grit/theme_resources.h" | 26 #include "chrome/grit/theme_resources.h" |
27 #include "components/grit/components_scaled_resources.h" | 27 #include "components/grit/components_scaled_resources.h" |
28 #include "components/omnibox/browser/autocomplete_input.h" | 28 #include "components/omnibox/browser/autocomplete_input.h" |
29 #include "components/omnibox/browser/autocomplete_match.h" | 29 #include "components/omnibox/browser/autocomplete_match.h" |
30 #include "components/omnibox/browser/omnibox_edit_controller.h" | 30 #include "components/omnibox/browser/omnibox_edit_controller.h" |
31 #include "components/omnibox/browser/omnibox_field_trial.h" | 31 #include "components/omnibox/browser/omnibox_field_trial.h" |
32 #include "components/omnibox/browser/omnibox_popup_model.h" | 32 #include "components/omnibox/browser/omnibox_popup_model.h" |
33 #include "components/security_state/security_state_model.h" | |
34 #include "components/toolbar/toolbar_model.h" | 33 #include "components/toolbar/toolbar_model.h" |
35 #include "content/public/browser/web_contents.h" | 34 #include "content/public/browser/web_contents.h" |
36 #include "extensions/common/constants.h" | 35 #include "extensions/common/constants.h" |
37 #import "skia/ext/skia_utils_mac.h" | 36 #import "skia/ext/skia_utils_mac.h" |
38 #import "third_party/mozilla/NSPasteboard+Utils.h" | 37 #import "third_party/mozilla/NSPasteboard+Utils.h" |
39 #include "ui/base/clipboard/clipboard.h" | 38 #include "ui/base/clipboard/clipboard.h" |
40 #include "ui/base/clipboard/clipboard_util_mac.h" | 39 #include "ui/base/clipboard/clipboard_util_mac.h" |
41 #import "ui/base/cocoa/cocoa_base_utils.h" | 40 #import "ui/base/cocoa/cocoa_base_utils.h" |
42 #import "ui/base/l10n/l10n_util_mac.h" | 41 #import "ui/base/l10n/l10n_util_mac.h" |
43 #include "ui/base/material_design/material_design_controller.h" | 42 #include "ui/base/material_design/material_design_controller.h" |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
168 : SkColorSetA(SK_ColorBLACK, 0x7F); | 167 : SkColorSetA(SK_ColorBLACK, 0x7F); |
169 } | 168 } |
170 | 169 |
171 // static | 170 // static |
172 NSColor* OmniboxViewMac::BaseTextColor(bool in_dark_mode) { | 171 NSColor* OmniboxViewMac::BaseTextColor(bool in_dark_mode) { |
173 return skia::SkColorToSRGBNSColor(BaseTextColorSkia(in_dark_mode)); | 172 return skia::SkColorToSRGBNSColor(BaseTextColorSkia(in_dark_mode)); |
174 } | 173 } |
175 | 174 |
176 // static | 175 // static |
177 NSColor* OmniboxViewMac::GetSecureTextColor( | 176 NSColor* OmniboxViewMac::GetSecureTextColor( |
178 security_state::SecurityStateModel::SecurityLevel security_level, | 177 security_state::SecurityLevel security_level, |
179 bool in_dark_mode) { | 178 bool in_dark_mode) { |
180 if (security_level == security_state::SecurityStateModel::EV_SECURE || | 179 if (security_level == security_state::EV_SECURE || |
181 security_level == security_state::SecurityStateModel::SECURE) { | 180 security_level == security_state::SECURE) { |
182 return SecureSchemeColor(in_dark_mode); | 181 return SecureSchemeColor(in_dark_mode); |
183 } | 182 } |
184 | 183 |
185 if (security_level == security_state::SecurityStateModel::DANGEROUS) | 184 if (security_level == security_state::DANGEROUS) |
186 return SecurityErrorSchemeColor(in_dark_mode); | 185 return SecurityErrorSchemeColor(in_dark_mode); |
187 | 186 |
188 DCHECK_EQ(security_state::SecurityStateModel::SECURITY_WARNING, | 187 DCHECK_EQ(security_state::SECURITY_WARNING, security_level); |
189 security_level); | |
190 return SecurityWarningSchemeColor(in_dark_mode); | 188 return SecurityWarningSchemeColor(in_dark_mode); |
191 } | 189 } |
192 | 190 |
193 OmniboxViewMac::OmniboxViewMac(OmniboxEditController* controller, | 191 OmniboxViewMac::OmniboxViewMac(OmniboxEditController* controller, |
194 Profile* profile, | 192 Profile* profile, |
195 CommandUpdater* command_updater, | 193 CommandUpdater* command_updater, |
196 AutocompleteTextField* field) | 194 AutocompleteTextField* field) |
197 : OmniboxView( | 195 : OmniboxView( |
198 controller, | 196 controller, |
199 base::WrapUnique(new ChromeOmniboxClient(controller, profile))), | 197 base::WrapUnique(new ChromeOmniboxClient(controller, profile))), |
(...skipping 392 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
592 if (!grey_out_url) { | 590 if (!grey_out_url) { |
593 [attributedString addAttribute:NSForegroundColorAttributeName | 591 [attributedString addAttribute:NSForegroundColorAttributeName |
594 value:HostTextColor(in_dark_mode) | 592 value:HostTextColor(in_dark_mode) |
595 range:ComponentToNSRange(host)]; | 593 range:ComponentToNSRange(host)]; |
596 } | 594 } |
597 } | 595 } |
598 | 596 |
599 // TODO(shess): GTK has this as a member var, figure out why. | 597 // TODO(shess): GTK has this as a member var, figure out why. |
600 // [Could it be to not change if no change? If so, I'm guessing | 598 // [Could it be to not change if no change? If so, I'm guessing |
601 // AppKit may already handle that.] | 599 // AppKit may already handle that.] |
602 const security_state::SecurityStateModel::SecurityLevel security_level = | 600 const security_state::SecurityLevel security_level = |
603 controller()->GetToolbarModel()->GetSecurityLevel(false); | 601 controller()->GetToolbarModel()->GetSecurityLevel(false); |
604 | 602 |
605 // Emphasize the scheme for security UI display purposes (if necessary). | 603 // Emphasize the scheme for security UI display purposes (if necessary). |
606 if (!model()->user_input_in_progress() && model()->CurrentTextIsURL() && | 604 if (!model()->user_input_in_progress() && model()->CurrentTextIsURL() && |
607 scheme.is_nonempty() && | 605 scheme.is_nonempty() && |
608 (security_level != security_state::SecurityStateModel::NONE) && | 606 (security_level != security_state::NONE) && |
609 (security_level != | 607 (security_level != security_state::HTTP_SHOW_WARNING)) { |
610 security_state::SecurityStateModel::HTTP_SHOW_WARNING)) { | 608 if (security_level == security_state::DANGEROUS) { |
611 if (security_level == security_state::SecurityStateModel::DANGEROUS) { | |
612 // Add a strikethrough through the scheme. | 609 // Add a strikethrough through the scheme. |
613 [attributedString addAttribute:NSStrikethroughStyleAttributeName | 610 [attributedString addAttribute:NSStrikethroughStyleAttributeName |
614 value:[NSNumber numberWithInt:NSUnderlineStyleSingle] | 611 value:[NSNumber numberWithInt:NSUnderlineStyleSingle] |
615 range:ComponentToNSRange(scheme)]; | 612 range:ComponentToNSRange(scheme)]; |
616 } | 613 } |
617 [attributedString | 614 [attributedString |
618 addAttribute:NSForegroundColorAttributeName | 615 addAttribute:NSForegroundColorAttributeName |
619 value:GetSecureTextColor(security_level, in_dark_mode) | 616 value:GetSecureTextColor(security_level, in_dark_mode) |
620 range:ComponentToNSRange(scheme)]; | 617 range:ComponentToNSRange(scheme)]; |
621 } | 618 } |
(...skipping 499 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1121 display_text); | 1118 display_text); |
1122 NSDictionary* notification_info = @{ | 1119 NSDictionary* notification_info = @{ |
1123 NSAccessibilityAnnouncementKey : announcement, | 1120 NSAccessibilityAnnouncementKey : announcement, |
1124 NSAccessibilityPriorityKey : @(NSAccessibilityPriorityHigh) | 1121 NSAccessibilityPriorityKey : @(NSAccessibilityPriorityHigh) |
1125 }; | 1122 }; |
1126 NSAccessibilityPostNotificationWithUserInfo( | 1123 NSAccessibilityPostNotificationWithUserInfo( |
1127 [field_ window], | 1124 [field_ window], |
1128 NSAccessibilityAnnouncementRequestedNotification, | 1125 NSAccessibilityAnnouncementRequestedNotification, |
1129 notification_info); | 1126 notification_info); |
1130 } | 1127 } |
OLD | NEW |