Index: chrome/browser/autocomplete/history_url_provider.cc |
=================================================================== |
--- chrome/browser/autocomplete/history_url_provider.cc (revision 43890) |
+++ chrome/browser/autocomplete/history_url_provider.cc (working copy) |
@@ -1,4 +1,4 @@ |
-// Copyright (c) 2009 The Chromium Authors. All rights reserved. |
+// Copyright (c) 2010 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. |
@@ -256,11 +256,9 @@ |
const GURL& url = input.canonicalized_url(); |
if (url.is_valid()) { |
match.destination_url = url; |
- match.fill_into_edit = StringForURLDisplay(url, false); |
+ match.fill_into_edit = StringForURLDisplay(url, false, trim_http); |
// NOTE: Don't set match.input_location (to allow inline autocompletion) |
// here, it's surprising and annoying. |
- // Trim off "http://" if the user didn't type it. |
- const size_t offset = trim_http ? TrimHttpPrefix(&match.fill_into_edit) : 0; |
// Try to highlight "innermost" match location. If we fix up "w" into |
// "www.w.com", we want to highlight the fifth character, not the first. |
@@ -272,7 +270,7 @@ |
// to not contain the user's input at all. In this case don't mark anything |
// as a match. |
const size_t match_location = (best_prefix == NULL) ? |
- std::wstring::npos : best_prefix->prefix.length() - offset; |
+ std::wstring::npos : best_prefix->prefix.length(); |
AutocompleteMatch::ClassifyLocationInString(match_location, |
input.text().length(), |
match.contents.length(), |
@@ -828,17 +826,13 @@ |
DCHECK(match.destination_url.is_valid()); |
size_t inline_autocomplete_offset = |
history_match.input_location + params->input.text().length(); |
+ const net::FormatUrlTypes format_types = |
+ (params->trim_http && !history_match.match_in_scheme) ? |
+ net::kFormatUrlOmitAll : net::kFormatUrlOmitUsernamePassword; |
match.fill_into_edit = net::FormatUrl(info.url(), |
- match_type == WHAT_YOU_TYPED ? std::wstring() : params->languages, true, |
- UnescapeRule::SPACES, NULL, NULL, &inline_autocomplete_offset); |
- size_t offset = 0; |
- if (params->trim_http && !history_match.match_in_scheme) { |
- offset = TrimHttpPrefix(&match.fill_into_edit); |
- if (inline_autocomplete_offset != std::wstring::npos) { |
- DCHECK(inline_autocomplete_offset >= offset); |
- inline_autocomplete_offset -= offset; |
- } |
- } |
+ match_type == WHAT_YOU_TYPED ? std::wstring() : params->languages, |
+ format_types, UnescapeRule::SPACES, NULL, NULL, |
+ &inline_autocomplete_offset); |
if (!params->input.prevent_inline_autocomplete()) |
match.inline_autocomplete_offset = inline_autocomplete_offset; |
DCHECK((match.inline_autocomplete_offset == std::wstring::npos) || |
@@ -846,15 +840,8 @@ |
size_t match_start = history_match.input_location; |
match.contents = net::FormatUrl(info.url(), |
- match_type == WHAT_YOU_TYPED ? std::wstring() : params->languages, true, |
- UnescapeRule::SPACES, NULL, NULL, &match_start); |
- if (offset) { |
- TrimHttpPrefix(&match.contents); |
- if (match_start != std::wstring::npos) { |
- DCHECK(match_start >= offset); |
- match_start -= offset; |
- } |
- } |
+ match_type == WHAT_YOU_TYPED ? std::wstring() : params->languages, |
+ format_types, UnescapeRule::SPACES, NULL, NULL, &match_start); |
if ((match_start != std::wstring::npos) && |
(inline_autocomplete_offset != std::wstring::npos) && |
(inline_autocomplete_offset != match_start)) { |