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/views/omnibox/omnibox_view_views.h" | 5 #include "chrome/browser/ui/views/omnibox/omnibox_view_views.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/string_util.h" | 8 #include "base/string_util.h" |
9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
10 #include "chrome/app/chrome_command_ids.h" | 10 #include "chrome/app/chrome_command_ids.h" |
(...skipping 810 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
821 | 821 |
822 void OmniboxViewViews::EmphasizeURLComponents() { | 822 void OmniboxViewViews::EmphasizeURLComponents() { |
823 // See whether the contents are a URL with a non-empty host portion, which we | 823 // See whether the contents are a URL with a non-empty host portion, which we |
824 // should emphasize. To check for a URL, rather than using the type returned | 824 // should emphasize. To check for a URL, rather than using the type returned |
825 // by Parse(), ask the model, which will check the desired page transition for | 825 // by Parse(), ask the model, which will check the desired page transition for |
826 // this input. This can tell us whether an UNKNOWN input string is going to | 826 // this input. This can tell us whether an UNKNOWN input string is going to |
827 // be treated as a search or a navigation, and is the same method the Paste | 827 // be treated as a search or a navigation, and is the same method the Paste |
828 // And Go system uses. | 828 // And Go system uses. |
829 url_parse::Component scheme, host; | 829 url_parse::Component scheme, host; |
830 AutocompleteInput::ParseForEmphasizeComponents(text(), &scheme, &host); | 830 AutocompleteInput::ParseForEmphasizeComponents(text(), &scheme, &host); |
831 const bool emphasize = model()->CurrentTextIsURL() && (host.len > 0); | 831 if (model()->CurrentTextIsURL() && |
Peter Kasting
2013/04/04 21:07:05
Nit: Slightly simpler:
bool grey_base = model()
Patrick Riordan
2013/04/10 02:00:24
Done.
| |
832 SetColor(location_bar_view_->GetColor(security_level_, | 832 (host.is_nonempty() || toolbar_model()->ShouldGreyOutURL())) { |
833 emphasize ? LocationBarView::DEEMPHASIZED_TEXT : LocationBarView::TEXT)); | 833 SetColor(location_bar_view_->GetColor(security_level_, |
834 if (emphasize) { | 834 LocationBarView::DEEMPHASIZED_TEXT)); |
835 ApplyColor( | 835 |
836 location_bar_view_->GetColor(security_level_, LocationBarView::TEXT), | 836 if (host.is_nonempty() && !toolbar_model()->ShouldGreyOutURL()) { |
837 ui::Range(host.begin, host.end())); | 837 ApplyColor( |
838 location_bar_view_->GetColor(security_level_, LocationBarView::TEXT), | |
839 ui::Range(host.begin, host.end())); | |
840 } | |
841 } else { | |
842 SetColor(location_bar_view_->GetColor(security_level_, | |
843 LocationBarView::TEXT)); | |
838 } | 844 } |
839 | 845 |
840 // Emphasize the scheme for security UI display purposes (if necessary). | 846 // Emphasize the scheme for security UI display purposes (if necessary). |
841 // Note that we check CurrentTextIsURL() because if we're replacing search | 847 // Note that we check CurrentTextIsURL() because if we're replacing search |
842 // URLs with search terms, we may have a non-URL even when the user is not | 848 // URLs with search terms, we may have a non-URL even when the user is not |
843 // editing; and in some cases, e.g. for "site:foo.com" searches, the parser | 849 // editing; and in some cases, e.g. for "site:foo.com" searches, the parser |
844 // may have incorrectly identified a qualifier as a scheme. | 850 // may have incorrectly identified a qualifier as a scheme. |
845 SetStyle(gfx::DIAGONAL_STRIKE, false); | 851 SetStyle(gfx::DIAGONAL_STRIKE, false); |
846 if (!model()->user_input_in_progress() && model()->CurrentTextIsURL() && | 852 if (!model()->user_input_in_progress() && model()->CurrentTextIsURL() && |
847 scheme.is_nonempty() && (security_level_ != ToolbarModel::NONE)) { | 853 scheme.is_nonempty() && (security_level_ != ToolbarModel::NONE)) { |
(...skipping 28 matching lines...) Expand all Loading... | |
876 const string16 text(GetClipboardText()); | 882 const string16 text(GetClipboardText()); |
877 if (!text.empty()) { | 883 if (!text.empty()) { |
878 // Record this paste, so we can do different behavior. | 884 // Record this paste, so we can do different behavior. |
879 model()->on_paste(); | 885 model()->on_paste(); |
880 // Force a Paste operation to trigger the text_changed code in | 886 // Force a Paste operation to trigger the text_changed code in |
881 // OnAfterPossibleChange(), even if identical contents are pasted. | 887 // OnAfterPossibleChange(), even if identical contents are pasted. |
882 text_before_change_.clear(); | 888 text_before_change_.clear(); |
883 ReplaceSelection(text); | 889 ReplaceSelection(text); |
884 } | 890 } |
885 } | 891 } |
OLD | NEW |