Disable view source for Developer Tools.
[chromium-blink-merge.git] / chrome / browser / prerender / prerender_util.h
blob261e57d8f065fdecde419effce76b5aea99d3467
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.
5 #ifndef CHROME_BROWSER_PRERENDER_PRERENDER_UTIL_H_
6 #define CHROME_BROWSER_PRERENDER_PRERENDER_UTIL_H_
8 #include "base/basictypes.h"
9 #include "url/gurl.h"
10 #include "webkit/common/resource_type.h"
12 namespace net {
13 class HttpResponseHeaders;
14 class URLRequest;
17 namespace prerender {
19 extern const char kChromeNavigateExtraDataKey[];
21 // ID indicating that no experiment is active.
22 const uint8 kNoExperiment = 0;
24 // Extracts a urlencoded URL stored in a url= query parameter from a URL
25 // supplied, if available, and stores it in alias_url. Returns whether or not
26 // the operation succeeded (i.e. a valid URL was found).
27 bool MaybeGetQueryStringBasedAliasURL(const GURL& url, GURL* alias_url);
29 // Extracts an experiment stored in the query parameter
30 // lpe= from the URL supplied, and returns it.
31 // Returns kNoExperiment if no experiment ID is found, or if the ID
32 // is not an integer in the range 1 to 9.
33 uint8 GetQueryStringBasedExperiment(const GURL& url);
35 // Indicates whether the URL provided has a Google domain
36 bool IsGoogleDomain(const GURL& url);
38 // Indicates whether the URL provided could be a Google search result page.
39 bool IsGoogleSearchResultURL(const GURL& url);
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);
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);
51 // Called by URLRequestResponseStarted to gather data about Pagespeed headers
52 // into the Prerender.PagespeedHeader histogram. Public so it can be accessed
53 // by the unit test.
54 void GatherPagespeedData(const ResourceType::Type resource_type,
55 const GURL& request_url,
56 const net::HttpResponseHeaders* response_headers);
58 // Static method gathering stats about a URLRequest for which a response has
59 // just started.
60 void URLRequestResponseStarted(net::URLRequest* request);
62 // Report a URL was canceled due to trying to handle an external URL.
63 void ReportPrerenderExternalURL();
65 // Report a URL was canceled due to unsupported prerender scheme.
66 void ReportUnsupportedPrerenderScheme(const GURL& url);
68 } // namespace prerender
70 #endif // CHROME_BROWSER_PRERENDER_PRERENDER_UTIL_H_