summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/browser_main.cc19
-rw-r--r--chrome/browser/browser_process.h1
-rw-r--r--chrome/browser/browser_process_impl.cc9
-rw-r--r--chrome/browser/browser_process_impl.h8
-rw-r--r--chrome/browser/extensions/extension_file_util.cc5
-rw-r--r--chrome/browser/utility_process_host.cc4
-rw-r--r--chrome/common/extensions/extension_l10n_util.cc20
-rw-r--r--chrome/common/extensions/extension_l10n_util.h6
-rw-r--r--chrome/common/extensions/extension_l10n_util_unittest.cc35
-rw-r--r--chrome/test/testing_browser_process.h1
10 files changed, 24 insertions, 84 deletions
diff --git a/chrome/browser/browser_main.cc b/chrome/browser/browser_main.cc
index 766fb91..9878994 100644
--- a/chrome/browser/browser_main.cc
+++ b/chrome/browser/browser_main.cc
@@ -559,15 +559,20 @@ int BrowserMain(const MainFunctionParams& parameters) {
// If we're running tests (ui_task is non-null), then the ResourceBundle
// has already been initialized.
- // Mac starts it earlier in Platform::WillInitializeMainMessageLoop (because
- // it is needed when loading the MainMenu.nib and the language doesn't depend
- // on anything since it comes from Cocoa.
-#if !defined(OS_MACOSX)
- if (!parameters.ui_task) {
- ResourceBundle::InitSharedInstance(
+ if (parameters.ui_task) {
+ g_browser_process->set_application_locale("en-US");
+ } else {
+ // Mac starts it earlier in Platform::WillInitializeMainMessageLoop (because
+ // it is needed when loading the MainMenu.nib and the language doesn't depend
+ // on anything since it comes from Cocoa.
+#if defined(OS_MACOSX)
+ g_browser_process->set_application_locale(l10n_util::GetLocaleOverride());
+#else
+ std::string app_locale = ResourceBundle::InitSharedInstance(
local_state->GetString(prefs::kApplicationLocale));
- }
+ g_browser_process->set_application_locale(app_locale);
#endif // !defined(OS_MACOSX)
+ }
#if defined(OS_LINUX)
gtk_util::SetDefaultWindowIcon();
diff --git a/chrome/browser/browser_process.h b/chrome/browser/browser_process.h
index 3283318..d826321 100644
--- a/chrome/browser/browser_process.h
+++ b/chrome/browser/browser_process.h
@@ -125,6 +125,7 @@ class BrowserProcess {
// Returns the locale used by the application.
virtual const std::string& GetApplicationLocale() = 0;
+ virtual void set_application_locale(const std::string& locale) = 0;
DownloadRequestManager* download_request_manager();
diff --git a/chrome/browser/browser_process_impl.cc b/chrome/browser/browser_process_impl.cc
index 9b110a65..54d7858 100644
--- a/chrome/browser/browser_process_impl.cc
+++ b/chrome/browser/browser_process_impl.cc
@@ -290,15 +290,6 @@ printing::PrintJobManager* BrowserProcessImpl::print_job_manager() {
return print_job_manager_.get();
}
-const std::string& BrowserProcessImpl::GetApplicationLocale() {
- DCHECK(CalledOnValidThread());
- if (locale_.empty()) {
- locale_ = l10n_util::GetApplicationLocale(
- local_state()->GetString(prefs::kApplicationLocale));
- }
- return locale_;
-}
-
void BrowserProcessImpl::CreateResourceDispatcherHost() {
DCHECK(!created_resource_dispatcher_host_ &&
resource_dispatcher_host_.get() == NULL);
diff --git a/chrome/browser/browser_process_impl.h b/chrome/browser/browser_process_impl.h
index 3d1bbcd..f4b0e7d 100644
--- a/chrome/browser/browser_process_impl.h
+++ b/chrome/browser/browser_process_impl.h
@@ -194,7 +194,13 @@ class BrowserProcessImpl : public BrowserProcess, public NonThreadSafe {
return google_url_tracker_.get();
}
- virtual const std::string& GetApplicationLocale();
+ virtual const std::string& GetApplicationLocale() {
+ DCHECK(!locale_.empty());
+ return locale_;
+ }
+ virtual void set_application_locale(const std::string& locale) {
+ locale_ = locale;
+ }
virtual base::WaitableEvent* shutdown_event() {
return shutdown_event_.get();
diff --git a/chrome/browser/extensions/extension_file_util.cc b/chrome/browser/extensions/extension_file_util.cc
index a1cace7..0c16ecd 100644
--- a/chrome/browser/extensions/extension_file_util.cc
+++ b/chrome/browser/extensions/extension_file_util.cc
@@ -9,6 +9,7 @@
#include "base/logging.h"
#include "base/scoped_temp_dir.h"
#include "base/string_util.h"
+#include "chrome/browser/browser_process.h"
#include "chrome/browser/extensions/extension_prefs.h"
#include "chrome/browser/privacy_blacklist/blacklist.h"
#include "chrome/browser/privacy_blacklist/blacklist_io.h"
@@ -414,9 +415,7 @@ ExtensionMessageBundle* LoadLocaleInfo(const FilePath& extension_path,
return NULL;
}
- // We can't call g_browser_process->GetApplicationLocale() since we are not
- // on the main thread.
- static std::string app_locale = l10n_util::GetApplicationLocale(L"");
+ std::string app_locale = g_browser_process->GetApplicationLocale();
if (locales.find(app_locale) == locales.end())
app_locale = "";
ExtensionMessageBundle* message_bundle =
diff --git a/chrome/browser/utility_process_host.cc b/chrome/browser/utility_process_host.cc
index 9b03634..76d24f2 100644
--- a/chrome/browser/utility_process_host.cc
+++ b/chrome/browser/utility_process_host.cc
@@ -74,9 +74,7 @@ bool UtilityProcessHost::StartProcess(const FilePath& exposed_dir) {
switches::kUtilityProcess);
cmd_line->AppendSwitchWithValue(switches::kProcessChannelID,
ASCIIToWide(channel_id()));
- // Pass on the browser locale. TODO(tony): This touches the disk and
- // checks for locale dlls/pak files. It shouldn't need to.
- std::string locale = l10n_util::GetApplicationLocale(L"");
+ std::string locale = g_browser_process->GetApplicationLocale();
cmd_line->AppendSwitchWithValue(switches::kLang, locale);
SetCrashReporterCommandLine(cmd_line);
diff --git a/chrome/common/extensions/extension_l10n_util.cc b/chrome/common/extensions/extension_l10n_util.cc
index 0095227..4157083 100644
--- a/chrome/common/extensions/extension_l10n_util.cc
+++ b/chrome/common/extensions/extension_l10n_util.cc
@@ -192,24 +192,4 @@ ExtensionMessageBundle* LoadMessageCatalogs(
return ExtensionMessageBundle::Create(catalogs, error);
}
-void GetL10nRelativePaths(const FilePath& relative_resource_path,
- std::vector<FilePath>* l10n_paths) {
- DCHECK(NULL != l10n_paths);
-
- std::string* current_locale = GetProcessLocale();
- if (current_locale->empty())
- *current_locale = l10n_util::GetApplicationLocale(L"");
-
- std::vector<std::string> locales;
- GetParentLocales(*current_locale, &locales);
-
- FilePath locale_relative_path;
- for (size_t i = 0; i < locales.size(); ++i) {
- l10n_paths->push_back(locale_relative_path
- .AppendASCII(Extension::kLocaleFolder)
- .AppendASCII(locales[i])
- .Append(relative_resource_path));
- }
-}
-
} // namespace extension_l10n_util
diff --git a/chrome/common/extensions/extension_l10n_util.h b/chrome/common/extensions/extension_l10n_util.h
index 87ad43f..7be62912 100644
--- a/chrome/common/extensions/extension_l10n_util.h
+++ b/chrome/common/extensions/extension_l10n_util.h
@@ -71,12 +71,6 @@ ExtensionMessageBundle* LoadMessageCatalogs(
const std::set<std::string>& valid_locales,
std::string* error);
-// Returns relative l10n paths to the resource.
-// Returned vector starts with more specific locale path, and ends with the
-// least specific one.
-void GetL10nRelativePaths(const FilePath& relative_resource_path,
- std::vector<FilePath>* l10n_paths);
-
} // namespace extension_l10n_util
#endif // CHROME_COMMON_EXTENSIONS_EXTENSION_L10N_UTIL_H_
diff --git a/chrome/common/extensions/extension_l10n_util_unittest.cc b/chrome/common/extensions/extension_l10n_util_unittest.cc
index 2825a4c..da46b78 100644
--- a/chrome/common/extensions/extension_l10n_util_unittest.cc
+++ b/chrome/common/extensions/extension_l10n_util_unittest.cc
@@ -193,39 +193,4 @@ TEST(ExtensionL10nUtil, GetParentLocales) {
EXPECT_EQ("sr", locales[2]);
}
-bool PathsAreEqual(const FilePath& path1, const FilePath& path2) {
- FilePath::StringType path1_str = path1.value();
- std::replace(path1_str.begin(), path1_str.end(), '\\', '/');
-
- FilePath::StringType path2_str = path2.value();
- std::replace(path2_str.begin(), path2_str.end(), '\\', '/');
-
- if (path1_str == path2_str) {
- return true;
- } else {
- return false;
- }
-}
-
-TEST(ExtensionL10nUtil, GetL10nRelativePath) {
- static std::string current_locale =
- extension_l10n_util::NormalizeLocale(l10n_util::GetApplicationLocale(L""));
-
- std::vector<FilePath> l10n_paths;
- extension_l10n_util::GetL10nRelativePaths(
- FilePath(FILE_PATH_LITERAL("foo/bar.js")), &l10n_paths);
- ASSERT_FALSE(l10n_paths.empty());
-
- std::vector<std::string> locales;
- extension_l10n_util::GetParentLocales(current_locale, &locales);
- ASSERT_EQ(locales.size(), l10n_paths.size());
-
- for (size_t i = 0; i < locales.size(); ++i) {
- FilePath tmp;
- tmp = tmp.AppendASCII(Extension::kLocaleFolder)
- .AppendASCII(locales[i]).AppendASCII("foo/bar.js");
- EXPECT_TRUE(PathsAreEqual(tmp, l10n_paths[i]));
- }
-}
-
} // namespace
diff --git a/chrome/test/testing_browser_process.h b/chrome/test/testing_browser_process.h
index 070c865..2131ed7 100644
--- a/chrome/test/testing_browser_process.h
+++ b/chrome/test/testing_browser_process.h
@@ -139,6 +139,7 @@ class TestingBrowserProcess : public BrowserProcess {
value = new std::string("en");
return *value;
}
+ virtual void set_application_locale(const std::string& app_locale) {}
virtual base::WaitableEvent* shutdown_event() {
return shutdown_event_.get();