[email protected] | e253ab0 | 2011-07-07 21:58:39 | [diff] [blame] | 1 | // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #ifndef CHROME_BROWSER_PRERENDER_PRERENDER_UTIL_H_ |
| 6 | #define CHROME_BROWSER_PRERENDER_PRERENDER_UTIL_H_ |
| 7 | |
| 8 | #include "base/basictypes.h" |
| 9 | #include "googleurl/src/gurl.h" |
| 10 | |
[email protected] | 3e9e7a1 | 2012-12-14 02:27:48 | [diff] [blame] | 11 | namespace net { |
| 12 | class URLRequest; |
| 13 | } |
| 14 | |
[email protected] | e253ab0 | 2011-07-07 21:58:39 | [diff] [blame] | 15 | namespace prerender { |
| 16 | |
| 17 | // ID indicating that no experiment is active. |
| 18 | const uint8 kNoExperiment = 0; |
| 19 | |
| 20 | // Extracts a urlencoded URL stored in a url= query parameter from a URL |
| 21 | // supplied, if available, and stores it in alias_url. Returns whether or not |
| 22 | // the operation succeeded (i.e. a valid URL was found). |
| 23 | bool MaybeGetQueryStringBasedAliasURL(const GURL& url, GURL* alias_url); |
| 24 | |
| 25 | // Extracts an experiment stored in the query parameter |
| 26 | // lpe= from the URL supplied, and returns it. |
| 27 | // Returns kNoExperiment if no experiment ID is found, or if the ID |
| 28 | // is not an integer in the range 1 to 9. |
| 29 | uint8 GetQueryStringBasedExperiment(const GURL& url); |
| 30 | |
[email protected] | c97f7e66 | 2011-10-04 00:50:36 | [diff] [blame] | 31 | // Indicates whether the URL provided has a Google domain |
| 32 | bool IsGoogleDomain(const GURL& url); |
| 33 | |
[email protected] | 2d02bea | 2011-08-30 23:50:59 | [diff] [blame] | 34 | // Indicates whether the URL provided could be a Google search result page. |
| 35 | bool IsGoogleSearchResultURL(const GURL& url); |
| 36 | |
[email protected] | 66a225c | 2011-10-07 23:00:10 | [diff] [blame] | 37 | // Returns true iff the URL provided is Web URL, using the scheme http |
| 38 | // or https. |
| 39 | bool IsWebURL(const GURL& url); |
| 40 | |
[email protected] | 0ce62595 | 2012-03-20 22:48:16 | [diff] [blame] | 41 | // The prerender contents of some experiments should never be swapped in |
| 42 | // by pretending to never match on the URL. This function will return true |
| 43 | // iff this is the case for the experiment_id specified. |
| 44 | bool IsNoSwapInExperiment(uint8 experiment_id); |
| 45 | |
[email protected] | 4a1c144c | 2012-06-07 17:43:04 | [diff] [blame] | 46 | // The prerender contents of some experiments should behave identical to the |
| 47 | // control group, regardless of the field trial. This function will return true |
| 48 | // iff this is the case for the experiment_id specified. |
| 49 | bool IsControlGroupExperiment(uint8 experiment_id); |
| 50 | |
[email protected] | 3e9e7a1 | 2012-12-14 02:27:48 | [diff] [blame] | 51 | // Static method gathering stats about a URLRequest for which a response has |
| 52 | // just started. |
| 53 | void URLRequestResponseStarted(net::URLRequest* request); |
| 54 | |
[email protected] | e253ab0 | 2011-07-07 21:58:39 | [diff] [blame] | 55 | } // namespace prerender |
| 56 | |
| 57 | #endif // CHROME_BROWSER_PRERENDER_PRERENDER_UTIL_H_ |