summaryrefslogtreecommitdiffstats
path: root/ui
diff options
context:
space:
mode:
authorflackr@chromium.org <flackr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-08-31 00:28:33 +0000
committerflackr@chromium.org <flackr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-08-31 00:28:33 +0000
commit6e5656d7fb3b18cc7e14ae94dc79790aa450a758 (patch)
treeeb5ad0e0a32ebd267aff3a309ac0d2873563dbb3 /ui
parent136f00fef84348cf10bc0beba131291cbad009e1 (diff)
downloadchromium_src-6e5656d7fb3b18cc7e14ae94dc79790aa450a758.zip
chromium_src-6e5656d7fb3b18cc7e14ae94dc79790aa450a758.tar.gz
chromium_src-6e5656d7fb3b18cc7e14ae94dc79790aa450a758.tar.bz2
Add optional attribute to ResourceBundle::AddDataPack* and flag 2x chromeos resources optional
BUG=140040,142661 TEST=Run chrome (chromeos build) without chrome_200_percent.pak, there should be no error message. Review URL: https://chromiumcodereview.appspot.com/10871065 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@154326 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui')
-rw-r--r--ui/base/resource/resource_bundle.cc49
-rw-r--r--ui/base/resource/resource_bundle.h11
-rw-r--r--ui/base/resource/resource_bundle_aurax11.cc6
3 files changed, 44 insertions, 22 deletions
diff --git a/ui/base/resource/resource_bundle.cc b/ui/base/resource/resource_bundle.cc
index 9c3b392..5a2db84 100644
--- a/ui/base/resource/resource_bundle.cc
+++ b/ui/base/resource/resource_bundle.cc
@@ -202,26 +202,12 @@ bool ResourceBundle::LocaleDataPakExists(const std::string& locale) {
void ResourceBundle::AddDataPackFromPath(const FilePath& path,
ScaleFactor scale_factor) {
- // Do not pass an empty |path| value to this method. If the absolute path is
- // unknown pass just the pack file name.
- DCHECK(!path.empty());
-
- FilePath pack_path = path;
- if (delegate_)
- pack_path = delegate_->GetPathForResourcePack(pack_path, scale_factor);
-
- // Don't try to load empty values or values that are not absolute paths.
- if (pack_path.empty() || !pack_path.IsAbsolute())
- return;
+ AddDataPackFromPathInternal(path, scale_factor, false);
+}
- scoped_ptr<DataPack> data_pack(
- new DataPack(scale_factor));
- if (data_pack->LoadFromPath(pack_path)) {
- data_packs_.push_back(data_pack.release());
- } else {
- LOG(ERROR) << "Failed to load " << pack_path.value()
- << "\nSome features may not be available.";
- }
+void ResourceBundle::AddOptionalDataPackFromPath(const FilePath& path,
+ ScaleFactor scale_factor) {
+ AddDataPackFromPathInternal(path, scale_factor, true);
}
void ResourceBundle::AddDataPackFromFile(base::PlatformFile file,
@@ -526,6 +512,31 @@ void ResourceBundle::FreeImages() {
images_.clear();
}
+void ResourceBundle::AddDataPackFromPathInternal(const FilePath& path,
+ ScaleFactor scale_factor,
+ bool optional) {
+ // Do not pass an empty |path| value to this method. If the absolute path is
+ // unknown pass just the pack file name.
+ DCHECK(!path.empty());
+
+ FilePath pack_path = path;
+ if (delegate_)
+ pack_path = delegate_->GetPathForResourcePack(pack_path, scale_factor);
+
+ // Don't try to load empty values or values that are not absolute paths.
+ if (pack_path.empty() || !pack_path.IsAbsolute())
+ return;
+
+ scoped_ptr<DataPack> data_pack(
+ new DataPack(scale_factor));
+ if (data_pack->LoadFromPath(pack_path)) {
+ data_packs_.push_back(data_pack.release());
+ } else if (!optional) {
+ LOG(ERROR) << "Failed to load " << pack_path.value()
+ << "\nSome features may not be available.";
+ }
+}
+
void ResourceBundle::LoadFontsIfNecessary() {
images_and_fonts_lock_->AssertAcquired();
if (!base_font_.get()) {
diff --git a/ui/base/resource/resource_bundle.h b/ui/base/resource/resource_bundle.h
index 4fe430c..570de5c 100644
--- a/ui/base/resource/resource_bundle.h
+++ b/ui/base/resource/resource_bundle.h
@@ -152,6 +152,11 @@ class UI_EXPORT ResourceBundle {
// Same as above but using an already open file.
void AddDataPackFromFile(base::PlatformFile file, ScaleFactor scale_factor);
+ // Same as AddDataPackFromPath but does not log an error if the pack fails to
+ // load.
+ void AddOptionalDataPackFromPath(const FilePath& path,
+ 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
// the strings for this new locale. This has no effect on existing or future
@@ -256,6 +261,12 @@ class UI_EXPORT ResourceBundle {
// Load the main resources.
void LoadCommonResources();
+ // Implementation for AddDataPackFromPath and AddOptionalDataPackFromPath, if
+ // the pack is not |optional| logs an error on failure to load.
+ void AddDataPackFromPathInternal(const FilePath& path,
+ ScaleFactor scale_factor,
+ bool optional);
+
// Try to load the locale specific strings from an external data module.
// Returns the locale that is loaded.
std::string LoadLocaleResources(const std::string& pref_locale);
diff --git a/ui/base/resource/resource_bundle_aurax11.cc b/ui/base/resource/resource_bundle_aurax11.cc
index 0da0e25..2fd2166 100644
--- a/ui/base/resource/resource_bundle_aurax11.cc
+++ b/ui/base/resource/resource_bundle_aurax11.cc
@@ -51,9 +51,9 @@ void ResourceBundle::LoadCommonResources() {
// 2x non touch
// TODO(flackr): Don't log an error message if these are not found as this
// is an expected case in ChromeOS.
- AddDataPackFromPath(GetResourcesPakFilePath(
- "chrome_200_percent.pak"),
- SCALE_FACTOR_200P);
+ AddOptionalDataPackFromPath(GetResourcesPakFilePath(
+ "chrome_200_percent.pak"),
+ SCALE_FACTOR_200P);
}
}