summaryrefslogtreecommitdiffstats
path: root/chrome/browser/autocomplete/search_provider.cc
diff options
context:
space:
mode:
authorpkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-05-29 00:10:17 +0000
committerpkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-05-29 00:10:17 +0000
commit45b2e16d81eb606ecbd102ca36dc51d87298f966 (patch)
tree1b1359211be9aede274ab6f824e88402fd433960 /chrome/browser/autocomplete/search_provider.cc
parent1c0be54a98e2f801e8fa22c01aac83e36485eee4 (diff)
downloadchromium_src-45b2e16d81eb606ecbd102ca36dc51d87298f966.zip
chromium_src-45b2e16d81eb606ecbd102ca36dc51d87298f966.tar.gz
chromium_src-45b2e16d81eb606ecbd102ca36dc51d87298f966.tar.bz2
Hoist TrimHttpPrefix() so we only have one copy, not one per provider.
Make use of this in HistoryContentsProvider so results from it get their schemes trimmed appropriately. BUG=10558 Review URL: http://codereview.chromium.org/115885 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@17145 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/autocomplete/search_provider.cc')
-rw-r--r--chrome/browser/autocomplete/search_provider.cc26
1 files changed, 2 insertions, 24 deletions
diff --git a/chrome/browser/autocomplete/search_provider.cc b/chrome/browser/autocomplete/search_provider.cc
index a4c3134..9d2dce4 100644
--- a/chrome/browser/autocomplete/search_provider.cc
+++ b/chrome/browser/autocomplete/search_provider.cc
@@ -748,9 +748,8 @@ AutocompleteMatch SearchProvider::NavigationToMatch(
AutocompleteMatch::NAVSUGGEST);
match.destination_url = navigation.url;
match.contents = StringForURLDisplay(navigation.url, true);
- // TODO(kochi): Consider moving HistoryURLProvider::TrimHttpPrefix() to some
- // public utility function.
- if (!url_util::FindAndCompareScheme(WideToUTF8(input_text), "http", NULL))
+ if (!url_util::FindAndCompareScheme(WideToUTF8(input_text),
+ chrome::kHttpScheme, NULL))
TrimHttpPrefix(&match.contents);
AutocompleteMatch::ClassifyMatchInString(input_text, match.contents,
ACMatchClassification::URL,
@@ -772,24 +771,3 @@ AutocompleteMatch SearchProvider::NavigationToMatch(
return match;
}
-
-// TODO(kochi): This is duplicate from HistoryURLProvider.
-// static
-size_t SearchProvider::TrimHttpPrefix(std::wstring* url) {
- url_parse::Component scheme;
- if (!url_util::FindAndCompareScheme(WideToUTF8(*url), chrome::kHttpScheme,
- &scheme))
- return 0; // Not "http".
-
- // Erase scheme plus up to two slashes.
- size_t prefix_len = scheme.end() + 1; // "http:"
- const size_t after_slashes = std::min(url->length(),
- static_cast<size_t>(scheme.end() + 3));
- while ((prefix_len < after_slashes) && ((*url)[prefix_len] == L'/'))
- ++prefix_len;
- if (prefix_len == url->length())
- url->clear();
- else
- url->erase(url->begin(), url->begin() + prefix_len);
- return prefix_len;
-}