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

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

Issue 10867038: A simple version of search term replacement for testing . (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 4 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/ui/browser_browsertest.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 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() &&
« no previous file with comments | « chrome/browser/google/google_util.h ('k') | chrome/browser/ui/browser_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698