OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // We handle some special browser-level URLs (like "about:version") | 5 // We handle some special browser-level URLs (like "about:version") |
6 // before they're handed to a renderer. This lets us do the URL handling | 6 // before they're handed to a renderer. This lets us do the URL handling |
7 // on the browser side (which has access to more information than the | 7 // on the browser side (which has access to more information than the |
8 // renderers do) as well as sidestep the risk of exposing data to | 8 // renderers do) as well as sidestep the risk of exposing data to |
9 // random web pages (because from the resource loader's perspective, these | 9 // random web pages (because from the resource loader's perspective, these |
10 // URL schemes don't exist). | 10 // URL schemes don't exist). |
11 | 11 |
12 #ifndef CHROME_BROWSER_BROWSER_URL_HANDLER_H_ | 12 #ifndef CHROME_BROWSER_BROWSER_URL_HANDLER_H_ |
13 #define CHROME_BROWSER_BROWSER_URL_HANDLER_H_ | 13 #define CHROME_BROWSER_BROWSER_URL_HANDLER_H_ |
14 | 14 |
15 #include <vector> | 15 #include <vector> |
16 | 16 |
17 class GURL; | 17 class GURL; |
| 18 class Profile; |
18 | 19 |
19 // BrowserURLHandler manages the list of all special URLs and manages | 20 // BrowserURLHandler manages the list of all special URLs and manages |
20 // dispatching the URL handling to registered handlers. | 21 // dispatching the URL handling to registered handlers. |
21 class BrowserURLHandler { | 22 class BrowserURLHandler { |
22 public: | 23 public: |
23 // The type of functions that can process a URL. | 24 // The type of functions that can process a URL. |
24 // If a handler handles |url|, it should : | 25 // If a handler handles |url|, it should : |
25 // - optionally modify |url| to the URL that should be sent to the renderer | 26 // - optionally modify |url| to the URL that should be sent to the renderer |
26 // - optionally set |dispatcher| to the necessary DOMMessageDispatcher | 27 // - optionally set |dispatcher| to the necessary DOMMessageDispatcher |
27 // - return true. | 28 // - return true. |
28 // If the URL is not handled by a handler, it should return false. | 29 // If the URL is not handled by a handler, it should return false. |
29 typedef bool (*URLHandler)(GURL* url); | 30 typedef bool (*URLHandler)(GURL* url, Profile* profile); |
30 | 31 |
31 // HandleBrowserURL gives all registered URLHandlers a shot at processing | 32 // HandleBrowserURL gives all registered URLHandlers a shot at processing |
32 // the given URL, and modifies it in place. | 33 // the given URL, and modifies it in place. |
33 static void RewriteURLIfNecessary(GURL* url); | 34 static void RewriteURLIfNecessary(GURL* url, Profile* profile); |
34 | 35 |
35 // We initialize the list of url_handlers_ lazily the first time MaybeHandle | 36 // We initialize the list of url_handlers_ lazily the first time MaybeHandle |
36 // is called. | 37 // is called. |
37 static void InitURLHandlers(); | 38 static void InitURLHandlers(); |
38 | 39 |
39 // The list of known URLHandlers. | 40 // The list of known URLHandlers. |
40 static std::vector<URLHandler> url_handlers_; | 41 static std::vector<URLHandler> url_handlers_; |
41 }; | 42 }; |
42 | 43 |
43 #endif // CHROME_BROWSER_BROWSER_URL_HANDLER_H_ | 44 #endif // CHROME_BROWSER_BROWSER_URL_HANDLER_H_ |
OLD | NEW |