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