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

Unified Diff: chrome/browser/google/google_util.cc

Issue 10908226: Introduces a search term extraction mechanism working for arbitrary search providers. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Removed version_46.sql, committed separately. Created 8 years, 2 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/google/google_util.h ('k') | chrome/browser/google/google_util_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/google/google_util.cc
diff --git a/chrome/browser/google/google_util.cc b/chrome/browser/google/google_util.cc
index 013437ec00a71f0e88795690e6a3e22d8578bf56..0d47f5675ab91f8479ddee5385c3c2b49f715810 100644
--- a/chrome/browser/google/google_util.cc
+++ b/chrome/browser/google/google_util.cc
@@ -19,8 +19,6 @@
#include "chrome/common/net/url_util.h"
#include "chrome/installer/util/google_update_settings.h"
#include "googleurl/src/gurl.h"
-#include "googleurl/src/url_parse.h"
-#include "net/base/escape.h"
#include "net/base/registry_controlled_domains/registry_controlled_domain.h"
#if defined(OS_MACOSX)
@@ -57,30 +55,6 @@ bool HasQueryParameter(const std::string& str) {
bool gUseMockLinkDoctorBaseURLForTesting = false;
-// Finds the first key-value pair where the key matches |query_key|. Returns
-// true if a match is found and sets |search_terms| to the value.
-bool ExtractSearchTermsFromComponent(const std::string& url,
- url_parse::Component* component,
- string16* search_terms) {
- const std::string query_key = "q";
- url_parse::Component key, value;
-
- while (url_parse::ExtractQueryKeyValue(url.c_str(), component,
- &key, &value)) {
- if (url.compare(key.begin, key.len, query_key) != 0)
- continue;
- std::string value_str = url.substr(value.begin, value.len);
- *search_terms = net::UnescapeAndDecodeUTF8URLComponent(
- value_str,
- net::UnescapeRule::SPACES |
- net::UnescapeRule::URL_SPECIAL_CHARS |
- net::UnescapeRule::REPLACE_PLUS_WITH_SPACE,
- NULL);
- return true;
- }
- return false;
-}
-
} // anonymous namespace
namespace google_util {
@@ -179,25 +153,6 @@ bool GetReactivationBrand(std::string* brand) {
#endif
-string16 GetSearchTermsFromGoogleSearchURL(const std::string& url) {
- if (!IsInstantExtendedAPIGoogleSearchUrl(url))
- return string16();
-
- url_parse::Parsed parsed_url;
- url_parse::ParseStandardURL(url.c_str(), url.length(), &parsed_url);
-
- string16 search_terms;
- // The search terms can be in either the query or ref component - for
- // instance, in a regular Google search they'll be in the query but in a
- // Google Instant search they can be in both. The ref is the correct one to
- // return in this case, so test the ref component first.
- if (ExtractSearchTermsFromComponent(url, &parsed_url.ref, &search_terms) ||
- ExtractSearchTermsFromComponent(url, &parsed_url.query, &search_terms)) {
- return search_terms;
- }
- return string16();
-}
-
bool IsGoogleDomainUrl(const std::string& url,
SubdomainPermission subdomain_permission,
PortPermission port_permission) {
« no previous file with comments | « chrome/browser/google/google_util.h ('k') | chrome/browser/google/google_util_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698