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_BROWSER_WEBUI_WEB_UI_FACTORY_H_ | |
6 #define CONTENT_BROWSER_WEBUI_WEB_UI_FACTORY_H_ | |
7 #pragma once | |
8 | |
9 #include "content/browser/webui/web_ui.h" | |
10 #include "content/common/content_export.h" | |
11 | |
12 class TabContents; | |
13 class GURL; | |
14 | |
15 namespace content { | |
16 | |
17 class BrowserContext; | |
18 | |
19 // Interface for an object which controls which URLs are considered WebUI URLs | |
20 // and creates WebUI instances for given URLs. | |
21 class CONTENT_EXPORT WebUIFactory { | |
22 public: | |
23 // Returns a WebUI instance for the given URL, or NULL if the URL doesn't | |
24 // correspond to a WebUI. | |
25 virtual WebUI* CreateWebUIForURL(TabContents* source, | |
26 const GURL& url) const = 0; | |
27 | |
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 | |
30 // if CreateWebUIForURL would succeed. | |
31 virtual WebUI::TypeID GetWebUIType(content::BrowserContext* browser_context, | |
32 const GURL& url) const = 0; | |
33 | |
34 // Shorthand for the above, but returns a simple yes/no. | |
35 virtual bool UseWebUIForURL(content::BrowserContext* browser_context, | |
36 const GURL& url) const = 0; | |
37 | |
38 // Returns true for the subset of WebUIs that actually need WebUI bindings. | |
39 virtual bool UseWebUIBindingsForURL(content::BrowserContext* browser_context, | |
40 const GURL& url) const = 0; | |
41 | |
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 | |
44 // determine security policy. | |
45 virtual bool HasWebUIScheme(const GURL& url) const = 0; | |
46 | |
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 | |
49 // normal tabs such as javascript: URLs or about:hang. | |
50 virtual bool IsURLAcceptableForWebUI(content::BrowserContext* browser_context, | |
51 const GURL& url) const = 0; | |
52 | |
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 }; | |
59 | |
60 | |
61 } // namespace content | |
62 | |
63 #endif // CONTENT_BROWSER_WEBUI_WEB_UI_FACTORY_H_ | |
OLD | NEW |