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

Unified Diff: chrome/browser/autocomplete/autocomplete_match.cc

Issue 6731036: Enabled pressing TAB to cycle through the Omnibox results. (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: '' Created 9 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/autocomplete/autocomplete_match.cc
===================================================================
--- chrome/browser/autocomplete/autocomplete_match.cc (revision 81359)
+++ chrome/browser/autocomplete/autocomplete_match.cc (working copy)
@@ -16,9 +16,10 @@
transition(PageTransition::GENERATED),
is_history_what_you_typed_match(false),
type(SEARCH_WHAT_YOU_TYPED),
- template_url(NULL),
+ keyword_url(NULL),
starred(false),
- from_previous(false) {
+ from_previous(false),
+ keyword_state(NO_KEYWORD) {
}
AutocompleteMatch::AutocompleteMatch(AutocompleteProvider* provider,
@@ -32,9 +33,10 @@
transition(PageTransition::TYPED),
is_history_what_you_typed_match(false),
type(type),
- template_url(NULL),
+ keyword_url(NULL),
starred(false),
- from_previous(false) {
+ from_previous(false),
+ keyword_state(NO_KEYWORD) {
}
AutocompleteMatch::~AutocompleteMatch() {
@@ -94,15 +96,15 @@
// Sort identical destination_urls together. Place the most relevant matches
// first, so that when we call std::unique(), these are the ones that get
// preserved.
- return (elem1.destination_url != elem2.destination_url) ?
- (elem1.destination_url < elem2.destination_url) :
+ return (elem1.stripped_destination_url != elem2.stripped_destination_url) ?
+ (elem1.stripped_destination_url < elem2.stripped_destination_url) :
MoreRelevant(elem1, elem2);
}
// static
bool AutocompleteMatch::DestinationsEqual(const AutocompleteMatch& elem1,
const AutocompleteMatch& elem2) {
- return elem1.destination_url == elem2.destination_url;
+ return elem1.stripped_destination_url == elem2.stripped_destination_url;
}
// static
@@ -151,6 +153,22 @@
}
}
+void AutocompleteMatch::ComputeStrippedDestinationURL() {
+ static const char prefix[] = "www.";
+ static const size_t prefix_len = arraysize(prefix) - 1;
+
+ std::string host = destination_url.host();
+ if (destination_url.is_valid() && host.compare(0, prefix_len, prefix) == 0) {
+ host = host.substr(prefix_len);
+ GURL::Replacements replace_host;
+ replace_host.SetHostStr(host);
+ stripped_destination_url =
+ destination_url.ReplaceComponents(replace_host);
+ } else {
+ stripped_destination_url = destination_url;
+ }
+}
+
#ifndef NDEBUG
void AutocompleteMatch::Validate() const {
ValidateClassifications(contents, contents_class);

Powered by Google App Engine
This is Rietveld 408576698