diff options
author | mrossetti@chromium.org <mrossetti@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-01-30 21:04:39 +0000 |
---|---|---|
committer | mrossetti@chromium.org <mrossetti@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-01-30 21:04:39 +0000 |
commit | 29a89ddaa26fc11e66dac8f9c3f904231af220b3 (patch) | |
tree | 56ee554dc38dff11b955929b4a0c7481f4fe290b /chrome/browser/autocomplete/history_quick_provider.cc | |
parent | 63f52fc08cf9ba569ecf879c0125cd277d69d2bf (diff) | |
download | chromium_src-29a89ddaa26fc11e66dac8f9c3f904231af220b3.zip chromium_src-29a89ddaa26fc11e66dac8f9c3f904231af220b3.tar.gz chromium_src-29a89ddaa26fc11e66dac8f9c3f904231af220b3.tar.bz2 |
Properly calculate inline autocomplete offset.
The calculation of the inline_autocomplete_offset_ was incorrect. Eliminated unnecessary function parameter.
BUG=110892
TEST=1) Visit an URL such as "www.amazon.com". 2) Now type 'ama' into the omnibox. 3) Verify that the presentation is "ama[zon.com]" where the bracketted section is the to-be-autocompleted portion. Also enhanced the HistoryQuickProviderTest unit tests.
Review URL: https://chromiumcodereview.appspot.com/9298017
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@119730 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/autocomplete/history_quick_provider.cc')
-rw-r--r-- | chrome/browser/autocomplete/history_quick_provider.cc | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/chrome/browser/autocomplete/history_quick_provider.cc b/chrome/browser/autocomplete/history_quick_provider.cc index 8c3fe80..8c7d7fc 100644 --- a/chrome/browser/autocomplete/history_quick_provider.cc +++ b/chrome/browser/autocomplete/history_quick_provider.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -98,7 +98,7 @@ void HistoryQuickProvider::DoAutocomplete() { const ScoredHistoryMatch& history_match(*match_iter); if (history_match.raw_score > 0) { AutocompleteMatch ac_match = QuickMatchToACMatch( - history_match, matches, + history_match, PreventInlineAutocomplete(autocomplete_input_), &max_match_score); matches_.push_back(ac_match); @@ -108,7 +108,6 @@ void HistoryQuickProvider::DoAutocomplete() { AutocompleteMatch HistoryQuickProvider::QuickMatchToACMatch( const ScoredHistoryMatch& history_match, - const ScoredHistoryMatches& history_matches, bool prevent_inline_autocomplete, int* max_match_score) { DCHECK(max_match_score); @@ -123,19 +122,24 @@ AutocompleteMatch HistoryQuickProvider::QuickMatchToACMatch( // Format the URL autocomplete presentation. std::vector<size_t> offsets = OffsetsFromTermMatches(history_match.url_matches); - match.contents = net::FormatUrlWithOffsets(info.url(), languages_, - net::kFormatUrlOmitAll, net::UnescapeRule::SPACES, NULL, NULL, &offsets); + const net::FormatUrlTypes format_types = net::kFormatUrlOmitAll & + ~(!history_match.match_in_scheme ? 0 : net::kFormatUrlOmitHTTP); + match.fill_into_edit = + AutocompleteInput::FormattedStringWithEquivalentMeaning(info.url(), + net::FormatUrlWithOffsets(info.url(), languages_, format_types, + net::UnescapeRule::SPACES, NULL, NULL, &offsets)); + match.contents = net::FormatUrl(info.url(), languages_); history::TermMatches new_matches = ReplaceOffsetsInTermMatches(history_match.url_matches, offsets); match.contents_class = SpansFromTermMatch(new_matches, match.contents.length(), true); - match.fill_into_edit = match.contents; if (prevent_inline_autocomplete || !history_match.can_inline) { match.inline_autocomplete_offset = string16::npos; } else { - match.inline_autocomplete_offset = - history_match.input_location + match.fill_into_edit.length(); + DCHECK(!new_matches.empty()); + match.inline_autocomplete_offset = new_matches[0].offset + + new_matches[0].length; DCHECK_LE(match.inline_autocomplete_offset, match.fill_into_edit.length()); } |