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 "base/basictypes.h" | |
10 #include "chrome/browser/favicon_service.h" | |
11 | |
12 class WebUI; | |
13 class GURL; | |
14 class Profile; | |
15 class RefCountedMemory; | |
16 class TabContents; | |
17 | |
18 // An opaque identifier used to identify a WebUI. This can only be compared to | |
19 // kNoWebUI or other WebUI types. See GetWebUIType. | |
20 typedef void* WebUITypeID; | |
21 | |
22 class WebUIFactory { | |
23 public: | |
24 // A special WebUI type that signifies that a given page would not use the | |
25 // Web UI system. | |
26 static const WebUITypeID kNoWebUI; | |
27 | |
28 // Returns a type identifier indicating what WebUI we would use for the | |
29 // given URL. This is useful for comparing the potential WebUIs for two URLs. | |
30 // Returns kNoWebUI if the given URL will not use the Web UI system. | |
31 static WebUITypeID GetWebUIType(Profile* profile, const GURL& url); | |
32 | |
33 // Returns true if the given URL's scheme would trigger the Web UI system. | |
34 // This is a less precise test than UseDONUIForURL, which tells you whether | |
35 // that specific URL matches a known one. This one is faster and can be used | |
36 // to determine security policy. | |
37 static bool HasWebUIScheme(const GURL& url); | |
38 | |
39 // Returns true if the given URL must use the Web UI system. | |
40 static bool UseWebUIForURL(Profile* profile, const GURL& url); | |
41 | |
42 // Returns true if the given URL can be loaded by Web UI system. This | |
43 // includes URLs that can be loaded by normal tabs as well, such as | |
44 // javascript: URLs or about:hang. | |
45 static bool IsURLAcceptableForWebUI(Profile* profile, const GURL& url); | |
46 | |
47 // Allocates a new WebUI object for the given URL, and returns it. If the URL | |
48 // is not a Web UI URL, then it will return NULL. When non-NULL, ownership of | |
49 // the returned pointer is passed to the caller. | |
50 static WebUI* CreateWebUIForURL(TabContents* tab_contents, const GURL& url); | |
51 | |
52 // Get the favicon for |page_url| and forward the result to the |request| | |
53 // when loaded. | |
54 static void GetFaviconForURL(Profile* profile, | |
55 FaviconService::GetFaviconRequest* request, | |
56 const GURL& page_url); | |
57 | |
58 private: | |
59 // Gets the data for the favicon for a WebUI page. Returns NULL if the WebUI | |
60 // does not have a favicon. | |
61 static RefCountedMemory* GetFaviconResourceBytes(Profile* profile, | |
62 const GURL& page_url); | |
63 | |
64 DISALLOW_IMPLICIT_CONSTRUCTORS(WebUIFactory); | |
65 }; | |
66 | |
67 #endif // CONTENT_BROWSER_WEBUI_WEB_UI_FACTORY_H_ | |
OLD | NEW |