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 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
139 | 139 |
140 // Initialize the ResourceBundle using given data pack path for testing. | 140 // Initialize the ResourceBundle using given data pack path for testing. |
141 static void InitSharedInstanceWithPakPath(const base::FilePath& path); | 141 static void InitSharedInstanceWithPakPath(const base::FilePath& path); |
142 | 142 |
143 // Delete the ResourceBundle for this process if it exists. | 143 // Delete the ResourceBundle for this process if it exists. |
144 static void CleanupSharedInstance(); | 144 static void CleanupSharedInstance(); |
145 | 145 |
146 // Returns true after the global resource loader instance has been created. | 146 // Returns true after the global resource loader instance has been created. |
147 static bool HasSharedInstance(); | 147 static bool HasSharedInstance(); |
148 | 148 |
149 // Initialize the ResourceBundle using data pack from given buffer. | |
149 // Return the global resource loader instance. | 150 // Return the global resource loader instance. |
150 static ResourceBundle& GetSharedInstance(); | 151 static ResourceBundle& GetSharedInstance(); |
151 | 152 |
152 // Check if the .pak for the given locale exists. | 153 // Check if the .pak for the given locale exists. |
153 bool LocaleDataPakExists(const std::string& locale); | 154 bool LocaleDataPakExists(const std::string& locale); |
154 | 155 |
155 // Registers additional data pack files with this ResourceBundle. When | 156 // Registers additional data pack files with this ResourceBundle. When |
156 // looking for a DataResource, we will search these files after searching the | 157 // looking for a DataResource, we will search these files after searching the |
157 // main module. |path| should be the complete path to the pack file if known | 158 // main module. |path| should be the complete path to the pack file if known |
158 // or just the pack file name otherwise (the delegate may optionally override | 159 // or just the pack file name otherwise (the delegate may optionally override |
159 // this value). |scale_factor| is the scale of images in this resource pak | 160 // this value). |scale_factor| is the scale of images in this resource pak |
160 // relative to the images in the 1x resource pak. This method is not thread | 161 // relative to the images in the 1x resource pak. This method is not thread |
161 // safe! You should call it immediately after calling InitSharedInstance. | 162 // safe! You should call it immediately after calling InitSharedInstance. |
162 void AddDataPackFromPath(const base::FilePath& path, | 163 void AddDataPackFromPath(const base::FilePath& path, |
163 ScaleFactor scale_factor); | 164 ScaleFactor scale_factor); |
164 | 165 |
165 // Same as above but using an already open file. | 166 // Same as above but using an already open file. |
166 void AddDataPackFromFile(base::File file, ScaleFactor scale_factor); | 167 void AddDataPackFromFile(base::File file, ScaleFactor scale_factor); |
167 | 168 |
168 // Same as above but using only a region (offset + size) of the file. | 169 // Same as above but using only a region (offset + size) of the file. |
169 void AddDataPackFromFileRegion(base::File file, | 170 void AddDataPackFromFileRegion(base::File file, |
170 const base::MemoryMappedFile::Region& region, | 171 const base::MemoryMappedFile::Region& region, |
171 ScaleFactor scale_factor); | 172 ScaleFactor scale_factor); |
172 | 173 |
174 // Same as above but using contents of the given buffer. | |
175 void AddDataPackFromBuffer(base::StringPiece buffer, | |
176 ScaleFactor scale_factor); | |
177 | |
173 // Same as AddDataPackFromPath but does not log an error if the pack fails to | 178 // Same as AddDataPackFromPath but does not log an error if the pack fails to |
174 // load. | 179 // load. |
175 void AddOptionalDataPackFromPath(const base::FilePath& path, | 180 void AddOptionalDataPackFromPath(const base::FilePath& path, |
176 ScaleFactor scale_factor); | 181 ScaleFactor scale_factor); |
177 | 182 |
178 // Changes the locale for an already-initialized ResourceBundle, returning the | 183 // Changes the locale for an already-initialized ResourceBundle, returning the |
179 // name of the newly-loaded locale. Future calls to get strings will return | 184 // name of the newly-loaded locale. Future calls to get strings will return |
180 // the strings for this new locale. This has no effect on existing or future | 185 // the strings for this new locale. This has no effect on existing or future |
181 // image resources. |locale_resources_data_| is protected by a lock for the | 186 // image resources. |locale_resources_data_| is protected by a lock for the |
182 // duration of the swap, as GetLocalizedString() may be concurrently invoked | 187 // duration of the swap, as GetLocalizedString() may be concurrently invoked |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
328 | 333 |
329 // Try to load the locale specific strings from an external data module. | 334 // Try to load the locale specific strings from an external data module. |
330 // Returns the locale that is loaded. | 335 // Returns the locale that is loaded. |
331 std::string LoadLocaleResources(const std::string& pref_locale); | 336 std::string LoadLocaleResources(const std::string& pref_locale); |
332 | 337 |
333 // Load test resources in given paths. If either path is empty an empty | 338 // Load test resources in given paths. If either path is empty an empty |
334 // resource pack is loaded. | 339 // resource pack is loaded. |
335 void LoadTestResources(const base::FilePath& path, | 340 void LoadTestResources(const base::FilePath& path, |
336 const base::FilePath& locale_path); | 341 const base::FilePath& locale_path); |
337 | 342 |
343 // Load test resources from given buffers. | |
344 void LoadTestResourcesFromBuffer(base::StringPiece data, | |
sky
2017/02/08 22:22:58
Is this used?
altimin
2017/02/09 00:13:52
No, thanks.
| |
345 base::StringPiece locale_data); | |
346 | |
338 // Unload the locale specific strings and prepares to load new ones. See | 347 // Unload the locale specific strings and prepares to load new ones. See |
339 // comments for ReloadLocaleResources(). | 348 // comments for ReloadLocaleResources(). |
340 void UnloadLocaleResources(); | 349 void UnloadLocaleResources(); |
341 | 350 |
342 // Initializes the font description of default gfx::FontList. | 351 // Initializes the font description of default gfx::FontList. |
343 void InitDefaultFontList(); | 352 void InitDefaultFontList(); |
344 | 353 |
345 // Fills the |bitmap| given the data file to look in and the |resource_id|. | 354 // Fills the |bitmap| given the data file to look in and the |resource_id|. |
346 // Returns false if the resource does not exist. | 355 // Returns false if the resource does not exist. |
347 // | 356 // |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
422 | 431 |
423 DISALLOW_COPY_AND_ASSIGN(ResourceBundle); | 432 DISALLOW_COPY_AND_ASSIGN(ResourceBundle); |
424 }; | 433 }; |
425 | 434 |
426 } // namespace ui | 435 } // namespace ui |
427 | 436 |
428 // TODO(beng): Someday, maybe, get rid of this. | 437 // TODO(beng): Someday, maybe, get rid of this. |
429 using ui::ResourceBundle; | 438 using ui::ResourceBundle; |
430 | 439 |
431 #endif // UI_BASE_RESOURCE_RESOURCE_BUNDLE_H_ | 440 #endif // UI_BASE_RESOURCE_RESOURCE_BUNDLE_H_ |
OLD | NEW |