1 // Copyright 2013 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_THEMES_CUSTOM_THEME_SUPPLIER_H_
6 #define CHROME_BROWSER_THEMES_CUSTOM_THEME_SUPPLIER_H_
8 #include "base/memory/ref_counted.h"
9 #include "content/public/browser/browser_thread.h"
10 #include "third_party/skia/include/core/SkColor.h"
11 #include "ui/base/layout.h"
14 class RefCountedMemory
;
17 namespace color_utils
{
25 // A representation of a theme. All theme properties can be accessed through the
26 // public methods. Subclasses are expected to override all methods which should
27 // provide non-default values.
28 class CustomThemeSupplier
: public base::RefCountedThreadSafe
<
29 CustomThemeSupplier
, content::BrowserThread::DeleteOnFileThread
> {
34 SUPERVISED_USER_THEME
,
37 explicit CustomThemeSupplier(ThemeType type
);
39 ThemeType
get_theme_type() const {
43 // Called when the theme starts being used.
44 virtual void StartUsingTheme();
46 // Called when the theme is not used anymore.
47 virtual void StopUsingTheme();
49 // If the theme specifies data for the corresponding |id|, returns true and
50 // writes the corresponding value to the output parameter. These methods
51 // should not return the default data. These methods should only be called
52 // from the UI thread.
53 virtual bool GetTint(int id
, color_utils::HSL
* hsl
) const;
54 virtual bool GetColor(int id
, SkColor
* color
) const;
55 virtual bool GetDisplayProperty(int id
, int* result
) const;
57 // Returns the theme image for |id|. Returns an empty image if no image is
59 virtual gfx::Image
GetImageNamed(int id
);
61 // Returns the raw PNG encoded data for IDR_THEME_NTP_*. This method only
62 // works for the NTP attribution and background resources.
63 virtual base::RefCountedMemory
* GetRawData(
64 int id
, ui::ScaleFactor scale_factor
) const;
66 // Whether this theme provides an image for |id|.
67 virtual bool HasCustomImage(int id
) const;
70 virtual ~CustomThemeSupplier();
73 friend struct content::BrowserThread::DeleteOnThread
<
74 content::BrowserThread::FILE>;
75 friend class base::DeleteHelper
<CustomThemeSupplier
>;
77 ThemeType theme_type_
;
79 DISALLOW_COPY_AND_ASSIGN(CustomThemeSupplier
);
82 #endif // CHROME_BROWSER_THEMES_CUSTOM_THEME_SUPPLIER_H_