Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(107)

Side by Side Diff: chrome/browser/search/search.h

Issue 1260033003: Partially componentize //chrome/browser/search/search.{h,cc} (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix compilation on iOS Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/browser/search/local_ntp_source.cc ('k') | chrome/browser/search/search.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 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 CHROME_BROWSER_SEARCH_SEARCH_H_ 5 #ifndef CHROME_BROWSER_SEARCH_SEARCH_H_
6 #define CHROME_BROWSER_SEARCH_SEARCH_H_ 6 #define CHROME_BROWSER_SEARCH_SEARCH_H_
7 7
8 #include <string> 8 #include <string>
9 #include <utility> 9 #include <utility>
10 #include <vector> 10 #include <vector>
(...skipping 10 matching lines...) Expand all
21 namespace content { 21 namespace content {
22 class BrowserContext; 22 class BrowserContext;
23 class NavigationEntry; 23 class NavigationEntry;
24 class WebContents; 24 class WebContents;
25 } 25 }
26 26
27 namespace user_prefs { 27 namespace user_prefs {
28 class PrefRegistrySyncable; 28 class PrefRegistrySyncable;
29 } 29 }
30 30
31 namespace chrome { 31 namespace search {
32 32
33 // For reporting Cacheable NTP navigations. 33 // For reporting Cacheable NTP navigations.
34 enum CacheableNTPLoad { 34 enum CacheableNTPLoad {
35 CACHEABLE_NTP_LOAD_FAILED = 0, 35 CACHEABLE_NTP_LOAD_FAILED = 0,
36 CACHEABLE_NTP_LOAD_SUCCEEDED = 1, 36 CACHEABLE_NTP_LOAD_SUCCEEDED = 1,
37 CACHEABLE_NTP_LOAD_MAX = 2 37 CACHEABLE_NTP_LOAD_MAX = 2
38 }; 38 };
39 39
40 enum OptInState { 40 enum OptInState {
41 // The user has not manually opted in/out of InstantExtended. 41 // The user has not manually opted in/out of InstantExtended.
42 INSTANT_EXTENDED_NOT_SET, 42 INSTANT_EXTENDED_NOT_SET,
43 // The user has opted-in to InstantExtended. 43 // The user has opted-in to InstantExtended.
44 INSTANT_EXTENDED_OPT_IN, 44 INSTANT_EXTENDED_OPT_IN,
45 // The user has opted-out of InstantExtended. 45 // The user has opted-out of InstantExtended.
46 INSTANT_EXTENDED_OPT_OUT, 46 INSTANT_EXTENDED_OPT_OUT,
47 INSTANT_EXTENDED_OPT_IN_STATE_ENUM_COUNT, 47 INSTANT_EXTENDED_OPT_IN_STATE_ENUM_COUNT,
48 }; 48 };
49 49
50 // Use this value for "start margin" to prevent the "es_sm" parameter from
51 // being used.
52 extern const int kDisableStartMargin;
53
54 // Returns whether the suggest is enabled for the given |profile|. 50 // Returns whether the suggest is enabled for the given |profile|.
55 bool IsSuggestPrefEnabled(Profile* profile); 51 bool IsSuggestPrefEnabled(Profile* profile);
56 52
57 // Returns a string indicating whether InstantExtended is enabled, suitable
58 // for adding as a query string param to the homepage or search requests.
59 // Returns an empty string otherwise.
60 //
61 // |for_search| should be set to true for search requests, in which case this
62 // returns a non-empty string only if query extraction is enabled.
63 std::string InstantExtendedEnabledParam(bool for_search);
64
65 // Returns a string that will cause the search results page to update
66 // incrementally. Currently, Instant Extended passes a different param to
67 // search results pages that also has this effect, so by default this function
68 // returns the empty string when Instant Extended is enabled. However, when
69 // doing instant search result prerendering, we still need to pass this param,
70 // as Instant Extended does not cause incremental updates by default for the
71 // prerender page. Callers should set |for_prerender| in this case to force
72 // the returned string to be non-empty.
73 std::string ForceInstantResultsParam(bool for_prerender);
74
75 // Returns whether query extraction is enabled.
76 bool IsQueryExtractionEnabled();
77
78 // Extracts and returns search terms from |url|. Does not consider 53 // Extracts and returns search terms from |url|. Does not consider
79 // IsQueryExtractionEnabled() and Instant support state of the page and does 54 // IsQueryExtractionEnabled() and Instant support state of the page and does
80 // not check for a privileged process, so most callers should use 55 // not check for a privileged process, so most callers should use
81 // GetSearchTerms() below instead. 56 // GetSearchTerms() below instead.
82 base::string16 ExtractSearchTermsFromURL(Profile* profile, const GURL& url); 57 base::string16 ExtractSearchTermsFromURL(Profile* profile, const GURL& url);
83 58
84 // Returns true if it is okay to extract search terms from |url|. |url| must 59 // Returns true if it is okay to extract search terms from |url|. |url| must
85 // have a secure scheme and must contain the search terms replacement key for 60 // have a secure scheme and must contain the search terms replacement key for
86 // the default search provider. 61 // the default search provider.
87 bool IsQueryExtractionAllowedForURL(Profile* profile, const GURL& url); 62 bool IsQueryExtractionAllowedForURL(Profile* profile, const GURL& url);
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 GURL GetInstantURL(Profile* profile, bool force_instant_results); 116 GURL GetInstantURL(Profile* profile, bool force_instant_results);
142 117
143 // Returns URLs associated with the default search engine for |profile|. 118 // Returns URLs associated with the default search engine for |profile|.
144 std::vector<GURL> GetSearchURLs(Profile* profile); 119 std::vector<GURL> GetSearchURLs(Profile* profile);
145 120
146 // Returns the default search engine base page URL to prefetch search results. 121 // Returns the default search engine base page URL to prefetch search results.
147 // Returns an empty URL if 'prefetch_results' flag is set to false in field 122 // Returns an empty URL if 'prefetch_results' flag is set to false in field
148 // trials. 123 // trials.
149 GURL GetSearchResultPrefetchBaseURL(Profile* profile); 124 GURL GetSearchResultPrefetchBaseURL(Profile* profile);
150 125
151 // Returns true if 'prefetch_results' flag is set to true in field trials to
152 // prefetch high-confidence search suggestions.
153 bool ShouldPrefetchSearchResults();
154
155 // Returns true if 'allow_prefetch_non_default_match' flag is enabled in field
156 // trials to allow prefetching the suggestion marked to be prefetched by the
157 // suggest server even if it is not the default match.
158 bool ShouldAllowPrefetchNonDefaultMatch();
159
160 // Returns true if 'prerender_instant_url_on_omnibox_focus' flag is enabled in 126 // Returns true if 'prerender_instant_url_on_omnibox_focus' flag is enabled in
161 // field trials to prerender Instant search base page when the omnibox is 127 // field trials to prerender Instant search base page when the omnibox is
162 // focused. 128 // focused.
163 bool ShouldPrerenderInstantUrlOnOmniboxFocus(); 129 bool ShouldPrerenderInstantUrlOnOmniboxFocus();
164 130
165 // Returns true if 'reuse_instant_search_base_page' flag is set to true in field
166 // trials to reuse the prerendered page to commit any search query.
167 bool ShouldReuseInstantSearchBasePage();
168
169 // Returns the Local Instant URL of the New Tab Page. 131 // Returns the Local Instant URL of the New Tab Page.
170 // TODO(kmadhusu): Remove this function and update the call sites. 132 // TODO(kmadhusu): Remove this function and update the call sites.
171 GURL GetLocalInstantURL(Profile* profile); 133 GURL GetLocalInstantURL(Profile* profile);
172 134
173 // Returns true if the local new tab page should show a Google logo and search 135 // Returns true if the local new tab page should show a Google logo and search
174 // box for users whose default search provider is Google, or false if not. 136 // box for users whose default search provider is Google, or false if not.
175 bool ShouldShowGoogleLocalNTP(); 137 bool ShouldShowGoogleLocalNTP();
176 138
177 // Transforms the input |url| into its "effective URL". The returned URL 139 // Transforms the input |url| into its "effective URL". The returned URL
178 // facilitates grouping process-per-site. The |url| is transformed, for 140 // facilitates grouping process-per-site. The |url| is transformed, for
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 InstantSupportState GetInstantSupportStateFromNavigationEntry( 175 InstantSupportState GetInstantSupportStateFromNavigationEntry(
214 const content::NavigationEntry& entry); 176 const content::NavigationEntry& entry);
215 177
216 // Returns true if the field trial flag is enabled to prefetch results on SRP. 178 // Returns true if the field trial flag is enabled to prefetch results on SRP.
217 bool ShouldPrefetchSearchResultsOnSRP(); 179 bool ShouldPrefetchSearchResultsOnSRP();
218 180
219 // ----------------------------------------------------- 181 // -----------------------------------------------------
220 // The following APIs are exposed for use in tests only. 182 // The following APIs are exposed for use in tests only.
221 // ----------------------------------------------------- 183 // -----------------------------------------------------
222 184
223 // Forces query in the omnibox to be on for tests.
224 void EnableQueryExtractionForTesting();
225
226 // Returns the Cacheable New Tab Page URL for the given |profile|. 185 // Returns the Cacheable New Tab Page URL for the given |profile|.
227 GURL GetNewTabPageURL(Profile* profile); 186 GURL GetNewTabPageURL(Profile* profile);
228 187
229 // Returns true if 'use_alternate_instant_url' flag is set to true in field 188 // Returns true if 'use_alternate_instant_url' flag is set to true in field
230 // trials to use an alternate Instant search base page URL for prefetching 189 // trials to use an alternate Instant search base page URL for prefetching
231 // search results. This allows experimentation of Instant search. 190 // search results. This allows experimentation of Instant search.
232 bool ShouldUseAltInstantURL(); 191 bool ShouldUseAltInstantURL();
233 192
234 // Returns true if 'use_search_path_for_instant' flag is set to true in field 193 // Returns true if 'use_search_path_for_instant' flag is set to true in field
235 // trials to use an '/search' path in an alternate Instant search base page URL 194 // trials to use an '/search' path in an alternate Instant search base page URL
236 // for prefetching search results. This allows experimentation of Instant 195 // for prefetching search results. This allows experimentation of Instant
237 // search. 196 // search.
238 bool ShouldUseSearchPathForInstant(); 197 bool ShouldUseSearchPathForInstant();
239 198
240 } // namespace chrome 199 } // namespace search
241 200
242 #endif // CHROME_BROWSER_SEARCH_SEARCH_H_ 201 #endif // CHROME_BROWSER_SEARCH_SEARCH_H_
OLDNEW
« no previous file with comments | « chrome/browser/search/local_ntp_source.cc ('k') | chrome/browser/search/search.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698