OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 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 CONTENT_BROWSER_BROWSER_URL_HANDLER_H_ | 12 #ifndef CONTENT_BROWSER_BROWSER_URL_HANDLER_H_ |
13 #define CONTENT_BROWSER_BROWSER_URL_HANDLER_H_ | 13 #define CONTENT_BROWSER_BROWSER_URL_HANDLER_H_ |
14 #pragma once | 14 #pragma once |
15 | 15 |
16 #include <vector> | 16 #include <vector> |
17 #include <utility> | 17 #include <utility> |
18 | 18 |
19 #include "base/gtest_prod_util.h" | 19 #include "base/gtest_prod_util.h" |
20 #include "base/memory/singleton.h" | 20 #include "base/memory/singleton.h" |
| 21 #include "content/common/content_export.h" |
21 | 22 |
22 class GURL; | 23 class GURL; |
23 | 24 |
24 namespace content { | 25 namespace content { |
25 class BrowserContext; | 26 class BrowserContext; |
26 } | 27 } |
27 | 28 |
28 // BrowserURLHandler manages the list of all special URLs and manages | 29 // BrowserURLHandler manages the list of all special URLs and manages |
29 // dispatching the URL handling to registered handlers. | 30 // dispatching the URL handling to registered handlers. |
30 class BrowserURLHandler { | 31 class CONTENT_EXPORT BrowserURLHandler { |
31 public: | 32 public: |
32 // The type of functions that can process a URL. | 33 // The type of functions that can process a URL. |
33 // If a handler handles |url|, it should : | 34 // If a handler handles |url|, it should : |
34 // - optionally modify |url| to the URL that should be sent to the renderer | 35 // - optionally modify |url| to the URL that should be sent to the renderer |
35 // If the URL is not handled by a handler, it should return false. | 36 // If the URL is not handled by a handler, it should return false. |
36 typedef bool (*URLHandler)(GURL* url, | 37 typedef bool (*URLHandler)(GURL* url, |
37 content::BrowserContext* browser_context); | 38 content::BrowserContext* browser_context); |
38 | 39 |
39 // Returns the singleton instance. | 40 // Returns the singleton instance. |
40 static BrowserURLHandler* GetInstance(); | 41 static BrowserURLHandler* GetInstance(); |
(...skipping 26 matching lines...) Expand all Loading... |
67 typedef std::pair<URLHandler, URLHandler> HandlerPair; | 68 typedef std::pair<URLHandler, URLHandler> HandlerPair; |
68 std::vector<HandlerPair> url_handlers_; | 69 std::vector<HandlerPair> url_handlers_; |
69 | 70 |
70 FRIEND_TEST_ALL_PREFIXES(BrowserURLHandlerTest, BasicRewriteAndReverse); | 71 FRIEND_TEST_ALL_PREFIXES(BrowserURLHandlerTest, BasicRewriteAndReverse); |
71 FRIEND_TEST_ALL_PREFIXES(BrowserURLHandlerTest, NullHandlerReverse); | 72 FRIEND_TEST_ALL_PREFIXES(BrowserURLHandlerTest, NullHandlerReverse); |
72 | 73 |
73 DISALLOW_COPY_AND_ASSIGN(BrowserURLHandler); | 74 DISALLOW_COPY_AND_ASSIGN(BrowserURLHandler); |
74 }; | 75 }; |
75 | 76 |
76 #endif // CONTENT_BROWSER_BROWSER_URL_HANDLER_H_ | 77 #endif // CONTENT_BROWSER_BROWSER_URL_HANDLER_H_ |
OLD | NEW |