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

Unified Diff: chrome/browser/lifetime/application_lifetime.cc

Issue 2652793003: Add login screen locale and input method device policies (Closed)
Patch Set: Rebase. Created 3 years, 10 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
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..e6578f0cc5a7d7c0f39d685f53c6935e000605e7 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,34 @@ 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;
+}
+
// Whether chrome should send stop request to a session manager.
bool g_send_stop_request_to_session_manager = false;
#endif
@@ -168,12 +199,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();
}

Powered by Google App Engine
This is Rietveld 408576698