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