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

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: Fixed mac typos and fixed unit test 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 807 matching lines...) Expand 10 before | Expand all | Expand 10 after
842 843
843 void OmniboxViewViews::EmphasizeURLComponents() { 844 void OmniboxViewViews::EmphasizeURLComponents() {
844 // See whether the contents are a URL with a non-empty host portion, which we 845 // See whether the contents are a URL with a non-empty host portion, which we
845 // should emphasize. To check for a URL, rather than using the type returned 846 // should emphasize. To check for a URL, rather than using the type returned
846 // by Parse(), ask the model, which will check the desired page transition for 847 // by Parse(), ask the model, which will check the desired page transition for
847 // this input. This can tell us whether an UNKNOWN input string is going to 848 // this input. This can tell us whether an UNKNOWN input string is going to
848 // be treated as a search or a navigation, and is the same method the Paste 849 // be treated as a search or a navigation, and is the same method the Paste
849 // And Go system uses. 850 // And Go system uses.
850 url_parse::Component scheme, host; 851 url_parse::Component scheme, host;
851 AutocompleteInput::ParseForEmphasizeComponents(text(), &scheme, &host); 852 AutocompleteInput::ParseForEmphasizeComponents(text(), &scheme, &host);
852 const bool emphasize = model()->CurrentTextIsURL() && (host.len > 0); 853 bool grey_out_url = text().substr(scheme.begin, scheme.len) ==
853 SetColor(location_bar_view_->GetColor(security_level_, 854 UTF8ToUTF16(extensions::kExtensionScheme);
854 emphasize ? LocationBarView::DEEMPHASIZED_TEXT : LocationBarView::TEXT)); 855 bool grey_base = model()->CurrentTextIsURL() &&
855 if (emphasize) { 856 (host.is_nonempty() || grey_out_url);
857 SetColor(location_bar_view_->GetColor(
858 security_level_,
859 grey_base ? LocationBarView::DEEMPHASIZED_TEXT : LocationBarView::TEXT));
860 if (grey_base && !grey_out_url) {
856 ApplyColor( 861 ApplyColor(
857 location_bar_view_->GetColor(security_level_, LocationBarView::TEXT), 862 location_bar_view_->GetColor(security_level_, LocationBarView::TEXT),
858 ui::Range(host.begin, host.end())); 863 ui::Range(host.begin, host.end()));
859 } 864 }
860 865
861 // Emphasize the scheme for security UI display purposes (if necessary). 866 // Emphasize the scheme for security UI display purposes (if necessary).
862 // Note that we check CurrentTextIsURL() because if we're replacing search 867 // Note that we check CurrentTextIsURL() because if we're replacing search
863 // URLs with search terms, we may have a non-URL even when the user is not 868 // URLs with search terms, we may have a non-URL even when the user is not
864 // editing; and in some cases, e.g. for "site:foo.com" searches, the parser 869 // editing; and in some cases, e.g. for "site:foo.com" searches, the parser
865 // may have incorrectly identified a qualifier as a scheme. 870 // may have incorrectly identified a qualifier as a scheme.
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
897 const string16 text(GetClipboardText()); 902 const string16 text(GetClipboardText());
898 if (!text.empty()) { 903 if (!text.empty()) {
899 // Record this paste, so we can do different behavior. 904 // Record this paste, so we can do different behavior.
900 model()->on_paste(); 905 model()->on_paste();
901 // Force a Paste operation to trigger the text_changed code in 906 // Force a Paste operation to trigger the text_changed code in
902 // OnAfterPossibleChange(), even if identical contents are pasted. 907 // OnAfterPossibleChange(), even if identical contents are pasted.
903 text_before_change_.clear(); 908 text_before_change_.clear();
904 ReplaceSelection(text); 909 ReplaceSelection(text);
905 } 910 }
906 } 911 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/toolbar/toolbar_model_unittest.cc ('k') | chrome/browser/ui/views/omnibox/omnibox_view_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698