Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(18)

Side by Side Diff: chrome/browser/ui/views/omnibox/omnibox_view_views.cc

Issue 12463042: Shows chrome-extension urls and greys out the whole url. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: No longer involves toolbar model Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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"
11 #include "chrome/browser/autocomplete/autocomplete_input.h" 11 #include "chrome/browser/autocomplete/autocomplete_input.h"
12 #include "chrome/browser/autocomplete/autocomplete_match.h" 12 #include "chrome/browser/autocomplete/autocomplete_match.h"
13 #include "chrome/browser/bookmarks/bookmark_node_data.h" 13 #include "chrome/browser/bookmarks/bookmark_node_data.h"
14 #include "chrome/browser/chromeos/input_method/input_method_configuration.h" 14 #include "chrome/browser/chromeos/input_method/input_method_configuration.h"
15 #include "chrome/browser/command_updater.h" 15 #include "chrome/browser/command_updater.h"
16 #include "chrome/browser/profiles/profile.h" 16 #include "chrome/browser/profiles/profile.h"
17 #include "chrome/browser/search/search.h" 17 #include "chrome/browser/search/search.h"
18 #include "chrome/browser/ui/omnibox/omnibox_edit_controller.h" 18 #include "chrome/browser/ui/omnibox/omnibox_edit_controller.h"
19 #include "chrome/browser/ui/omnibox/omnibox_edit_model.h" 19 #include "chrome/browser/ui/omnibox/omnibox_edit_model.h"
20 #include "chrome/browser/ui/omnibox/omnibox_popup_model.h" 20 #include "chrome/browser/ui/omnibox/omnibox_popup_model.h"
21 #include "chrome/browser/ui/view_ids.h" 21 #include "chrome/browser/ui/view_ids.h"
22 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" 22 #include "chrome/browser/ui/views/location_bar/location_bar_view.h"
23 #include "chrome/browser/ui/views/omnibox/omnibox_popup_contents_view.h" 23 #include "chrome/browser/ui/views/omnibox/omnibox_popup_contents_view.h"
24 #include "content/public/browser/web_contents.h" 24 #include "content/public/browser/web_contents.h"
25 #include "extensions/common/constants.h"
25 #include "googleurl/src/gurl.h" 26 #include "googleurl/src/gurl.h"
26 #include "grit/app_locale_settings.h" 27 #include "grit/app_locale_settings.h"
27 #include "grit/generated_resources.h" 28 #include "grit/generated_resources.h"
28 #include "grit/ui_strings.h" 29 #include "grit/ui_strings.h"
29 #include "net/base/escape.h" 30 #include "net/base/escape.h"
30 #include "third_party/skia/include/core/SkColor.h" 31 #include "third_party/skia/include/core/SkColor.h"
31 #include "ui/base/accessibility/accessible_view_state.h" 32 #include "ui/base/accessibility/accessible_view_state.h"
32 #include "ui/base/clipboard/scoped_clipboard_writer.h" 33 #include "ui/base/clipboard/scoped_clipboard_writer.h"
33 #include "ui/base/dragdrop/drag_drop_types.h" 34 #include "ui/base/dragdrop/drag_drop_types.h"
34 #include "ui/base/dragdrop/os_exchange_data.h" 35 #include "ui/base/dragdrop/os_exchange_data.h"
(...skipping 804 matching lines...) Expand 10 before | Expand all | Expand 10 after
839 840
840 void OmniboxViewViews::EmphasizeURLComponents() { 841 void OmniboxViewViews::EmphasizeURLComponents() {
841 // See whether the contents are a URL with a non-empty host portion, which we 842 // See whether the contents are a URL with a non-empty host portion, which we
842 // should emphasize. To check for a URL, rather than using the type returned 843 // should emphasize. To check for a URL, rather than using the type returned
843 // by Parse(), ask the model, which will check the desired page transition for 844 // by Parse(), ask the model, which will check the desired page transition for
844 // this input. This can tell us whether an UNKNOWN input string is going to 845 // this input. This can tell us whether an UNKNOWN input string is going to
845 // be treated as a search or a navigation, and is the same method the Paste 846 // be treated as a search or a navigation, and is the same method the Paste
846 // And Go system uses. 847 // And Go system uses.
847 url_parse::Component scheme, host; 848 url_parse::Component scheme, host;
848 AutocompleteInput::ParseForEmphasizeComponents(text(), &scheme, &host); 849 AutocompleteInput::ParseForEmphasizeComponents(text(), &scheme, &host);
849 const bool emphasize = model()->CurrentTextIsURL() && (host.len > 0); 850 bool grey_out_url = GetText().substr(scheme.begin, scheme.len) ==
Peter Kasting 2013/04/11 23:10:40 Use text() here instead of GetText().
Patrick Riordan 2013/04/11 23:27:38 Done.
850 SetColor(location_bar_view_->GetColor(security_level_, 851 UTF8ToUTF16(extensions::kExtensionScheme);
851 emphasize ? LocationBarView::DEEMPHASIZED_TEXT : LocationBarView::TEXT)); 852 bool grey_base = model()->CurrentTextIsURL() &&
852 if (emphasize) { 853 (host.is_nonempty() || grey_out_url);
854 SetColor(location_bar_view_->GetColor(
855 security_level_,
856 grey_base ? LocationBarView::DEEMPHASIZED_TEXT : LocationBarView::TEXT));
857 if (grey_base && !grey_out_url) {
853 ApplyColor( 858 ApplyColor(
854 location_bar_view_->GetColor(security_level_, LocationBarView::TEXT), 859 location_bar_view_->GetColor(security_level_, LocationBarView::TEXT),
855 ui::Range(host.begin, host.end())); 860 ui::Range(host.begin, host.end()));
856 } 861 }
857 862
858 // Emphasize the scheme for security UI display purposes (if necessary). 863 // Emphasize the scheme for security UI display purposes (if necessary).
859 // Note that we check CurrentTextIsURL() because if we're replacing search 864 // Note that we check CurrentTextIsURL() because if we're replacing search
860 // URLs with search terms, we may have a non-URL even when the user is not 865 // URLs with search terms, we may have a non-URL even when the user is not
861 // editing; and in some cases, e.g. for "site:foo.com" searches, the parser 866 // editing; and in some cases, e.g. for "site:foo.com" searches, the parser
862 // may have incorrectly identified a qualifier as a scheme. 867 // may have incorrectly identified a qualifier as a scheme.
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
894 const string16 text(GetClipboardText()); 899 const string16 text(GetClipboardText());
895 if (!text.empty()) { 900 if (!text.empty()) {
896 // Record this paste, so we can do different behavior. 901 // Record this paste, so we can do different behavior.
897 model()->on_paste(); 902 model()->on_paste();
898 // Force a Paste operation to trigger the text_changed code in 903 // Force a Paste operation to trigger the text_changed code in
899 // OnAfterPossibleChange(), even if identical contents are pasted. 904 // OnAfterPossibleChange(), even if identical contents are pasted.
900 text_before_change_.clear(); 905 text_before_change_.clear();
901 ReplaceSelection(text); 906 ReplaceSelection(text);
902 } 907 }
903 } 908 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698