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 <map> | 8 #include <map> |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
117 // Initialize the ResourceBundle for this process. Does not take ownership of | 117 // Initialize the ResourceBundle for this process. Does not take ownership of |
118 // the |delegate| value. Returns the language selected. | 118 // the |delegate| value. Returns the language selected. |
119 // NOTE: Mac ignores this and always loads up resources for the language | 119 // NOTE: Mac ignores this and always loads up resources for the language |
120 // defined by the Cocoa UI (i.e., NSBundle does the language work). | 120 // defined by the Cocoa UI (i.e., NSBundle does the language work). |
121 // | 121 // |
122 // TODO(sergeyu): This method also loads common resources (i.e. chrome.pak). | 122 // TODO(sergeyu): This method also loads common resources (i.e. chrome.pak). |
123 // There is no way to specify which resource files are loaded, i.e. names of | 123 // There is no way to specify which resource files are loaded, i.e. names of |
124 // the files are hardcoded in ResourceBundle. Fix it to allow to specify which | 124 // the files are hardcoded in ResourceBundle. Fix it to allow to specify which |
125 // files are loaded (e.g. add a new method in Delegate). | 125 // files are loaded (e.g. add a new method in Delegate). |
126 static std::string InitSharedInstanceWithLocale( | 126 static std::string InitSharedInstanceWithLocale( |
127 const std::string& pref_locale, Delegate* delegate); | 127 const std::string& pref_locale, |
128 Delegate* delegate); | |
oshima
2014/07/29 08:24:41
Is anyone using this delegate?
tony
2014/07/29 16:34:05
Yes, the delegate is used by CEF. We should add a
oshima
2014/07/29 16:43:39
Oh I see. I asked because all instances hit by cs
| |
128 | 129 |
129 // Same as InitSharedInstanceWithLocale(), but loads only localized resources, | 130 // Same as InitSharedInstanceWithLocale(), but loads only localized resources, |
130 // without default resource packs. | 131 // without default resource packs. |
131 static std::string InitSharedInstanceLocaleOnly( | 132 static std::string InitSharedInstanceLocaleOnly( |
132 const std::string& pref_locale, Delegate* delegate); | 133 const std::string& pref_locale, |
134 Delegate* delegate); | |
133 | 135 |
134 // Initialize the ResourceBundle using given file. The second argument | 136 // Initialize the ResourceBundle using given file. This allows the use of this |
135 // controls whether or not ResourceBundle::LoadCommonResources is called. | 137 // function in a sandbox without local file access (as on Android). |
oshima
2014/07/29 08:24:41
I think we should ifdef for android as that's the
| |
136 // This allows the use of this function in a sandbox without local file | 138 static void InitSharedInstanceWithPakFile(base::File file); |
137 // access (as on Android). | |
138 static void InitSharedInstanceWithPakFile(base::File file, | |
139 bool should_load_common_resources); | |
140 | 139 |
141 // Initialize the ResourceBundle using given data pack path for testing. | 140 // Initialize the ResourceBundle using given data pack path for testing. |
142 static void InitSharedInstanceWithPakPath(const base::FilePath& path); | 141 static void InitSharedInstanceWithPakPath(const base::FilePath& path); |
oshima
2014/07/29 08:24:41
This should retire.
| |
143 | 142 |
144 // Delete the ResourceBundle for this process if it exists. | 143 // Delete the ResourceBundle for this process if it exists. |
145 static void CleanupSharedInstance(); | 144 static void CleanupSharedInstance(); |
146 | 145 |
147 // Returns true after the global resource loader instance has been created. | 146 // Returns true after the global resource loader instance has been created. |
148 static bool HasSharedInstance(); | 147 static bool HasSharedInstance(); |
149 | 148 |
150 // Return the global resource loader instance. | 149 // Return the global resource loader instance. |
151 static ResourceBundle& GetSharedInstance(); | 150 static ResourceBundle& GetSharedInstance(); |
152 | 151 |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
286 // Ctor/dtor are private, since we're a singleton. | 285 // Ctor/dtor are private, since we're a singleton. |
287 explicit ResourceBundle(Delegate* delegate); | 286 explicit ResourceBundle(Delegate* delegate); |
288 ~ResourceBundle(); | 287 ~ResourceBundle(); |
289 | 288 |
290 // Shared initialization. | 289 // Shared initialization. |
291 static void InitSharedInstance(Delegate* delegate); | 290 static void InitSharedInstance(Delegate* delegate); |
292 | 291 |
293 // Free skia_images_. | 292 // Free skia_images_. |
294 void FreeImages(); | 293 void FreeImages(); |
295 | 294 |
296 // Load the main resources. | |
297 void LoadCommonResources(); | |
298 | |
299 // Implementation for AddDataPackFromPath and AddOptionalDataPackFromPath, if | 295 // Implementation for AddDataPackFromPath and AddOptionalDataPackFromPath, if |
300 // the pack is not |optional| logs an error on failure to load. | 296 // the pack is not |optional| logs an error on failure to load. |
301 void AddDataPackFromPathInternal(const base::FilePath& path, | 297 void AddDataPackFromPathInternal(const base::FilePath& path, |
302 ScaleFactor scale_factor, | 298 ScaleFactor scale_factor, |
303 bool optional); | 299 bool optional); |
304 | 300 |
305 // Inserts |data_pack| to |data_pack_| and updates |max_scale_factor_| | 301 // Inserts |data_pack| to |data_pack_| and updates |max_scale_factor_| |
306 // accordingly. | 302 // accordingly. |
307 void AddDataPack(DataPack* data_pack); | 303 void AddDataPack(DataPack* data_pack); |
308 | 304 |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
411 | 407 |
412 DISALLOW_COPY_AND_ASSIGN(ResourceBundle); | 408 DISALLOW_COPY_AND_ASSIGN(ResourceBundle); |
413 }; | 409 }; |
414 | 410 |
415 } // namespace ui | 411 } // namespace ui |
416 | 412 |
417 // TODO(beng): Someday, maybe, get rid of this. | 413 // TODO(beng): Someday, maybe, get rid of this. |
418 using ui::ResourceBundle; | 414 using ui::ResourceBundle; |
419 | 415 |
420 #endif // UI_BASE_RESOURCE_RESOURCE_BUNDLE_H_ | 416 #endif // UI_BASE_RESOURCE_RESOURCE_BUNDLE_H_ |
OLD | NEW |