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

Side by Side Diff: chrome/browser/autocomplete/history_url_provider.cc

Issue 18878007: Omnibox: Make the Controller Reorder Matches for Inlining (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Peter's comments Created 7 years, 5 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 | Annotate | Revision Log
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/autocomplete/history_url_provider.h" 5 #include "chrome/browser/autocomplete/history_url_provider.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after
342 // NOTE: We use TrimHttpPrefix() here rather than StringForURLDisplay() to 342 // NOTE: We use TrimHttpPrefix() here rather than StringForURLDisplay() to
343 // strip the scheme as we need to know the offset so we can adjust the 343 // strip the scheme as we need to know the offset so we can adjust the
344 // |match_location| below. StringForURLDisplay() and TrimHttpPrefix() have 344 // |match_location| below. StringForURLDisplay() and TrimHttpPrefix() have
345 // slightly different behavior as well (the latter will strip even without 345 // slightly different behavior as well (the latter will strip even without
346 // two slashes after the scheme). 346 // two slashes after the scheme).
347 string16 display_string(provider->StringForURLDisplay(url, false, false)); 347 string16 display_string(provider->StringForURLDisplay(url, false, false));
348 const size_t offset = trim_http ? TrimHttpPrefix(&display_string) : 0; 348 const size_t offset = trim_http ? TrimHttpPrefix(&display_string) : 0;
349 match.fill_into_edit = 349 match.fill_into_edit =
350 AutocompleteInput::FormattedStringWithEquivalentMeaning(url, 350 AutocompleteInput::FormattedStringWithEquivalentMeaning(url,
351 display_string); 351 display_string);
352 match.allowed_to_be_default_match = true;
msw 2013/07/18 06:23:57 How does this relate to the seemingly contradictor
Peter Kasting 2013/07/18 17:35:28 We do want the match to be default, we just don't
msw 2013/07/18 17:46:53 Ah, thanks for clarifying.
352 // NOTE: Don't set match.inline_autocomplete_offset (to allow inline 353 // NOTE: Don't set match.inline_autocomplete_offset (to allow inline
353 // autocompletion) here, it's surprising and annoying. 354 // autocompletion) here, it's surprising and annoying.
354 355
355 // Try to highlight "innermost" match location. If we fix up "w" into 356 // Try to highlight "innermost" match location. If we fix up "w" into
356 // "www.w.com", we want to highlight the fifth character, not the first. 357 // "www.w.com", we want to highlight the fifth character, not the first.
357 // This relies on match.destination_url being the non-prefix-trimmed version 358 // This relies on match.destination_url being the non-prefix-trimmed version
358 // of match.contents. 359 // of match.contents.
359 match.contents = display_string; 360 match.contents = display_string;
360 const URLPrefix* best_prefix = URLPrefix::BestURLPrefix( 361 const URLPrefix* best_prefix = URLPrefix::BestURLPrefix(
361 UTF8ToUTF16(match.destination_url.spec()), input.text()); 362 UTF8ToUTF16(match.destination_url.spec()), input.text());
(...skipping 690 matching lines...) Expand 10 before | Expand all | Expand 10 after
1052 std::string languages = (match_type == WHAT_YOU_TYPED) ? 1053 std::string languages = (match_type == WHAT_YOU_TYPED) ?
1053 std::string() : params->languages; 1054 std::string() : params->languages;
1054 const net::FormatUrlTypes format_types = net::kFormatUrlOmitAll & 1055 const net::FormatUrlTypes format_types = net::kFormatUrlOmitAll &
1055 ~((params->trim_http && !history_match.match_in_scheme) ? 1056 ~((params->trim_http && !history_match.match_in_scheme) ?
1056 0 : net::kFormatUrlOmitHTTP); 1057 0 : net::kFormatUrlOmitHTTP);
1057 match.fill_into_edit = 1058 match.fill_into_edit =
1058 AutocompleteInput::FormattedStringWithEquivalentMeaning(info.url(), 1059 AutocompleteInput::FormattedStringWithEquivalentMeaning(info.url(),
1059 net::FormatUrl(info.url(), languages, format_types, 1060 net::FormatUrl(info.url(), languages, format_types,
1060 net::UnescapeRule::SPACES, NULL, NULL, 1061 net::UnescapeRule::SPACES, NULL, NULL,
1061 &inline_autocomplete_offset)); 1062 &inline_autocomplete_offset));
1062 if (!params->prevent_inline_autocomplete) 1063 if (!params->prevent_inline_autocomplete) {
1064 match.allowed_to_be_default_match = true;
msw 2013/07/18 06:23:57 Should this only be true is inline_autocomplete_of
Peter Kasting 2013/07/18 17:35:28 I don't think so but I'm not actually sure.
Mark P 2013/07/21 20:31:05 I think the current code is right: HistoryURL pro
msw 2013/07/23 21:55:32 It looks like you took my suggestion in r212693 an
Mark P 2013/07/26 16:48:13 Thought more; revised this code.
1063 match.inline_autocomplete_offset = inline_autocomplete_offset; 1065 match.inline_autocomplete_offset = inline_autocomplete_offset;
1066 }
1064 DCHECK((match.inline_autocomplete_offset == string16::npos) || 1067 DCHECK((match.inline_autocomplete_offset == string16::npos) ||
1065 (match.inline_autocomplete_offset <= match.fill_into_edit.length())); 1068 (match.inline_autocomplete_offset <= match.fill_into_edit.length()));
1066 1069
1067 size_t match_start = history_match.input_location; 1070 size_t match_start = history_match.input_location;
1068 match.contents = net::FormatUrl(info.url(), languages, 1071 match.contents = net::FormatUrl(info.url(), languages,
1069 format_types, net::UnescapeRule::SPACES, NULL, NULL, &match_start); 1072 format_types, net::UnescapeRule::SPACES, NULL, NULL, &match_start);
1070 if ((match_start != string16::npos) && 1073 if ((match_start != string16::npos) &&
1071 (inline_autocomplete_offset != string16::npos) && 1074 (inline_autocomplete_offset != string16::npos) &&
1072 (inline_autocomplete_offset != match_start)) { 1075 (inline_autocomplete_offset != match_start)) {
1073 DCHECK(inline_autocomplete_offset > match_start); 1076 DCHECK(inline_autocomplete_offset > match_start);
1074 AutocompleteMatch::ClassifyLocationInString(match_start, 1077 AutocompleteMatch::ClassifyLocationInString(match_start,
1075 inline_autocomplete_offset - match_start, match.contents.length(), 1078 inline_autocomplete_offset - match_start, match.contents.length(),
1076 ACMatchClassification::URL, &match.contents_class); 1079 ACMatchClassification::URL, &match.contents_class);
1077 } else { 1080 } else {
1078 AutocompleteMatch::ClassifyLocationInString(string16::npos, 0, 1081 AutocompleteMatch::ClassifyLocationInString(string16::npos, 0,
1079 match.contents.length(), ACMatchClassification::URL, 1082 match.contents.length(), ACMatchClassification::URL,
1080 &match.contents_class); 1083 &match.contents_class);
1081 } 1084 }
1082 match.description = info.title(); 1085 match.description = info.title();
1083 AutocompleteMatch::ClassifyMatchInString(params->input.text(), 1086 AutocompleteMatch::ClassifyMatchInString(params->input.text(),
1084 info.title(), 1087 info.title(),
1085 ACMatchClassification::NONE, 1088 ACMatchClassification::NONE,
1086 &match.description_class); 1089 &match.description_class);
1087 RecordAdditionalInfoFromUrlRow(info, &match); 1090 RecordAdditionalInfoFromUrlRow(info, &match);
1088 return match; 1091 return match;
1089 } 1092 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698