OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 CHROME_BROWSER_DOM_UI_DOM_UI_FACTORY_H_ | 5 #ifndef CHROME_BROWSER_DOM_UI_DOM_UI_FACTORY_H_ |
6 #define CHROME_BROWSER_DOM_UI_DOM_UI_FACTORY_H_ | 6 #define CHROME_BROWSER_DOM_UI_DOM_UI_FACTORY_H_ |
7 | 7 |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 class DOMUI; | 10 class DOMUI; |
11 class GURL; | 11 class GURL; |
12 class TabContents; | 12 class TabContents; |
13 | 13 |
| 14 // An opaque identifier used to identify a DOMUI. This can only be compared to |
| 15 // kNoDOMUI or other DOMUI types. See GetDOMUIType. |
| 16 typedef void* DOMUITypeID; |
| 17 |
14 class DOMUIFactory { | 18 class DOMUIFactory { |
15 public: | 19 public: |
| 20 // A special DOMUI type that signifies that a given page would not use the |
| 21 // DOM UI system. |
| 22 static const DOMUITypeID kNoDOMUI; |
| 23 |
| 24 // Returns a type identifier indicating what DOMUI we would use for the |
| 25 // given URL. This is useful for comparing the potential DOMUIs for two URLs. |
| 26 // Returns kNoDOMUI if the given URL will not use the DOM UI system. |
| 27 static DOMUITypeID GetDOMUIType(const GURL& url); |
| 28 |
16 // Returns true if the given URL's scheme would trigger the DOM UI system. | 29 // Returns true if the given URL's scheme would trigger the DOM UI system. |
17 // This is a less precise test than UseDONUIForURL, which tells you whether | 30 // This is a less precise test than UseDONUIForURL, which tells you whether |
18 // that specific URL matches a known one. This one is faster and can be used | 31 // that specific URL matches a known one. This one is faster and can be used |
19 // to determine security policy. | 32 // to determine security policy. |
20 static bool HasDOMUIScheme(const GURL& url); | 33 static bool HasDOMUIScheme(const GURL& url); |
21 | 34 |
22 // Returns true if the given URL will use the DOM UI system. | 35 // Returns true if the given URL will use the DOM UI system. |
23 static bool UseDOMUIForURL(const GURL& url); | 36 static bool UseDOMUIForURL(const GURL& url); |
24 | 37 |
25 // Allocates a new DOMUI object for the given URL, and returns it. If the URL | 38 // Allocates a new DOMUI object for the given URL, and returns it. If the URL |
26 // is not a DOM UI URL, then it will return NULL. When non-NULL, ownership of | 39 // is not a DOM UI URL, then it will return NULL. When non-NULL, ownership of |
27 // the returned pointer is passed to the caller. | 40 // the returned pointer is passed to the caller. |
28 static DOMUI* CreateDOMUIForURL(TabContents* tab_contents, const GURL& url); | 41 static DOMUI* CreateDOMUIForURL(TabContents* tab_contents, const GURL& url); |
29 | 42 |
30 // Gets the data for the favicon for a DOMUI page. Returns false if the DOMUI | 43 // Gets the data for the favicon for a DOMUI page. Returns false if the DOMUI |
31 // does not have a favicon. | 44 // does not have a favicon. |
32 static bool GetFaviconResourceBytes(const GURL& page_url, | 45 static bool GetFaviconResourceBytes(const GURL& page_url, |
33 std::vector<unsigned char>* bytes); | 46 std::vector<unsigned char>* bytes); |
34 | 47 |
35 private: | 48 private: |
36 // Class is for scoping only. | 49 // Class is for scoping only. |
37 DOMUIFactory() {}; | 50 DOMUIFactory() {}; |
38 }; | 51 }; |
39 | 52 |
40 #endif // CHROME_BROWSER_DOM_UI_DOM_UI_FACTORY_H_ | 53 #endif // CHROME_BROWSER_DOM_UI_DOM_UI_FACTORY_H_ |
OLD | NEW |