Chromium Code Reviews| 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 #ifndef COMPONENTS_SEARCH_SEARCH_H_ | 5 #ifndef COMPONENTS_SEARCH_SEARCH_H_ |
| 6 #define COMPONENTS_SEARCH_SEARCH_H_ | 6 #define COMPONENTS_SEARCH_SEARCH_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 #include <utility> | 9 #include <utility> |
| 10 #include <vector> | 10 #include <vector> |
| 11 | 11 |
| 12 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
| 13 #include "base/strings/string16.h" | 13 #include "base/strings/string16.h" |
| 14 #include "base/strings/string_split.h" | 14 #include "base/strings/string_split.h" |
| 15 | 15 |
| 16 namespace chrome { | 16 class GURL; |
| 17 class TemplateURL; | |
| 18 | |
| 19 namespace search { | |
| 20 | |
| 21 // Use this value for "start margin" to prevent the "es_sm" parameter from | |
| 22 // being used. | |
| 23 extern const int kDisableStartMargin; | |
| 17 | 24 |
| 18 // Returns whether the Instant Extended API is enabled. | 25 // Returns whether the Instant Extended API is enabled. |
| 19 bool IsInstantExtendedAPIEnabled(); | 26 bool IsInstantExtendedAPIEnabled(); |
| 20 | 27 |
| 21 // Returns the value to pass to the &espv CGI parameter when loading the | 28 // Returns the value to pass to the &espv CGI parameter when loading the |
| 22 // embedded search page from the user's default search provider. Returns 0 if | 29 // embedded search page from the user's default search provider. Returns 0 if |
| 23 // the Instant Extended API is not enabled. | 30 // the Instant Extended API is not enabled. |
| 24 uint64 EmbeddedSearchPageVersion(); | 31 uint64 EmbeddedSearchPageVersion(); |
| 25 | 32 |
| 26 // Type for a collection of experiment configuration parameters. | 33 // Type for a collection of experiment configuration parameters. |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 48 uint64 GetUInt64ValueForFlagWithDefault(const std::string& flag, | 55 uint64 GetUInt64ValueForFlagWithDefault(const std::string& flag, |
| 49 uint64 default_value, | 56 uint64 default_value, |
| 50 const FieldTrialFlags& flags); | 57 const FieldTrialFlags& flags); |
| 51 | 58 |
| 52 // Given a FieldTrialFlags object, returns the bool value of the provided flag. | 59 // Given a FieldTrialFlags object, returns the bool value of the provided flag. |
| 53 // Exposed for testing only. | 60 // Exposed for testing only. |
| 54 bool GetBoolValueForFlagWithDefault(const std::string& flag, | 61 bool GetBoolValueForFlagWithDefault(const std::string& flag, |
| 55 bool default_value, | 62 bool default_value, |
| 56 const FieldTrialFlags& flags); | 63 const FieldTrialFlags& flags); |
| 57 | 64 |
| 58 } // namespace chrome | 65 // Returns a string indicating whether InstantExtended is enabled, suitable |
| 66 // for adding as a query string param to the homepage or search requests. | |
| 67 // Returns an empty string otherwise. | |
| 68 // | |
| 69 // |for_search| should be set to true for search requests, in which case this | |
| 70 // returns a non-empty string only if query extraction is enabled. | |
| 71 std::string InstantExtendedEnabledParam(bool for_search); | |
| 72 | |
| 73 // Returns a string that will cause the search results page to update | |
| 74 // incrementally. Currently, Instant Extended passes a different param to | |
| 75 // search results pages that also has this effect, so by default this function | |
| 76 // returns the empty string when Instant Extended is enabled. However, when | |
| 77 // doing instant search result prerendering, we still need to pass this param, | |
| 78 // as Instant Extended does not cause incremental updates by default for the | |
| 79 // prerender page. Callers should set |for_prerender| in this case to force | |
| 80 // the returned string to be non-empty. | |
| 81 std::string ForceInstantResultsParam(bool for_prerender); | |
| 82 | |
| 83 // Returns whether query extraction is enabled. | |
| 84 bool IsQueryExtractionEnabled(); | |
| 85 | |
| 86 // Returns true if 'prefetch_results' flag is set to true in field trials to | |
| 87 // prefetch high-confidence search suggestions. | |
| 88 bool ShouldPrefetchSearchResults(); | |
| 89 | |
| 90 // Returns true if 'reuse_instant_search_base_page' flag is set to true in field | |
| 91 // trials to reuse the prerendered page to commit any search query. | |
| 92 bool ShouldReuseInstantSearchBasePage(); | |
| 93 | |
| 94 // Returns true if 'allow_prefetch_non_default_match' flag is enabled in field | |
| 95 // trials to allow prefetching the suggestion marked to be prefetched by the | |
| 96 // suggest server even if it is not the default match. | |
| 97 bool ShouldAllowPrefetchNonDefaultMatch(); | |
| 98 | |
| 99 // |url| should either have a secure scheme or have a non-HTTPS base URL that | |
| 100 // the user specified using --google-base-url. (This allows testers to use | |
| 101 // --google-base-url to point at non-HTTPS servers, which eases testing.) | |
| 102 bool IsSuitableURLForInstant(const GURL& url, const TemplateURL* template_url); | |
|
Jered
2015/07/31 15:38:45
This function prototype wasn't exposed previously.
sdefresne
2015/07/31 17:09:30
There were three call sites in chrome/browser/sear
Jered
2015/07/31 19:50:11
It's fine here. Thanks for explaining the rational
| |
| 103 | |
| 104 // ----------------------------------------------------- | |
| 105 // The following APIs are exposed for use in tests only. | |
| 106 // ----------------------------------------------------- | |
| 107 | |
| 108 // Forces query in the omnibox to be on for tests. | |
| 109 void EnableQueryExtractionForTesting(); | |
| 110 | |
| 111 } // namespace search | |
| 59 | 112 |
| 60 #endif // COMPONENTS_SEARCH_SEARCH_H_ | 113 #endif // COMPONENTS_SEARCH_SEARCH_H_ |
| OLD | NEW |