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 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
144 // Delete the ResourceBundle for this process if it exists. | 144 // Delete the ResourceBundle for this process if it exists. |
145 static void CleanupSharedInstance(); | 145 static void CleanupSharedInstance(); |
146 | 146 |
147 // Returns true after the global resource loader instance has been created. | 147 // Returns true after the global resource loader instance has been created. |
148 static bool HasSharedInstance(); | 148 static bool HasSharedInstance(); |
149 | 149 |
150 // Initialize the ResourceBundle using data pack from given buffer. | 150 // Initialize the ResourceBundle using data pack from given buffer. |
151 // Return the global resource loader instance. | 151 // Return the global resource loader instance. |
152 static ResourceBundle& GetSharedInstance(); | 152 static ResourceBundle& GetSharedInstance(); |
153 | 153 |
| 154 // Loads a secondary locale data pack using the given file region. |
| 155 void LoadSecondaryLocaleDataWithPakFileRegion( |
| 156 base::File pak_file, |
| 157 const base::MemoryMappedFile::Region& region); |
| 158 |
154 // Check if the .pak for the given locale exists. | 159 // Check if the .pak for the given locale exists. |
155 bool LocaleDataPakExists(const std::string& locale); | 160 bool LocaleDataPakExists(const std::string& locale); |
156 | 161 |
157 // Registers additional data pack files with this ResourceBundle. When | 162 // Registers additional data pack files with this ResourceBundle. When |
158 // looking for a DataResource, we will search these files after searching the | 163 // looking for a DataResource, we will search these files after searching the |
159 // main module. |path| should be the complete path to the pack file if known | 164 // main module. |path| should be the complete path to the pack file if known |
160 // or just the pack file name otherwise (the delegate may optionally override | 165 // or just the pack file name otherwise (the delegate may optionally override |
161 // this value). |scale_factor| is the scale of images in this resource pak | 166 // this value). |scale_factor| is the scale of images in this resource pak |
162 // relative to the images in the 1x resource pak. This method is not thread | 167 // relative to the images in the 1x resource pak. This method is not thread |
163 // safe! You should call it immediately after calling InitSharedInstance. | 168 // safe! You should call it immediately after calling InitSharedInstance. |
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
392 | 397 |
393 // This pointer is guaranteed to outlive the ResourceBundle instance and may | 398 // This pointer is guaranteed to outlive the ResourceBundle instance and may |
394 // be NULL. | 399 // be NULL. |
395 Delegate* delegate_; | 400 Delegate* delegate_; |
396 | 401 |
397 // Protects |locale_resources_data_|. | 402 // Protects |locale_resources_data_|. |
398 std::unique_ptr<base::Lock> locale_resources_data_lock_; | 403 std::unique_ptr<base::Lock> locale_resources_data_lock_; |
399 | 404 |
400 // Handles for data sources. | 405 // Handles for data sources. |
401 std::unique_ptr<ResourceHandle> locale_resources_data_; | 406 std::unique_ptr<ResourceHandle> locale_resources_data_; |
| 407 std::unique_ptr<ResourceHandle> secondary_locale_resources_data_; |
402 std::vector<std::unique_ptr<ResourceHandle>> data_packs_; | 408 std::vector<std::unique_ptr<ResourceHandle>> data_packs_; |
403 | 409 |
404 // The maximum scale factor currently loaded. | 410 // The maximum scale factor currently loaded. |
405 ScaleFactor max_scale_factor_; | 411 ScaleFactor max_scale_factor_; |
406 | 412 |
407 // Cached images. The ResourceBundle caches all retrieved images and keeps | 413 // Cached images. The ResourceBundle caches all retrieved images and keeps |
408 // ownership of the pointers. | 414 // ownership of the pointers. |
409 typedef std::map<int, gfx::Image> ImageMap; | 415 typedef std::map<int, gfx::Image> ImageMap; |
410 ImageMap images_; | 416 ImageMap images_; |
411 | 417 |
(...skipping 15 matching lines...) Expand all Loading... |
427 | 433 |
428 DISALLOW_COPY_AND_ASSIGN(ResourceBundle); | 434 DISALLOW_COPY_AND_ASSIGN(ResourceBundle); |
429 }; | 435 }; |
430 | 436 |
431 } // namespace ui | 437 } // namespace ui |
432 | 438 |
433 // TODO(beng): Someday, maybe, get rid of this. | 439 // TODO(beng): Someday, maybe, get rid of this. |
434 using ui::ResourceBundle; | 440 using ui::ResourceBundle; |
435 | 441 |
436 #endif // UI_BASE_RESOURCE_RESOURCE_BUNDLE_H_ | 442 #endif // UI_BASE_RESOURCE_RESOURCE_BUNDLE_H_ |
OLD | NEW |