| 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 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 208 const std::string& selection, | 208 const std::string& selection, |
| 209 const std::string& content, | 209 const std::string& content, |
| 210 const std::string& base_page_url, | 210 const std::string& base_page_url, |
| 211 const std::string& encoding) | 211 const std::string& encoding) |
| 212 : version(version), | 212 : version(version), |
| 213 start(start), | 213 start(start), |
| 214 end(end), | 214 end(end), |
| 215 selection(selection), | 215 selection(selection), |
| 216 content(content), | 216 content(content), |
| 217 base_page_url(base_page_url), | 217 base_page_url(base_page_url), |
| 218 encoding(encoding) { | 218 encoding(encoding), |
| 219 resolve(true) { |
| 219 } | 220 } |
| 220 | 221 |
| 221 TemplateURLRef::SearchTermsArgs::ContextualSearchParams:: | 222 TemplateURLRef::SearchTermsArgs::ContextualSearchParams:: |
| 223 ContextualSearchParams( |
| 224 const int version, |
| 225 const size_t start, |
| 226 const size_t end, |
| 227 const std::string& selection, |
| 228 const std::string& content, |
| 229 const std::string& base_page_url, |
| 230 const std::string& encoding, |
| 231 const bool resolve) |
| 232 : version(version), |
| 233 start(start), |
| 234 end(end), |
| 235 selection(selection), |
| 236 content(content), |
| 237 base_page_url(base_page_url), |
| 238 encoding(encoding), |
| 239 resolve(resolve) { |
| 240 } |
| 241 |
| 242 TemplateURLRef::SearchTermsArgs::ContextualSearchParams:: |
| 222 ~ContextualSearchParams() { | 243 ~ContextualSearchParams() { |
| 223 } | 244 } |
| 224 | 245 |
| 225 // TemplateURLRef ------------------------------------------------------------- | 246 // TemplateURLRef ------------------------------------------------------------- |
| 226 | 247 |
| 227 TemplateURLRef::TemplateURLRef(TemplateURL* owner, Type type) | 248 TemplateURLRef::TemplateURLRef(TemplateURL* owner, Type type) |
| 228 : owner_(owner), | 249 : owner_(owner), |
| 229 type_(type), | 250 type_(type), |
| 230 index_in_owner_(0), | 251 index_in_owner_(0), |
| 231 parsed_(false), | 252 parsed_(false), |
| (...skipping 725 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 957 params.end) + "&"); | 978 params.end) + "&"); |
| 958 } | 979 } |
| 959 | 980 |
| 960 if (!params.selection.empty()) | 981 if (!params.selection.empty()) |
| 961 context_data.append("q=" + params.selection + "&"); | 982 context_data.append("q=" + params.selection + "&"); |
| 962 | 983 |
| 963 if (!params.content.empty()) | 984 if (!params.content.empty()) |
| 964 context_data.append("ctxs_content=" + params.content + "&"); | 985 context_data.append("ctxs_content=" + params.content + "&"); |
| 965 | 986 |
| 966 if (!params.base_page_url.empty()) | 987 if (!params.base_page_url.empty()) |
| 967 context_data.append("ctxs_url=" + params.base_page_url + "&"); | 988 context_data.append("ctxsl_url=" + params.base_page_url + "&"); |
| 968 | 989 |
| 969 if (!params.encoding.empty()) { | 990 if (!params.encoding.empty()) { |
| 970 context_data.append("ctxs_encoding=" + params.encoding + "&"); | 991 context_data.append("ctxs_encoding=" + params.encoding + "&"); |
| 971 } | 992 } |
| 972 | 993 |
| 994 context_data.append( |
| 995 params.resolve ? "ctxsl_resolve=1" : "ctxsl_resolve=0"); |
| 996 |
| 973 HandleReplacement(std::string(), context_data, *i, &url); | 997 HandleReplacement(std::string(), context_data, *i, &url); |
| 974 break; | 998 break; |
| 975 } | 999 } |
| 976 | 1000 |
| 977 case GOOGLE_ORIGINAL_QUERY_FOR_SUGGESTION: | 1001 case GOOGLE_ORIGINAL_QUERY_FOR_SUGGESTION: |
| 978 DCHECK(!i->is_post_param); | 1002 DCHECK(!i->is_post_param); |
| 979 if (search_terms_args.accepted_suggestion >= 0 || | 1003 if (search_terms_args.accepted_suggestion >= 0 || |
| 980 !search_terms_args.assisted_query_stats.empty()) { | 1004 !search_terms_args.assisted_query_stats.empty()) { |
| 981 HandleReplacement( | 1005 HandleReplacement( |
| 982 "oq", base::UTF16ToUTF8(encoded_original_query), *i, &url); | 1006 "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 | 1468 // patterns. This means that given patterns |
| 1445 // [ "http://foo/#q={searchTerms}", "http://foo/?q={searchTerms}" ], | 1469 // [ "http://foo/#q={searchTerms}", "http://foo/?q={searchTerms}" ], |
| 1446 // calling ExtractSearchTermsFromURL() on "http://foo/?q=bar#q=' would | 1470 // calling ExtractSearchTermsFromURL() on "http://foo/?q=bar#q=' would |
| 1447 // return false. This is important for at least Google, where such URLs | 1471 // return false. This is important for at least Google, where such URLs |
| 1448 // are invalid. | 1472 // are invalid. |
| 1449 return !search_terms->empty(); | 1473 return !search_terms->empty(); |
| 1450 } | 1474 } |
| 1451 } | 1475 } |
| 1452 return false; | 1476 return false; |
| 1453 } | 1477 } |
| OLD | NEW |