summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/autocomplete/autocomplete_input.cc11
-rw-r--r--chrome/browser/autocomplete/autocomplete_input.h3
-rw-r--r--chrome/browser/autocomplete/autocomplete_provider.cc11
-rw-r--r--chrome/browser/autocomplete/autocomplete_provider.h3
-rw-r--r--chrome/browser/autocomplete/history_provider.cc4
-rw-r--r--chrome/browser/autocomplete/history_url_provider.cc4
-rw-r--r--chrome/browser/autocomplete/search_provider.cc3
7 files changed, 20 insertions, 19 deletions
diff --git a/chrome/browser/autocomplete/autocomplete_input.cc b/chrome/browser/autocomplete/autocomplete_input.cc
index 0ddfa5c..110fbea 100644
--- a/chrome/browser/autocomplete/autocomplete_input.cc
+++ b/chrome/browser/autocomplete/autocomplete_input.cc
@@ -13,6 +13,7 @@
#include "net/base/net_util.h"
#include "net/base/registry_controlled_domains/registry_controlled_domain.h"
#include "url/url_canon_ip.h"
+#include "url/url_util.h"
namespace {
@@ -497,6 +498,16 @@ int AutocompleteInput::NumNonHostComponents(const url_parse::Parsed& parts) {
return num_nonhost_components;
}
+// static
+bool AutocompleteInput::HasHTTPScheme(const string16& input) {
+ std::string utf8_input(UTF16ToUTF8(input));
+ url_parse::Component scheme;
+ if (url_util::FindAndCompareScheme(utf8_input, content::kViewSourceScheme,
+ &scheme))
+ utf8_input.erase(0, scheme.end() + 1);
+ return url_util::FindAndCompareScheme(utf8_input, content::kHttpScheme, NULL);
+}
+
void AutocompleteInput::UpdateText(const string16& text,
size_t cursor_position,
const url_parse::Parsed& parts) {
diff --git a/chrome/browser/autocomplete/autocomplete_input.h b/chrome/browser/autocomplete/autocomplete_input.h
index 6c6b2e8..b65ef67 100644
--- a/chrome/browser/autocomplete/autocomplete_input.h
+++ b/chrome/browser/autocomplete/autocomplete_input.h
@@ -183,6 +183,9 @@ class AutocompleteInput {
// Returns the number of non-empty components in |parts| besides the host.
static int NumNonHostComponents(const url_parse::Parsed& parts);
+ // Returns whether |text| begins "http:" or "view-source:http:".
+ static bool HasHTTPScheme(const string16& text);
+
// User-provided text to be completed.
const string16& text() const { return text_; }
diff --git a/chrome/browser/autocomplete/autocomplete_provider.cc b/chrome/browser/autocomplete/autocomplete_provider.cc
index 15af9ab..859b7e4 100644
--- a/chrome/browser/autocomplete/autocomplete_provider.cc
+++ b/chrome/browser/autocomplete/autocomplete_provider.cc
@@ -16,7 +16,6 @@
#include "content/public/common/url_constants.h"
#include "net/base/net_util.h"
#include "url/gurl.h"
-#include "url/url_util.h"
// static
const size_t AutocompleteProvider::kMaxMatches = 3;
@@ -122,16 +121,6 @@ AutocompleteProvider::~AutocompleteProvider() {
Stop(false);
}
-// static
-bool AutocompleteProvider::HasHTTPScheme(const string16& input) {
- std::string utf8_input(UTF16ToUTF8(input));
- url_parse::Component scheme;
- if (url_util::FindAndCompareScheme(utf8_input, content::kViewSourceScheme,
- &scheme))
- utf8_input.erase(0, scheme.end() + 1);
- return url_util::FindAndCompareScheme(utf8_input, content::kHttpScheme, NULL);
-}
-
void AutocompleteProvider::UpdateStarredStateOfMatches() {
if (matches_.empty())
return;
diff --git a/chrome/browser/autocomplete/autocomplete_provider.h b/chrome/browser/autocomplete/autocomplete_provider.h
index 950670d..02668b7 100644
--- a/chrome/browser/autocomplete/autocomplete_provider.h
+++ b/chrome/browser/autocomplete/autocomplete_provider.h
@@ -242,9 +242,6 @@ class AutocompleteProvider
virtual ~AutocompleteProvider();
- // Returns whether |input| begins "http:" or "view-source:http:".
- static bool HasHTTPScheme(const string16& input);
-
// Updates the starred state of each of the matches in matches_ from the
// profile's bookmark bar model.
void UpdateStarredStateOfMatches();
diff --git a/chrome/browser/autocomplete/history_provider.cc b/chrome/browser/autocomplete/history_provider.cc
index 32776b9..64d7063 100644
--- a/chrome/browser/autocomplete/history_provider.cc
+++ b/chrome/browser/autocomplete/history_provider.cc
@@ -95,7 +95,7 @@ bool HistoryProvider::FixupUserInput(AutocompleteInput* input) {
string16 output = UTF8ToUTF16(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.
- if (!HasHTTPScheme(input_text))
+ if (!AutocompleteInput::HasHTTPScheme(input_text))
TrimHttpPrefix(&output);
// Make the number of trailing slashes on the output exactly match the input.
@@ -135,7 +135,7 @@ bool HistoryProvider::FixupUserInput(AutocompleteInput* input) {
// static
size_t HistoryProvider::TrimHttpPrefix(string16* url) {
// Find any "http:".
- if (!HasHTTPScheme(*url))
+ if (!AutocompleteInput::HasHTTPScheme(*url))
return 0;
size_t scheme_pos =
url->find(ASCIIToUTF16(content::kHttpScheme) + char16(':'));
diff --git a/chrome/browser/autocomplete/history_url_provider.cc b/chrome/browser/autocomplete/history_url_provider.cc
index 789a3a5..fef8c71 100644
--- a/chrome/browser/autocomplete/history_url_provider.cc
+++ b/chrome/browser/autocomplete/history_url_provider.cc
@@ -390,7 +390,7 @@ AutocompleteMatch HistoryURLProvider::SuggestExactInput(
// |match_location| below. StringForURLDisplay() and TrimHttpPrefix() have
// slightly different behavior as well (the latter will strip even without
// two slashes after the scheme).
- DCHECK(!trim_http || !HasHTTPScheme(input.text()));
+ DCHECK(!trim_http || !AutocompleteInput::HasHTTPScheme(input.text()));
string16 display_string(provider->StringForURLDisplay(url, false, false));
const size_t offset = trim_http ? TrimHttpPrefix(&display_string) : 0;
match.fill_into_edit =
@@ -673,7 +673,7 @@ void HistoryURLProvider::RunAutocompletePasses(
// Create a match for exactly what the user typed. This will only be used as
// a fallback in case we can't get the history service or URL DB; otherwise,
// we'll run this again in DoAutocomplete() and use that result instead.
- const bool trim_http = !HasHTTPScheme(input.text());
+ const bool trim_http = !AutocompleteInput::HasHTTPScheme(input.text());
// Don't do this for queries -- while we can sometimes mark up a match for
// this, it's not what the user wants, and just adds noise.
if ((input.type() != AutocompleteInput::QUERY) &&
diff --git a/chrome/browser/autocomplete/search_provider.cc b/chrome/browser/autocomplete/search_provider.cc
index d1e5998..7373008 100644
--- a/chrome/browser/autocomplete/search_provider.cc
+++ b/chrome/browser/autocomplete/search_provider.cc
@@ -1689,7 +1689,8 @@ AutocompleteMatch SearchProvider::NavigationToMatch(
untrimmed_fill_into_edit.find(input) : prefix->prefix.length();
size_t inline_autocomplete_offset = (prefix == NULL) ?
string16::npos : (match_start + input.length());
- bool trim_http = !HasHTTPScheme(input) && (!prefix || (match_start != 0));
+ bool trim_http = !AutocompleteInput::HasHTTPScheme(input) &&
+ (!prefix || (match_start != 0));
// Preserve the forced query '?' prefix in |match.fill_into_edit|.
// Otherwise, user edits to a suggestion would show non-Search results.