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

Unified Diff: ui/base/resource/resource_bundle_posix.cc

Issue 7677004: Switch to using .pak files for locale data on Windows. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: comment Created 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/base/resource/resource_bundle_linux.cc ('k') | ui/base/resource/resource_bundle_win.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/base/resource/resource_bundle_posix.cc
diff --git a/ui/base/resource/resource_bundle_posix.cc b/ui/base/resource/resource_bundle_posix.cc
index d23a5b1da0986e82e09bd0cd52c68204084066a7..2669b6881ebe867ce3dab3128f5df85bced83d94 100644
--- a/ui/base/resource/resource_bundle_posix.cc
+++ b/ui/base/resource/resource_bundle_posix.cc
@@ -18,20 +18,6 @@
namespace ui {
-namespace {
-
-DataPack* LoadResourcesDataPak(FilePath resources_pak_path) {
- DataPack* resources_pak = new DataPack;
- bool success = resources_pak->Load(resources_pak_path);
- if (!success) {
- delete resources_pak;
- resources_pak = NULL;
- }
- return resources_pak;
-}
-
-} // namespace
-
ResourceBundle::~ResourceBundle() {
FreeImages();
UnloadLocaleResources();
@@ -41,11 +27,6 @@ ResourceBundle::~ResourceBundle() {
resources_data_ = NULL;
}
-void ResourceBundle::UnloadLocaleResources() {
- delete locale_resources_data_;
- locale_resources_data_ = NULL;
-}
-
// static
RefCountedStaticMemory* ResourceBundle::LoadResourceBytes(
DataHandle module, int resource_id) {
@@ -69,32 +50,6 @@ base::StringPiece ResourceBundle::GetRawDataResource(int resource_id) const {
return data;
}
-string16 ResourceBundle::GetLocalizedString(int message_id) {
- // If for some reason we were unable to load a resource pak, return an empty
- // string (better than crashing).
- if (!locale_resources_data_) {
- LOG(WARNING) << "locale resources are not loaded";
- return string16();
- }
-
- base::StringPiece data;
- if (!locale_resources_data_->GetStringPiece(message_id, &data)) {
- // Fall back on the main data pack (shouldn't be any strings here except in
- // unittests).
- data = GetRawDataResource(message_id);
- if (data.empty()) {
- NOTREACHED() << "unable to find resource: " << message_id;
- return string16();
- }
- }
-
- // Data pack encodes strings as UTF16.
- DCHECK_EQ(data.length() % 2, 0U);
- string16 msg(reinterpret_cast<const char16*>(data.data()),
- data.length() / 2);
- return msg;
-}
-
void ResourceBundle::LoadCommonResources() {
DCHECK(!resources_data_) << "chrome.pak already loaded";
FilePath resources_file_path = GetResourcesFilePath();
@@ -111,34 +66,12 @@ void ResourceBundle::LoadCommonResources() {
}
}
-std::string ResourceBundle::LoadLocaleResources(
- const std::string& pref_locale) {
- DCHECK(!locale_resources_data_) << "locale.pak already loaded";
- std::string app_locale = l10n_util::GetApplicationLocale(pref_locale);
- FilePath locale_file_path;
- CommandLine *command_line = CommandLine::ForCurrentProcess();
- if (command_line->HasSwitch(switches::kLocalePak)) {
- locale_file_path =
- command_line->GetSwitchValuePath(switches::kLocalePak);
- } else {
- locale_file_path = GetLocaleFilePath(app_locale);
- }
- if (locale_file_path.empty()) {
- // It's possible that there is no locale.pak.
- NOTREACHED();
- return std::string();
- }
- locale_resources_data_ = LoadResourcesDataPak(locale_file_path);
- CHECK(locale_resources_data_) << "failed to load locale.pak";
- return app_locale;
-}
-
void ResourceBundle::LoadTestResources(const FilePath& path) {
DCHECK(!resources_data_) << "resource already loaded";
// Use the given resource pak for both common and localized resources.
resources_data_ = LoadResourcesDataPak(path);
- locale_resources_data_ = LoadResourcesDataPak(path);
+ locale_resources_data_.reset(LoadResourcesDataPak(path));
}
} // namespace ui
« no previous file with comments | « ui/base/resource/resource_bundle_linux.cc ('k') | ui/base/resource/resource_bundle_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698