1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
|
// Copyright (c) 2009 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef APP_THEME_PROVIDER_H_
#define APP_THEME_PROVIDER_H_
#include <vector>
#include "base/basictypes.h"
#include "third_party/skia/include/core/SkColor.h"
#if defined(OS_MACOSX)
#ifdef __OBJC__
@class NSColor;
@class NSGradient;
@class NSImage;
#else
class NSColor;
class NSGradient;
class NSImage;
#endif // __OBJC__
#elif !defined(OS_WIN)
typedef struct _GdkColor GdkColor;
typedef struct _GdkPixbuf GdkPixbuf;
#endif // OS_*
class Profile;
class RefCountedMemory;
class SkBitmap;
////////////////////////////////////////////////////////////////////////////////
//
// ThemeProvider
//
// ThemeProvider is an abstract class that defines the API that should be
// implemented to provide bitmaps and color information for a given theme.
//
////////////////////////////////////////////////////////////////////////////////
class ThemeProvider {
public:
virtual ~ThemeProvider();
// Initialize the provider with the passed in profile.
virtual void Init(Profile* profile) = 0;
// Get the bitmap specified by |id|. An implementation of ThemeProvider should
// have its own source of ids (e.g. an enum, or external resource bundle).
virtual SkBitmap* GetBitmapNamed(int id) const = 0;
// Get the color specified by |id|.
virtual SkColor GetColor(int id) const = 0;
// Get the property (e.g. an alignment expressed in an enum, or a width or
// height) specified by |id|.
virtual bool GetDisplayProperty(int id, int* result) const = 0;
// Whether we should use the native system frame (typically Aero glass) or
// a custom frame.
virtual bool ShouldUseNativeFrame() const = 0;
// Whether or not we have a certain image. Used for when the default theme
// doesn't provide a certain image, but custom themes might (badges, etc).
virtual bool HasCustomImage(int id) const = 0;
// Reads the image data from the theme file into the specified vector. Only
// valid for un-themed resources and the themed IDR_THEME_NTP_* in most
// implementations of ThemeProvider. Returns NULL on error.
virtual RefCountedMemory* GetRawData(int id) const = 0;
#if defined(OS_MACOSX)
// Gets the NSImage with the specified |id|.
//
// The bitmap is not assumed to exist. If a theme does not provide an image,
// if |allow_default| is true, then the default image will be returned, else
// this function will return nil.
virtual NSImage* GetNSImageNamed(int id, bool allow_default) const = 0;
// Gets the NSColor with the specified |id|.
//
// The color is not assumed to exist. If a theme does not provide an color, if
// |allow_default| is true, then the default color will be returned, else this
// function will return nil.
virtual NSColor* GetNSColor(int id, bool allow_default) const = 0;
// Gets the NSColor for tinting with the specified |id|.
//
// The tint is not assumed to exist. If a theme does not provide a tint with
// that id, if |allow_default| is true, then the default tint will be
// returned, else this function will return nil.
virtual NSColor* GetNSColorTint(int id, bool allow_default) const = 0;
// Gets the NSGradient with the specified |id|.
virtual NSGradient* GetNSGradient(int id) const = 0;
#elif defined(OS_POSIX) && !defined(TOOLKIT_VIEWS)
// Gets the GdkPixbuf with the specified |id|. Returns a pointer to a shared
// instance of the GdkPixbuf. This shared GdkPixbuf is owned by the theme
// provider and should not be freed.
//
// The bitmap is assumed to exist. This function will log in release, and
// assert in debug mode if it does not. On failure, this will return a
// pointer to a shared empty placeholder bitmap so it will be visible what
// is missing.
virtual GdkPixbuf* GetPixbufNamed(int id) const = 0;
// As above, but flips it in RTL locales.
virtual GdkPixbuf* GetRTLEnabledPixbufNamed(int id) const = 0;
#endif
};
#endif // APP_THEME_PROVIDER_H_
|