Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1066)

Unified Diff: content/browser/webui/web_ui_factory.h

Issue 6713082: Move WebUIFactory to chrome/browser. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: synced Created 9 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/browser/webui/web_ui.cc ('k') | content/browser/webui/web_ui_factory.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/webui/web_ui_factory.h
diff --git a/content/browser/webui/web_ui_factory.h b/content/browser/webui/web_ui_factory.h
index 2be656aadaaf72aed75e08cdc7fb19556c8521fa..0658c436b944a17acb06baee150c1c35eaa6ca82 100644
--- a/content/browser/webui/web_ui_factory.h
+++ b/content/browser/webui/web_ui_factory.h
@@ -6,62 +6,51 @@
#define CONTENT_BROWSER_WEBUI_WEB_UI_FACTORY_H_
#pragma once
-#include "base/basictypes.h"
-#include "chrome/browser/favicon_service.h"
+#include "content/browser/webui/web_ui.h"
-class WebUI;
-class GURL;
class Profile;
-class RefCountedMemory;
class TabContents;
+class GURL;
-// An opaque identifier used to identify a WebUI. This can only be compared to
-// kNoWebUI or other WebUI types. See GetWebUIType.
-typedef void* WebUITypeID;
+namespace content {
+// Interface for an object which controls which URLs are considered WebUI URLs
+// and creates WebUI instances for given URLs.
class WebUIFactory {
public:
- // A special WebUI type that signifies that a given page would not use the
- // Web UI system.
- static const WebUITypeID kNoWebUI;
-
- // Returns a type identifier indicating what WebUI we would use for the
- // given URL. This is useful for comparing the potential WebUIs for two URLs.
- // Returns kNoWebUI if the given URL will not use the Web UI system.
- static WebUITypeID GetWebUIType(Profile* profile, const GURL& url);
-
- // Returns true if the given URL's scheme would trigger the Web UI system.
- // This is a less precise test than UseDONUIForURL, which tells you whether
- // that specific URL matches a known one. This one is faster and can be used
- // to determine security policy.
- static bool HasWebUIScheme(const GURL& url);
-
- // Returns true if the given URL must use the Web UI system.
- static bool UseWebUIForURL(Profile* profile, const GURL& url);
-
- // Returns true if the given URL can be loaded by Web UI system. This
- // includes URLs that can be loaded by normal tabs as well, such as
- // javascript: URLs or about:hang.
- static bool IsURLAcceptableForWebUI(Profile* profile, const GURL& url);
-
- // Allocates a new WebUI object for the given URL, and returns it. If the URL
- // is not a Web UI URL, then it will return NULL. When non-NULL, ownership of
- // the returned pointer is passed to the caller.
- static WebUI* CreateWebUIForURL(TabContents* tab_contents, const GURL& url);
-
- // Get the favicon for |page_url| and forward the result to the |request|
- // when loaded.
- static void GetFaviconForURL(Profile* profile,
- FaviconService::GetFaviconRequest* request,
- const GURL& page_url);
+ // Returns a WebUI instance for the given URL, or NULL if the URL doesn't
+ // correspond to a WebUI.
+ virtual WebUI* CreateWebUIForURL(TabContents* source,
+ const GURL& url) const = 0;
+
+ // Gets the WebUI type for the given URL. This will return kNoWebUI if the
+ // corresponding call to CreateWebUIForURL would fail, or something non-NULL
+ // if CreateWebUIForURL would succeed.
+ virtual WebUI::TypeID GetWebUIType(Profile* profile,
+ const GURL& url) const = 0;
+
+ // Shorthand for the above, but returns a simple yes/no.
+ virtual bool UseWebUIForURL(Profile* profile, const GURL& url) const = 0;
+
+ // Returns true if the url has a scheme for WebUI. This differs from the above
+ // in that it only checks the scheme; it is faster and can be used to
+ // determine security policy.
+ virtual bool HasWebUIScheme(const GURL& url) const = 0;
+
+ // Returns true if the given URL can be loaded by Web UI system. This allows
+ // URLs with WebUI types (as above) and also URLs that can be loaded by
+ // normal tabs such as javascript: URLs or about:hang.
+ virtual bool IsURLAcceptableForWebUI(Profile* profile,
+ const GURL& url) const = 0;
+
+ virtual ~WebUIFactory() {}
+
+ // Helper function to streamline retrieval of the current WebUIFactory. Only
+ // to be used in content/.
+ static WebUIFactory* Get();
+};
- private:
- // Gets the data for the favicon for a WebUI page. Returns NULL if the WebUI
- // does not have a favicon.
- static RefCountedMemory* GetFaviconResourceBytes(Profile* profile,
- const GURL& page_url);
- DISALLOW_IMPLICIT_CONSTRUCTORS(WebUIFactory);
-};
+} // namespace content
#endif // CONTENT_BROWSER_WEBUI_WEB_UI_FACTORY_H_
« no previous file with comments | « content/browser/webui/web_ui.cc ('k') | content/browser/webui/web_ui_factory.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698