Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(464)

Side by Side Diff: ui/base/resource/resource_bundle.h

Issue 19666006: Supports FontList in Textfield. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Updates ui_unittests_disabled for Android. Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 "build/build_config.h" 8 #include "build/build_config.h"
9 9
10 #include <map> 10 #include <map>
11 #include <string> 11 #include <string>
12 12
13 #include "base/basictypes.h" 13 #include "base/basictypes.h"
14 #include "base/files/file_path.h" 14 #include "base/files/file_path.h"
15 #include "base/gtest_prod_util.h" 15 #include "base/gtest_prod_util.h"
16 #include "base/memory/scoped_ptr.h" 16 #include "base/memory/scoped_ptr.h"
17 #include "base/memory/scoped_vector.h" 17 #include "base/memory/scoped_vector.h"
18 #include "base/platform_file.h" 18 #include "base/platform_file.h"
19 #include "base/strings/string16.h" 19 #include "base/strings/string16.h"
20 #include "base/strings/string_piece.h" 20 #include "base/strings/string_piece.h"
21 #include "ui/base/layout.h" 21 #include "ui/base/layout.h"
22 #include "ui/base/ui_export.h" 22 #include "ui/base/ui_export.h"
23 #include "ui/gfx/font.h" 23 #include "ui/gfx/font_list.h"
24 #include "ui/gfx/image/image.h" 24 #include "ui/gfx/image/image.h"
25 #include "ui/gfx/native_widget_types.h" 25 #include "ui/gfx/native_widget_types.h"
26 26
27 class SkBitmap; 27 class SkBitmap;
28 28
29 namespace base { 29 namespace base {
30 class Lock; 30 class Lock;
31 class RefCountedStaticMemory; 31 class RefCountedStaticMemory;
32 } 32 }
33 33
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 // Retrieve a raw data resource. Return true if a resource was provided or 100 // Retrieve a raw data resource. Return true if a resource was provided or
101 // false to attempt retrieval of the default resource. 101 // false to attempt retrieval of the default resource.
102 virtual bool GetRawDataResource(int resource_id, 102 virtual bool GetRawDataResource(int resource_id,
103 ScaleFactor scale_factor, 103 ScaleFactor scale_factor,
104 base::StringPiece* value) = 0; 104 base::StringPiece* value) = 0;
105 105
106 // Retrieve a localized string. Return true if a string was provided or 106 // Retrieve a localized string. Return true if a string was provided or
107 // false to attempt retrieval of the default string. 107 // false to attempt retrieval of the default string.
108 virtual bool GetLocalizedString(int message_id, string16* value) = 0; 108 virtual bool GetLocalizedString(int message_id, string16* value) = 0;
109 109
110 // Return a font resource or NULL to attempt retrieval of the default 110 // Returns a font list or NULL to attempt retrieval of the default
111 // resource. 111 // resource.
112 virtual scoped_ptr<gfx::Font> GetFont(FontStyle style) = 0; 112 virtual scoped_ptr<gfx::FontList> GetFontList(FontStyle style) = 0;
113 113
114 protected: 114 protected:
115 virtual ~Delegate() {} 115 virtual ~Delegate() {}
116 }; 116 };
117 117
118 // Initialize the ResourceBundle for this process. Does not take ownership of 118 // Initialize the ResourceBundle for this process. Does not take ownership of
119 // the |delegate| value. Returns the language selected. 119 // the |delegate| value. Returns the language selected.
120 // NOTE: Mac ignores this and always loads up resources for the language 120 // NOTE: Mac ignores this and always loads up resources for the language
121 // defined by the Cocoa UI (i.e., NSBundle does the language work). 121 // defined by the Cocoa UI (i.e., NSBundle does the language work).
122 // 122 //
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 // nearest the scale factor |scale_factor|. 226 // nearest the scale factor |scale_factor|.
227 // Use ResourceHandle::SCALE_FACTOR_NONE for scale independent image resources 227 // Use ResourceHandle::SCALE_FACTOR_NONE for scale independent image resources
228 // (such as wallpaper). 228 // (such as wallpaper).
229 base::StringPiece GetRawDataResourceForScale(int resource_id, 229 base::StringPiece GetRawDataResourceForScale(int resource_id,
230 ScaleFactor scale_factor) const; 230 ScaleFactor scale_factor) const;
231 231
232 // Get a localized string given a message id. Returns an empty 232 // Get a localized string given a message id. Returns an empty
233 // string if the message_id is not found. 233 // string if the message_id is not found.
234 string16 GetLocalizedString(int message_id); 234 string16 GetLocalizedString(int message_id);
235 235
236 // Returns the font for the specified style. 236 // Returns the font for the specified style.
msw 2013/07/30 21:32:27 nit: s/font/font list/
Yuki 2013/07/31 05:38:43 Done.
237 const gfx::FontList& GetFontList(FontStyle style);
238
239 // Returns the font for the specified style.
237 const gfx::Font& GetFont(FontStyle style); 240 const gfx::Font& GetFont(FontStyle style);
238 241
239 // Resets and reloads the cached fonts. This is useful when the fonts of the 242 // Resets and reloads the cached fonts. This is useful when the fonts of the
240 // system have changed, for example, when the locale has changed. 243 // system have changed, for example, when the locale has changed.
241 void ReloadFonts(); 244 void ReloadFonts();
242 245
243 // Overrides the path to the pak file from which the locale resources will be 246 // Overrides the path to the pak file from which the locale resources will be
244 // loaded. Pass an empty path to undo. 247 // loaded. Pass an empty path to undo.
245 void OverrideLocalePakForTest(const base::FilePath& pak_path); 248 void OverrideLocalePakForTest(const base::FilePath& pak_path);
246 249
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
363 // The maximum scale factor currently loaded. 366 // The maximum scale factor currently loaded.
364 ScaleFactor max_scale_factor_; 367 ScaleFactor max_scale_factor_;
365 368
366 // Cached images. The ResourceBundle caches all retrieved images and keeps 369 // Cached images. The ResourceBundle caches all retrieved images and keeps
367 // ownership of the pointers. 370 // ownership of the pointers.
368 typedef std::map<int, gfx::Image> ImageMap; 371 typedef std::map<int, gfx::Image> ImageMap;
369 ImageMap images_; 372 ImageMap images_;
370 373
371 gfx::Image empty_image_; 374 gfx::Image empty_image_;
372 375
373 // The various fonts used. Cached to avoid repeated GDI creation/destruction. 376 // The various font lists used. Cached to avoid repeated GDI
374 scoped_ptr<gfx::Font> base_font_; 377 // creation/destruction.
375 scoped_ptr<gfx::Font> bold_font_; 378 scoped_ptr<gfx::FontList> base_font_list_;
376 scoped_ptr<gfx::Font> small_font_; 379 scoped_ptr<gfx::FontList> bold_font_list_;
377 scoped_ptr<gfx::Font> small_bold_font_; 380 scoped_ptr<gfx::FontList> small_font_list_;
378 scoped_ptr<gfx::Font> medium_font_; 381 scoped_ptr<gfx::FontList> small_bold_font_list_;
379 scoped_ptr<gfx::Font> medium_bold_font_; 382 scoped_ptr<gfx::FontList> medium_font_list_;
380 scoped_ptr<gfx::Font> large_font_; 383 scoped_ptr<gfx::FontList> medium_bold_font_list_;
381 scoped_ptr<gfx::Font> large_bold_font_; 384 scoped_ptr<gfx::FontList> large_font_list_;
382 scoped_ptr<gfx::Font> web_font_; 385 scoped_ptr<gfx::FontList> large_bold_font_list_;
386 scoped_ptr<gfx::FontList> web_font_list_;
383 387
384 base::FilePath overridden_pak_path_; 388 base::FilePath overridden_pak_path_;
385 389
386 DISALLOW_COPY_AND_ASSIGN(ResourceBundle); 390 DISALLOW_COPY_AND_ASSIGN(ResourceBundle);
387 }; 391 };
388 392
389 } // namespace ui 393 } // namespace ui
390 394
391 // TODO(beng): Someday, maybe, get rid of this. 395 // TODO(beng): Someday, maybe, get rid of this.
392 using ui::ResourceBundle; 396 using ui::ResourceBundle;
393 397
394 #endif // UI_BASE_RESOURCE_RESOURCE_BUNDLE_H_ 398 #endif // UI_BASE_RESOURCE_RESOURCE_BUNDLE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698