Index: chrome/browser/lifetime/application_lifetime.cc |
diff --git a/chrome/browser/lifetime/application_lifetime.cc b/chrome/browser/lifetime/application_lifetime.cc |
index 44eee4a5efdde082522773039100c600665971d8..8b17d4f2b4869a7c0a05a1f7753ce415e14e788d 100644 |
--- a/chrome/browser/lifetime/application_lifetime.cc |
+++ b/chrome/browser/lifetime/application_lifetime.cc |
@@ -46,10 +46,13 @@ |
#if defined(OS_CHROMEOS) |
#include "base/sys_info.h" |
#include "chrome/browser/chromeos/boot_times_recorder.h" |
+#include "chrome/browser/chromeos/settings/cros_settings.h" |
#include "chromeos/dbus/dbus_thread_manager.h" |
#include "chromeos/dbus/power_policy_controller.h" |
#include "chromeos/dbus/session_manager_client.h" |
#include "chromeos/dbus/update_engine_client.h" |
+#include "chromeos/settings/cros_settings_names.h" |
+#include "ui/base/l10n/l10n_util.h" |
#endif |
#if defined(OS_WIN) |
@@ -83,6 +86,36 @@ bool AreAllBrowsersCloseable() { |
#endif // !defined(OS_ANDROID) |
#if defined(OS_CHROMEOS) |
+// Sets kApplicationLocale in |local_state| for the login screen on the next |
+// application start, if it is forced to a specific value due to enterprise |
+// policy or the owner's locale. Returns true if any pref has been modified. |
+bool SetLocaleForNextStart(PrefService* local_state) { |
+ // If a policy mandates the login screen locale, use it. |
+ chromeos::CrosSettings* cros_settings = chromeos::CrosSettings::Get(); |
+ const base::ListValue* login_screen_locales = nullptr; |
+ std::string login_screen_locale; |
+ if (cros_settings->GetList(chromeos::kDeviceLoginScreenLocales, |
+ &login_screen_locales) && |
+ !login_screen_locales->empty() && |
+ login_screen_locales->GetString(0, &login_screen_locale)) { |
+ local_state->SetString(prefs::kApplicationLocale, login_screen_locale); |
+ return true; |
+ } |
+ |
+ // Login screen should show up in owner's locale. |
+ std::string owner_locale = local_state->GetString(prefs::kOwnerLocale); |
+ if (!owner_locale.empty() && |
+ local_state->GetString(prefs::kApplicationLocale) != owner_locale && |
+ !local_state->IsManagedPreference(prefs::kApplicationLocale)) { |
+ local_state->SetString(prefs::kApplicationLocale, owner_locale); |
+ return true; |
+ } |
+ |
+ return false; |
+} |
+#endif |
+ |
+#if defined(OS_CHROMEOS) |
// Whether chrome should send stop request to a session manager. |
bool g_send_stop_request_to_session_manager = false; |
#endif |
@@ -168,12 +201,7 @@ void AttemptUserExit() { |
if (state) { |
chromeos::BootTimesRecorder::Get()->OnLogoutStarted(state); |
- // Login screen should show up in owner's locale. |
- std::string owner_locale = state->GetString(prefs::kOwnerLocale); |
- if (!owner_locale.empty() && |
- state->GetString(prefs::kApplicationLocale) != owner_locale && |
- !state->IsManagedPreference(prefs::kApplicationLocale)) { |
- state->SetString(prefs::kApplicationLocale, owner_locale); |
+ if (SetLocaleForNextStart(state)) { |
TRACE_EVENT0("shutdown", "CommitPendingWrite"); |
state->CommitPendingWrite(); |
} |