Adding instrumentation to locate the source of jankiness
[chromium-blink-merge.git] / chrome / browser / ui / webui / chrome_web_ui_controller_factory.h
blobe7f0dad1c930fc5a985d605c35d37c5b134bb5a0
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 "components/favicon_base/favicon_callback.h"
11 #include "content/public/browser/web_ui.h"
12 #include "content/public/browser/web_ui_controller_factory.h"
13 #include "ui/base/layout.h"
15 class Profile;
17 namespace base {
18 class RefCountedMemory;
21 class ChromeWebUIControllerFactory : public content::WebUIControllerFactory {
22 public:
23 virtual content::WebUI::TypeID GetWebUIType(
24 content::BrowserContext* browser_context,
25 const GURL& url) const override;
26 virtual bool UseWebUIForURL(content::BrowserContext* browser_context,
27 const GURL& url) const override;
28 virtual bool UseWebUIBindingsForURL(content::BrowserContext* browser_context,
29 const GURL& url) const override;
30 virtual content::WebUIController* CreateWebUIControllerForURL(
31 content::WebUI* web_ui,
32 const GURL& url) const override;
34 // Get the favicon for |page_url| and run |callback| with result when loaded.
35 // Note. |callback| is always run asynchronously.
36 void GetFaviconForURL(
37 Profile* profile,
38 const GURL& page_url,
39 const std::vector<int>& desired_sizes_in_pixel,
40 const favicon_base::FaviconResultsCallback& callback) const;
42 static ChromeWebUIControllerFactory* GetInstance();
44 protected:
45 ChromeWebUIControllerFactory();
46 virtual ~ChromeWebUIControllerFactory();
48 private:
49 friend struct DefaultSingletonTraits<ChromeWebUIControllerFactory>;
51 // Gets the data for the favicon for a WebUI page. Returns NULL if the WebUI
52 // does not have a favicon.
53 // The returned favicon data must be
54 // |gfx::kFaviconSize| x |gfx::kFaviconSize| DIP. GetFaviconForURL() should
55 // be updated if this changes.
56 base::RefCountedMemory* GetFaviconResourceBytes(
57 const GURL& page_url, ui::ScaleFactor scale_factor) const;
59 DISALLOW_COPY_AND_ASSIGN(ChromeWebUIControllerFactory);
62 #endif // CHROME_BROWSER_UI_WEBUI_CHROME_WEB_UI_CONTROLLER_FACTORY_H_