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

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

Issue 1969313005: [headless] Embed pak file into binary. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixes according to comments. Created 4 years, 7 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
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 <stddef.h> 8 #include <stddef.h>
9 9
10 #include <map> 10 #include <map>
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 // MemoryMappedFile::Region::kWholeFile, the entire |pak_file| is used. 135 // MemoryMappedFile::Region::kWholeFile, the entire |pak_file| is used.
136 // This allows the use of this function in a sandbox without local file 136 // This allows the use of this function in a sandbox without local file
137 // access (as on Android). 137 // access (as on Android).
138 static void InitSharedInstanceWithPakFileRegion( 138 static void InitSharedInstanceWithPakFileRegion(
139 base::File pak_file, 139 base::File pak_file,
140 const base::MemoryMappedFile::Region& region); 140 const base::MemoryMappedFile::Region& region);
141 141
142 // Initialize the ResourceBundle using given data pack path for testing. 142 // Initialize the ResourceBundle using given data pack path for testing.
143 static void InitSharedInstanceWithPakPath(const base::FilePath& path); 143 static void InitSharedInstanceWithPakPath(const base::FilePath& path);
144 144
145 // Initialize the ResourceBundle using data pack from given buffer.
sky 2016/05/19 20:25:54 Also document lifetime here.
altimin 2016/05/19 23:04:48 Done.
146 static void InitSharedInstanceWithPakBuffer(base::StringPiece buffer);
sky 2016/05/19 20:25:54 I dislike exposing functions in the public class t
altimin 2016/05/19 23:04:47 Actually, this is not test-only function. InitShar
sky 2016/05/20 15:49:04 Content shell is primarily there for tests, and no
147
145 // Delete the ResourceBundle for this process if it exists. 148 // Delete the ResourceBundle for this process if it exists.
146 static void CleanupSharedInstance(); 149 static void CleanupSharedInstance();
147 150
148 // Returns true after the global resource loader instance has been created. 151 // Returns true after the global resource loader instance has been created.
149 static bool HasSharedInstance(); 152 static bool HasSharedInstance();
150 153
154 // Initialize the ResourceBundle using data pack from given buffer.
151 // Return the global resource loader instance. 155 // Return the global resource loader instance.
152 static ResourceBundle& GetSharedInstance(); 156 static ResourceBundle& GetSharedInstance();
153 157
154 // Check if the .pak for the given locale exists. 158 // Check if the .pak for the given locale exists.
155 bool LocaleDataPakExists(const std::string& locale); 159 bool LocaleDataPakExists(const std::string& locale);
156 160
157 // Registers additional data pack files with this ResourceBundle. When 161 // Registers additional data pack files with this ResourceBundle. When
158 // looking for a DataResource, we will search these files after searching the 162 // looking for a DataResource, we will search these files after searching the
159 // main module. |path| should be the complete path to the pack file if known 163 // main module. |path| should be the complete path to the pack file if known
160 // or just the pack file name otherwise (the delegate may optionally override 164 // or just the pack file name otherwise (the delegate may optionally override
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
349 353
350 // Try to load the locale specific strings from an external data module. 354 // Try to load the locale specific strings from an external data module.
351 // Returns the locale that is loaded. 355 // Returns the locale that is loaded.
352 std::string LoadLocaleResources(const std::string& pref_locale); 356 std::string LoadLocaleResources(const std::string& pref_locale);
353 357
354 // Load test resources in given paths. If either path is empty an empty 358 // Load test resources in given paths. If either path is empty an empty
355 // resource pack is loaded. 359 // resource pack is loaded.
356 void LoadTestResources(const base::FilePath& path, 360 void LoadTestResources(const base::FilePath& path,
357 const base::FilePath& locale_path); 361 const base::FilePath& locale_path);
358 362
363 // Load test resources from given buffers.
364 void LoadTestResourcesFromBuffer(base::StringPiece data,
365 base::StringPiece locale_data);
366
359 // Unload the locale specific strings and prepares to load new ones. See 367 // Unload the locale specific strings and prepares to load new ones. See
360 // comments for ReloadLocaleResources(). 368 // comments for ReloadLocaleResources().
361 void UnloadLocaleResources(); 369 void UnloadLocaleResources();
362 370
363 // Initializes the font description of default gfx::FontList. 371 // Initializes the font description of default gfx::FontList.
364 void InitDefaultFontList(); 372 void InitDefaultFontList();
365 373
366 // Fills the |bitmap| given the data file to look in and the |resource_id|. 374 // Fills the |bitmap| given the data file to look in and the |resource_id|.
367 // Returns false if the resource does not exist. 375 // Returns false if the resource does not exist.
368 // 376 //
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
443 451
444 DISALLOW_COPY_AND_ASSIGN(ResourceBundle); 452 DISALLOW_COPY_AND_ASSIGN(ResourceBundle);
445 }; 453 };
446 454
447 } // namespace ui 455 } // namespace ui
448 456
449 // TODO(beng): Someday, maybe, get rid of this. 457 // TODO(beng): Someday, maybe, get rid of this.
450 using ui::ResourceBundle; 458 using ui::ResourceBundle;
451 459
452 #endif // UI_BASE_RESOURCE_RESOURCE_BUNDLE_H_ 460 #endif // UI_BASE_RESOURCE_RESOURCE_BUNDLE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698