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

Unified Diff: chrome/browser/autocomplete/autocomplete.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/autocomplete.h ('k') | chrome/browser/autocomplete/history_contents_provider.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/autocomplete/autocomplete.cc
===================================================================
--- chrome/browser/autocomplete/autocomplete.cc (revision 17014)
+++ chrome/browser/autocomplete/autocomplete.cc (working copy)
@@ -24,6 +24,7 @@
#include "chrome/common/url_constants.h"
#include "googleurl/src/gurl.h"
#include "googleurl/src/url_canon_ip.h"
+#include "googleurl/src/url_util.h"
#include "grit/generated_resources.h"
#include "net/base/net_util.h"
#include "net/base/registry_controlled_domain.h"
@@ -474,6 +475,26 @@
profile_ = profile;
}
+// static
+size_t AutocompleteProvider::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;
+}
+
void AutocompleteProvider::UpdateStarredStateOfMatches() {
if (matches_.empty())
return;
« no previous file with comments | « chrome/browser/autocomplete/autocomplete.h ('k') | chrome/browser/autocomplete/history_contents_provider.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698