Chromium Code Reviews| Index: chrome/browser/google/google_util.cc |
| diff --git a/chrome/browser/google/google_util.cc b/chrome/browser/google/google_util.cc |
| index 1e5945984b18014f8518b5fbef89f64b43489b5e..cfe0911d8a503014ec8a2fc32a84f8de47863141 100644 |
| --- a/chrome/browser/google/google_util.cc |
| +++ b/chrome/browser/google/google_util.cc |
| @@ -20,6 +20,7 @@ |
| #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) |
| @@ -137,6 +138,26 @@ bool GetReactivationBrand(std::string* brand) { |
| #endif |
| +string16 GetSearchTermsFromGoogleSearchURL(const GURL& url) { |
| + if (!IsInstantExtendedAPIGoogleSearchUrl(url.spec())) |
| + return string16(); |
| + |
| + std::vector<std::pair<std::string, std::string> > key_value_pairs; |
| + base::SplitStringIntoKeyValuePairs(url.query(), '=', '&', &key_value_pairs); |
|
Ilya Sherman
2012/08/23 19:50:51
Optional nit: Did you consider using ExtractQueryK
dominich
2012/08/23 20:45:37
Thanks for the pointer - that's much better.
|
| + for (std::vector<std::pair<std::string, std::string> >::const_iterator it = |
| + key_value_pairs.begin(); it != key_value_pairs.end(); ++it) { |
| + if (it->first == "q") { |
| + return net::UnescapeAndDecodeUTF8URLComponent( |
| + it->second, |
| + net::UnescapeRule::SPACES | |
| + net::UnescapeRule::URL_SPECIAL_CHARS | |
| + net::UnescapeRule::REPLACE_PLUS_WITH_SPACE, |
| + NULL); |
| + } |
| + } |
| + return string16(); |
| +} |
| + |
| bool IsGoogleDomainUrl(const std::string& url, SubdomainPermission permission) { |
| GURL original_url(url); |
| return original_url.is_valid() && original_url.port().empty() && |