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 CHROME_BROWSER_UI_WEBUI_CHROME_WEB_UI_FACTORY_H_ 6 #define CHROME_BROWSER_UI_WEBUI_CHROME_WEB_UI_FACTORY_H_ 7 #pragma once 8 9 #include "base/basictypes.h" 10 #include "base/memory/singleton.h" 11 #include "content/browser/webui/web_ui.h" 12 #include "content/browser/webui/web_ui_factory.h" 13 #include "chrome/browser/favicon_service.h" 14 15 class WebUI; 16 class GURL; 17 class Profile; 18 class RefCountedMemory; 19 class TabContents; 20 21 class ChromeWebUIFactory : public content::WebUIFactory { 22 public: 23 virtual WebUI::TypeID GetWebUIType(Profile* profile, const GURL& url) const; 24 virtual bool UseWebUIForURL(Profile* profile, const GURL& url) const; 25 virtual bool HasWebUIScheme(const GURL& url) const; 26 virtual bool IsURLAcceptableForWebUI(Profile* profile, const GURL& url) const; 27 virtual WebUI* CreateWebUIForURL(TabContents* tab_contents, 28 const GURL& url) const; 29 30 // Get the favicon for |page_url| and forward the result to the |request| 31 // when loaded. 32 void GetFaviconForURL(Profile* profile, 33 FaviconService::GetFaviconRequest* request, 34 const GURL& page_url) const; 35 36 static ChromeWebUIFactory* GetInstance(); 37 38 private: 39 virtual ~ChromeWebUIFactory(); 40 41 friend struct DefaultSingletonTraits<ChromeWebUIFactory>; 42 43 // Gets the data for the favicon for a WebUI page. Returns NULL if the WebUI 44 // does not have a favicon. 45 RefCountedMemory* GetFaviconResourceBytes(const GURL& page_url) const; 46 47 DISALLOW_IMPLICIT_CONSTRUCTORS(ChromeWebUIFactory); 48 }; 49 50 #endif // CHROME_BROWSER_UI_WEBUI_CHROME_WEB_UI_FACTORY_H_ 51