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

Unified Diff: ui/base/resource/resource_bundle.h

Issue 10686005: Add methods to add DataPack from open files (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 8 years, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/base/resource/data_pack_unittest.cc ('k') | ui/base/resource/resource_bundle.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/base/resource/resource_bundle.h
diff --git a/ui/base/resource/resource_bundle.h b/ui/base/resource/resource_bundle.h
index 62d8fd6d17aa1577a07cdf3496cf782cd99543a7..597102e0b99e652cd43f71bf6f6ba35ac0aa8f47 100644
--- a/ui/base/resource/resource_bundle.h
+++ b/ui/base/resource/resource_bundle.h
@@ -16,6 +16,7 @@
#include "base/gtest_prod_util.h"
#include "base/memory/scoped_ptr.h"
#include "base/memory/scoped_vector.h"
+#include "base/platform_file.h"
#include "base/string16.h"
#include "base/string_piece.h"
#include "ui/base/layout.h"
@@ -118,8 +119,15 @@ class UI_EXPORT ResourceBundle {
static std::string InitSharedInstanceWithLocale(
const std::string& pref_locale, Delegate* delegate);
+ // Initialize the ResourceBundle using given file. The second argument
+ // controls whether or not ResourceBundle::LoadCommonResources is called.
+ // This allows the use of this function in a sandbox without local file
+ // access (as on Android).
+ static void InitSharedInstanceWithPakFile(
+ base::PlatformFile file, bool should_load_common_resources);
+
// Initialize the ResourceBundle using given data pack path for testing.
- static void InitSharedInstanceWithPakFile(const FilePath& path);
+ static void InitSharedInstanceWithPakPath(const FilePath& path);
// Delete the ResourceBundle for this process if it exists.
static void CleanupSharedInstance();
@@ -140,7 +148,10 @@ class UI_EXPORT ResourceBundle {
// this value). |scale_factor| is the scale of images in this resource pak
// relative to the images in the 1x resource pak. This method is not thread
// safe! You should call it immediately after calling InitSharedInstance.
- void AddDataPack(const FilePath& path, ScaleFactor scale_factor);
+ void AddDataPackFromPath(const FilePath& path, ScaleFactor scale_factor);
+
+ // Same as above but using an already open file.
+ void AddDataPackFromFile(base::PlatformFile file, ScaleFactor scale_factor);
// Changes the locale for an already-initialized ResourceBundle, returning the
// name of the newly-loaded locale. Future calls to get strings will return
@@ -213,6 +224,13 @@ class UI_EXPORT ResourceBundle {
// loaded. Pass an empty path to undo.
void OverrideLocalePakForTest(const FilePath& pak_path);
+ // Returns the full pathname of the locale file to load. May return an empty
+ // string if no locale data files are found and |test_file_exists| is true.
+ // Used on Android to load the local file in the browser process and pass it
+ // to the sandboxed renderer process.
+ FilePath GetLocaleFilePath(const std::string& app_locale,
+ bool test_file_exists);
+
private:
FRIEND_TEST_ALL_PREFIXES(ResourceBundle, DelegateGetPathForResourcePack);
FRIEND_TEST_ALL_PREFIXES(ResourceBundle, DelegateGetPathForLocalePack);
@@ -251,10 +269,6 @@ class UI_EXPORT ResourceBundle {
// Initialize all the gfx::Font members if they haven't yet been initialized.
void LoadFontsIfNecessary();
- // Returns the full pathname of the locale file to load. May return an empty
- // string if no locale data files are found.
- FilePath GetLocaleFilePath(const std::string& app_locale);
-
// Creates and returns a new SkBitmap given the data file to look in and the
// resource id. It's up to the caller to free the returned bitmap when
// done.
« no previous file with comments | « ui/base/resource/data_pack_unittest.cc ('k') | ui/base/resource/resource_bundle.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698