Chromium Code Reviews| 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 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 239 ScaleFactor scale_factor) const; | 239 ScaleFactor scale_factor) const; |
| 240 | 240 |
| 241 // Get a localized string given a message id. Returns an empty | 241 // Get a localized string given a message id. Returns an empty |
| 242 // string if the message_id is not found. | 242 // string if the message_id is not found. |
| 243 base::string16 GetLocalizedString(int message_id); | 243 base::string16 GetLocalizedString(int message_id); |
| 244 | 244 |
| 245 // Returns a font list derived from the platform-specific "Base" font list. | 245 // Returns a font list derived from the platform-specific "Base" font list. |
| 246 // The result is always cached and exists for the lifetime of the process. | 246 // The result is always cached and exists for the lifetime of the process. |
| 247 const gfx::FontList& GetFontListWithDelta( | 247 const gfx::FontList& GetFontListWithDelta( |
| 248 int size_delta, | 248 int size_delta, |
| 249 gfx::Font::FontStyle style = gfx::Font::NORMAL); | 249 gfx::Font::FontStyle style = gfx::Font::NORMAL, |
| 250 gfx::Font::Weight weight = gfx::Font::Weight::NORMAL); | |
| 250 | 251 |
| 251 // Returns the primary font from the FontList given by GetFontListWithDelta(). | 252 // Returns the primary font from the FontList given by GetFontListWithDelta(). |
| 252 const gfx::Font& GetFontWithDelta( | 253 const gfx::Font& GetFontWithDelta( |
| 253 int size_delta, | 254 int size_delta, |
| 254 gfx::Font::FontStyle style = gfx::Font::NORMAL); | 255 gfx::Font::FontStyle style = gfx::Font::NORMAL, |
| 256 gfx::Font::Weight weight = gfx::Font::Weight::NORMAL); | |
|
sky
2016/03/31 17:04:08
The style guide says not to use defaults like this
Peter Kasting
2016/03/31 21:04:49
No longer true (style guide was recently updated).
Mikus
2016/04/04 12:16:25
Acknowledged.
| |
| 255 | 257 |
| 256 // Deprecated. Returns fonts using hard-coded size deltas implied by |style|. | 258 // Deprecated. Returns fonts using hard-coded size deltas implied by |style|. |
| 257 const gfx::FontList& GetFontList(FontStyle style); | 259 const gfx::FontList& GetFontList(FontStyle style); |
| 258 const gfx::Font& GetFont(FontStyle style); | 260 const gfx::Font& GetFont(FontStyle style); |
| 259 | 261 |
| 260 // Resets and reloads the cached fonts. This is useful when the fonts of the | 262 // Resets and reloads the cached fonts. This is useful when the fonts of the |
| 261 // system have changed, for example, when the locale has changed. | 263 // system have changed, for example, when the locale has changed. |
| 262 void ReloadFonts(); | 264 void ReloadFonts(); |
| 263 | 265 |
| 264 // Overrides the path to the pak file from which the locale resources will be | 266 // Overrides the path to the pak file from which the locale resources will be |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 307 MDResourceAccess); | 309 MDResourceAccess); |
| 308 | 310 |
| 309 friend class ResourceBundleMacImageTest; | 311 friend class ResourceBundleMacImageTest; |
| 310 friend class ResourceBundleImageTest; | 312 friend class ResourceBundleImageTest; |
| 311 friend class ResourceBundleTest; | 313 friend class ResourceBundleTest; |
| 312 friend class ChromeBrowserMainMacBrowserTest; | 314 friend class ChromeBrowserMainMacBrowserTest; |
| 313 | 315 |
| 314 class ResourceBundleImageSource; | 316 class ResourceBundleImageSource; |
| 315 friend class ResourceBundleImageSource; | 317 friend class ResourceBundleImageSource; |
| 316 | 318 |
| 319 struct FontKey; | |
| 320 | |
| 317 typedef base::hash_map<int, base::string16> IdToStringMap; | 321 typedef base::hash_map<int, base::string16> IdToStringMap; |
| 318 | 322 |
| 319 // Ctor/dtor are private, since we're a singleton. | 323 // Ctor/dtor are private, since we're a singleton. |
| 320 explicit ResourceBundle(Delegate* delegate); | 324 explicit ResourceBundle(Delegate* delegate); |
| 321 ~ResourceBundle(); | 325 ~ResourceBundle(); |
| 322 | 326 |
| 323 // Shared initialization. | 327 // Shared initialization. |
| 324 static void InitSharedInstance(Delegate* delegate); | 328 static void InitSharedInstance(Delegate* delegate); |
| 325 | 329 |
| 326 // Free skia_images_. | 330 // Free skia_images_. |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 426 // ownership of the pointers. | 430 // ownership of the pointers. |
| 427 typedef std::map<int, gfx::Image> ImageMap; | 431 typedef std::map<int, gfx::Image> ImageMap; |
| 428 ImageMap images_; | 432 ImageMap images_; |
| 429 | 433 |
| 430 gfx::Image empty_image_; | 434 gfx::Image empty_image_; |
| 431 | 435 |
| 432 // The various font lists used, as a map from a signed size delta from the | 436 // The various font lists used, as a map from a signed size delta from the |
| 433 // platform base font size, plus style, to the FontList. Cached to avoid | 437 // platform base font size, plus style, to the FontList. Cached to avoid |
| 434 // repeated GDI creation/destruction and font derivation. | 438 // repeated GDI creation/destruction and font derivation. |
| 435 // Must be accessed only while holding |images_and_fonts_lock_|. | 439 // Must be accessed only while holding |images_and_fonts_lock_|. |
| 436 std::map<std::pair<int, gfx::Font::FontStyle>, gfx::FontList> font_cache_; | 440 std::map<FontKey, gfx::FontList> font_cache_; |
| 437 | 441 |
| 438 base::FilePath overridden_pak_path_; | 442 base::FilePath overridden_pak_path_; |
| 439 | 443 |
| 440 IdToStringMap overridden_locale_strings_; | 444 IdToStringMap overridden_locale_strings_; |
| 441 | 445 |
| 442 DISALLOW_COPY_AND_ASSIGN(ResourceBundle); | 446 DISALLOW_COPY_AND_ASSIGN(ResourceBundle); |
| 443 }; | 447 }; |
| 444 | 448 |
| 445 } // namespace ui | 449 } // namespace ui |
| 446 | 450 |
| 447 // TODO(beng): Someday, maybe, get rid of this. | 451 // TODO(beng): Someday, maybe, get rid of this. |
| 448 using ui::ResourceBundle; | 452 using ui::ResourceBundle; |
| 449 | 453 |
| 450 #endif // UI_BASE_RESOURCE_RESOURCE_BUNDLE_H_ | 454 #endif // UI_BASE_RESOURCE_RESOURCE_BUNDLE_H_ |
| OLD | NEW |