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 "url/gurl.h" 10 11 namespace net { 12 class URLRequest; 13 } 14 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 31 // Indicates whether the URL provided has a Google domain 32 bool IsGoogleDomain(const GURL& url); 33 34 // Indicates whether the URL provided could be a Google search result page. 35 bool IsGoogleSearchResultURL(const GURL& url); 36 37 // Returns true iff the URL provided is Web URL, using the scheme http 38 // or https. 39 bool IsWebURL(const GURL& url); 40 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 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 51 // Static method gathering stats about a URLRequest for which a response has 52 // just started. 53 void URLRequestResponseStarted(net::URLRequest* request); 54 55 } // namespace prerender 56 57 #endif // CHROME_BROWSER_PRERENDER_PRERENDER_UTIL_H_ 58