| 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 <stddef.h> | 8 #include <stddef.h> |
| 9 | 9 |
| 10 #include <map> | 10 #include <map> |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 52 SmallFont, | 52 SmallFont, |
| 53 SmallBoldFont, | 53 SmallBoldFont, |
| 54 BaseFont, | 54 BaseFont, |
| 55 BoldFont, | 55 BoldFont, |
| 56 MediumFont, | 56 MediumFont, |
| 57 MediumBoldFont, | 57 MediumBoldFont, |
| 58 LargeFont, | 58 LargeFont, |
| 59 LargeBoldFont, | 59 LargeBoldFont, |
| 60 }; | 60 }; |
| 61 | 61 |
| 62 enum ImageRTL { | |
| 63 // Images are flipped in RTL locales. | |
| 64 RTL_ENABLED, | |
| 65 // Images are never flipped. | |
| 66 RTL_DISABLED, | |
| 67 }; | |
| 68 | |
| 69 enum LoadResources { | 62 enum LoadResources { |
| 70 LOAD_COMMON_RESOURCES, | 63 LOAD_COMMON_RESOURCES, |
| 71 DO_NOT_LOAD_COMMON_RESOURCES | 64 DO_NOT_LOAD_COMMON_RESOURCES |
| 72 }; | 65 }; |
| 73 | 66 |
| 74 // Delegate class that allows interception of pack file loading and resource | 67 // Delegate class that allows interception of pack file loading and resource |
| 75 // requests. The methods of this class may be called on multiple threads. | 68 // requests. The methods of this class may be called on multiple threads. |
| 76 class Delegate { | 69 class Delegate { |
| 77 public: | 70 public: |
| 78 // Called before a resource pack file is loaded. Return the full path for | 71 // Called before a resource pack file is loaded. Return the full path for |
| (...skipping 11 matching lines...) Expand all Loading... |
| 90 virtual base::FilePath GetPathForLocalePack( | 83 virtual base::FilePath GetPathForLocalePack( |
| 91 const base::FilePath& pack_path, | 84 const base::FilePath& pack_path, |
| 92 const std::string& locale) = 0; | 85 const std::string& locale) = 0; |
| 93 | 86 |
| 94 // Return an image resource or an empty value to attempt retrieval of the | 87 // Return an image resource or an empty value to attempt retrieval of the |
| 95 // default resource. | 88 // default resource. |
| 96 virtual gfx::Image GetImageNamed(int resource_id) = 0; | 89 virtual gfx::Image GetImageNamed(int resource_id) = 0; |
| 97 | 90 |
| 98 // Return an image resource or an empty value to attempt retrieval of the | 91 // Return an image resource or an empty value to attempt retrieval of the |
| 99 // default resource. | 92 // default resource. |
| 100 virtual gfx::Image GetNativeImageNamed(int resource_id, ImageRTL rtl) = 0; | 93 virtual gfx::Image GetNativeImageNamed(int resource_id) = 0; |
| 101 | 94 |
| 102 // Return a static memory resource or NULL to attempt retrieval of the | 95 // Return a static memory resource or NULL to attempt retrieval of the |
| 103 // default resource. | 96 // default resource. |
| 104 virtual base::RefCountedStaticMemory* LoadDataResourceBytes( | 97 virtual base::RefCountedStaticMemory* LoadDataResourceBytes( |
| 105 int resource_id, | 98 int resource_id, |
| 106 ScaleFactor scale_factor) = 0; | 99 ScaleFactor scale_factor) = 0; |
| 107 | 100 |
| 108 // Retrieve a raw data resource. Return true if a resource was provided or | 101 // Retrieve a raw data resource. Return true if a resource was provided or |
| 109 // false to attempt retrieval of the default resource. | 102 // false to attempt retrieval of the default resource. |
| 110 virtual bool GetRawDataResource(int resource_id, | 103 virtual bool GetRawDataResource(int resource_id, |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 212 // image in Skia format by default. The ResourceBundle owns this. | 205 // image in Skia format by default. The ResourceBundle owns this. |
| 213 gfx::Image& GetImageNamed(int resource_id); | 206 gfx::Image& GetImageNamed(int resource_id); |
| 214 | 207 |
| 215 // Similar to GetImageNamed, but rather than loading the image in Skia format, | 208 // Similar to GetImageNamed, but rather than loading the image in Skia format, |
| 216 // it will load in the native platform type. This can avoid conversion from | 209 // it will load in the native platform type. This can avoid conversion from |
| 217 // one image type to another. ResourceBundle owns the result. | 210 // one image type to another. ResourceBundle owns the result. |
| 218 // | 211 // |
| 219 // Note that if the same resource has already been loaded in GetImageNamed(), | 212 // Note that if the same resource has already been loaded in GetImageNamed(), |
| 220 // gfx::Image will perform a conversion, rather than using the native image | 213 // gfx::Image will perform a conversion, rather than using the native image |
| 221 // loading code of ResourceBundle. | 214 // loading code of ResourceBundle. |
| 222 // | |
| 223 // If |rtl| is RTL_ENABLED then the image is flipped in RTL locales. | |
| 224 gfx::Image& GetNativeImageNamed(int resource_id, ImageRTL rtl); | |
| 225 | |
| 226 // Same as GetNativeImageNamed() except that RTL is not enabled. | |
| 227 gfx::Image& GetNativeImageNamed(int resource_id); | 215 gfx::Image& GetNativeImageNamed(int resource_id); |
| 228 | 216 |
| 229 // Loads the raw bytes of a scale independent data resource. | 217 // Loads the raw bytes of a scale independent data resource. |
| 230 base::RefCountedStaticMemory* LoadDataResourceBytes(int resource_id) const; | 218 base::RefCountedStaticMemory* LoadDataResourceBytes(int resource_id) const; |
| 231 | 219 |
| 232 // Loads the raw bytes of a data resource nearest the scale factor | 220 // Loads the raw bytes of a data resource nearest the scale factor |
| 233 // |scale_factor| into |bytes|, without doing any processing or | 221 // |scale_factor| into |bytes|, without doing any processing or |
| 234 // interpretation of the resource. Use ResourceHandle::SCALE_FACTOR_NONE | 222 // interpretation of the resource. Use ResourceHandle::SCALE_FACTOR_NONE |
| 235 // for scale independent image resources (such as wallpaper). | 223 // for scale independent image resources (such as wallpaper). |
| 236 // Returns NULL if we fail to read the resource. | 224 // Returns NULL if we fail to read the resource. |
| (...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 448 | 436 |
| 449 DISALLOW_COPY_AND_ASSIGN(ResourceBundle); | 437 DISALLOW_COPY_AND_ASSIGN(ResourceBundle); |
| 450 }; | 438 }; |
| 451 | 439 |
| 452 } // namespace ui | 440 } // namespace ui |
| 453 | 441 |
| 454 // TODO(beng): Someday, maybe, get rid of this. | 442 // TODO(beng): Someday, maybe, get rid of this. |
| 455 using ui::ResourceBundle; | 443 using ui::ResourceBundle; |
| 456 | 444 |
| 457 #endif // UI_BASE_RESOURCE_RESOURCE_BUNDLE_H_ | 445 #endif // UI_BASE_RESOURCE_RESOURCE_BUNDLE_H_ |
| OLD | NEW |