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

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: Address pkasting, tfarina, and remaining nits. 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
« 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 eda66b334eb9ae10da12bec84c65276edf8ab0cc..97a16a71542218656c77463fc861e1aa9d83afe4 100644
--- a/chrome/browser/google/google_util.cc
+++ b/chrome/browser/google/google_util.cc
@@ -9,6 +9,7 @@
#include "base/command_line.h"
#include "base/string16.h"
+#include "base/string_number_conversions.h"
#include "base/string_split.h"
#include "base/string_util.h"
#include "base/utf_string_conversions.h"
@@ -18,6 +19,7 @@
#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/registry_controlled_domain.h"
#if defined(OS_MACOSX)
@@ -203,6 +205,29 @@ bool IsGoogleSearchUrl(const std::string& url) {
(!is_home_page_base && HasQueryParameter(query));
}
+bool IsInstantExtendedAPIGoogleSearchUrl(const std::string& url) {
+ if (!IsGoogleSearchUrl(url))
+ return false;
+
+ const std::string embedded_search_key = "espv";
+
+ url_parse::Parsed parsed_url;
+ url_parse::ParseStandardURL(url.c_str(), url.length(), &parsed_url);
+ url_parse::Component key, value;
+ while (url_parse::ExtractQueryKeyValue(
+ url.c_str(), &parsed_url.query, &key, &value)) {
+ // If the parameter key is |embedded_search_key| and the value is not 0 this
+ // is an Instant Extended API Google search URL.
+ if (!url.compare(key.begin, key.len, embedded_search_key)) {
+ int int_value = 0;
+ if (value.is_nonempty())
+ base::StringToInt(url.substr(value.begin, value.len), &int_value);
+ return int_value != 0;
+ }
+ }
+ return false;
+}
+
bool IsOrganic(const std::string& brand) {
const CommandLine& command_line = *CommandLine::ForCurrentProcess();
if (command_line.HasSwitch(switches::kOrganicInstall))
« 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