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

Unified Diff: chrome/common/instant_types.cc

Issue 609493002: Propagate the search request params from the browser to the Instant search base page to fix the embe (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 6 years, 1 month 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/common/instant_types.h ('k') | chrome/common/instant_types_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/common/instant_types.cc
diff --git a/chrome/common/instant_types.cc b/chrome/common/instant_types.cc
index 5d199ae46de6f95e173c6aa4142a162161cd528a..4dca3a53501e4118678e06d9e8128d0420549bc8 100644
--- a/chrome/common/instant_types.cc
+++ b/chrome/common/instant_types.cc
@@ -4,6 +4,19 @@
#include "chrome/common/instant_types.h"
+#include "base/strings/utf_string_conversions.h"
+#include "net/base/escape.h"
+
+namespace {
+
+std::string GetComponent(const std::string& url,
+ const url::Component component) {
+ return (component.len > 0) ? url.substr(component.begin, component.len) :
+ std::string();
+}
+
+} // namespace
+
InstantSuggestion::InstantSuggestion() {
}
@@ -68,3 +81,50 @@ bool ThemeBackgroundInfo::operator==(const ThemeBackgroundInfo& rhs) const {
has_attribution == rhs.has_attribution &&
logo_alternate == rhs.logo_alternate;
}
+
+const char kSearchQueryKey[] = "q";
+const char kOriginalQueryKey[] = "oq";
+const char kRLZParameterKey[] = "rlz";
+const char kInputEncodingKey[] = "ie";
+const char kAssistedQueryStatsKey[] = "aqs";
+
+EmbeddedSearchRequestParams::EmbeddedSearchRequestParams() {
+}
+
+EmbeddedSearchRequestParams::EmbeddedSearchRequestParams(const GURL& url) {
+ const std::string& url_params(url.query());
+ url::Component query, key, value;
+ query.len = static_cast<int>(url_params.size());
+
+ const net::UnescapeRule::Type unescape_rules =
+ net::UnescapeRule::CONTROL_CHARS | net::UnescapeRule::SPACES |
+ net::UnescapeRule::URL_SPECIAL_CHARS | net::UnescapeRule::NORMAL |
+ net::UnescapeRule::REPLACE_PLUS_WITH_SPACE;
+
+ while (url::ExtractQueryKeyValue(url_params.c_str(), &query, &key, &value)) {
+ if (!key.is_nonempty())
+ continue;
+
+ std::string key_param(GetComponent(url_params, key));
+ std::string value_param(GetComponent(url_params, value));
+ if (key_param == kSearchQueryKey) {
+ search_query = base::UTF8ToUTF16(net::UnescapeURLComponent(
+ value_param, unescape_rules));
+ } else if (key_param == kOriginalQueryKey) {
+ original_query = base::UTF8ToUTF16(net::UnescapeURLComponent(
+ value_param, unescape_rules));
+ } else if (key_param == kRLZParameterKey) {
+ rlz_parameter_value = net::UnescapeAndDecodeUTF8URLComponent(
+ value_param, net::UnescapeRule::NORMAL);
+ } else if (key_param == kInputEncodingKey) {
+ input_encoding = net::UnescapeAndDecodeUTF8URLComponent(
+ value_param, net::UnescapeRule::NORMAL);
+ } else if (key_param == kAssistedQueryStatsKey) {
+ assisted_query_stats = net::UnescapeAndDecodeUTF8URLComponent(
+ value_param, net::UnescapeRule::NORMAL);
+ }
+ }
+}
+
+EmbeddedSearchRequestParams::~EmbeddedSearchRequestParams() {
+}
« no previous file with comments | « chrome/common/instant_types.h ('k') | chrome/common/instant_types_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698