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