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 UI_BASE_THEME_PROVIDER_H_
6 #define UI_BASE_THEME_PROVIDER_H_
8 #include "base/basictypes.h"
9 #include "third_party/skia/include/core/SkColor.h"
10 #include "ui/base/layout.h"
11 #include "ui/base/ui_base_export.h"
13 #if defined(OS_MACOSX)
28 class RefCountedMemory
;
37 ////////////////////////////////////////////////////////////////////////////////
41 // ThemeProvider is an abstract class that defines the API that should be
42 // implemented to provide bitmaps and color information for a given theme.
44 ////////////////////////////////////////////////////////////////////////////////
46 class UI_BASE_EXPORT ThemeProvider
{
48 virtual ~ThemeProvider();
50 // Whether we're using the system theme (which may or may not be the
51 // same as the default theme).
52 virtual bool UsingSystemTheme() const = 0;
54 // Get the image specified by |id|. An implementation of ThemeProvider should
55 // have its own source of ids (e.g. an enum, or external resource bundle).
56 virtual gfx::ImageSkia
* GetImageSkiaNamed(int id
) const = 0;
58 // Get the color specified by |id|.
59 virtual SkColor
GetColor(int id
) const = 0;
61 // Get the property (e.g. an alignment expressed in an enum, or a width or
62 // height) specified by |id|.
63 virtual int GetDisplayProperty(int id
) const = 0;
65 // Whether we should use the native system frame (typically Aero glass) or
67 virtual bool ShouldUseNativeFrame() const = 0;
69 // Whether or not we have a certain image. Used for when the default theme
70 // doesn't provide a certain image, but custom themes might (badges, etc).
71 virtual bool HasCustomImage(int id
) const = 0;
73 // Reads the image data from the theme file into the specified vector. Only
74 // valid for un-themed resources and the themed IDR_THEME_NTP_* in most
75 // implementations of ThemeProvider. Returns NULL on error.
76 virtual base::RefCountedMemory
* GetRawData(
78 ui::ScaleFactor scale_factor
) const = 0;
80 #if defined(OS_MACOSX)
81 // Gets the NSImage with the specified |id|.
82 virtual NSImage
* GetNSImageNamed(int id
) const = 0;
84 // Gets the NSImage that GetNSImageNamed (above) would return, but returns it
85 // as a pattern color.
86 virtual NSColor
* GetNSImageColorNamed(int id
) const = 0;
88 // Gets the NSColor with the specified |id|.
89 virtual NSColor
* GetNSColor(int id
) const = 0;
91 // Gets the NSColor for tinting with the specified |id|.
92 virtual NSColor
* GetNSColorTint(int id
) const = 0;
94 // Gets the NSGradient with the specified |id|.
95 virtual NSGradient
* GetNSGradient(int id
) const = 0;
101 #endif // UI_BASE_THEME_PROVIDER_H_