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