OLD | NEW |
1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef APP_RESOURCE_BUNDLE_H_ | 5 #ifndef APP_RESOURCE_BUNDLE_H_ |
6 #define APP_RESOURCE_BUNDLE_H_ | 6 #define APP_RESOURCE_BUNDLE_H_ |
7 | 7 |
8 #include "build/build_config.h" | 8 #include "build/build_config.h" |
9 | 9 |
10 #if defined(OS_WIN) | 10 #if defined(OS_WIN) |
11 #include <windows.h> | 11 #include <windows.h> |
12 #endif | 12 #endif |
13 | 13 |
14 #include <map> | 14 #include <map> |
15 #include <string> | 15 #include <string> |
16 | 16 |
17 #include "base/basictypes.h" | 17 #include "base/basictypes.h" |
18 #include "base/file_path.h" | 18 #include "base/file_path.h" |
19 #include "base/lock.h" | 19 #include "base/lock.h" |
20 #include "base/scoped_ptr.h" | 20 #include "base/scoped_ptr.h" |
21 #include "base/string16.h" | 21 #include "base/string16.h" |
22 | 22 |
23 #if defined(OS_LINUX) || defined(OS_MACOSX) | 23 #if defined(USE_BASE_DATA_PACK) |
24 namespace base { | 24 namespace base { |
25 class DataPack; | 25 class DataPack; |
26 } | 26 } |
27 #endif | 27 #endif |
28 #if defined(OS_LINUX) | 28 #if defined(USE_X11) |
29 typedef struct _GdkPixbuf GdkPixbuf; | 29 typedef struct _GdkPixbuf GdkPixbuf; |
30 #endif | 30 #endif |
31 namespace gfx { | 31 namespace gfx { |
32 class Font; | 32 class Font; |
33 } | 33 } |
34 class SkBitmap; | 34 class SkBitmap; |
35 typedef uint32 SkColor; | 35 typedef uint32 SkColor; |
36 class StringPiece; | 36 class StringPiece; |
37 | 37 |
38 #if defined(OS_MACOSX) | 38 #if defined(OS_MACOSX) |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
116 | 116 |
117 #if defined(OS_WIN) | 117 #if defined(OS_WIN) |
118 // Loads and returns an icon from the theme dll. | 118 // Loads and returns an icon from the theme dll. |
119 HICON LoadThemeIcon(int icon_id); | 119 HICON LoadThemeIcon(int icon_id); |
120 | 120 |
121 // Loads and returns a cursor from the app module. | 121 // Loads and returns a cursor from the app module. |
122 HCURSOR LoadCursor(int cursor_id); | 122 HCURSOR LoadCursor(int cursor_id); |
123 #elif defined(OS_MACOSX) | 123 #elif defined(OS_MACOSX) |
124 // Wrapper for GetBitmapNamed. Converts the bitmap to an autoreleased NSImage. | 124 // Wrapper for GetBitmapNamed. Converts the bitmap to an autoreleased NSImage. |
125 NSImage* GetNSImageNamed(int resource_id); | 125 NSImage* GetNSImageNamed(int resource_id); |
126 #elif defined(OS_LINUX) | 126 #elif defined(USE_X11) |
127 // Gets the GdkPixbuf with the specified resource_id, first by looking into | 127 // Gets the GdkPixbuf with the specified resource_id, first by looking into |
128 // the theme data, than in the current module data if applicable. Returns a | 128 // the theme data, than in the current module data if applicable. Returns a |
129 // pointer to a shared instance of the GdkPixbuf. This shared GdkPixbuf is | 129 // pointer to a shared instance of the GdkPixbuf. This shared GdkPixbuf is |
130 // owned by the resource bundle and should not be freed. | 130 // owned by the resource bundle and should not be freed. |
131 // | 131 // |
132 // The bitmap is assumed to exist. This function will log in release, and | 132 // The bitmap is assumed to exist. This function will log in release, and |
133 // assert in debug mode if it does not. On failure, this will return a | 133 // assert in debug mode if it does not. On failure, this will return a |
134 // pointer to a shared empty placeholder bitmap so it will be visible what | 134 // pointer to a shared empty placeholder bitmap so it will be visible what |
135 // is missing. | 135 // is missing. |
136 GdkPixbuf* GetPixbufNamed(int resource_id); | 136 GdkPixbuf* GetPixbufNamed(int resource_id); |
(...skipping 16 matching lines...) Expand all Loading... |
153 static const SkColor frame_color_incognito_inactive; | 153 static const SkColor frame_color_incognito_inactive; |
154 static const SkColor toolbar_color; | 154 static const SkColor toolbar_color; |
155 static const SkColor toolbar_separator_color; | 155 static const SkColor toolbar_separator_color; |
156 | 156 |
157 private: | 157 private: |
158 // We define a DataHandle typedef to abstract across how data is stored | 158 // We define a DataHandle typedef to abstract across how data is stored |
159 // across platforms. | 159 // across platforms. |
160 #if defined(OS_WIN) | 160 #if defined(OS_WIN) |
161 // Windows stores resources in DLLs, which are managed by HINSTANCE. | 161 // Windows stores resources in DLLs, which are managed by HINSTANCE. |
162 typedef HINSTANCE DataHandle; | 162 typedef HINSTANCE DataHandle; |
163 #elif defined(OS_LINUX) || defined(OS_MACOSX) | 163 #elif defined(USE_BASE_DATA_PACK) |
164 // Linux uses base::DataPack. | 164 // Linux uses base::DataPack. |
165 typedef base::DataPack* DataHandle; | 165 typedef base::DataPack* DataHandle; |
166 #endif | 166 #endif |
167 | 167 |
168 // Ctor/dtor are private, since we're a singleton. | 168 // Ctor/dtor are private, since we're a singleton. |
169 ResourceBundle(); | 169 ResourceBundle(); |
170 ~ResourceBundle(); | 170 ~ResourceBundle(); |
171 | 171 |
172 // Free skia_images_. | 172 // Free skia_images_. |
173 void FreeImages(); | 173 void FreeImages(); |
(...skipping 27 matching lines...) Expand all Loading... |
201 | 201 |
202 // Handles for data sources. | 202 // Handles for data sources. |
203 DataHandle resources_data_; | 203 DataHandle resources_data_; |
204 DataHandle locale_resources_data_; | 204 DataHandle locale_resources_data_; |
205 DataHandle theme_data_; | 205 DataHandle theme_data_; |
206 | 206 |
207 // Cached images. The ResourceBundle caches all retrieved bitmaps and keeps | 207 // Cached images. The ResourceBundle caches all retrieved bitmaps and keeps |
208 // ownership of the pointers. | 208 // ownership of the pointers. |
209 typedef std::map<int, SkBitmap*> SkImageMap; | 209 typedef std::map<int, SkBitmap*> SkImageMap; |
210 SkImageMap skia_images_; | 210 SkImageMap skia_images_; |
211 #if defined(OS_LINUX) | 211 #if defined(USE_X11) |
212 typedef std::map<int, GdkPixbuf*> GdkPixbufMap; | 212 typedef std::map<int, GdkPixbuf*> GdkPixbufMap; |
213 GdkPixbufMap gdk_pixbufs_; | 213 GdkPixbufMap gdk_pixbufs_; |
214 #endif | 214 #endif |
215 | 215 |
216 // The various fonts used. Cached to avoid repeated GDI creation/destruction. | 216 // The various fonts used. Cached to avoid repeated GDI creation/destruction. |
217 scoped_ptr<gfx::Font> base_font_; | 217 scoped_ptr<gfx::Font> base_font_; |
218 scoped_ptr<gfx::Font> small_font_; | 218 scoped_ptr<gfx::Font> small_font_; |
219 scoped_ptr<gfx::Font> medium_font_; | 219 scoped_ptr<gfx::Font> medium_font_; |
220 scoped_ptr<gfx::Font> medium_bold_font_; | 220 scoped_ptr<gfx::Font> medium_bold_font_; |
221 scoped_ptr<gfx::Font> large_font_; | 221 scoped_ptr<gfx::Font> large_font_; |
222 scoped_ptr<gfx::Font> web_font_; | 222 scoped_ptr<gfx::Font> web_font_; |
223 | 223 |
224 static ResourceBundle* g_shared_instance_; | 224 static ResourceBundle* g_shared_instance_; |
225 | 225 |
226 DISALLOW_EVIL_CONSTRUCTORS(ResourceBundle); | 226 DISALLOW_EVIL_CONSTRUCTORS(ResourceBundle); |
227 }; | 227 }; |
228 | 228 |
229 #endif // APP_RESOURCE_BUNDLE_H_ | 229 #endif // APP_RESOURCE_BUNDLE_H_ |
OLD | NEW |