| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 UI_BASE_RESOURCE_RESOURCE_BUNDLE_H_ |
| 6 #define APP_RESOURCE_BUNDLE_H_ | 6 #define UI_BASE_RESOURCE_RESOURCE_BUNDLE_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include "build/build_config.h" | 9 #include "build/build_config.h" |
| 10 | 10 |
| 11 #if defined(OS_WIN) | 11 #if defined(OS_WIN) |
| 12 #include <windows.h> | 12 #include <windows.h> |
| 13 #endif | 13 #endif |
| 14 | 14 |
| 15 #include <map> | 15 #include <map> |
| 16 #include <string> | 16 #include <string> |
| 17 #include <vector> | 17 #include <vector> |
| 18 | 18 |
| 19 #include "base/basictypes.h" | 19 #include "base/basictypes.h" |
| 20 #include "base/file_path.h" | 20 #include "base/file_path.h" |
| 21 #include "base/ref_counted_memory.h" | 21 #include "base/ref_counted_memory.h" |
| 22 #include "base/scoped_ptr.h" | 22 #include "base/scoped_ptr.h" |
| 23 #include "base/string16.h" | 23 #include "base/string16.h" |
| 24 #include "gfx/native_widget_types.h" | 24 #include "gfx/native_widget_types.h" |
| 25 | 25 |
| 26 namespace app { | 26 class SkBitmap; |
| 27 class DataPack; | 27 typedef uint32 SkColor; |
| 28 } | 28 |
| 29 namespace base { | 29 namespace base { |
| 30 class Lock; | 30 class Lock; |
| 31 class StringPiece; |
| 31 } | 32 } |
| 33 |
| 32 namespace gfx { | 34 namespace gfx { |
| 33 class Font; | 35 class Font; |
| 34 } | 36 } |
| 35 class SkBitmap; | |
| 36 typedef uint32 SkColor; | |
| 37 namespace base { | |
| 38 class StringPiece; | |
| 39 } | |
| 40 | 37 |
| 41 #if defined(OS_MACOSX) | 38 #if defined(OS_MACOSX) |
| 42 #ifdef __OBJC__ | 39 #ifdef __OBJC__ |
| 43 @class NSImage; | 40 @class NSImage; |
| 44 #else | 41 #else |
| 45 class NSImage; | 42 class NSImage; |
| 46 #endif // __OBJC__ | 43 #endif // __OBJC__ |
| 47 #endif // defined(OS_MACOSX) | 44 #endif // defined(OS_MACOSX) |
| 48 | 45 |
| 49 #if defined(USE_X11) | 46 #if defined(USE_X11) |
| 50 typedef struct _GdkPixbuf GdkPixbuf; | 47 typedef struct _GdkPixbuf GdkPixbuf; |
| 51 #endif | 48 #endif |
| 52 | 49 |
| 50 namespace ui { |
| 51 |
| 52 class DataPack; |
| 53 |
| 53 // ResourceBundle is a central facility to load images and other resources, | 54 // ResourceBundle is a central facility to load images and other resources, |
| 54 // such as theme graphics. | 55 // such as theme graphics. |
| 55 // Every resource is loaded only once. | 56 // Every resource is loaded only once. |
| 56 class ResourceBundle { | 57 class ResourceBundle { |
| 57 public: | 58 public: |
| 58 // An enumeration of the various font styles used throughout Chrome. | 59 // An enumeration of the various font styles used throughout Chrome. |
| 59 // The following holds true for the font sizes: | 60 // The following holds true for the font sizes: |
| 60 // Small <= Base <= Bold <= Medium <= MediumBold <= Large. | 61 // Small <= Base <= Bold <= Medium <= MediumBold <= Large. |
| 61 enum FontStyle { | 62 enum FontStyle { |
| 62 SmallFont, | 63 SmallFont, |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 169 class LoadedDataPack { | 170 class LoadedDataPack { |
| 170 public: | 171 public: |
| 171 explicit LoadedDataPack(const FilePath& path); | 172 explicit LoadedDataPack(const FilePath& path); |
| 172 ~LoadedDataPack(); | 173 ~LoadedDataPack(); |
| 173 bool GetStringPiece(int resource_id, base::StringPiece* data) const; | 174 bool GetStringPiece(int resource_id, base::StringPiece* data) const; |
| 174 RefCountedStaticMemory* GetStaticMemory(int resource_id) const; | 175 RefCountedStaticMemory* GetStaticMemory(int resource_id) const; |
| 175 | 176 |
| 176 private: | 177 private: |
| 177 void Load(); | 178 void Load(); |
| 178 | 179 |
| 179 scoped_ptr<app::DataPack> data_pack_; | 180 scoped_ptr<DataPack> data_pack_; |
| 180 FilePath path_; | 181 FilePath path_; |
| 181 | 182 |
| 182 DISALLOW_COPY_AND_ASSIGN(LoadedDataPack); | 183 DISALLOW_COPY_AND_ASSIGN(LoadedDataPack); |
| 183 }; | 184 }; |
| 184 | 185 |
| 185 // We define a DataHandle typedef to abstract across how data is stored | 186 // We define a DataHandle typedef to abstract across how data is stored |
| 186 // across platforms. | 187 // across platforms. |
| 187 #if defined(OS_WIN) | 188 #if defined(OS_WIN) |
| 188 // Windows stores resources in DLLs, which are managed by HINSTANCE. | 189 // Windows stores resources in DLLs, which are managed by HINSTANCE. |
| 189 typedef HINSTANCE DataHandle; | 190 typedef HINSTANCE DataHandle; |
| 190 #elif defined(USE_BASE_DATA_PACK) | 191 #elif defined(USE_BASE_DATA_PACK) |
| 191 // Linux uses base::DataPack. | 192 // Linux uses base::DataPack. |
| 192 typedef app::DataPack* DataHandle; | 193 typedef DataPack* DataHandle; |
| 193 #endif | 194 #endif |
| 194 | 195 |
| 195 // Ctor/dtor are private, since we're a singleton. | 196 // Ctor/dtor are private, since we're a singleton. |
| 196 ResourceBundle(); | 197 ResourceBundle(); |
| 197 ~ResourceBundle(); | 198 ~ResourceBundle(); |
| 198 | 199 |
| 199 // Free skia_images_. | 200 // Free skia_images_. |
| 200 void FreeImages(); | 201 void FreeImages(); |
| 201 | 202 |
| 202 #if defined(USE_X11) | 203 #if defined(USE_X11) |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 267 scoped_ptr<gfx::Font> medium_font_; | 268 scoped_ptr<gfx::Font> medium_font_; |
| 268 scoped_ptr<gfx::Font> medium_bold_font_; | 269 scoped_ptr<gfx::Font> medium_bold_font_; |
| 269 scoped_ptr<gfx::Font> large_font_; | 270 scoped_ptr<gfx::Font> large_font_; |
| 270 scoped_ptr<gfx::Font> web_font_; | 271 scoped_ptr<gfx::Font> web_font_; |
| 271 | 272 |
| 272 static ResourceBundle* g_shared_instance_; | 273 static ResourceBundle* g_shared_instance_; |
| 273 | 274 |
| 274 DISALLOW_COPY_AND_ASSIGN(ResourceBundle); | 275 DISALLOW_COPY_AND_ASSIGN(ResourceBundle); |
| 275 }; | 276 }; |
| 276 | 277 |
| 277 #endif // APP_RESOURCE_BUNDLE_H_ | 278 } // namespace ui |
| 279 |
| 280 // TODO(beng): Someday, maybe, get rid of this. |
| 281 using ui::ResourceBundle; |
| 282 |
| 283 #endif // UI_BASE_RESOURCE_RESOURCE_BUNDLE_H_ |
| OLD | NEW |