| 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/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/metrics/field_trial.h" | 10 #include "base/metrics/field_trial.h" |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 52 const char kEmbeddedSearchFieldTrialName[] = "EmbeddedSearch"; | 52 const char kEmbeddedSearchFieldTrialName[] = "EmbeddedSearch"; |
| 53 | 53 |
| 54 // If the field trial's group name ends with this string its configuration will | 54 // If the field trial's group name ends with this string its configuration will |
| 55 // be ignored and Instant Extended will not be enabled by default. | 55 // be ignored and Instant Extended will not be enabled by default. |
| 56 const char kDisablingSuffix[] = "DISABLED"; | 56 const char kDisablingSuffix[] = "DISABLED"; |
| 57 | 57 |
| 58 #if !defined(OS_IOS) && !defined(OS_ANDROID) | 58 #if !defined(OS_IOS) && !defined(OS_ANDROID) |
| 59 const char kEnableQueryExtractionFlagName[] = "query_extraction"; | 59 const char kEnableQueryExtractionFlagName[] = "query_extraction"; |
| 60 #endif | 60 #endif |
| 61 | 61 |
| 62 const char kAllowPrefetchNonDefaultMatch[] = "allow_prefetch_non_default_match"; | |
| 63 | |
| 64 #if defined(OS_ANDROID) | 62 #if defined(OS_ANDROID) |
| 65 const char kPrefetchSearchResultsFlagName[] = "prefetch_results"; | 63 const char kPrefetchSearchResultsFlagName[] = "prefetch_results"; |
| 66 | 64 |
| 67 // Controls whether to reuse prerendered Instant Search base page to commit any | 65 // Controls whether to reuse prerendered Instant Search base page to commit any |
| 68 // search query. | 66 // search query. |
| 69 const char kReuseInstantSearchBasePage[] = "reuse_instant_search_base_page"; | 67 const char kReuseInstantSearchBasePage[] = "reuse_instant_search_base_page"; |
| 70 #endif | 68 #endif |
| 71 | 69 |
| 72 } // namespace | 70 } // namespace |
| 73 | 71 |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 221 #if defined(OS_ANDROID) | 219 #if defined(OS_ANDROID) |
| 222 FieldTrialFlags flags; | 220 FieldTrialFlags flags; |
| 223 return GetFieldTrialInfo(&flags) && | 221 return GetFieldTrialInfo(&flags) && |
| 224 GetBoolValueForFlagWithDefault(kReuseInstantSearchBasePage, false, | 222 GetBoolValueForFlagWithDefault(kReuseInstantSearchBasePage, false, |
| 225 flags); | 223 flags); |
| 226 #else | 224 #else |
| 227 return true; | 225 return true; |
| 228 #endif | 226 #endif |
| 229 } | 227 } |
| 230 | 228 |
| 231 bool ShouldAllowPrefetchNonDefaultMatch() { | |
| 232 if (!ShouldPrefetchSearchResults()) | |
| 233 return false; | |
| 234 | |
| 235 FieldTrialFlags flags; | |
| 236 return GetFieldTrialInfo(&flags) && | |
| 237 GetBoolValueForFlagWithDefault(kAllowPrefetchNonDefaultMatch, false, | |
| 238 flags); | |
| 239 } | |
| 240 | |
| 241 // |url| should either have a secure scheme or have a non-HTTPS base URL that | 229 // |url| should either have a secure scheme or have a non-HTTPS base URL that |
| 242 // the user specified using --google-base-url. (This allows testers to use | 230 // the user specified using --google-base-url. (This allows testers to use |
| 243 // --google-base-url to point at non-HTTPS servers, which eases testing.) | 231 // --google-base-url to point at non-HTTPS servers, which eases testing.) |
| 244 bool IsSuitableURLForInstant(const GURL& url, const TemplateURL* template_url) { | 232 bool IsSuitableURLForInstant(const GURL& url, const TemplateURL* template_url) { |
| 245 return template_url->HasSearchTermsReplacementKey(url) && | 233 return template_url->HasSearchTermsReplacementKey(url) && |
| 246 (url.SchemeIsCryptographic() || | 234 (url.SchemeIsCryptographic() || |
| 247 google_util::StartsWithCommandLineGoogleBaseURL(url)); | 235 google_util::StartsWithCommandLineGoogleBaseURL(url)); |
| 248 } | 236 } |
| 249 | 237 |
| 250 void EnableQueryExtractionForTesting() { | 238 void EnableQueryExtractionForTesting() { |
| 251 #if !defined(OS_IOS) && !defined(OS_ANDROID) | 239 #if !defined(OS_IOS) && !defined(OS_ANDROID) |
| 252 base::CommandLine* cl = base::CommandLine::ForCurrentProcess(); | 240 base::CommandLine* cl = base::CommandLine::ForCurrentProcess(); |
| 253 cl->AppendSwitch(switches::kEnableQueryExtraction); | 241 cl->AppendSwitch(switches::kEnableQueryExtraction); |
| 254 #endif | 242 #endif |
| 255 } | 243 } |
| 256 | 244 |
| 257 } // namespace search | 245 } // namespace search |
| OLD | NEW |