| 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 553 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 564 range:as_entire_string]; | 564 range:as_entire_string]; |
| 565 | 565 |
| 566 [attributedString addAttribute:NSForegroundColorAttributeName | 566 [attributedString addAttribute:NSForegroundColorAttributeName |
| 567 value:HostTextColor(in_dark_mode) | 567 value:HostTextColor(in_dark_mode) |
| 568 range:as_entire_string]; | 568 range:as_entire_string]; |
| 569 | 569 |
| 570 url::Component scheme, host; | 570 url::Component scheme, host; |
| 571 AutocompleteInput::ParseForEmphasizeComponents( | 571 AutocompleteInput::ParseForEmphasizeComponents( |
| 572 display_text, ChromeAutocompleteSchemeClassifier(profile_), &scheme, | 572 display_text, ChromeAutocompleteSchemeClassifier(profile_), &scheme, |
| 573 &host); | 573 &host); |
| 574 bool grey_out_url = display_text.substr(scheme.begin, scheme.len) == | 574 |
| 575 base::UTF8ToUTF16(extensions::kExtensionScheme); | 575 const base::string16 url_scheme = |
| 576 display_text.substr(scheme.begin, scheme.len); |
| 577 |
| 578 // Is the scheme one that might be abused for spoofing purposes? |
| 579 bool spoofy_scheme = url_scheme == base::UTF8ToUTF16(url::kDataScheme); |
| 580 |
| 581 // Should the full URL be deemphasized? |
| 582 bool grey_out_url = |
| 583 (spoofy_scheme || |
| 584 url_scheme == base::UTF8ToUTF16(extensions::kExtensionScheme)); |
| 585 |
| 576 if (model()->CurrentTextIsURL() && | 586 if (model()->CurrentTextIsURL() && |
| 577 (host.is_nonempty() || grey_out_url)) { | 587 (host.is_nonempty() || grey_out_url)) { |
| 578 [attributedString addAttribute:NSForegroundColorAttributeName | 588 [attributedString addAttribute:NSForegroundColorAttributeName |
| 579 value:BaseTextColor(in_dark_mode) | 589 value:BaseTextColor(in_dark_mode) |
| 580 range:as_entire_string]; | 590 range:as_entire_string]; |
| 581 | 591 |
| 582 if (!grey_out_url) { | 592 if (!grey_out_url) { |
| 583 [attributedString addAttribute:NSForegroundColorAttributeName | 593 [attributedString addAttribute:NSForegroundColorAttributeName |
| 584 value:HostTextColor(in_dark_mode) | 594 value:HostTextColor(in_dark_mode) |
| 585 range:ComponentToNSRange(host)]; | 595 range:ComponentToNSRange(host)]; |
| 596 } else if (spoofy_scheme) { |
| 597 [attributedString addAttribute:NSForegroundColorAttributeName |
| 598 value:HostTextColor(in_dark_mode) |
| 599 range:ComponentToNSRange(scheme)]; |
| 586 } | 600 } |
| 587 } | 601 } |
| 588 | 602 |
| 589 // TODO(shess): GTK has this as a member var, figure out why. | 603 // TODO(shess): GTK has this as a member var, figure out why. |
| 590 // [Could it be to not change if no change? If so, I'm guessing | 604 // [Could it be to not change if no change? If so, I'm guessing |
| 591 // AppKit may already handle that.] | 605 // AppKit may already handle that.] |
| 592 const security_state::SecurityLevel security_level = | 606 const security_state::SecurityLevel security_level = |
| 593 controller()->GetToolbarModel()->GetSecurityLevel(false); | 607 controller()->GetToolbarModel()->GetSecurityLevel(false); |
| 594 | 608 |
| 595 // Emphasize the scheme for security UI display purposes (if necessary). | 609 // Emphasize the scheme for security UI display purposes (if necessary). |
| (...skipping 492 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1088 display_text); | 1102 display_text); |
| 1089 NSDictionary* notification_info = @{ | 1103 NSDictionary* notification_info = @{ |
| 1090 NSAccessibilityAnnouncementKey : announcement, | 1104 NSAccessibilityAnnouncementKey : announcement, |
| 1091 NSAccessibilityPriorityKey : @(NSAccessibilityPriorityHigh) | 1105 NSAccessibilityPriorityKey : @(NSAccessibilityPriorityHigh) |
| 1092 }; | 1106 }; |
| 1093 NSAccessibilityPostNotificationWithUserInfo( | 1107 NSAccessibilityPostNotificationWithUserInfo( |
| 1094 [field_ window], | 1108 [field_ window], |
| 1095 NSAccessibilityAnnouncementRequestedNotification, | 1109 NSAccessibilityAnnouncementRequestedNotification, |
| 1096 notification_info); | 1110 notification_info); |
| 1097 } | 1111 } |
| OLD | NEW |