1 // Copyright (c) 2012 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.
5 #ifndef CHROME_BROWSER_UI_WEBUI_CHROME_WEB_UI_CONTROLLER_FACTORY_H_
6 #define CHROME_BROWSER_UI_WEBUI_CHROME_WEB_UI_CONTROLLER_FACTORY_H_
8 #include "base/basictypes.h"
9 #include "base/memory/singleton.h"
10 #include "content/public/browser/web_ui.h"
11 #include "content/public/browser/web_ui_controller_factory.h"
12 #include "chrome/browser/favicon/favicon_service.h"
17 class RefCountedMemory
;
20 class ChromeWebUIControllerFactory
: public content::WebUIControllerFactory
{
22 virtual content::WebUI::TypeID
GetWebUIType(
23 content::BrowserContext
* browser_context
,
24 const GURL
& url
) const OVERRIDE
;
25 virtual bool UseWebUIForURL(content::BrowserContext
* browser_context
,
26 const GURL
& url
) const OVERRIDE
;
27 virtual bool UseWebUIBindingsForURL(content::BrowserContext
* browser_context
,
28 const GURL
& url
) const OVERRIDE
;
29 virtual content::WebUIController
* CreateWebUIControllerForURL(
30 content::WebUI
* web_ui
,
31 const GURL
& url
) const OVERRIDE
;
33 // Get the favicon for |page_url| and run |callback| with result when loaded.
34 // Note. |callback| is always run asynchronously.
35 void GetFaviconForURL(
38 const std::vector
<ui::ScaleFactor
>& scale_factors
,
39 const FaviconService::FaviconResultsCallback
& callback
) const;
41 static ChromeWebUIControllerFactory
* GetInstance();
44 ChromeWebUIControllerFactory();
45 virtual ~ChromeWebUIControllerFactory();
48 friend struct DefaultSingletonTraits
<ChromeWebUIControllerFactory
>;
50 // Gets the data for the favicon for a WebUI page. Returns NULL if the WebUI
51 // does not have a favicon.
52 // The returned favicon data must be
53 // |gfx::kFaviconSize| x |gfx::kFaviconSize| DIP. GetFaviconForURL() should
54 // be updated if this changes.
55 base::RefCountedMemory
* GetFaviconResourceBytes(
56 const GURL
& page_url
, ui::ScaleFactor scale_factor
) const;
58 DISALLOW_COPY_AND_ASSIGN(ChromeWebUIControllerFactory
);
61 #endif // CHROME_BROWSER_UI_WEBUI_CHROME_WEB_UI_CONTROLLER_FACTORY_H_