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 #ifndef CONTENT_BROWSER_WEBUI_WEB_UI_FACTORY_H_ | 5 #ifndef CONTENT_PUBLIC_BROWSER_WEB_UI_FACTORY_H_ |
6 #define CONTENT_BROWSER_WEBUI_WEB_UI_FACTORY_H_ | 6 #define CONTENT_PUBLIC_BROWSER_WEB_UI_FACTORY_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "content/browser/webui/web_ui.h" | 9 #include "content/browser/webui/web_ui.h" |
10 #include "content/common/content_export.h" | 10 #include "content/common/content_export.h" |
11 | 11 |
12 class TabContents; | |
13 class GURL; | 12 class GURL; |
14 | 13 |
15 namespace content { | 14 namespace content { |
16 | 15 |
17 class BrowserContext; | 16 class BrowserContext; |
| 17 class WebContents; |
18 | 18 |
19 // Interface for an object which controls which URLs are considered WebUI URLs | 19 // Interface for an object which controls which URLs are considered WebUI URLs |
20 // and creates WebUI instances for given URLs. | 20 // and creates WebUI instances for given URLs. |
21 class CONTENT_EXPORT WebUIFactory { | 21 class CONTENT_EXPORT WebUIFactory { |
22 public: | 22 public: |
23 // Returns a WebUI instance for the given URL, or NULL if the URL doesn't | 23 // Returns a WebUI instance for the given URL, or NULL if the URL doesn't |
24 // correspond to a WebUI. | 24 // correspond to a WebUI. |
25 virtual WebUI* CreateWebUIForURL(TabContents* source, | 25 virtual WebUI* CreateWebUIForURL(WebContents* source, |
26 const GURL& url) const = 0; | 26 const GURL& url) const = 0; |
27 | 27 |
28 // Gets the WebUI type for the given URL. This will return kNoWebUI if the | 28 // Gets the WebUI type for the given URL. This will return kNoWebUI if the |
29 // corresponding call to CreateWebUIForURL would fail, or something non-NULL | 29 // corresponding call to CreateWebUIForURL would fail, or something non-NULL |
30 // if CreateWebUIForURL would succeed. | 30 // if CreateWebUIForURL would succeed. |
31 virtual WebUI::TypeID GetWebUIType(content::BrowserContext* browser_context, | 31 virtual WebUI::TypeID GetWebUIType(BrowserContext* browser_context, |
32 const GURL& url) const = 0; | 32 const GURL& url) const = 0; |
33 | 33 |
34 // Shorthand for the above, but returns a simple yes/no. | 34 // Shorthand for the above, but returns a simple yes/no. |
35 virtual bool UseWebUIForURL(content::BrowserContext* browser_context, | 35 virtual bool UseWebUIForURL(BrowserContext* browser_context, |
36 const GURL& url) const = 0; | 36 const GURL& url) const = 0; |
37 | 37 |
38 // Returns true for the subset of WebUIs that actually need WebUI bindings. | 38 // Returns true for the subset of WebUIs that actually need WebUI bindings. |
39 virtual bool UseWebUIBindingsForURL(content::BrowserContext* browser_context, | 39 virtual bool UseWebUIBindingsForURL(BrowserContext* browser_context, |
40 const GURL& url) const = 0; | 40 const GURL& url) const = 0; |
41 | 41 |
42 // Returns true if the url has a scheme for WebUI. This differs from the above | 42 // Returns true if the url has a scheme for WebUI. This differs from the above |
43 // in that it only checks the scheme; it is faster and can be used to | 43 // in that it only checks the scheme; it is faster and can be used to |
44 // determine security policy. | 44 // determine security policy. |
45 virtual bool HasWebUIScheme(const GURL& url) const = 0; | 45 virtual bool HasWebUIScheme(const GURL& url) const = 0; |
46 | 46 |
47 // Returns true if the given URL can be loaded by Web UI system. This allows | 47 // Returns true if the given URL can be loaded by Web UI system. This allows |
48 // URLs with WebUI types (as above) and also URLs that can be loaded by | 48 // URLs with WebUI types (as above) and also URLs that can be loaded by |
49 // normal tabs such as javascript: URLs or about:hang. | 49 // normal tabs such as javascript: URLs or about:hang. |
50 virtual bool IsURLAcceptableForWebUI(content::BrowserContext* browser_context, | 50 virtual bool IsURLAcceptableForWebUI(BrowserContext* browser_context, |
51 const GURL& url) const = 0; | 51 const GURL& url) const = 0; |
52 | 52 |
53 virtual ~WebUIFactory() {} | 53 virtual ~WebUIFactory() {} |
54 | |
55 // Helper function to streamline retrieval of the current WebUIFactory. Only | |
56 // to be used in content/. Guaranteed to return non-NULL. | |
57 static WebUIFactory* Get(); | |
58 }; | 54 }; |
59 | 55 |
60 | |
61 } // namespace content | 56 } // namespace content |
62 | 57 |
63 #endif // CONTENT_BROWSER_WEBUI_WEB_UI_FACTORY_H_ | 58 #endif // CONTENT_PUBLIC_BROWSER_WEB_UI_FACTORY_H_ |
OLD | NEW |