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

Unified Diff: chrome/browser/autocomplete/history_url_provider.cc

Issue 115885: Hoist TrimHttpPrefix() so we only have one copy, not one per provider.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 11 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/autocomplete/history_url_provider.h ('k') | chrome/browser/autocomplete/search_provider.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/autocomplete/history_url_provider.cc
===================================================================
--- chrome/browser/autocomplete/history_url_provider.cc (revision 17014)
+++ chrome/browser/autocomplete/history_url_provider.cc (working copy)
@@ -372,10 +372,9 @@
std::wstring output(UTF8ToWide(canonical_gurl_str));
// Don't prepend a scheme when the user didn't have one. Since the fixer
// upper only prepends the "http" scheme, that's all we need to check for.
- url_parse::Component scheme;
if (canonical_gurl.SchemeIs(chrome::kHttpScheme) &&
!url_util::FindAndCompareScheme(WideToUTF8(input_text),
- chrome::kHttpScheme, &scheme))
+ chrome::kHttpScheme, NULL))
TrimHttpPrefix(&output);
// Make the number of trailing slashes on the output exactly match the input.
@@ -408,26 +407,6 @@
}
// static
-size_t HistoryURLProvider::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;
-}
-
-// static
bool HistoryURLProvider::IsHostOnly(const GURL& url) {
DCHECK(url.is_valid());
return (!url.has_path() || (url.path() == "/")) && !url.has_query() &&
« no previous file with comments | « chrome/browser/autocomplete/history_url_provider.h ('k') | chrome/browser/autocomplete/search_provider.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698