Re-enable index-basics-workers test to see if still times
[chromium-blink-merge.git] / content / public / browser / browser_url_handler.h
blobd880fd30eb2f73af750ed480a7e41937296ca7bd
1 // Copyright (c) 2012 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 CONTENT_PUBLIC_BROWSER_BROWSER_URL_HANDLER_H_
6 #define CONTENT_PUBLIC_BROWSER_BROWSER_URL_HANDLER_H_
8 #include "content/common/content_export.h"
10 class GURL;
12 namespace content {
13 class BrowserContext;
15 // We handle some special browser-level URLs (like "about:version")
16 // before they're handed to a renderer. This lets us do the URL handling
17 // on the browser side (which has access to more information than the
18 // renderers do) as well as sidestep the risk of exposing data to
19 // random web pages (because from the resource loader's perspective, these
20 // URL schemes don't exist).
21 // BrowserURLHandler manages the list of all special URLs and manages
22 // dispatching the URL handling to registered handlers.
23 class CONTENT_EXPORT BrowserURLHandler {
24 public:
25 // The type of functions that can process a URL.
26 // If a handler handles |url|, it should :
27 // - optionally modify |url| to the URL that should be sent to the renderer
28 // If the URL is not handled by a handler, it should return false.
29 typedef bool (*URLHandler)(GURL* url,
30 BrowserContext* browser_context);
32 // Returns the null handler for use with |AddHandlerPair()|.
33 static URLHandler null_handler();
35 // Returns the singleton instance.
36 static BrowserURLHandler* GetInstance();
38 // RewriteURLIfNecessary gives all registered URLHandlers a shot at processing
39 // the given URL, and modifies it in place.
40 // If the original URL needs to be adjusted if the modified URL is redirected,
41 // this function sets |reverse_on_redirect| to true.
42 virtual void RewriteURLIfNecessary(GURL* url,
43 BrowserContext* browser_context,
44 bool* reverse_on_redirect) = 0;
46 // Add the specified handler pair to the list of URL handlers.
47 virtual void AddHandlerPair(URLHandler handler,
48 URLHandler reverse_handler) = 0;
50 protected:
51 virtual ~BrowserURLHandler() {}
54 } // namespace content
56 #endif // CONTENT_PUBLIC_BROWSER_BROWSER_URL_HANDLER_H_