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 |
11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
12 #include "base/containers/hash_tables.h" | |
12 #include "base/files/file_path.h" | 13 #include "base/files/file_path.h" |
13 #include "base/gtest_prod_util.h" | 14 #include "base/gtest_prod_util.h" |
14 #include "base/memory/scoped_ptr.h" | 15 #include "base/memory/scoped_ptr.h" |
15 #include "base/memory/scoped_vector.h" | 16 #include "base/memory/scoped_vector.h" |
16 #include "base/strings/string16.h" | 17 #include "base/strings/string16.h" |
17 #include "base/strings/string_piece.h" | 18 #include "base/strings/string_piece.h" |
18 #include "build/build_config.h" | 19 #include "build/build_config.h" |
19 #include "ui/base/layout.h" | 20 #include "ui/base/layout.h" |
20 #include "ui/base/ui_base_export.h" | 21 #include "ui/base/ui_base_export.h" |
21 #include "ui/gfx/font_list.h" | 22 #include "ui/gfx/font_list.h" |
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
238 const gfx::Font& GetFont(FontStyle style); | 239 const gfx::Font& GetFont(FontStyle style); |
239 | 240 |
240 // Resets and reloads the cached fonts. This is useful when the fonts of the | 241 // Resets and reloads the cached fonts. This is useful when the fonts of the |
241 // system have changed, for example, when the locale has changed. | 242 // system have changed, for example, when the locale has changed. |
242 void ReloadFonts(); | 243 void ReloadFonts(); |
243 | 244 |
244 // Overrides the path to the pak file from which the locale resources will be | 245 // Overrides the path to the pak file from which the locale resources will be |
245 // loaded. Pass an empty path to undo. | 246 // loaded. Pass an empty path to undo. |
246 void OverrideLocalePakForTest(const base::FilePath& pak_path); | 247 void OverrideLocalePakForTest(const base::FilePath& pak_path); |
247 | 248 |
249 // Overrides a localized string resource with the given string. If no delegate | |
250 // is present, the |string| will be returned when getting the localized string | |
251 // |message_id|. If |ReloadLocaleResources| is called, all overrides are | |
252 // cleared. This is intended to be used in conjunction with field trials and | |
253 // the variations service to experiment with different UI strings. This method | |
254 // is not thread safe! | |
255 void OverrideLocaleStringResource(int message_id, | |
grt (UTC plus 2)
2014/07/03 19:00:34
how will this be used so that it's safe?
jwd
2014/07/11 19:23:27
It's only used in prethreadcreate...
It's only cal
| |
256 const base::string16& string); | |
257 | |
248 // Returns the full pathname of the locale file to load. May return an empty | 258 // Returns the full pathname of the locale file to load. May return an empty |
249 // string if no locale data files are found and |test_file_exists| is true. | 259 // string if no locale data files are found and |test_file_exists| is true. |
250 // Used on Android to load the local file in the browser process and pass it | 260 // Used on Android to load the local file in the browser process and pass it |
251 // to the sandboxed renderer process. | 261 // to the sandboxed renderer process. |
252 base::FilePath GetLocaleFilePath(const std::string& app_locale, | 262 base::FilePath GetLocaleFilePath(const std::string& app_locale, |
253 bool test_file_exists); | 263 bool test_file_exists); |
254 | 264 |
255 // Returns the maximum scale factor currently loaded. | 265 // Returns the maximum scale factor currently loaded. |
256 // Returns SCALE_FACTOR_100P if no resource is loaded. | 266 // Returns SCALE_FACTOR_100P if no resource is loaded. |
257 ScaleFactor GetMaxScaleFactor() const; | 267 ScaleFactor GetMaxScaleFactor() const; |
258 | 268 |
259 private: | 269 private: |
260 FRIEND_TEST_ALL_PREFIXES(ResourceBundleTest, DelegateGetPathForLocalePack); | 270 FRIEND_TEST_ALL_PREFIXES(ResourceBundleTest, DelegateGetPathForLocalePack); |
261 FRIEND_TEST_ALL_PREFIXES(ResourceBundleTest, DelegateGetImageNamed); | 271 FRIEND_TEST_ALL_PREFIXES(ResourceBundleTest, DelegateGetImageNamed); |
262 FRIEND_TEST_ALL_PREFIXES(ResourceBundleTest, DelegateGetNativeImageNamed); | 272 FRIEND_TEST_ALL_PREFIXES(ResourceBundleTest, DelegateGetNativeImageNamed); |
263 | 273 |
264 friend class ResourceBundleImageTest; | 274 friend class ResourceBundleImageTest; |
265 friend class ResourceBundleTest; | 275 friend class ResourceBundleTest; |
266 | 276 |
267 class ResourceBundleImageSource; | 277 class ResourceBundleImageSource; |
268 friend class ResourceBundleImageSource; | 278 friend class ResourceBundleImageSource; |
269 | 279 |
280 typedef base::hash_map<int, base::string16> IdToStringMap; | |
281 | |
270 // Ctor/dtor are private, since we're a singleton. | 282 // Ctor/dtor are private, since we're a singleton. |
271 explicit ResourceBundle(Delegate* delegate); | 283 explicit ResourceBundle(Delegate* delegate); |
272 ~ResourceBundle(); | 284 ~ResourceBundle(); |
273 | 285 |
274 // Shared initialization. | 286 // Shared initialization. |
275 static void InitSharedInstance(Delegate* delegate); | 287 static void InitSharedInstance(Delegate* delegate); |
276 | 288 |
277 // Free skia_images_. | 289 // Free skia_images_. |
278 void FreeImages(); | 290 void FreeImages(); |
279 | 291 |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
384 scoped_ptr<gfx::FontList> small_font_list_; | 396 scoped_ptr<gfx::FontList> small_font_list_; |
385 scoped_ptr<gfx::FontList> small_bold_font_list_; | 397 scoped_ptr<gfx::FontList> small_bold_font_list_; |
386 scoped_ptr<gfx::FontList> medium_font_list_; | 398 scoped_ptr<gfx::FontList> medium_font_list_; |
387 scoped_ptr<gfx::FontList> medium_bold_font_list_; | 399 scoped_ptr<gfx::FontList> medium_bold_font_list_; |
388 scoped_ptr<gfx::FontList> large_font_list_; | 400 scoped_ptr<gfx::FontList> large_font_list_; |
389 scoped_ptr<gfx::FontList> large_bold_font_list_; | 401 scoped_ptr<gfx::FontList> large_bold_font_list_; |
390 scoped_ptr<gfx::FontList> web_font_list_; | 402 scoped_ptr<gfx::FontList> web_font_list_; |
391 | 403 |
392 base::FilePath overridden_pak_path_; | 404 base::FilePath overridden_pak_path_; |
393 | 405 |
406 IdToStringMap overridden_locale_strings_; | |
407 | |
394 DISALLOW_COPY_AND_ASSIGN(ResourceBundle); | 408 DISALLOW_COPY_AND_ASSIGN(ResourceBundle); |
395 }; | 409 }; |
396 | 410 |
397 } // namespace ui | 411 } // namespace ui |
398 | 412 |
399 // TODO(beng): Someday, maybe, get rid of this. | 413 // TODO(beng): Someday, maybe, get rid of this. |
400 using ui::ResourceBundle; | 414 using ui::ResourceBundle; |
401 | 415 |
402 #endif // UI_BASE_RESOURCE_RESOURCE_BUNDLE_H_ | 416 #endif // UI_BASE_RESOURCE_RESOURCE_BUNDLE_H_ |
OLD | NEW |