| OLD | NEW |
| 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 18 matching lines...) Expand all Loading... |
| 29 | 29 |
| 30 namespace search { | 30 namespace search { |
| 31 | 31 |
| 32 // For reporting Cacheable NTP navigations. | 32 // For reporting Cacheable NTP navigations. |
| 33 enum CacheableNTPLoad { | 33 enum CacheableNTPLoad { |
| 34 CACHEABLE_NTP_LOAD_FAILED = 0, | 34 CACHEABLE_NTP_LOAD_FAILED = 0, |
| 35 CACHEABLE_NTP_LOAD_SUCCEEDED = 1, | 35 CACHEABLE_NTP_LOAD_SUCCEEDED = 1, |
| 36 CACHEABLE_NTP_LOAD_MAX = 2 | 36 CACHEABLE_NTP_LOAD_MAX = 2 |
| 37 }; | 37 }; |
| 38 | 38 |
| 39 enum OptInState { | |
| 40 // The user has not manually opted in/out of InstantExtended. | |
| 41 INSTANT_EXTENDED_NOT_SET, | |
| 42 // The user has opted-in to InstantExtended. | |
| 43 INSTANT_EXTENDED_OPT_IN, | |
| 44 // The user has opted-out of InstantExtended. | |
| 45 INSTANT_EXTENDED_OPT_OUT, | |
| 46 INSTANT_EXTENDED_OPT_IN_STATE_ENUM_COUNT, | |
| 47 }; | |
| 48 | |
| 49 // Returns whether the suggest is enabled for the given |profile|. | 39 // Returns whether the suggest is enabled for the given |profile|. |
| 50 bool IsSuggestPrefEnabled(Profile* profile); | 40 bool IsSuggestPrefEnabled(Profile* profile); |
| 51 | 41 |
| 52 // Extracts and returns search terms from |url|. Does not consider | 42 // Extracts and returns search terms from |url|. Does not consider |
| 53 // IsQueryExtractionEnabled() and Instant support state of the page and does | 43 // IsQueryExtractionEnabled() and Instant support state of the page and does |
| 54 // not check for a privileged process, so most callers should use | 44 // not check for a privileged process, so most callers should use |
| 55 // GetSearchTerms() below instead. | 45 // GetSearchTerms() below instead. |
| 56 base::string16 ExtractSearchTermsFromURL(Profile* profile, const GURL& url); | 46 base::string16 ExtractSearchTermsFromURL(Profile* profile, const GURL& url); |
| 57 | 47 |
| 58 // Returns true if it is okay to extract search terms from |url|. |url| must | 48 // Returns true if it is okay to extract search terms from |url|. |url| must |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 // Returns the default search engine base page URL to prefetch search results. | 117 // Returns the default search engine base page URL to prefetch search results. |
| 128 // Returns an empty URL if 'prefetch_results' flag is set to false in field | 118 // Returns an empty URL if 'prefetch_results' flag is set to false in field |
| 129 // trials. | 119 // trials. |
| 130 GURL GetSearchResultPrefetchBaseURL(Profile* profile); | 120 GURL GetSearchResultPrefetchBaseURL(Profile* profile); |
| 131 | 121 |
| 132 // Returns true if 'prerender_instant_url_on_omnibox_focus' flag is enabled in | 122 // Returns true if 'prerender_instant_url_on_omnibox_focus' flag is enabled in |
| 133 // field trials to prerender Instant search base page when the omnibox is | 123 // field trials to prerender Instant search base page when the omnibox is |
| 134 // focused. | 124 // focused. |
| 135 bool ShouldPrerenderInstantUrlOnOmniboxFocus(); | 125 bool ShouldPrerenderInstantUrlOnOmniboxFocus(); |
| 136 | 126 |
| 137 // Transforms the input |url| into its "effective URL". The returned URL | 127 // Transforms the input |url| into its "effective URL". |url| must be an |
| 138 // facilitates grouping process-per-site. The |url| is transformed, for | 128 // Instant URL, i.e. ShouldAssignURLToInstantRenderer must return true. The |
| 139 // example, from | 129 // returned URL facilitates grouping process-per-site. The |url| is transformed, |
| 130 // for example, from |
| 140 // | 131 // |
| 141 // https://www.google.com/search?espv=1&q=tractors | 132 // https://www.google.com/search?espv=1&q=tractors |
| 142 // | 133 // |
| 143 // to the privileged URL | 134 // to the privileged URL |
| 144 // | 135 // |
| 145 // chrome-search://www.google.com/search?espv=1&q=tractors | 136 // chrome-search://www.google.com/search?espv=1&q=tractors |
| 146 // | 137 // |
| 147 // Notice the scheme change. | 138 // Notice the scheme change. |
| 148 // | 139 // |
| 149 // If the input is already a privileged URL then that same URL is returned. | 140 // If the input is already a privileged URL then that same URL is returned. |
| 150 // | 141 // |
| 151 // If |url| is that of the online NTP, its host is replaced with "online-ntp". | 142 // If |url| is that of the online NTP, its host is replaced with "remote-ntp". |
| 152 // This forces the NTP and search results pages to have different SiteIntances, | 143 // This forces the NTP and search results pages to have different SiteIntances, |
| 153 // and hence different processes. | 144 // and hence different processes. |
| 154 GURL GetEffectiveURLForInstant(const GURL& url, Profile* profile); | 145 GURL GetEffectiveURLForInstant(const GURL& url, Profile* profile); |
| 155 | 146 |
| 156 // Rewrites |url| if | 147 // Rewrites |url| to the actual NTP URL to use if |
| 157 // 1. |url| is kChromeUINewTabURL, | 148 // 1. |url| is "chrome://newtab", |
| 158 // 2. InstantExtended is enabled, and | 149 // 2. InstantExtended is enabled, and |
| 159 // 3. The --instant-new-tab-url switch is set to a valid URL. | 150 // 3. |browser_context| doesn't correspond to an incognito profile. |
| 160 // |url| is rewritten to the value of --instant-new-tab-url. | |
| 161 bool HandleNewTabURLRewrite(GURL* url, | 151 bool HandleNewTabURLRewrite(GURL* url, |
| 162 content::BrowserContext* browser_context); | 152 content::BrowserContext* browser_context); |
| 163 // Reverses the operation from HandleNewTabURLRewrite. | 153 // Reverses the operation from HandleNewTabURLRewrite. |
| 164 bool HandleNewTabURLReverseRewrite(GURL* url, | 154 bool HandleNewTabURLReverseRewrite(GURL* url, |
| 165 content::BrowserContext* browser_context); | 155 content::BrowserContext* browser_context); |
| 166 | 156 |
| 167 // Sets the Instant support |state| in the navigation |entry|. | 157 // Sets the Instant support |state| in the navigation |entry|. |
| 168 void SetInstantSupportStateInNavigationEntry(InstantSupportState state, | 158 void SetInstantSupportStateInNavigationEntry(InstantSupportState state, |
| 169 content::NavigationEntry* entry); | 159 content::NavigationEntry* entry); |
| 170 | 160 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 190 | 180 |
| 191 // Returns true if 'use_search_path_for_instant' flag is set to true in field | 181 // Returns true if 'use_search_path_for_instant' flag is set to true in field |
| 192 // trials to use an '/search' path in an alternate Instant search base page URL | 182 // trials to use an '/search' path in an alternate Instant search base page URL |
| 193 // for prefetching search results. This allows experimentation of Instant | 183 // for prefetching search results. This allows experimentation of Instant |
| 194 // search. | 184 // search. |
| 195 bool ShouldUseSearchPathForInstant(); | 185 bool ShouldUseSearchPathForInstant(); |
| 196 | 186 |
| 197 } // namespace search | 187 } // namespace search |
| 198 | 188 |
| 199 #endif // CHROME_BROWSER_SEARCH_SEARCH_H_ | 189 #endif // CHROME_BROWSER_SEARCH_SEARCH_H_ |
| OLD | NEW |