summaryrefslogtreecommitdiffstats
path: root/chrome/browser/autocomplete
diff options
context:
space:
mode:
authorsky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-04-09 22:20:40 +0000
committersky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-04-09 22:20:40 +0000
commit1685f9b0efb3f65bc084e8b012357e2986d073d1 (patch)
treedafcc9e7d2bf8cddff882638432bd492c983fd77 /chrome/browser/autocomplete
parent6d1b928bc85521046fa7713abadc762beba11881 (diff)
downloadchromium_src-1685f9b0efb3f65bc084e8b012357e2986d073d1.zip
chromium_src-1685f9b0efb3f65bc084e8b012357e2986d073d1.tar.gz
chromium_src-1685f9b0efb3f65bc084e8b012357e2986d073d1.tar.bz2
Strips http from the omnibox
BUG=none TEST=type in urls and make sure once loaded we don't show http. Make sure we do show https (and other schemes) though. Review URL: http://codereview.chromium.org/1513023 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@44140 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/autocomplete')
-rw-r--r--chrome/browser/autocomplete/autocomplete.cc8
-rw-r--r--chrome/browser/autocomplete/autocomplete.h3
-rw-r--r--chrome/browser/autocomplete/history_contents_provider.cc6
-rw-r--r--chrome/browser/autocomplete/history_url_provider.cc35
-rw-r--r--chrome/browser/autocomplete/search_provider.cc7
5 files changed, 24 insertions, 35 deletions
diff --git a/chrome/browser/autocomplete/autocomplete.cc b/chrome/browser/autocomplete/autocomplete.cc
index b6d7764..1278a9b 100644
--- a/chrome/browser/autocomplete/autocomplete.cc
+++ b/chrome/browser/autocomplete/autocomplete.cc
@@ -595,10 +595,14 @@ void AutocompleteProvider::UpdateStarredStateOfMatches() {
std::wstring AutocompleteProvider::StringForURLDisplay(
const GURL& url,
- bool check_accept_lang) const {
+ bool check_accept_lang,
+ bool trim_http) const {
std::wstring languages = (check_accept_lang && profile_) ?
profile_->GetPrefs()->GetString(prefs::kAcceptLanguages) : std::wstring();
- return net::FormatUrl(url, languages);
+ const net::FormatUrlTypes format_types = trim_http ?
+ net::kFormatUrlOmitAll : net::kFormatUrlOmitUsernamePassword;
+ return net::FormatUrl(url, languages, format_types, UnescapeRule::SPACES,
+ NULL, NULL, NULL);
}
// AutocompleteResult ---------------------------------------------------------
diff --git a/chrome/browser/autocomplete/autocomplete.h b/chrome/browser/autocomplete/autocomplete.h
index 124783f1..54bd9ff 100644
--- a/chrome/browser/autocomplete/autocomplete.h
+++ b/chrome/browser/autocomplete/autocomplete.h
@@ -561,7 +561,8 @@ class AutocompleteProvider
// "Accept Languages" when check_accept_lang is true. Otherwise, it's called
// with an empty list.
std::wstring StringForURLDisplay(const GURL& url,
- bool check_accept_lang) const;
+ bool check_accept_lang,
+ bool trim_http) const;
// The profile associated with the AutocompleteProvider. Reference is not
// owned by us.
diff --git a/chrome/browser/autocomplete/history_contents_provider.cc b/chrome/browser/autocomplete/history_contents_provider.cc
index ac81c31..1e72ceb 100644
--- a/chrome/browser/autocomplete/history_contents_provider.cc
+++ b/chrome/browser/autocomplete/history_contents_provider.cc
@@ -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.
@@ -207,11 +207,9 @@ AutocompleteMatch HistoryContentsProvider::ResultToMatch(
// Also show star in popup.
AutocompleteMatch match(this, score, false, MatchInTitle(result) ?
AutocompleteMatch::HISTORY_TITLE : AutocompleteMatch::HISTORY_BODY);
- match.fill_into_edit = StringForURLDisplay(result.url(), true);
+ match.fill_into_edit = StringForURLDisplay(result.url(), true, trim_http_);
match.destination_url = result.url();
match.contents = match.fill_into_edit;
- if (trim_http_)
- TrimHttpPrefix(&match.contents);
match.contents_class.push_back(
ACMatchClassification(0, ACMatchClassification::URL));
match.description = result.title();
diff --git a/chrome/browser/autocomplete/history_url_provider.cc b/chrome/browser/autocomplete/history_url_provider.cc
index 2708d47..8462925 100644
--- a/chrome/browser/autocomplete/history_url_provider.cc
+++ b/chrome/browser/autocomplete/history_url_provider.cc
@@ -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 @@ AutocompleteMatch HistoryURLProvider::SuggestExactInput(
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 @@ AutocompleteMatch HistoryURLProvider::SuggestExactInput(
// 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 @@ AutocompleteMatch HistoryURLProvider::HistoryMatchToACMatch(
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 @@ AutocompleteMatch HistoryURLProvider::HistoryMatchToACMatch(
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)) {
diff --git a/chrome/browser/autocomplete/search_provider.cc b/chrome/browser/autocomplete/search_provider.cc
index 9a01fef..acba81e 100644
--- a/chrome/browser/autocomplete/search_provider.cc
+++ b/chrome/browser/autocomplete/search_provider.cc
@@ -737,10 +737,9 @@ AutocompleteMatch SearchProvider::NavigationToMatch(
AutocompleteMatch match(this, relevance, false,
AutocompleteMatch::NAVSUGGEST);
match.destination_url = navigation.url;
- match.contents = StringForURLDisplay(navigation.url, true);
- if (!url_util::FindAndCompareScheme(WideToUTF8(input_text),
- chrome::kHttpScheme, NULL))
- TrimHttpPrefix(&match.contents);
+ const bool trim_http = !url_util::FindAndCompareScheme(
+ WideToUTF8(input_text), chrome::kHttpScheme, NULL);
+ match.contents = StringForURLDisplay(navigation.url, true, trim_http);
AutocompleteMatch::ClassifyMatchInString(input_text, match.contents,
ACMatchClassification::URL,
&match.contents_class);