| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "components/search_engines/template_url.h" | 5 #include "components/search_engines/template_url.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| (...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 190 contextual_search_params(ContextualSearchParams()) { | 190 contextual_search_params(ContextualSearchParams()) { |
| 191 } | 191 } |
| 192 | 192 |
| 193 TemplateURLRef::SearchTermsArgs::~SearchTermsArgs() { | 193 TemplateURLRef::SearchTermsArgs::~SearchTermsArgs() { |
| 194 } | 194 } |
| 195 | 195 |
| 196 TemplateURLRef::SearchTermsArgs::ContextualSearchParams:: | 196 TemplateURLRef::SearchTermsArgs::ContextualSearchParams:: |
| 197 ContextualSearchParams() | 197 ContextualSearchParams() |
| 198 : version(-1), | 198 : version(-1), |
| 199 start(base::string16::npos), | 199 start(base::string16::npos), |
| 200 end(base::string16::npos) { | 200 end(base::string16::npos), |
| 201 resolve(true) { |
| 201 } | 202 } |
| 202 | 203 |
| 203 TemplateURLRef::SearchTermsArgs::ContextualSearchParams:: | 204 TemplateURLRef::SearchTermsArgs::ContextualSearchParams:: |
| 204 ContextualSearchParams( | 205 ContextualSearchParams( |
| 205 const int version, | 206 const int version, |
| 206 const size_t start, | 207 const size_t start, |
| 207 const size_t end, | 208 const size_t end, |
| 208 const std::string& selection, | 209 const std::string& selection, |
| 209 const std::string& content, | 210 const std::string& content, |
| 210 const std::string& base_page_url, | 211 const std::string& base_page_url, |
| 211 const std::string& encoding) | 212 const std::string& encoding) |
| 212 : version(version), | 213 : version(version), |
| 213 start(start), | 214 start(start), |
| 214 end(end), | 215 end(end), |
| 215 selection(selection), | 216 selection(selection), |
| 216 content(content), | 217 content(content), |
| 217 base_page_url(base_page_url), | 218 base_page_url(base_page_url), |
| 218 encoding(encoding) { | 219 encoding(encoding), |
| 220 resolve(true) { |
| 219 } | 221 } |
| 220 | 222 |
| 221 TemplateURLRef::SearchTermsArgs::ContextualSearchParams:: | 223 TemplateURLRef::SearchTermsArgs::ContextualSearchParams:: |
| 224 ContextualSearchParams( |
| 225 const int version, |
| 226 const size_t start, |
| 227 const size_t end, |
| 228 const std::string& selection, |
| 229 const std::string& content, |
| 230 const std::string& base_page_url, |
| 231 const std::string& encoding, |
| 232 const bool resolve) |
| 233 : version(version), |
| 234 start(start), |
| 235 end(end), |
| 236 selection(selection), |
| 237 content(content), |
| 238 base_page_url(base_page_url), |
| 239 encoding(encoding), |
| 240 resolve(resolve) { |
| 241 } |
| 242 |
| 243 TemplateURLRef::SearchTermsArgs::ContextualSearchParams:: |
| 222 ~ContextualSearchParams() { | 244 ~ContextualSearchParams() { |
| 223 } | 245 } |
| 224 | 246 |
| 225 // TemplateURLRef ------------------------------------------------------------- | 247 // TemplateURLRef ------------------------------------------------------------- |
| 226 | 248 |
| 227 TemplateURLRef::TemplateURLRef(TemplateURL* owner, Type type) | 249 TemplateURLRef::TemplateURLRef(TemplateURL* owner, Type type) |
| 228 : owner_(owner), | 250 : owner_(owner), |
| 229 type_(type), | 251 type_(type), |
| 230 index_in_owner_(0), | 252 index_in_owner_(0), |
| 231 parsed_(false), | 253 parsed_(false), |
| (...skipping 725 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 957 params.end) + "&"); | 979 params.end) + "&"); |
| 958 } | 980 } |
| 959 | 981 |
| 960 if (!params.selection.empty()) | 982 if (!params.selection.empty()) |
| 961 context_data.append("q=" + params.selection + "&"); | 983 context_data.append("q=" + params.selection + "&"); |
| 962 | 984 |
| 963 if (!params.content.empty()) | 985 if (!params.content.empty()) |
| 964 context_data.append("ctxs_content=" + params.content + "&"); | 986 context_data.append("ctxs_content=" + params.content + "&"); |
| 965 | 987 |
| 966 if (!params.base_page_url.empty()) | 988 if (!params.base_page_url.empty()) |
| 967 context_data.append("ctxs_url=" + params.base_page_url + "&"); | 989 context_data.append("ctxsl_url=" + params.base_page_url + "&"); |
| 968 | 990 |
| 969 if (!params.encoding.empty()) { | 991 if (!params.encoding.empty()) { |
| 970 context_data.append("ctxs_encoding=" + params.encoding + "&"); | 992 context_data.append("ctxs_encoding=" + params.encoding + "&"); |
| 971 } | 993 } |
| 972 | 994 |
| 995 context_data.append( |
| 996 params.resolve ? "ctxsl_resolve=1" : "ctxsl_resolve=0"); |
| 997 |
| 973 HandleReplacement(std::string(), context_data, *i, &url); | 998 HandleReplacement(std::string(), context_data, *i, &url); |
| 974 break; | 999 break; |
| 975 } | 1000 } |
| 976 | 1001 |
| 977 case GOOGLE_ORIGINAL_QUERY_FOR_SUGGESTION: | 1002 case GOOGLE_ORIGINAL_QUERY_FOR_SUGGESTION: |
| 978 DCHECK(!i->is_post_param); | 1003 DCHECK(!i->is_post_param); |
| 979 if (search_terms_args.accepted_suggestion >= 0 || | 1004 if (search_terms_args.accepted_suggestion >= 0 || |
| 980 !search_terms_args.assisted_query_stats.empty()) { | 1005 !search_terms_args.assisted_query_stats.empty()) { |
| 981 HandleReplacement( | 1006 HandleReplacement( |
| 982 "oq", base::UTF16ToUTF8(encoded_original_query), *i, &url); | 1007 "oq", base::UTF16ToUTF8(encoded_original_query), *i, &url); |
| (...skipping 461 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1444 // patterns. This means that given patterns | 1469 // patterns. This means that given patterns |
| 1445 // [ "http://foo/#q={searchTerms}", "http://foo/?q={searchTerms}" ], | 1470 // [ "http://foo/#q={searchTerms}", "http://foo/?q={searchTerms}" ], |
| 1446 // calling ExtractSearchTermsFromURL() on "http://foo/?q=bar#q=' would | 1471 // calling ExtractSearchTermsFromURL() on "http://foo/?q=bar#q=' would |
| 1447 // return false. This is important for at least Google, where such URLs | 1472 // return false. This is important for at least Google, where such URLs |
| 1448 // are invalid. | 1473 // are invalid. |
| 1449 return !search_terms->empty(); | 1474 return !search_terms->empty(); |
| 1450 } | 1475 } |
| 1451 } | 1476 } |
| 1452 return false; | 1477 return false; |
| 1453 } | 1478 } |
| OLD | NEW |