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

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

Issue 419093002: ui: Remove ResourceBundle::LoadCommonResources(). Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: InitParams Created 6 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 <map> 8 #include <map>
9 #include <string> 9 #include <string>
10 10
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 // false to attempt retrieval of the default string. 108 // false to attempt retrieval of the default string.
109 virtual bool GetLocalizedString(int message_id, base::string16* value) = 0; 109 virtual bool GetLocalizedString(int message_id, base::string16* value) = 0;
110 110
111 // Returns a font or NULL to attempt retrieval of the default resource. 111 // Returns a font or NULL to attempt retrieval of the default resource.
112 virtual scoped_ptr<gfx::Font> GetFont(FontStyle style) = 0; 112 virtual scoped_ptr<gfx::Font> GetFont(FontStyle style) = 0;
113 113
114 protected: 114 protected:
115 virtual ~Delegate() {} 115 virtual ~Delegate() {}
116 }; 116 };
117 117
118 struct InitParams {
119 base::FilePath main_pak_path;
120 base::FilePath scaled_pak_path;
oshima 2014/08/07 17:01:10 There can be two pak files for scaled images. Are
tfarina 2014/08/07 17:12:33 Nope.
tfarina 2014/08/09 16:22:42 Done.
121 std::string pref_locale;
122 Delegate* delegate;
123 };
tony 2014/08/07 16:29:34 In the future when might need to do something more
124
118 // Initialize the ResourceBundle for this process. Does not take ownership of 125 // Initialize the ResourceBundle for this process. Does not take ownership of
119 // the |delegate| value. Returns the language selected. 126 // the |delegate| value. Returns the language selected.
120 // NOTE: Mac ignores this and always loads up resources for the language 127 // 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). 128 // defined by the Cocoa UI (i.e., NSBundle does the language work).
122 // 129 //
123 // TODO(sergeyu): This method also loads common resources (i.e. chrome.pak). 130 // TODO(sergeyu): This method also loads common resources (i.e. chrome.pak).
124 // There is no way to specify which resource files are loaded, i.e. names of 131 // There is no way to specify which resource files are loaded, i.e. names of
125 // the files are hardcoded in ResourceBundle. Fix it to allow to specify which 132 // the files are hardcoded in ResourceBundle. Fix it to allow to specify which
126 // files are loaded (e.g. add a new method in Delegate). 133 // files are loaded (e.g. add a new method in Delegate).
127 static std::string InitSharedInstanceWithLocale( 134 static std::string InitSharedInstanceWithLocale(
128 const std::string& pref_locale, Delegate* delegate); 135 const std::string& pref_locale,
136 Delegate* delegate);
129 137
130 // Same as InitSharedInstanceWithLocale(), but loads only localized resources, 138 // Same as InitSharedInstanceWithLocale(), but loads only localized resources,
131 // without default resource packs. 139 // without default resource packs.
132 static std::string InitSharedInstanceLocaleOnly( 140 static std::string InitSharedInstanceLocaleOnly(
133 const std::string& pref_locale, Delegate* delegate); 141 const std::string& pref_locale,
142 Delegate* delegate);
134 143
135 // Initialize the ResourceBundle using the given file region. If |region| is 144 // Initialize the ResourceBundle using the given file region. If |region| is
136 // MemoryMappedFile::Region::kWholeFile, the entire |pak_file| is used. 145 // MemoryMappedFile::Region::kWholeFile, the entire |pak_file| is used.
137 // |should_load_common_resources| controls whether or not LoadCommonResources 146 // |should_load_common_resources| controls whether or not LoadCommonResources
138 // is called. 147 // is called.
139 // This allows the use of this function in a sandbox without local file 148 // This allows the use of this function in a sandbox without local file
140 // access (as on Android). 149 // access (as on Android).
141 static void InitSharedInstanceWithPakFileRegion( 150 static void InitSharedInstanceWithPakFileRegion(
142 base::File pak_file, 151 base::File pak_file,
143 const base::MemoryMappedFile::Region& region, 152 const base::MemoryMappedFile::Region& region,
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
296 // Ctor/dtor are private, since we're a singleton. 305 // Ctor/dtor are private, since we're a singleton.
297 explicit ResourceBundle(Delegate* delegate); 306 explicit ResourceBundle(Delegate* delegate);
298 ~ResourceBundle(); 307 ~ResourceBundle();
299 308
300 // Shared initialization. 309 // Shared initialization.
301 static void InitSharedInstance(Delegate* delegate); 310 static void InitSharedInstance(Delegate* delegate);
302 311
303 // Free skia_images_. 312 // Free skia_images_.
304 void FreeImages(); 313 void FreeImages();
305 314
306 // Load the main resources.
307 void LoadCommonResources();
308
309 // Implementation for AddDataPackFromPath and AddOptionalDataPackFromPath, if 315 // Implementation for AddDataPackFromPath and AddOptionalDataPackFromPath, if
310 // the pack is not |optional| logs an error on failure to load. 316 // the pack is not |optional| logs an error on failure to load.
311 void AddDataPackFromPathInternal(const base::FilePath& path, 317 void AddDataPackFromPathInternal(const base::FilePath& path,
312 ScaleFactor scale_factor, 318 ScaleFactor scale_factor,
313 bool optional); 319 bool optional);
314 320
315 // Inserts |data_pack| to |data_pack_| and updates |max_scale_factor_| 321 // Inserts |data_pack| to |data_pack_| and updates |max_scale_factor_|
316 // accordingly. 322 // accordingly.
317 void AddDataPack(DataPack* data_pack); 323 void AddDataPack(DataPack* data_pack);
318 324
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
421 427
422 DISALLOW_COPY_AND_ASSIGN(ResourceBundle); 428 DISALLOW_COPY_AND_ASSIGN(ResourceBundle);
423 }; 429 };
424 430
425 } // namespace ui 431 } // namespace ui
426 432
427 // TODO(beng): Someday, maybe, get rid of this. 433 // TODO(beng): Someday, maybe, get rid of this.
428 using ui::ResourceBundle; 434 using ui::ResourceBundle;
429 435
430 #endif // UI_BASE_RESOURCE_RESOURCE_BUNDLE_H_ 436 #endif // UI_BASE_RESOURCE_RESOURCE_BUNDLE_H_
OLDNEW
« no previous file with comments | « no previous file | ui/base/resource/resource_bundle.cc » ('j') | ui/base/resource/resource_bundle_mac.mm » ('J')

Powered by Google App Engine
This is Rietveld 408576698