OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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 UI_BASE_RESOURCE_RESOURCE_BUNDLE_H_ | 5 #ifndef UI_BASE_RESOURCE_RESOURCE_BUNDLE_H_ |
6 #define UI_BASE_RESOURCE_RESOURCE_BUNDLE_H_ | 6 #define UI_BASE_RESOURCE_RESOURCE_BUNDLE_H_ |
7 | 7 |
8 #include "build/build_config.h" | 8 #include "build/build_config.h" |
9 | 9 |
10 #include <map> | 10 #include <map> |
11 #include <string> | 11 #include <string> |
12 | 12 |
13 #include "base/basictypes.h" | 13 #include "base/basictypes.h" |
14 #include "base/file_path.h" | 14 #include "base/file_path.h" |
15 #include "base/gtest_prod_util.h" | 15 #include "base/gtest_prod_util.h" |
16 #include "base/memory/scoped_ptr.h" | 16 #include "base/memory/scoped_ptr.h" |
17 #include "base/memory/scoped_vector.h" | 17 #include "base/memory/scoped_vector.h" |
18 #include "base/memory/weak_ptr.h" | |
18 #include "base/platform_file.h" | 19 #include "base/platform_file.h" |
19 #include "base/string16.h" | 20 #include "base/string16.h" |
20 #include "base/string_piece.h" | 21 #include "base/string_piece.h" |
21 #include "ui/base/layout.h" | 22 #include "ui/base/layout.h" |
22 #include "ui/base/ui_export.h" | 23 #include "ui/base/ui_export.h" |
23 #include "ui/gfx/font.h" | 24 #include "ui/gfx/font.h" |
24 #include "ui/gfx/image/image.h" | 25 #include "ui/gfx/image/image.h" |
25 #include "ui/gfx/native_widget_types.h" | 26 #include "ui/gfx/native_widget_types.h" |
26 | 27 |
27 class SkBitmap; | 28 class SkBitmap; |
28 | 29 |
29 namespace base { | 30 namespace base { |
30 class Lock; | 31 class Lock; |
31 class RefCountedStaticMemory; | 32 class RefCountedStaticMemory; |
32 } | 33 } |
33 | 34 |
34 namespace ui { | 35 namespace ui { |
35 | 36 |
36 class ResourceHandle; | 37 class ResourceHandle; |
37 | 38 |
38 // ResourceBundle is a central facility to load images and other resources, | 39 // ResourceBundle is a central facility to load images and other resources, |
39 // such as theme graphics. Every resource is loaded only once. | 40 // such as theme graphics. Every resource is loaded only once. |
40 class UI_EXPORT ResourceBundle { | 41 class UI_EXPORT ResourceBundle : public base::SupportsWeakPtr<ResourceBundle> { |
41 public: | 42 public: |
42 // An enumeration of the various font styles used throughout Chrome. | 43 // An enumeration of the various font styles used throughout Chrome. |
43 // The following holds true for the font sizes: | 44 // The following holds true for the font sizes: |
44 // Small <= Base <= Bold <= Medium <= MediumBold <= Large. | 45 // Small <= Base <= Bold <= Medium <= MediumBold <= Large. |
45 enum FontStyle { | 46 enum FontStyle { |
46 SmallFont, | 47 SmallFont, |
47 BaseFont, | 48 BaseFont, |
48 BoldFont, | 49 BoldFont, |
49 MediumFont, | 50 MediumFont, |
50 // NOTE: depending upon the locale, this may *not* result in a bold font. | 51 // NOTE: depending upon the locale, this may *not* result in a bold font. |
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
240 FRIEND_TEST_ALL_PREFIXES(ResourceBundle, DelegateGetPathForLocalePack); | 241 FRIEND_TEST_ALL_PREFIXES(ResourceBundle, DelegateGetPathForLocalePack); |
241 FRIEND_TEST_ALL_PREFIXES(ResourceBundle, DelegateGetImageNamed); | 242 FRIEND_TEST_ALL_PREFIXES(ResourceBundle, DelegateGetImageNamed); |
242 FRIEND_TEST_ALL_PREFIXES(ResourceBundle, DelegateGetNativeImageNamed); | 243 FRIEND_TEST_ALL_PREFIXES(ResourceBundle, DelegateGetNativeImageNamed); |
243 FRIEND_TEST_ALL_PREFIXES(ResourceBundle, DelegateLoadDataResourceBytes); | 244 FRIEND_TEST_ALL_PREFIXES(ResourceBundle, DelegateLoadDataResourceBytes); |
244 FRIEND_TEST_ALL_PREFIXES(ResourceBundle, DelegateGetRawDataResource); | 245 FRIEND_TEST_ALL_PREFIXES(ResourceBundle, DelegateGetRawDataResource); |
245 FRIEND_TEST_ALL_PREFIXES(ResourceBundle, DelegateGetLocalizedString); | 246 FRIEND_TEST_ALL_PREFIXES(ResourceBundle, DelegateGetLocalizedString); |
246 FRIEND_TEST_ALL_PREFIXES(ResourceBundle, DelegateGetFont); | 247 FRIEND_TEST_ALL_PREFIXES(ResourceBundle, DelegateGetFont); |
247 FRIEND_TEST_ALL_PREFIXES(ResourceBundle, GetRawDataResource); | 248 FRIEND_TEST_ALL_PREFIXES(ResourceBundle, GetRawDataResource); |
248 FRIEND_TEST_ALL_PREFIXES(ResourceBundle, LoadDataResourceBytes); | 249 FRIEND_TEST_ALL_PREFIXES(ResourceBundle, LoadDataResourceBytes); |
249 FRIEND_TEST_ALL_PREFIXES(ResourceBundle, LocaleDataPakExists); | 250 FRIEND_TEST_ALL_PREFIXES(ResourceBundle, LocaleDataPakExists); |
251 FRIEND_TEST_ALL_PREFIXES(ResourceBundle, GetImageNamed); | |
252 FRIEND_TEST_ALL_PREFIXES(ResourceBundle, ImageLifetime); | |
tony
2012/09/18 18:43:42
Nit: In a separate change, it would probably be wo
| |
250 | 253 |
251 class ResourceBundleImageSource; | 254 class ResourceBundleImageSource; |
252 friend class ResourceBundleImageSource; | 255 friend class ResourceBundleImageSource; |
253 | 256 |
254 // Ctor/dtor are private, since we're a singleton. | 257 // Ctor/dtor are private, since we're a singleton. |
255 explicit ResourceBundle(Delegate* delegate); | 258 explicit ResourceBundle(Delegate* delegate); |
256 ~ResourceBundle(); | 259 ~ResourceBundle(); |
257 | 260 |
258 // Free skia_images_. | 261 // Free skia_images_. |
259 void FreeImages(); | 262 void FreeImages(); |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
332 | 335 |
333 DISALLOW_COPY_AND_ASSIGN(ResourceBundle); | 336 DISALLOW_COPY_AND_ASSIGN(ResourceBundle); |
334 }; | 337 }; |
335 | 338 |
336 } // namespace ui | 339 } // namespace ui |
337 | 340 |
338 // TODO(beng): Someday, maybe, get rid of this. | 341 // TODO(beng): Someday, maybe, get rid of this. |
339 using ui::ResourceBundle; | 342 using ui::ResourceBundle; |
340 | 343 |
341 #endif // UI_BASE_RESOURCE_RESOURCE_BUNDLE_H_ | 344 #endif // UI_BASE_RESOURCE_RESOURCE_BUNDLE_H_ |
OLD | NEW |