| 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/search.h" | 5 #include "components/search/search.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include "base/metrics/field_trial.h" | 9 #include "base/metrics/field_trial.h" |
| 10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 140 } | 140 } |
| 141 | 141 |
| 142 // Given a FieldTrialFlags object, returns the boolean value of the provided | 142 // Given a FieldTrialFlags object, returns the boolean value of the provided |
| 143 // flag. | 143 // flag. |
| 144 bool GetBoolValueForFlagWithDefault(const std::string& flag, | 144 bool GetBoolValueForFlagWithDefault(const std::string& flag, |
| 145 bool default_value, | 145 bool default_value, |
| 146 const FieldTrialFlags& flags) { | 146 const FieldTrialFlags& flags) { |
| 147 return !!GetUInt64ValueForFlagWithDefault(flag, default_value ? 1 : 0, flags); | 147 return !!GetUInt64ValueForFlagWithDefault(flag, default_value ? 1 : 0, flags); |
| 148 } | 148 } |
| 149 | 149 |
| 150 std::string InstantExtendedEnabledParam(bool for_search) { | 150 std::string InstantExtendedEnabledParam() { |
| 151 // TODO(treib): Remove |for_search| and update callers that set it to true. | |
| 152 if (for_search) | |
| 153 return std::string(); | |
| 154 return std::string(google_util::kInstantExtendedAPIParam) + "=" + | 151 return std::string(google_util::kInstantExtendedAPIParam) + "=" + |
| 155 base::Uint64ToString(EmbeddedSearchPageVersion()) + "&"; | 152 base::Uint64ToString(EmbeddedSearchPageVersion()) + "&"; |
| 156 } | 153 } |
| 157 | 154 |
| 158 std::string ForceInstantResultsParam(bool for_prerender) { | 155 std::string ForceInstantResultsParam(bool for_prerender) { |
| 159 return (for_prerender || !IsInstantExtendedAPIEnabled()) ? "ion=1&" | 156 return (for_prerender || !IsInstantExtendedAPIEnabled()) ? "ion=1&" |
| 160 : std::string(); | 157 : std::string(); |
| 161 } | 158 } |
| 162 | 159 |
| 163 bool ShouldPrefetchSearchResults() { | 160 bool ShouldPrefetchSearchResults() { |
| (...skipping 27 matching lines...) Expand all Loading... |
| 191 // |url| should either have a secure scheme or have a non-HTTPS base URL that | 188 // |url| should either have a secure scheme or have a non-HTTPS base URL that |
| 192 // the user specified using --google-base-url. (This allows testers to use | 189 // the user specified using --google-base-url. (This allows testers to use |
| 193 // --google-base-url to point at non-HTTPS servers, which eases testing.) | 190 // --google-base-url to point at non-HTTPS servers, which eases testing.) |
| 194 bool IsSuitableURLForInstant(const GURL& url, const TemplateURL* template_url) { | 191 bool IsSuitableURLForInstant(const GURL& url, const TemplateURL* template_url) { |
| 195 return template_url->HasSearchTermsReplacementKey(url) && | 192 return template_url->HasSearchTermsReplacementKey(url) && |
| 196 (url.SchemeIsCryptographic() || | 193 (url.SchemeIsCryptographic() || |
| 197 google_util::StartsWithCommandLineGoogleBaseURL(url)); | 194 google_util::StartsWithCommandLineGoogleBaseURL(url)); |
| 198 } | 195 } |
| 199 | 196 |
| 200 } // namespace search | 197 } // namespace search |
| OLD | NEW |