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 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
422 | 427 |
423 DISALLOW_COPY_AND_ASSIGN(ResourceBundle); | 428 DISALLOW_COPY_AND_ASSIGN(ResourceBundle); |
424 }; | 429 }; |
425 | 430 |
426 } // namespace ui | 431 } // namespace ui |
427 | 432 |
428 // TODO(beng): Someday, maybe, get rid of this. | 433 // TODO(beng): Someday, maybe, get rid of this. |
429 using ui::ResourceBundle; | 434 using ui::ResourceBundle; |
430 | 435 |
431 #endif // UI_BASE_RESOURCE_RESOURCE_BUNDLE_H_ | 436 #endif // UI_BASE_RESOURCE_RESOURCE_BUNDLE_H_ |
OLD | NEW |