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

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

Issue 10644002: Add core plumbing for Instant Extended work (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Header Created 8 years, 6 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
Index: chrome/browser/google/google_util.cc
diff --git a/chrome/browser/google/google_util.cc b/chrome/browser/google/google_util.cc
index eda66b334eb9ae10da12bec84c65276edf8ab0cc..ef297f1ae8346abe3c8a5695a53266019e88fdab 100644
--- a/chrome/browser/google/google_util.cc
+++ b/chrome/browser/google/google_util.cc
@@ -203,6 +203,27 @@ bool IsGoogleSearchUrl(const std::string& url) {
(!is_home_page_base && HasQueryParameter(query));
}
+bool IsEmbeddedGoogleSearchUrl(const std::string& url) {
+ if (!IsGoogleSearchUrl(url))
+ return false;
+
+ const std::string embedded_search_key = "espv=";
+
+ GURL original_url(url);
+ std::vector<std::string> parameters;
+ base::SplitString(original_url.query(), '&', &parameters);
+ for (std::vector<std::string>::const_iterator it = parameters.begin();
+ it != parameters.end(); ++it) {
+ // If the parameter key is |embedded_search_key| and the value is not 0 this
+ // is an embedded Google search URL.
+ if (StartsWithASCII(*it, embedded_search_key, true)) {
+ std::string value = it->substr(embedded_search_key.length());
+ return value.length() > 0 && value != "0";
Ilya Sherman 2012/06/21 17:46:58 Optional nit: "value.length() > 0" -> "!value.empt
dhollowa 2012/06/21 22:16:43 Done. Rephrased with |Component| terminology.
+ }
+ }
Ilya Sherman 2012/06/21 17:46:58 You might want to use GURL's implementation [1] fo
dhollowa 2012/06/21 22:16:43 Much better. Thanks for the tip! On 2012/06/21 1
+ return false;
+}
+
bool IsOrganic(const std::string& brand) {
const CommandLine& command_line = *CommandLine::ForCurrentProcess();
if (command_line.HasSwitch(switches::kOrganicInstall))

Powered by Google App Engine
This is Rietveld 408576698