summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjeremycho@chromium.org <jeremycho@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-06-13 01:08:03 +0000
committerjeremycho@chromium.org <jeremycho@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-06-13 01:08:03 +0000
commit448b17f56f96134ba1119a212bc756345a63da6f (patch)
treefdceb434e4836e0b1e04bd107c6d8a9a89fd6099
parent283f0a5701a15772af2d2103bf52010e4b3cf999 (diff)
downloadchromium_src-448b17f56f96134ba1119a212bc756345a63da6f.zip
chromium_src-448b17f56f96134ba1119a212bc756345a63da6f.tar.gz
chromium_src-448b17f56f96134ba1119a212bc756345a63da6f.tar.bz2
This includes a new URL path /_/contextualsearch and a /search parameter specifying the contextual search version, if any.
BUG=379196 Review URL: https://codereview.chromium.org/308053009 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@276874 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/android/java/src/org/chromium/chrome/browser/search_engines/TemplateUrlService.java12
-rw-r--r--chrome/browser/search_engines/template_url.cc125
-rw-r--r--chrome/browser/search_engines/template_url.h45
-rw-r--r--chrome/browser/search_engines/template_url_prepopulate_data.cc13
-rw-r--r--chrome/browser/search_engines/template_url_prepopulate_data_unittest.cc2
-rw-r--r--chrome/browser/search_engines/template_url_service_android.cc19
-rw-r--r--chrome/browser/search_engines/template_url_service_android.h4
-rw-r--r--chrome/browser/search_engines/template_url_unittest.cc27
-rw-r--r--components/search_engines/prepopulated_engines.json3
-rw-r--r--components/search_engines/prepopulated_engines_schema.json2
-rw-r--r--components/search_engines/template_url_data.h1
11 files changed, 227 insertions, 26 deletions
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/search_engines/TemplateUrlService.java b/chrome/android/java/src/org/chromium/chrome/browser/search_engines/TemplateUrlService.java
index 0536558..efca1cf 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/search_engines/TemplateUrlService.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/search_engines/TemplateUrlService.java
@@ -223,6 +223,16 @@ public class TemplateUrlService {
return nativeReplaceSearchTermsInUrl(mNativeTemplateUrlServiceAndroid, query, url);
}
+ /**
+ * Finds the default search engine for the default provider and returns the url query
+ * {@link String} for {@code query} with the contextual search version param set.
+ * @return A {@link String} that contains the url of the default search engine with
+ * {@code query} inserted as the search parameter and contextual search param set.
+ */
+ public String getUrlForContextualSearchQuery(String query) {
+ return nativeGetUrlForContextualSearchQuery(mNativeTemplateUrlServiceAndroid, query);
+ }
+
private native long nativeInit();
private native void nativeLoad(long nativeTemplateUrlServiceAndroid);
private native boolean nativeIsLoaded(long nativeTemplateUrlServiceAndroid);
@@ -241,4 +251,6 @@ public class TemplateUrlService {
String query);
private native String nativeReplaceSearchTermsInUrl(long nativeTemplateUrlServiceAndroid,
String query, String currentUrl);
+ private native String nativeGetUrlForContextualSearchQuery(long nativeTemplateUrlServiceAndroid,
+ String query);
}
diff --git a/chrome/browser/search_engines/template_url.cc b/chrome/browser/search_engines/template_url.cc
index 227700b..b92f72f 100644
--- a/chrome/browser/search_engines/template_url.cc
+++ b/chrome/browser/search_engines/template_url.cc
@@ -63,9 +63,17 @@ const char kGoogleBaseURLParameterFull[] = "{google:baseURL}";
const char kGoogleBaseSuggestURLParameter[] = "google:baseSuggestURL";
const char kGoogleBaseSuggestURLParameterFull[] = "{google:baseSuggestURL}";
const char kGoogleBookmarkBarPinnedParameter[] = "google:bookmarkBarPinned";
+const char kGoogleContextualSearchContextData[] =
+ "google:contextualSearchContextData";
+const char kGoogleContextualSearchVersion[] = "google:contextualSearchVersion";
const char kGoogleCurrentPageUrlParameter[] = "google:currentPageUrl";
const char kGoogleCursorPositionParameter[] = "google:cursorPosition";
const char kGoogleForceInstantResultsParameter[] = "google:forceInstantResults";
+const char kGoogleImageSearchSource[] = "google:imageSearchSource";
+const char kGoogleImageThumbnailParameter[] = "google:imageThumbnail";
+const char kGoogleImageOriginalWidth[] = "google:imageOriginalWidth";
+const char kGoogleImageOriginalHeight[] = "google:imageOriginalHeight";
+const char kGoogleImageURLParameter[] = "google:imageURL";
const char kGoogleInputTypeParameter[] = "google:inputType";
const char kGoogleInstantExtendedEnabledParameter[] =
"google:instantExtendedEnabledParameter";
@@ -96,12 +104,6 @@ const char kGoogleUnescapedSearchTermsParameter[] =
const char kGoogleUnescapedSearchTermsParameterFull[] =
"{google:unescapedSearchTerms}";
-const char kGoogleImageSearchSource[] = "google:imageSearchSource";
-const char kGoogleImageThumbnailParameter[] = "google:imageThumbnail";
-const char kGoogleImageURLParameter[] = "google:imageURL";
-const char kGoogleImageOriginalWidth[] = "google:imageOriginalWidth";
-const char kGoogleImageOriginalHeight[] = "google:imageOriginalHeight";
-
// Display value for kSearchTermsParameter.
const char kDisplaySearchTerms[] = "%s";
@@ -209,12 +211,41 @@ TemplateURLRef::SearchTermsArgs::SearchTermsArgs(
bookmark_bar_pinned(false),
append_extra_query_params(false),
force_instant_results(false),
- from_app_list(false) {
+ from_app_list(false),
+ contextual_search_params(ContextualSearchParams()) {
}
TemplateURLRef::SearchTermsArgs::~SearchTermsArgs() {
}
+TemplateURLRef::SearchTermsArgs::ContextualSearchParams::
+ ContextualSearchParams()
+ : version(-1),
+ start(base::string16::npos),
+ end(base::string16::npos) {
+}
+
+TemplateURLRef::SearchTermsArgs::ContextualSearchParams::
+ ContextualSearchParams(
+ const int version,
+ const size_t start,
+ const size_t end,
+ const std::string& selection,
+ const std::string& content,
+ const std::string& base_page_url,
+ const std::string& encoding)
+ : version(version),
+ start(start),
+ end(end),
+ selection(selection),
+ content(content),
+ base_page_url(base_page_url),
+ encoding(encoding) {
+}
+
+TemplateURLRef::SearchTermsArgs::ContextualSearchParams::
+ ~ContextualSearchParams() {
+}
// TemplateURLRef -------------------------------------------------------------
@@ -251,24 +282,26 @@ TemplateURLRef::~TemplateURLRef() {
std::string TemplateURLRef::GetURL() const {
switch (type_) {
- case SEARCH: return owner_->url();
- case SUGGEST: return owner_->suggestions_url();
- case INSTANT: return owner_->instant_url();
- case IMAGE: return owner_->image_url();
- case NEW_TAB: return owner_->new_tab_url();
- case INDEXED: return owner_->GetURL(index_in_owner_);
- default: NOTREACHED(); return std::string(); // NOLINT
+ case SEARCH: return owner_->url();
+ case SUGGEST: return owner_->suggestions_url();
+ case INSTANT: return owner_->instant_url();
+ case IMAGE: return owner_->image_url();
+ case NEW_TAB: return owner_->new_tab_url();
+ case CONTEXTUAL_SEARCH: return owner_->contextual_search_url();
+ case INDEXED: return owner_->GetURL(index_in_owner_);
+ default: NOTREACHED(); return std::string(); // NOLINT
}
}
std::string TemplateURLRef::GetPostParamsString() const {
switch (type_) {
case INDEXED:
- case SEARCH: return owner_->search_url_post_params();
- case SUGGEST: return owner_->suggestions_url_post_params();
- case INSTANT: return owner_->instant_url_post_params();
- case NEW_TAB: return std::string();
- case IMAGE: return owner_->image_url_post_params();
+ case SEARCH: return owner_->search_url_post_params();
+ case SUGGEST: return owner_->suggestions_url_post_params();
+ case INSTANT: return owner_->instant_url_post_params();
+ case NEW_TAB: return std::string();
+ case CONTEXTUAL_SEARCH: return std::string();
+ case IMAGE: return owner_->image_url_post_params();
default: NOTREACHED(); return std::string(); // NOLINT
}
}
@@ -595,6 +628,12 @@ bool TemplateURLRef::ParseParameter(size_t start,
replacements->push_back(Replacement(GOOGLE_NTP_IS_THEMED, start));
} else if (parameter == kGoogleOmniboxStartMarginParameter) {
replacements->push_back(Replacement(GOOGLE_OMNIBOX_START_MARGIN, start));
+ } else if (parameter == kGoogleContextualSearchVersion) {
+ replacements->push_back(
+ Replacement(GOOGLE_CONTEXTUAL_SEARCH_VERSION, start));
+ } else if (parameter == kGoogleContextualSearchContextData) {
+ replacements->push_back(
+ Replacement(GOOGLE_CONTEXTUAL_SEARCH_CONTEXT_DATA, start));
} else if (parameter == kGoogleOriginalQueryForSuggestionParameter) {
replacements->push_back(Replacement(GOOGLE_ORIGINAL_QUERY_FOR_SUGGESTION,
start));
@@ -937,6 +976,51 @@ std::string TemplateURLRef::HandleReplacements(
}
break;
+ case GOOGLE_CONTEXTUAL_SEARCH_VERSION:
+ if (search_terms_args.contextual_search_params.version >= 0) {
+ HandleReplacement(
+ "ctxs",
+ base::IntToString(
+ search_terms_args.contextual_search_params.version),
+ *i,
+ &url);
+ }
+ break;
+
+ case GOOGLE_CONTEXTUAL_SEARCH_CONTEXT_DATA: {
+ DCHECK(!i->is_post_param);
+ std::string context_data;
+
+ const SearchTermsArgs::ContextualSearchParams& params =
+ search_terms_args.contextual_search_params;
+
+ if (params.start != std::string::npos) {
+ context_data.append("ctxs_start=" + base::IntToString(
+ params.start) + "&");
+ }
+
+ if (params.end != std::string::npos) {
+ context_data.append("ctxs_end=" + base::IntToString(
+ params.end) + "&");
+ }
+
+ if (!params.selection.empty())
+ context_data.append("q=" + params.selection + "&");
+
+ if (!params.content.empty())
+ context_data.append("ctxs_content=" + params.content + "&");
+
+ if (!params.base_page_url.empty())
+ context_data.append("ctxs_url=" + params.base_page_url + "&");
+
+ if (!params.encoding.empty()) {
+ context_data.append("ctxs_encoding=" + params.encoding + "&");
+ }
+
+ HandleReplacement(std::string(), context_data, *i, &url);
+ break;
+ }
+
case GOOGLE_ORIGINAL_QUERY_FOR_SUGGESTION:
DCHECK(!i->is_post_param);
if (search_terms_args.accepted_suggestion >= 0 ||
@@ -1075,7 +1159,8 @@ TemplateURL::TemplateURL(Profile* profile, const TemplateURLData& data)
instant_url_ref_(this,
TemplateURLRef::INSTANT),
image_url_ref_(this, TemplateURLRef::IMAGE),
- new_tab_url_ref_(this, TemplateURLRef::NEW_TAB) {
+ new_tab_url_ref_(this, TemplateURLRef::NEW_TAB),
+ contextual_search_url_ref_(this, TemplateURLRef::CONTEXTUAL_SEARCH) {
SetPrepopulateId(data_.prepopulate_id);
if (data_.search_terms_replacement_key ==
diff --git a/chrome/browser/search_engines/template_url.h b/chrome/browser/search_engines/template_url.h
index 293642d..1410440 100644
--- a/chrome/browser/search_engines/template_url.h
+++ b/chrome/browser/search_engines/template_url.h
@@ -54,6 +54,7 @@ class TemplateURLRef {
INSTANT,
IMAGE,
NEW_TAB,
+ CONTEXTUAL_SEARCH,
INDEXED
};
@@ -71,6 +72,39 @@ class TemplateURLRef {
explicit SearchTermsArgs(const base::string16& search_terms);
~SearchTermsArgs();
+ struct ContextualSearchParams {
+ ContextualSearchParams();
+ ContextualSearchParams(const int version,
+ const size_t start,
+ const size_t end,
+ const std::string& selection,
+ const std::string& content,
+ const std::string& base_page_url,
+ const std::string& encoding);
+ ~ContextualSearchParams();
+
+ // The version of contextual search.
+ int version;
+
+ // Offset into the page content of the start of the user selection.
+ size_t start;
+
+ // Offset into the page content of the end of the user selection.
+ size_t end;
+
+ // The user selection.
+ std::string selection;
+
+ // The text including and surrounding the user selection.
+ std::string content;
+
+ // The URL of the page containing the user selection.
+ std::string base_page_url;
+
+ // The encoding of content.
+ std::string encoding;
+ };
+
// The search terms (query).
base::string16 search_terms;
@@ -144,6 +178,8 @@ class TemplateURLRef {
// True if the search was made using the app list search box. Otherwise, the
// search was made using the omnibox.
bool from_app_list;
+
+ ContextualSearchParams contextual_search_params;
};
TemplateURLRef(TemplateURL* owner, Type type);
@@ -276,6 +312,8 @@ class TemplateURLRef {
GOOGLE_INSTANT_EXTENDED_ENABLED,
GOOGLE_NTP_IS_THEMED,
GOOGLE_OMNIBOX_START_MARGIN,
+ GOOGLE_CONTEXTUAL_SEARCH_VERSION,
+ GOOGLE_CONTEXTUAL_SEARCH_CONTEXT_DATA,
GOOGLE_ORIGINAL_QUERY_FOR_SUGGESTION,
GOOGLE_PAGE_CLASSIFICATION,
GOOGLE_RLZ,
@@ -488,6 +526,9 @@ class TemplateURL {
const std::string& instant_url() const { return data_.instant_url; }
const std::string& image_url() const { return data_.image_url; }
const std::string& new_tab_url() const { return data_.new_tab_url; }
+ const std::string& contextual_search_url() const {
+ return data_.contextual_search_url;
+ }
const std::string& search_url_post_params() const {
return data_.search_url_post_params;
}
@@ -543,6 +584,9 @@ class TemplateURL {
const TemplateURLRef& instant_url_ref() const { return instant_url_ref_; }
const TemplateURLRef& image_url_ref() const { return image_url_ref_; }
const TemplateURLRef& new_tab_url_ref() const { return new_tab_url_ref_; }
+ const TemplateURLRef& contextual_search_url_ref() const {
+ return contextual_search_url_ref_;
+ }
// Returns true if |url| supports replacement.
bool SupportsReplacement() const;
@@ -673,6 +717,7 @@ class TemplateURL {
TemplateURLRef instant_url_ref_;
TemplateURLRef image_url_ref_;
TemplateURLRef new_tab_url_ref_;
+ TemplateURLRef contextual_search_url_ref_;
scoped_ptr<AssociatedExtensionInfo> extension_info_;
// TODO(sky): Add date last parsed OSD file.
diff --git a/chrome/browser/search_engines/template_url_prepopulate_data.cc b/chrome/browser/search_engines/template_url_prepopulate_data.cc
index 14ae45e..eea7b75 100644
--- a/chrome/browser/search_engines/template_url_prepopulate_data.cc
+++ b/chrome/browser/search_engines/template_url_prepopulate_data.cc
@@ -1062,6 +1062,7 @@ scoped_ptr<TemplateURLData> MakePrepopulatedTemplateURLData(
const base::StringPiece& instant_url,
const base::StringPiece& image_url,
const base::StringPiece& new_tab_url,
+ const base::StringPiece& contextual_search_url,
const base::StringPiece& search_url_post_params,
const base::StringPiece& suggest_url_post_params,
const base::StringPiece& instant_url_post_params,
@@ -1080,6 +1081,7 @@ scoped_ptr<TemplateURLData> MakePrepopulatedTemplateURLData(
data->instant_url = instant_url.as_string();
data->image_url = image_url.as_string();
data->new_tab_url = new_tab_url.as_string();
+ data->contextual_search_url = contextual_search_url.as_string();
data->search_url_post_params = search_url_post_params.as_string();
data->suggestions_url_post_params = suggest_url_post_params.as_string();
data->instant_url_post_params = instant_url_post_params.as_string();
@@ -1134,6 +1136,7 @@ ScopedVector<TemplateURLData> GetPrepopulatedTemplateURLData(
std::string instant_url;
std::string image_url;
std::string new_tab_url;
+ std::string contextual_search_url;
std::string search_url_post_params;
std::string suggest_url_post_params;
std::string instant_url_post_params;
@@ -1145,6 +1148,7 @@ ScopedVector<TemplateURLData> GetPrepopulatedTemplateURLData(
engine->GetString("instant_url", &instant_url);
engine->GetString("image_url", &image_url);
engine->GetString("new_tab_url", &new_tab_url);
+ engine->GetString("contextual_search_url", &contextual_search_url);
engine->GetString("search_url_post_params", &search_url_post_params);
engine->GetString("suggest_url_post_params", &suggest_url_post_params);
engine->GetString("instant_url_post_params", &instant_url_post_params);
@@ -1154,10 +1158,10 @@ ScopedVector<TemplateURLData> GetPrepopulatedTemplateURLData(
&search_terms_replacement_key);
t_urls.push_back(MakePrepopulatedTemplateURLData(name, keyword,
search_url, suggest_url, instant_url, image_url, new_tab_url,
- search_url_post_params, suggest_url_post_params,
- instant_url_post_params, image_url_post_params,
- favicon_url, encoding, *alternate_urls, search_terms_replacement_key,
- id).release());
+ contextual_search_url, search_url_post_params,
+ suggest_url_post_params, instant_url_post_params,
+ image_url_post_params, favicon_url, encoding, *alternate_urls,
+ search_terms_replacement_key, id).release());
}
}
return t_urls.Pass();
@@ -1179,6 +1183,7 @@ scoped_ptr<TemplateURLData>
engine.instant_url,
engine.image_url,
engine.new_tab_url,
+ engine.contextual_search_url,
engine.search_url_post_params,
engine.suggest_url_post_params,
engine.instant_url_post_params,
diff --git a/chrome/browser/search_engines/template_url_prepopulate_data_unittest.cc b/chrome/browser/search_engines/template_url_prepopulate_data_unittest.cc
index 90e828d..04fa313 100644
--- a/chrome/browser/search_engines/template_url_prepopulate_data_unittest.cc
+++ b/chrome/browser/search_engines/template_url_prepopulate_data_unittest.cc
@@ -238,6 +238,7 @@ TEST(TemplateURLPrepopulateDataTest, ClearProvidersFromPrefs) {
EXPECT_FALSE(t_urls[default_index]->instant_url.empty());
EXPECT_FALSE(t_urls[default_index]->image_url.empty());
EXPECT_FALSE(t_urls[default_index]->new_tab_url.empty());
+ EXPECT_FALSE(t_urls[default_index]->contextual_search_url.empty());
EXPECT_FALSE(t_urls[default_index]->image_url_post_params.empty());
EXPECT_EQ(SEARCH_ENGINE_GOOGLE,
TemplateURLPrepopulateData::GetEngineType(
@@ -271,6 +272,7 @@ TEST(TemplateURLPrepopulateDataTest, ProvidersFromPrepopulated) {
EXPECT_FALSE(t_urls[default_index]->instant_url.empty());
EXPECT_FALSE(t_urls[default_index]->image_url.empty());
EXPECT_FALSE(t_urls[default_index]->new_tab_url.empty());
+ EXPECT_FALSE(t_urls[default_index]->contextual_search_url.empty());
EXPECT_FALSE(t_urls[default_index]->image_url_post_params.empty());
// Expect at least 2 alternate_urls.
// This caught a bug with static initialization of arrays, so leave this in.
diff --git a/chrome/browser/search_engines/template_url_service_android.cc b/chrome/browser/search_engines/template_url_service_android.cc
index 86ee2a6..f880c25 100644
--- a/chrome/browser/search_engines/template_url_service_android.cc
+++ b/chrome/browser/search_engines/template_url_service_android.cc
@@ -165,7 +165,7 @@ TemplateUrlServiceAndroid::GetUrlForVoiceSearchQuery(JNIEnv* env,
std::string url;
if (!query.empty()) {
- GURL gurl = GetDefaultSearchURLForSearchTerms(GetOriginalProfile(), query);
+ GURL gurl(GetDefaultSearchURLForSearchTerms(GetOriginalProfile(), query));
if (google_util::IsGoogleSearchUrl(gurl))
gurl = net::AppendQueryParameter(gurl, "inm", "vs");
url = gurl.spec();
@@ -194,6 +194,23 @@ TemplateUrlServiceAndroid::ReplaceSearchTermsInUrl(JNIEnv* env,
return base::android::ScopedJavaLocalRef<jstring>(env, NULL);
}
+base::android::ScopedJavaLocalRef<jstring>
+TemplateUrlServiceAndroid::GetUrlForContextualSearchQuery(JNIEnv* env,
+ jobject obj,
+ jstring jquery) {
+ base::string16 query(ConvertJavaStringToUTF16(env, jquery));
+ std::string url;
+
+ if (!query.empty()) {
+ GURL gurl(GetDefaultSearchURLForSearchTerms(GetOriginalProfile(), query));
+ if (google_util::IsGoogleSearchUrl(gurl))
+ gurl = net::AppendQueryParameter(gurl, "ctxs", "1");
+ url = gurl.spec();
+ }
+
+ return ConvertUTF8ToJavaString(env, url);
+}
+
static jlong Init(JNIEnv* env, jobject obj) {
TemplateUrlServiceAndroid* template_url_service_android =
new TemplateUrlServiceAndroid(env, obj);
diff --git a/chrome/browser/search_engines/template_url_service_android.h b/chrome/browser/search_engines/template_url_service_android.h
index 3ee33a8..40fa993 100644
--- a/chrome/browser/search_engines/template_url_service_android.h
+++ b/chrome/browser/search_engines/template_url_service_android.h
@@ -45,6 +45,10 @@ class TemplateUrlServiceAndroid {
jobject obj,
jstring jquery,
jstring jcurrent_url);
+ base::android::ScopedJavaLocalRef<jstring> GetUrlForContextualSearchQuery(
+ JNIEnv* env,
+ jobject obj,
+ jstring jquery);
static bool Register(JNIEnv* env);
diff --git a/chrome/browser/search_engines/template_url_unittest.cc b/chrome/browser/search_engines/template_url_unittest.cc
index 089dd53..a97a919 100644
--- a/chrome/browser/search_engines/template_url_unittest.cc
+++ b/chrome/browser/search_engines/template_url_unittest.cc
@@ -1396,3 +1396,30 @@ TEST_F(TemplateURLTest, SessionToken) {
result = url.url_ref().ReplaceSearchTerms(search_terms_args);
EXPECT_EQ("http://bar/search?q=foo&xssi=t", result);
}
+
+TEST_F(TemplateURLTest, ContextualSearchParameters) {
+ TemplateURLData data;
+ UIThreadSearchTermsData::SetGoogleBaseURL("http://bar/");
+ data.SetURL("http://bar/_/contextualsearch?"
+ "{google:contextualSearchVersion}"
+ "{google:contextualSearchContextData}");
+
+ TemplateURL url(NULL, data);
+ TemplateURLRef::SearchTermsArgs search_terms_args(ASCIIToUTF16("foo"));
+ std::string result = url.url_ref().ReplaceSearchTerms(search_terms_args);
+ EXPECT_EQ("http://bar/_/contextualsearch?", result);
+
+ TemplateURLRef::SearchTermsArgs::ContextualSearchParams params(
+ 1, 6, 11, "allen", "woody+allen+movies", "www.wikipedia.org",
+ "utf-8");
+ search_terms_args.contextual_search_params = params;
+ result = url.url_ref().ReplaceSearchTerms(search_terms_args);
+ EXPECT_EQ("http://bar/_/contextualsearch?"
+ "ctxs=1&"
+ "ctxs_start=6&"
+ "ctxs_end=11&"
+ "q=allen&"
+ "ctxs_content=woody+allen+movies&"
+ "ctxs_url=www.wikipedia.org&"
+ "ctxs_encoding=utf-8&", result);
+}
diff --git a/components/search_engines/prepopulated_engines.json b/components/search_engines/prepopulated_engines.json
index 66295c1..4b7f720 100644
--- a/components/search_engines/prepopulated_engines.json
+++ b/components/search_engines/prepopulated_engines.json
@@ -525,11 +525,12 @@
"name": "Google",
"keyword": "google.com",
"favicon_url": "http://www.google.com/favicon.ico",
- "search_url": "{google:baseURL}search?q={searchTerms}&{google:RLZ}{google:originalQueryForSuggestion}{google:assistedQueryStats}{google:searchFieldtrialParameter}{google:bookmarkBarPinned}{google:searchClient}{google:sourceId}{google:instantExtendedEnabledParameter}{google:omniboxStartMarginParameter}ie={inputEncoding}",
+ "search_url": "{google:baseURL}search?q={searchTerms}&{google:RLZ}{google:originalQueryForSuggestion}{google:assistedQueryStats}{google:searchFieldtrialParameter}{google:bookmarkBarPinned}{google:searchClient}{google:sourceId}{google:instantExtendedEnabledParameter}{google:omniboxStartMarginParameter}{google:contextualSearchVersion}ie={inputEncoding}",
"suggest_url": "{google:baseSuggestURL}search?{google:searchFieldtrialParameter}client={google:suggestClient}&gs_ri={google:suggestRid}&xssi=t&q={searchTerms}&{google:inputType}{google:cursorPosition}{google:currentPageUrl}{google:pageClassification}{google:searchVersion}{google:sessionToken}sugkey={google:suggestAPIKeyParameter}",
"instant_url": "{google:baseURL}webhp?sourceid=chrome-instant&{google:RLZ}{google:forceInstantResults}{google:instantExtendedEnabledParameter}{google:ntpIsThemedParameter}{google:omniboxStartMarginParameter}ie={inputEncoding}",
"image_url": "{google:baseURL}searchbyimage/upload",
"new_tab_url": "{google:baseURL}_/chrome/newtab?{google:RLZ}{google:instantExtendedEnabledParameter}{google:ntpIsThemedParameter}ie={inputEncoding}",
+ "contextual_search_url": "{google:baseURL}_/contextualsearch?{google:contextualSearchVersion}{google:contextualSearchContextData}",
"image_url_post_params": "encoded_image={google:imageThumbnail},image_url={google:imageURL},sbisrc={google:imageSearchSource},original_width={google:imageOriginalWidth},original_height={google:imageOriginalHeight}",
"alternate_urls": [
"{google:baseURL}#q={searchTerms}",
diff --git a/components/search_engines/prepopulated_engines_schema.json b/components/search_engines/prepopulated_engines_schema.json
index cb5fc7b..ffe3810 100644
--- a/components/search_engines/prepopulated_engines_schema.json
+++ b/components/search_engines/prepopulated_engines_schema.json
@@ -30,6 +30,8 @@
{ "field": "image_url", "type": "string", "optional": true },
// If omitted, this engine does not support rendering a new tab page.
{ "field": "new_tab_url", "type": "string", "optional": true },
+ // If omitted, this engine does not support contextual search.
+ { "field": "contextual_search_url", "type": "string", "optional": true },
// The followings are post parameters for the corresponding search URL.
// If omitted, a GET request will be sent when using the corresponding
// search URL. Otherwise, a POST request will be sent.
diff --git a/components/search_engines/template_url_data.h b/components/search_engines/template_url_data.h
index 4479e84..b460150 100644
--- a/components/search_engines/template_url_data.h
+++ b/components/search_engines/template_url_data.h
@@ -39,6 +39,7 @@ struct TemplateURLData {
std::string instant_url;
std::string image_url;
std::string new_tab_url;
+ std::string contextual_search_url;
// The following post_params are comma-separated lists used to specify the
// post parameters for the corresponding URL.