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/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 631 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
642 #endif | 642 #endif |
643 } else if (parameter == "google:suggestAPIKeyParameter") { | 643 } else if (parameter == "google:suggestAPIKeyParameter") { |
644 url->insert(start, | 644 url->insert(start, |
645 net::EscapeQueryParamValue(google_apis::GetAPIKey(), false)); | 645 net::EscapeQueryParamValue(google_apis::GetAPIKey(), false)); |
646 } else if (parameter == "google:suggestClient") { | 646 } else if (parameter == "google:suggestClient") { |
647 replacements->push_back(Replacement(GOOGLE_SUGGEST_CLIENT, start)); | 647 replacements->push_back(Replacement(GOOGLE_SUGGEST_CLIENT, start)); |
648 } else if (parameter == "google:suggestRid") { | 648 } else if (parameter == "google:suggestRid") { |
649 replacements->push_back(Replacement(GOOGLE_SUGGEST_REQUEST_ID, start)); | 649 replacements->push_back(Replacement(GOOGLE_SUGGEST_REQUEST_ID, start)); |
650 } else if (parameter == kGoogleUnescapedSearchTermsParameter) { | 650 } else if (parameter == kGoogleUnescapedSearchTermsParameter) { |
651 replacements->push_back(Replacement(GOOGLE_UNESCAPED_SEARCH_TERMS, start)); | 651 replacements->push_back(Replacement(GOOGLE_UNESCAPED_SEARCH_TERMS, start)); |
652 } else if (parameter == "yandex:referralID") { | |
653 replacements->push_back(Replacement(YANDEX_REFERRAL_ID, start)); | |
652 } else if (parameter == "yandex:searchPath") { | 654 } else if (parameter == "yandex:searchPath") { |
653 switch (ui::GetDeviceFormFactor()) { | 655 switch (ui::GetDeviceFormFactor()) { |
654 case ui::DEVICE_FORM_FACTOR_DESKTOP: | 656 case ui::DEVICE_FORM_FACTOR_DESKTOP: |
655 url->insert(start, "search/"); | 657 url->insert(start, "search/"); |
656 break; | 658 break; |
657 case ui::DEVICE_FORM_FACTOR_PHONE: | 659 case ui::DEVICE_FORM_FACTOR_PHONE: |
658 url->insert(start, "search/touch/"); | 660 url->insert(start, "search/touch/"); |
659 break; | 661 break; |
660 case ui::DEVICE_FORM_FACTOR_TABLET: | 662 case ui::DEVICE_FORM_FACTOR_TABLET: |
661 url->insert(start, "search/pad/"); | 663 url->insert(start, "search/pad/"); |
(...skipping 456 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1118 &url); | 1120 &url); |
1119 break; | 1121 break; |
1120 | 1122 |
1121 case GOOGLE_IOS_SEARCH_LANGUAGE: | 1123 case GOOGLE_IOS_SEARCH_LANGUAGE: |
1122 #if defined(OS_IOS) | 1124 #if defined(OS_IOS) |
1123 HandleReplacement("hl", search_terms_data.GetApplicationLocale(), *i, | 1125 HandleReplacement("hl", search_terms_data.GetApplicationLocale(), *i, |
1124 &url); | 1126 &url); |
1125 #endif | 1127 #endif |
1126 break; | 1128 break; |
1127 | 1129 |
1130 case YANDEX_REFERRAL_ID: { | |
1131 DCHECK(!i->is_post_param); | |
Peter Kasting
2017/05/09 00:14:25
Is this important? Why?
Ted C
2017/05/09 04:38:32
this and the comment below were blatantly cribbed
| |
1132 // On platforms that don't have Referral ID, we still want this branch | |
1133 // to happen so that we replace the Referral ID template with the | |
1134 // empty string. (If we don't handle this case, we hit a | |
1135 // NOTREACHED below.) | |
Peter Kasting
2017/05/09 00:14:25
I'm confused. Is this referring to having a case
| |
1136 std::string referral_id = search_terms_data.YandexReferralID(); | |
1137 if (!referral_id.empty()) | |
1138 HandleReplacement("clid", referral_id, *i, &url); | |
1139 break; | |
1140 } | |
1141 | |
1128 default: | 1142 default: |
1129 NOTREACHED(); | 1143 NOTREACHED(); |
1130 break; | 1144 break; |
1131 } | 1145 } |
1132 } | 1146 } |
1133 | 1147 |
1134 if (!post_params_.empty()) | 1148 if (!post_params_.empty()) |
1135 EncodeFormData(post_params_, post_content); | 1149 EncodeFormData(post_params_, post_content); |
1136 | 1150 |
1137 return url; | 1151 return url; |
(...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1522 // patterns. This means that given patterns | 1536 // patterns. This means that given patterns |
1523 // [ "http://foo/#q={searchTerms}", "http://foo/?q={searchTerms}" ], | 1537 // [ "http://foo/#q={searchTerms}", "http://foo/?q={searchTerms}" ], |
1524 // calling ExtractSearchTermsFromURL() on "http://foo/?q=bar#q=' would | 1538 // calling ExtractSearchTermsFromURL() on "http://foo/?q=bar#q=' would |
1525 // return false. This is important for at least Google, where such URLs | 1539 // return false. This is important for at least Google, where such URLs |
1526 // are invalid. | 1540 // are invalid. |
1527 return !search_terms->empty(); | 1541 return !search_terms->empty(); |
1528 } | 1542 } |
1529 } | 1543 } |
1530 return false; | 1544 return false; |
1531 } | 1545 } |
OLD | NEW |