summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--build/all.gyp2
-rw-r--r--chrome/chrome.gyp15
-rw-r--r--chrome/chrome_exe.gypi3
-rw-r--r--chrome/chrome_tests.gypi8
-rw-r--r--chrome/installer/mini_installer.gyp2
-rw-r--r--chrome/installer/mini_installer/chrome.release2
-rw-r--r--chrome/tools/build/win/FILES98
-rw-r--r--chrome/tools/build/win/FILES.cfg98
-rw-r--r--chrome_frame/chrome_frame.gyp2
-rw-r--r--ui/base/l10n/l10n_util.cc7
-rw-r--r--ui/base/l10n/l10n_util_unittest.cc9
-rw-r--r--ui/base/resource/resource_bundle.cc88
-rw-r--r--ui/base/resource/resource_bundle.h8
-rw-r--r--ui/base/resource/resource_bundle_dummy.cc3
-rw-r--r--ui/base/resource/resource_bundle_linux.cc14
-rw-r--r--ui/base/resource/resource_bundle_posix.cc69
-rw-r--r--ui/base/resource/resource_bundle_win.cc93
-rw-r--r--views/views.gyp2
18 files changed, 291 insertions, 232 deletions
diff --git a/build/all.gyp b/build/all.gyp
index cc8e292..d93347c 100644
--- a/build/all.gyp
+++ b/build/all.gyp
@@ -115,6 +115,7 @@
'dependencies': [
'../aura/aura.gyp:*',
'../breakpad/breakpad.gyp:*',
+ '../chrome/app/locales/locales.gyp:*',
'../chrome_frame/chrome_frame.gyp:*',
'../cloud_print/virtual_driver/virtual_driver.gyp:*',
'../courgette/courgette.gyp:*',
@@ -524,6 +525,7 @@
'target_name': 'chrome_official_builder',
'type': 'none',
'dependencies': [
+ '../chrome/app/locales/locales.gyp:*',
'../chrome/chrome.gyp:chromedriver',
'../chrome/chrome.gyp:crash_service',
'../chrome/chrome.gyp:crash_service_win64',
diff --git a/chrome/chrome.gyp b/chrome/chrome.gyp
index a15ea8f..3662bfd 100644
--- a/chrome/chrome.gyp
+++ b/chrome/chrome.gyp
@@ -1602,21 +1602,6 @@
'variables': {
'repack_path': '../tools/data_pack/repack.py',
},
- 'dependencies': [
- # MSVS needs the dependencies explictly named, Make is able to
- # derive the dependencies from the output files.
- 'chrome_resources',
- 'chrome_strings',
- 'default_plugin/default_plugin.gyp:default_plugin_resources',
- 'platform_locale_settings',
- 'theme_resources',
- '<(DEPTH)/net/net.gyp:net_resources',
- '<(DEPTH)/ui/base/strings/ui_strings.gyp:ui_strings',
- '<(DEPTH)/ui/ui.gyp:gfx_resources',
- '<(DEPTH)/ui/ui.gyp:ui_resources',
- '<(DEPTH)/webkit/support/webkit_support.gyp:webkit_resources',
- '<(DEPTH)/webkit/support/webkit_support.gyp:webkit_strings',
- ],
'actions': [
# TODO(mark): These actions are duplicated for the Mac in the
# chrome_dll target. Can they be unified?
diff --git a/chrome/chrome_exe.gypi b/chrome/chrome_exe.gypi
index aa4c491..d24b3f5 100644
--- a/chrome/chrome_exe.gypi
+++ b/chrome/chrome_exe.gypi
@@ -182,6 +182,7 @@
# Needed for chrome_main.cc initialization of libraries.
'../build/linux/system.gyp:dbus-glib',
'../build/linux/system.gyp:gtk',
+ 'packed_resources',
# Needed to use the master_preferences functions
'installer_util',
],
@@ -442,7 +443,6 @@
],
'dependencies': [
'packed_extra_resources',
- 'packed_resources',
# Copy Flash Player files to PRODUCT_DIR if applicable. Let the .gyp
# file decide what to do on a per-OS basis; on Mac, internal plugins
# go inside the framework, so this dependency is in chrome_dll.gypi.
@@ -479,6 +479,7 @@
'../breakpad/breakpad.gyp:breakpad_handler',
'../breakpad/breakpad.gyp:breakpad_sender',
'../sandbox/sandbox.gyp:sandbox',
+ 'app/locales/locales.gyp:*',
'app/policy/cloud_policy_codegen.gyp:policy',
],
'sources': [
diff --git a/chrome/chrome_tests.gypi b/chrome/chrome_tests.gypi
index 8c880ea..907aa8c 100644
--- a/chrome/chrome_tests.gypi
+++ b/chrome/chrome_tests.gypi
@@ -2164,6 +2164,11 @@
}],
],
}],
+ ['OS=="linux" or OS=="freebsd" or OS=="openbsd" or OS=="solaris"', {
+ 'dependencies': [
+ 'packed_resources',
+ ],
+ }],
['OS=="mac"', {
# The test fetches resources which means Mac need the app bundle to
# exist on disk so it can pull from it.
@@ -2216,7 +2221,6 @@
'dependencies': [
'convert_dict_lib',
'packed_extra_resources',
- 'packed_resources',
'../third_party/hunspell/hunspell.gyp:hunspell',
],
'sources!': [
@@ -3212,6 +3216,7 @@
'dependencies': [
'../build/linux/system.gyp:gtk',
'../build/linux/system.gyp:ssl',
+ 'packed_resources'
],
}],
['OS=="mac"', {
@@ -3226,7 +3231,6 @@
},{ # OS!="mac"
'dependencies': [
'packed_extra_resources',
- 'packed_resources'
],
}],
['OS=="linux" and chromeos==1', {
diff --git a/chrome/installer/mini_installer.gyp b/chrome/installer/mini_installer.gyp
index 4295fb4..f33432a 100644
--- a/chrome/installer/mini_installer.gyp
+++ b/chrome/installer/mini_installer.gyp
@@ -193,7 +193,7 @@
'<(PRODUCT_DIR)/ppGoogleNaClPluginChrome.dll',
'<(PRODUCT_DIR)/nacl_irt_x86_32.nexe',
'<(PRODUCT_DIR)/nacl_irt_x86_64.nexe',
- '<(PRODUCT_DIR)/locales/en-US.pak',
+ '<(PRODUCT_DIR)/locales/en-US.dll',
'<(PRODUCT_DIR)/icudt.dll',
],
'outputs': [
diff --git a/chrome/installer/mini_installer/chrome.release b/chrome/installer/mini_installer/chrome.release
index 555c3ee..1457df1 100644
--- a/chrome/installer/mini_installer/chrome.release
+++ b/chrome/installer/mini_installer/chrome.release
@@ -39,7 +39,7 @@ nacl_irt_x86_32.nexe: %(VersionDir)s\
nacl_irt_x86_64.nexe: %(VersionDir)s\
icudt.dll: %(VersionDir)s\
resources.pak: %(VersionDir)s\
-locales\*.pak: %(VersionDir)s\Locales
+locales\*.dll: %(VersionDir)s\Locales
servers\*.dll: %(VersionDir)s\
servers\*.exe: %(VersionDir)s\
chrome_frame_helper.exe: %(VersionDir)s\
diff --git a/chrome/tools/build/win/FILES b/chrome/tools/build/win/FILES
index 338415b..d00e39d 100644
--- a/chrome/tools/build/win/FILES
+++ b/chrome/tools/build/win/FILES
@@ -12,55 +12,55 @@ ppGoogleNaClPluginChrome.dll
nacl_irt_x86_32.nexe
nacl_irt_x86_64.nexe
icudt.dll
-locales/ar.pak
-locales/bg.pak
-locales/bn.pak
-locales/ca.pak
-locales/cs.pak
-locales/da.pak
-locales/de.pak
-locales/el.pak
-locales/en-GB.pak
-locales/en-US.pak
-locales/es-419.pak
-locales/es.pak
-locales/et.pak
-locales/fi.pak
-locales/fil.pak
-locales/fr.pak
-locales/gu.pak
-locales/he.pak
-locales/hi.pak
-locales/hr.pak
-locales/hu.pak
-locales/id.pak
-locales/it.pak
-locales/ja.pak
-locales/kn.pak
-locales/ko.pak
-locales/lt.pak
-locales/lv.pak
-locales/ml.pak
-locales/mr.pak
-locales/nb.pak
-locales/nl.pak
-locales/pl.pak
-locales/pt-BR.pak
-locales/pt-PT.pak
-locales/ro.pak
-locales/ru.pak
-locales/sk.pak
-locales/sl.pak
-locales/sr.pak
-locales/sv.pak
-locales/ta.pak
-locales/te.pak
-locales/th.pak
-locales/tr.pak
-locales/uk.pak
-locales/vi.pak
-locales/zh-CN.pak
-locales/zh-TW.pak
+locales/ar.dll
+locales/bg.dll
+locales/bn.dll
+locales/ca.dll
+locales/cs.dll
+locales/da.dll
+locales/de.dll
+locales/el.dll
+locales/en-GB.dll
+locales/en-US.dll
+locales/es-419.dll
+locales/es.dll
+locales/et.dll
+locales/fi.dll
+locales/fil.dll
+locales/fr.dll
+locales/gu.dll
+locales/he.dll
+locales/hi.dll
+locales/hr.dll
+locales/hu.dll
+locales/id.dll
+locales/it.dll
+locales/ja.dll
+locales/kn.dll
+locales/ko.dll
+locales/lt.dll
+locales/lv.dll
+locales/ml.dll
+locales/mr.dll
+locales/nb.dll
+locales/nl.dll
+locales/pl.dll
+locales/pt-BR.dll
+locales/pt-PT.dll
+locales/ro.dll
+locales/ru.dll
+locales/sk.dll
+locales/sl.dll
+locales/sr.dll
+locales/sv.dll
+locales/ta.dll
+locales/te.dll
+locales/th.dll
+locales/tr.dll
+locales/uk.dll
+locales/vi.dll
+locales/zh-CN.dll
+locales/zh-TW.dll
resources.pak
wow_helper.exe
gcswf32.dll
diff --git a/chrome/tools/build/win/FILES.cfg b/chrome/tools/build/win/FILES.cfg
index 35657a3..4fc4214 100644
--- a/chrome/tools/build/win/FILES.cfg
+++ b/chrome/tools/build/win/FILES.cfg
@@ -71,247 +71,247 @@ FILES = [
'buildtype': ['dev', 'official'],
},
{
- 'filename': 'locales/ar.pak',
+ 'filename': 'locales/ar.dll',
'arch': ['32bit', '64bit'],
'buildtype': ['dev', 'official'],
},
{
- 'filename': 'locales/bg.pak',
+ 'filename': 'locales/bg.dll',
'arch': ['32bit', '64bit'],
'buildtype': ['dev', 'official'],
},
{
- 'filename': 'locales/bn.pak',
+ 'filename': 'locales/bn.dll',
'arch': ['32bit', '64bit'],
'buildtype': ['dev', 'official'],
},
{
- 'filename': 'locales/ca.pak',
+ 'filename': 'locales/ca.dll',
'arch': ['32bit', '64bit'],
'buildtype': ['dev', 'official'],
},
{
- 'filename': 'locales/cs.pak',
+ 'filename': 'locales/cs.dll',
'arch': ['32bit', '64bit'],
'buildtype': ['dev', 'official'],
},
{
- 'filename': 'locales/da.pak',
+ 'filename': 'locales/da.dll',
'arch': ['32bit', '64bit'],
'buildtype': ['dev', 'official'],
},
{
- 'filename': 'locales/de.pak',
+ 'filename': 'locales/de.dll',
'arch': ['32bit', '64bit'],
'buildtype': ['dev', 'official'],
},
{
- 'filename': 'locales/el.pak',
+ 'filename': 'locales/el.dll',
'arch': ['32bit', '64bit'],
'buildtype': ['dev', 'official'],
},
{
- 'filename': 'locales/en-GB.pak',
+ 'filename': 'locales/en-GB.dll',
'arch': ['32bit', '64bit'],
'buildtype': ['dev', 'official'],
},
{
- 'filename': 'locales/en-US.pak',
+ 'filename': 'locales/en-US.dll',
'arch': ['32bit', '64bit'],
'buildtype': ['dev', 'official'],
},
{
- 'filename': 'locales/es-419.pak',
+ 'filename': 'locales/es-419.dll',
'arch': ['32bit', '64bit'],
'buildtype': ['dev', 'official'],
},
{
- 'filename': 'locales/es.pak',
+ 'filename': 'locales/es.dll',
'arch': ['32bit', '64bit'],
'buildtype': ['dev', 'official'],
},
{
- 'filename': 'locales/et.pak',
+ 'filename': 'locales/et.dll',
'arch': ['32bit', '64bit'],
'buildtype': ['dev', 'official'],
},
{
- 'filename': 'locales/fi.pak',
+ 'filename': 'locales/fi.dll',
'arch': ['32bit', '64bit'],
'buildtype': ['dev', 'official'],
},
{
- 'filename': 'locales/fil.pak',
+ 'filename': 'locales/fil.dll',
'arch': ['32bit', '64bit'],
'buildtype': ['dev', 'official'],
},
{
- 'filename': 'locales/fr.pak',
+ 'filename': 'locales/fr.dll',
'arch': ['32bit', '64bit'],
'buildtype': ['dev', 'official'],
},
{
- 'filename': 'locales/gu.pak',
+ 'filename': 'locales/gu.dll',
'arch': ['32bit', '64bit'],
'buildtype': ['dev', 'official'],
},
{
- 'filename': 'locales/he.pak',
+ 'filename': 'locales/he.dll',
'arch': ['32bit', '64bit'],
'buildtype': ['dev', 'official'],
},
{
- 'filename': 'locales/hi.pak',
+ 'filename': 'locales/hi.dll',
'arch': ['32bit', '64bit'],
'buildtype': ['dev', 'official'],
},
{
- 'filename': 'locales/hr.pak',
+ 'filename': 'locales/hr.dll',
'arch': ['32bit', '64bit'],
'buildtype': ['dev', 'official'],
},
{
- 'filename': 'locales/hu.pak',
+ 'filename': 'locales/hu.dll',
'arch': ['32bit', '64bit'],
'buildtype': ['dev', 'official'],
},
{
- 'filename': 'locales/id.pak',
+ 'filename': 'locales/id.dll',
'arch': ['32bit', '64bit'],
'buildtype': ['dev', 'official'],
},
{
- 'filename': 'locales/it.pak',
+ 'filename': 'locales/it.dll',
'arch': ['32bit', '64bit'],
'buildtype': ['dev', 'official'],
},
{
- 'filename': 'locales/ja.pak',
+ 'filename': 'locales/ja.dll',
'arch': ['32bit', '64bit'],
'buildtype': ['dev', 'official'],
},
{
- 'filename': 'locales/kn.pak',
+ 'filename': 'locales/kn.dll',
'arch': ['32bit', '64bit'],
'buildtype': ['dev', 'official'],
},
{
- 'filename': 'locales/ko.pak',
+ 'filename': 'locales/ko.dll',
'arch': ['32bit', '64bit'],
'buildtype': ['dev', 'official'],
},
{
- 'filename': 'locales/lt.pak',
+ 'filename': 'locales/lt.dll',
'arch': ['32bit', '64bit'],
'buildtype': ['dev', 'official'],
},
{
- 'filename': 'locales/lv.pak',
+ 'filename': 'locales/lv.dll',
'arch': ['32bit', '64bit'],
'buildtype': ['dev', 'official'],
},
{
- 'filename': 'locales/ml.pak',
+ 'filename': 'locales/ml.dll',
'arch': ['32bit', '64bit'],
'buildtype': ['dev', 'official'],
},
{
- 'filename': 'locales/mr.pak',
+ 'filename': 'locales/mr.dll',
'arch': ['32bit', '64bit'],
'buildtype': ['dev', 'official'],
},
{
- 'filename': 'locales/nb.pak',
+ 'filename': 'locales/nb.dll',
'arch': ['32bit', '64bit'],
'buildtype': ['dev', 'official'],
},
{
- 'filename': 'locales/nl.pak',
+ 'filename': 'locales/nl.dll',
'arch': ['32bit', '64bit'],
'buildtype': ['dev', 'official'],
},
{
- 'filename': 'locales/pl.pak',
+ 'filename': 'locales/pl.dll',
'arch': ['32bit', '64bit'],
'buildtype': ['dev', 'official'],
},
{
- 'filename': 'locales/pt-BR.pak',
+ 'filename': 'locales/pt-BR.dll',
'arch': ['32bit', '64bit'],
'buildtype': ['dev', 'official'],
},
{
- 'filename': 'locales/pt-PT.pak',
+ 'filename': 'locales/pt-PT.dll',
'arch': ['32bit', '64bit'],
'buildtype': ['dev', 'official'],
},
{
- 'filename': 'locales/ro.pak',
+ 'filename': 'locales/ro.dll',
'arch': ['32bit', '64bit'],
'buildtype': ['dev', 'official'],
},
{
- 'filename': 'locales/ru.pak',
+ 'filename': 'locales/ru.dll',
'arch': ['32bit', '64bit'],
'buildtype': ['dev', 'official'],
},
{
- 'filename': 'locales/sk.pak',
+ 'filename': 'locales/sk.dll',
'arch': ['32bit', '64bit'],
'buildtype': ['dev', 'official'],
},
{
- 'filename': 'locales/sl.pak',
+ 'filename': 'locales/sl.dll',
'arch': ['32bit', '64bit'],
'buildtype': ['dev', 'official'],
},
{
- 'filename': 'locales/sr.pak',
+ 'filename': 'locales/sr.dll',
'arch': ['32bit', '64bit'],
'buildtype': ['dev', 'official'],
},
{
- 'filename': 'locales/sv.pak',
+ 'filename': 'locales/sv.dll',
'arch': ['32bit', '64bit'],
'buildtype': ['dev', 'official'],
},
{
- 'filename': 'locales/ta.pak',
+ 'filename': 'locales/ta.dll',
'arch': ['32bit', '64bit'],
'buildtype': ['dev', 'official'],
},
{
- 'filename': 'locales/te.pak',
+ 'filename': 'locales/te.dll',
'arch': ['32bit', '64bit'],
'buildtype': ['dev', 'official'],
},
{
- 'filename': 'locales/th.pak',
+ 'filename': 'locales/th.dll',
'arch': ['32bit', '64bit'],
'buildtype': ['dev', 'official'],
},
{
- 'filename': 'locales/tr.pak',
+ 'filename': 'locales/tr.dll',
'arch': ['32bit', '64bit'],
'buildtype': ['dev', 'official'],
},
{
- 'filename': 'locales/uk.pak',
+ 'filename': 'locales/uk.dll',
'arch': ['32bit', '64bit'],
'buildtype': ['dev', 'official'],
},
{
- 'filename': 'locales/vi.pak',
+ 'filename': 'locales/vi.dll',
'arch': ['32bit', '64bit'],
'buildtype': ['dev', 'official'],
},
{
- 'filename': 'locales/zh-CN.pak',
+ 'filename': 'locales/zh-CN.dll',
'arch': ['32bit', '64bit'],
'buildtype': ['dev', 'official'],
},
{
- 'filename': 'locales/zh-TW.pak',
+ 'filename': 'locales/zh-TW.dll',
'arch': ['32bit', '64bit'],
'buildtype': ['dev', 'official'],
},
diff --git a/chrome_frame/chrome_frame.gyp b/chrome_frame/chrome_frame.gyp
index 47154cf..2c42b87 100644
--- a/chrome_frame/chrome_frame.gyp
+++ b/chrome_frame/chrome_frame.gyp
@@ -32,9 +32,9 @@
'target_defaults': {
'dependencies': [
# locales need to be built for the chrome frame binaries to be loadable.
+ '../chrome/app/locales/locales.gyp:*',
'../chrome/chrome.gyp:chrome_resources',
'../chrome/chrome.gyp:chrome_strings',
- '../chrome/chrome.gyp:packed_resources',
'../chrome/chrome.gyp:theme_resources',
'../skia/skia.gyp:skia',
],
diff --git a/ui/base/l10n/l10n_util.cc b/ui/base/l10n/l10n_util.cc
index ee4bb7c..cabda81 100644
--- a/ui/base/l10n/l10n_util.cc
+++ b/ui/base/l10n/l10n_util.cc
@@ -36,8 +36,11 @@
namespace {
-static const FilePath::CharType kLocaleFileExtension[] =
- FILE_PATH_LITERAL(".pak");
+#if defined(OS_WIN)
+static const FilePath::CharType kLocaleFileExtension[] = L".dll";
+#elif defined(OS_POSIX)
+static const FilePath::CharType kLocaleFileExtension[] = ".pak";
+#endif
static const char* const kAcceptLanguageList[] = {
"af", // Afrikaans
diff --git a/ui/base/l10n/l10n_util_unittest.cc b/ui/base/l10n/l10n_util_unittest.cc
index 8ab08d5..778476c 100644
--- a/ui/base/l10n/l10n_util_unittest.cc
+++ b/ui/base/l10n/l10n_util_unittest.cc
@@ -90,7 +90,7 @@ void SetDefaultLocaleForTest(const std::string& tag, base::Environment* env) {
TEST_F(L10nUtilTest, GetAppLocale) {
scoped_ptr<base::Environment> env;
// Use a temporary locale dir so we don't have to actually build the locale
- // pak files for this test.
+ // dlls for this test.
FilePath orig_locale_dir;
PathService::Get(ui::DIR_LOCALES, &orig_locale_dir);
FilePath new_locale_dir;
@@ -115,9 +115,14 @@ TEST_F(L10nUtilTest, GetAppLocale) {
"ca@valencia",
};
+#if defined(OS_WIN)
+ static const char kLocaleFileExtension[] = ".dll";
+#elif defined(OS_POSIX)
+ static const char kLocaleFileExtension[] = ".pak";
+#endif
for (size_t i = 0; i < arraysize(filenames); ++i) {
FilePath filename = new_locale_dir.AppendASCII(
- filenames[i] + ".pak");
+ filenames[i] + kLocaleFileExtension);
file_util::WriteFile(filename, "", 0);
}
diff --git a/ui/base/resource/resource_bundle.cc b/ui/base/resource/resource_bundle.cc
index 6a68f20..8322566 100644
--- a/ui/base/resource/resource_bundle.cc
+++ b/ui/base/resource/resource_bundle.cc
@@ -4,19 +4,13 @@
#include "ui/base/resource/resource_bundle.h"
-#include "base/command_line.h"
-#include "base/file_util.h"
#include "base/logging.h"
-#include "base/path_service.h"
#include "base/stl_util.h"
#include "base/string_piece.h"
#include "base/synchronization/lock.h"
#include "build/build_config.h"
#include "third_party/skia/include/core/SkBitmap.h"
-#include "ui/base/l10n/l10n_util.h"
#include "ui/base/resource/data_pack.h"
-#include "ui/base/ui_base_paths.h"
-#include "ui/base/ui_base_switches.h"
#include "ui/gfx/codec/png_codec.h"
#include "ui/gfx/font.h"
#include "ui/gfx/image/image.h"
@@ -79,17 +73,6 @@ void ResourceBundle::InitSharedInstanceForTest(const FilePath& path) {
}
/* static */
-DataPack* ResourceBundle::LoadResourcesDataPak(const FilePath& path) {
- DataPack* datapack = new DataPack;
- bool success = datapack->Load(path);
- if (!success) {
- delete datapack;
- datapack = NULL;
- }
- return datapack;
-}
-
-/* static */
std::string ResourceBundle::ReloadSharedInstance(
const std::string& pref_locale) {
DCHECK(g_shared_instance_ != NULL) << "ResourceBundle not initialized";
@@ -119,74 +102,6 @@ ResourceBundle& ResourceBundle::GetSharedInstance() {
return *g_shared_instance_;
}
-#if !defined(OS_MACOSX)
-/* static */
-FilePath ResourceBundle::GetLocaleFilePath(const std::string& app_locale) {
- FilePath locale_file_path;
- PathService::Get(ui::DIR_LOCALES, &locale_file_path);
- if (locale_file_path.empty())
- return locale_file_path;
- if (app_locale.empty())
- return FilePath();
- locale_file_path = locale_file_path.AppendASCII(app_locale + ".pak");
- if (!file_util::PathExists(locale_file_path))
- return FilePath();
- return locale_file_path;
-}
-#endif
-
-std::string ResourceBundle::LoadLocaleResources(
- const std::string& pref_locale) {
- DCHECK(!locale_resources_data_.get()) << "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_.reset(LoadResourcesDataPak(locale_file_path));
- CHECK(locale_resources_data_.get()) << "failed to load locale.pak";
- return app_locale;
-}
-
-void ResourceBundle::UnloadLocaleResources() {
- locale_resources_data_.reset();
-}
-
-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_.get()) {
- 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;
-}
-
SkBitmap* ResourceBundle::GetBitmapNamed(int resource_id) {
const SkBitmap* bitmap =
static_cast<const SkBitmap*>(GetImageNamed(resource_id));
@@ -279,7 +194,8 @@ void ResourceBundle::ReloadFonts() {
ResourceBundle::ResourceBundle()
: lock_(new base::Lock),
resources_data_(NULL),
- large_icon_resources_data_(NULL) {
+ large_icon_resources_data_(NULL),
+ locale_resources_data_(NULL) {
}
void ResourceBundle::FreeImages() {
diff --git a/ui/base/resource/resource_bundle.h b/ui/base/resource/resource_bundle.h
index 7076a6e..37d3ef1 100644
--- a/ui/base/resource/resource_bundle.h
+++ b/ui/base/resource/resource_bundle.h
@@ -83,10 +83,6 @@ class UI_EXPORT ResourceBundle {
// Initialize the ResourceBundle using given data pack path for testing.
static void InitSharedInstanceForTest(const FilePath& path);
- // Load a .pak file. Returns NULL if we fail to load |path|. The caller
- // is responsible for deleting up this pointer.
- static DataPack* LoadResourcesDataPak(const FilePath& path);
-
// Changes the locale for an already-initialized ResourceBundle. Future
// calls to get strings will return the strings for this new locale. This
// has no effect on existing or future image resources. This has no effect
@@ -275,9 +271,7 @@ class UI_EXPORT ResourceBundle {
// Handles for data sources.
DataHandle resources_data_;
DataHandle large_icon_resources_data_;
-#if !defined(NACL_WIN64)
- scoped_ptr<DataPack> locale_resources_data_;
-#endif
+ DataHandle locale_resources_data_;
// References to extra data packs loaded via AddDataPackToSharedInstance.
std::vector<LoadedDataPack*> data_packs_;
diff --git a/ui/base/resource/resource_bundle_dummy.cc b/ui/base/resource/resource_bundle_dummy.cc
index 529e63a..8a2ad08 100644
--- a/ui/base/resource/resource_bundle_dummy.cc
+++ b/ui/base/resource/resource_bundle_dummy.cc
@@ -45,7 +45,8 @@ ResourceBundle& ResourceBundle::GetSharedInstance() {
ResourceBundle::ResourceBundle()
: lock_(new base::Lock),
- resources_data_(NULL) {
+ resources_data_(NULL),
+ locale_resources_data_(NULL) {
}
ResourceBundle::~ResourceBundle() {
diff --git a/ui/base/resource/resource_bundle_linux.cc b/ui/base/resource/resource_bundle_linux.cc
index 0ea8b0d..d1eb654 100644
--- a/ui/base/resource/resource_bundle_linux.cc
+++ b/ui/base/resource/resource_bundle_linux.cc
@@ -71,6 +71,20 @@ FilePath ResourceBundle::GetLargeIconResourcesFilePath() {
return FilePath();
}
+// static
+FilePath ResourceBundle::GetLocaleFilePath(const std::string& app_locale) {
+ FilePath locale_file_path;
+ PathService::Get(ui::DIR_LOCALES, &locale_file_path);
+ if (locale_file_path.empty())
+ return locale_file_path;
+ if (app_locale.empty())
+ return FilePath();
+ locale_file_path = locale_file_path.AppendASCII(app_locale + ".pak");
+ if (!file_util::PathExists(locale_file_path))
+ return FilePath();
+ return locale_file_path;
+}
+
gfx::Image& ResourceBundle::GetNativeImageNamed(int resource_id) {
return *GetPixbufImpl(resource_id, false);
}
diff --git a/ui/base/resource/resource_bundle_posix.cc b/ui/base/resource/resource_bundle_posix.cc
index 2669b68..d23a5b1 100644
--- a/ui/base/resource/resource_bundle_posix.cc
+++ b/ui/base/resource/resource_bundle_posix.cc
@@ -18,6 +18,20 @@
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();
@@ -27,6 +41,11 @@ 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) {
@@ -50,6 +69,32 @@ 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();
@@ -66,12 +111,34 @@ 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_.reset(LoadResourcesDataPak(path));
+ locale_resources_data_ = LoadResourcesDataPak(path);
}
} // namespace ui
diff --git a/ui/base/resource/resource_bundle_win.cc b/ui/base/resource/resource_bundle_win.cc
index 5778db2..308340e 100644
--- a/ui/base/resource/resource_bundle_win.cc
+++ b/ui/base/resource/resource_bundle_win.cc
@@ -7,13 +7,17 @@
#include <atlbase.h>
#include "base/debug/stack_trace.h"
+#include "base/file_util.h"
#include "base/logging.h"
#include "base/path_service.h"
#include "base/stl_util.h"
#include "base/string_piece.h"
+#include "base/synchronization/lock.h"
#include "base/win/resource_util.h"
#include "base/win/windows_version.h"
+#include "ui/base/l10n/l10n_util.h"
#include "ui/base/resource/data_pack.h"
+#include "ui/base/ui_base_paths.h"
#include "ui/gfx/font.h"
namespace ui {
@@ -51,11 +55,50 @@ void ResourceBundle::LoadCommonResources() {
}
}
+std::string ResourceBundle::LoadLocaleResources(
+ const std::string& pref_locale) {
+ DCHECK(NULL == locale_resources_data_) << "locale dll already loaded";
+ const std::string app_locale = l10n_util::GetApplicationLocale(pref_locale);
+ const FilePath& locale_path = GetLocaleFilePath(app_locale);
+ if (locale_path.value().empty()) {
+ // It's possible that there are no locale dlls found, in which case we just
+ // return.
+ NOTREACHED();
+ return std::string();
+ }
+
+ // The dll should only have resources, not executable code.
+ locale_resources_data_ = LoadLibraryEx(locale_path.value().c_str(), NULL,
+ GetDataDllLoadFlags());
+ DCHECK(locale_resources_data_ != NULL) <<
+ "unable to load generated resources";
+ return app_locale;
+}
+
void ResourceBundle::LoadTestResources(const FilePath& path) {
// On Windows, the test resources are normally compiled into the binary
// itself.
}
+void ResourceBundle::UnloadLocaleResources() {
+ if (locale_resources_data_) {
+ BOOL rv = FreeLibrary(locale_resources_data_);
+ DCHECK(rv);
+ locale_resources_data_ = NULL;
+ }
+}
+
+// static
+FilePath ResourceBundle::GetLocaleFilePath(const std::string& app_locale) {
+ FilePath locale_path;
+ PathService::Get(ui::DIR_LOCALES, &locale_path);
+
+ if (app_locale.empty())
+ return FilePath();
+
+ return locale_path.AppendASCII(app_locale + ".dll");
+}
+
// static
RefCountedStaticMemory* ResourceBundle::LoadResourceBytes(
DataHandle module, int resource_id) {
@@ -82,26 +125,20 @@ HICON ResourceBundle::LoadThemeIcon(int icon_id) {
base::StringPiece ResourceBundle::GetRawDataResource(int resource_id) const {
void* data_ptr;
size_t data_size;
- base::StringPiece data;
if (base::win::GetDataResourceFromModule(resources_data_,
resource_id,
&data_ptr,
&data_size)) {
return base::StringPiece(static_cast<const char*>(data_ptr), data_size);
- } else if (locale_resources_data_.get() &&
- locale_resources_data_->GetStringPiece(resource_id, &data)) {
- return data;
- }
-
- // TODO(tony): Remove this ATL code once we remove the strings in
- // chrome.dll.
- const ATLSTRINGRESOURCEIMAGE* image = AtlGetStringResourceImage(
- resources_data_, resource_id);
- if (image) {
- return base::StringPiece(reinterpret_cast<const char*>(image->achString),
- image->nLength * 2);
+ } else if (locale_resources_data_ &&
+ base::GetDataResourceFromModule(locale_resources_data_,
+ resource_id,
+ &data_ptr,
+ &data_size)) {
+ return base::StringPiece(static_cast<const char*>(data_ptr), data_size);
}
+ base::StringPiece data;
for (size_t i = 0; i < data_packs_.size(); ++i) {
if (data_packs_[i]->GetStringPiece(resource_id, &data))
return data;
@@ -115,6 +152,36 @@ HCURSOR ResourceBundle::LoadCursor(int cursor_id) {
return ::LoadCursor(resources_data_, MAKEINTRESOURCE(cursor_id));
}
+string16 ResourceBundle::GetLocalizedString(int message_id) {
+ // If for some reason we were unable to load a resource dll, return an empty
+ // string (better than crashing).
+ if (!locale_resources_data_) {
+ base::debug::StackTrace().PrintBacktrace(); // See http://crbug.com/21925.
+ LOG(WARNING) << "locale resources are not loaded";
+ return string16();
+ }
+
+ DCHECK(IS_INTRESOURCE(message_id));
+
+ // Get a reference directly to the string resource.
+ HINSTANCE hinstance = locale_resources_data_;
+ const ATLSTRINGRESOURCEIMAGE* image = AtlGetStringResourceImage(hinstance,
+ message_id);
+ if (!image) {
+ // Fall back on the current module (shouldn't be any strings here except
+ // in unittests).
+ image = AtlGetStringResourceImage(resources_data_, message_id);
+ if (!image) {
+ // See http://crbug.com/21925.
+ base::debug::StackTrace().PrintBacktrace();
+ NOTREACHED() << "unable to find resource: " << message_id;
+ return string16();
+ }
+ }
+ // Copy into a string16 and return.
+ return string16(image->achString, image->nLength);
+}
+
// Windows only uses SkBitmap for gfx::Image, so this is the same as
// GetImageNamed.
gfx::Image& ResourceBundle::GetNativeImageNamed(int resource_id) {
diff --git a/views/views.gyp b/views/views.gyp
index 12a13a1..e8bea3b 100644
--- a/views/views.gyp
+++ b/views/views.gyp
@@ -557,7 +557,7 @@
# TODO(jcivelli): ideally the resource needed by views would be
# factored out. (for some reason it pulls in a bunch
# unrelated things like v8, sqlite nss...).
- '../chrome/chrome.gyp:packed_resources',
+ '../chrome/app/locales/locales.gyp:en-US',
],
'link_settings': {
'libraries': [