| 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> |
| (...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 236 FRIEND_TEST_ALL_PREFIXES(ResourceBundle, DelegateGetImageNamed); | 236 FRIEND_TEST_ALL_PREFIXES(ResourceBundle, DelegateGetImageNamed); |
| 237 FRIEND_TEST_ALL_PREFIXES(ResourceBundle, DelegateGetNativeImageNamed); | 237 FRIEND_TEST_ALL_PREFIXES(ResourceBundle, DelegateGetNativeImageNamed); |
| 238 FRIEND_TEST_ALL_PREFIXES(ResourceBundle, DelegateLoadDataResourceBytes); | 238 FRIEND_TEST_ALL_PREFIXES(ResourceBundle, DelegateLoadDataResourceBytes); |
| 239 FRIEND_TEST_ALL_PREFIXES(ResourceBundle, DelegateGetRawDataResource); | 239 FRIEND_TEST_ALL_PREFIXES(ResourceBundle, DelegateGetRawDataResource); |
| 240 FRIEND_TEST_ALL_PREFIXES(ResourceBundle, DelegateGetLocalizedString); | 240 FRIEND_TEST_ALL_PREFIXES(ResourceBundle, DelegateGetLocalizedString); |
| 241 FRIEND_TEST_ALL_PREFIXES(ResourceBundle, DelegateGetFont); | 241 FRIEND_TEST_ALL_PREFIXES(ResourceBundle, DelegateGetFont); |
| 242 FRIEND_TEST_ALL_PREFIXES(ResourceBundle, GetRawDataResource); | 242 FRIEND_TEST_ALL_PREFIXES(ResourceBundle, GetRawDataResource); |
| 243 FRIEND_TEST_ALL_PREFIXES(ResourceBundle, LoadDataResourceBytes); | 243 FRIEND_TEST_ALL_PREFIXES(ResourceBundle, LoadDataResourceBytes); |
| 244 FRIEND_TEST_ALL_PREFIXES(ResourceBundle, LocaleDataPakExists); | 244 FRIEND_TEST_ALL_PREFIXES(ResourceBundle, LocaleDataPakExists); |
| 245 | 245 |
| 246 class ResourceBundleImageSource; |
| 247 friend class ResourceBundleImageSource; |
| 248 |
| 246 // Ctor/dtor are private, since we're a singleton. | 249 // Ctor/dtor are private, since we're a singleton. |
| 247 explicit ResourceBundle(Delegate* delegate); | 250 explicit ResourceBundle(Delegate* delegate); |
| 248 ~ResourceBundle(); | 251 ~ResourceBundle(); |
| 249 | 252 |
| 250 // Free skia_images_. | 253 // Free skia_images_. |
| 251 void FreeImages(); | 254 void FreeImages(); |
| 252 | 255 |
| 253 // Load the main resources. | 256 // Load the main resources. |
| 254 void LoadCommonResources(); | 257 void LoadCommonResources(); |
| 255 | 258 |
| 256 // Try to load the locale specific strings from an external data module. | 259 // Try to load the locale specific strings from an external data module. |
| 257 // Returns the locale that is loaded. | 260 // Returns the locale that is loaded. |
| 258 std::string LoadLocaleResources(const std::string& pref_locale); | 261 std::string LoadLocaleResources(const std::string& pref_locale); |
| 259 | 262 |
| 260 // Load test resources in given paths. If either path is empty an empty | 263 // Load test resources in given paths. If either path is empty an empty |
| 261 // resource pack is loaded. | 264 // resource pack is loaded. |
| 262 void LoadTestResources(const FilePath& path, const FilePath& locale_path); | 265 void LoadTestResources(const FilePath& path, const FilePath& locale_path); |
| 263 | 266 |
| 264 // Unload the locale specific strings and prepares to load new ones. See | 267 // Unload the locale specific strings and prepares to load new ones. See |
| 265 // comments for ReloadLocaleResources(). | 268 // comments for ReloadLocaleResources(). |
| 266 void UnloadLocaleResources(); | 269 void UnloadLocaleResources(); |
| 267 | 270 |
| 268 // Initialize all the gfx::Font members if they haven't yet been initialized. | 271 // Initialize all the gfx::Font members if they haven't yet been initialized. |
| 269 void LoadFontsIfNecessary(); | 272 void LoadFontsIfNecessary(); |
| 270 | 273 |
| 271 // Creates and returns a new SkBitmap given the data file to look in and the | 274 // Creates and returns a new SkBitmap given the data file to look in and the |
| 272 // resource id. It's up to the caller to free the returned bitmap when | 275 // |resource_id|. It's up to the caller to free the returned bitmap when |
| 273 // done. | 276 // done. |
| 274 SkBitmap* LoadBitmap(const ResourceHandle& dll_inst, int resource_id); | 277 SkBitmap* LoadBitmap(const ResourceHandle& dll_inst, int resource_id) const; |
| 278 |
| 279 // Creates and returns a new SkBitmap for |resource_id| and |scale_factor|. |
| 280 // Returns NULL if the resource does not exist. |
| 281 SkBitmap* LoadBitmap(int resource_id, ScaleFactor scale_factor) const; |
| 275 | 282 |
| 276 // Returns an empty image for when a resource cannot be loaded. This is a | 283 // Returns an empty image for when a resource cannot be loaded. This is a |
| 277 // bright red bitmap. | 284 // bright red bitmap. |
| 278 gfx::Image& GetEmptyImage(); | 285 gfx::Image& GetEmptyImage(); |
| 279 | 286 |
| 280 const FilePath& GetOverriddenPakPath(); | 287 const FilePath& GetOverriddenPakPath(); |
| 281 | 288 |
| 282 // This pointer is guaranteed to outlive the ResourceBundle instance and may | 289 // This pointer is guaranteed to outlive the ResourceBundle instance and may |
| 283 // be NULL. | 290 // be NULL. |
| 284 Delegate* delegate_; | 291 Delegate* delegate_; |
| (...skipping 18 matching lines...) Expand all Loading... |
| 303 // The various fonts used. Cached to avoid repeated GDI creation/destruction. | 310 // The various fonts used. Cached to avoid repeated GDI creation/destruction. |
| 304 scoped_ptr<gfx::Font> base_font_; | 311 scoped_ptr<gfx::Font> base_font_; |
| 305 scoped_ptr<gfx::Font> bold_font_; | 312 scoped_ptr<gfx::Font> bold_font_; |
| 306 scoped_ptr<gfx::Font> small_font_; | 313 scoped_ptr<gfx::Font> small_font_; |
| 307 scoped_ptr<gfx::Font> medium_font_; | 314 scoped_ptr<gfx::Font> medium_font_; |
| 308 scoped_ptr<gfx::Font> medium_bold_font_; | 315 scoped_ptr<gfx::Font> medium_bold_font_; |
| 309 scoped_ptr<gfx::Font> large_font_; | 316 scoped_ptr<gfx::Font> large_font_; |
| 310 scoped_ptr<gfx::Font> large_bold_font_; | 317 scoped_ptr<gfx::Font> large_bold_font_; |
| 311 scoped_ptr<gfx::Font> web_font_; | 318 scoped_ptr<gfx::Font> web_font_; |
| 312 | 319 |
| 313 static ResourceBundle* g_shared_instance_; | |
| 314 | |
| 315 FilePath overridden_pak_path_; | 320 FilePath overridden_pak_path_; |
| 316 | 321 |
| 317 DISALLOW_COPY_AND_ASSIGN(ResourceBundle); | 322 DISALLOW_COPY_AND_ASSIGN(ResourceBundle); |
| 318 }; | 323 }; |
| 319 | 324 |
| 320 } // namespace ui | 325 } // namespace ui |
| 321 | 326 |
| 322 // TODO(beng): Someday, maybe, get rid of this. | 327 // TODO(beng): Someday, maybe, get rid of this. |
| 323 using ui::ResourceBundle; | 328 using ui::ResourceBundle; |
| 324 | 329 |
| 325 #endif // UI_BASE_RESOURCE_RESOURCE_BUNDLE_H_ | 330 #endif // UI_BASE_RESOURCE_RESOURCE_BUNDLE_H_ |
| OLD | NEW |