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

Side by Side Diff: chrome/browser/lifetime/application_lifetime.cc

Issue 2652793003: Add login screen locale and input method device policies (Closed)
Patch Set: Cleanup variable names Created 3 years, 11 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/lifetime/application_lifetime.h" 5 #include "chrome/browser/lifetime/application_lifetime.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <string> 8 #include <string>
9 9
10 #if defined(OS_WIN) 10 #if defined(OS_WIN)
(...skipping 28 matching lines...) Expand all
39 #include "chrome/common/pref_names.h" 39 #include "chrome/common/pref_names.h"
40 #include "components/metrics/metrics_service.h" 40 #include "components/metrics/metrics_service.h"
41 #include "components/prefs/pref_service.h" 41 #include "components/prefs/pref_service.h"
42 #include "content/public/browser/browser_thread.h" 42 #include "content/public/browser/browser_thread.h"
43 #include "content/public/browser/navigation_details.h" 43 #include "content/public/browser/navigation_details.h"
44 #include "content/public/browser/notification_service.h" 44 #include "content/public/browser/notification_service.h"
45 45
46 #if defined(OS_CHROMEOS) 46 #if defined(OS_CHROMEOS)
47 #include "base/sys_info.h" 47 #include "base/sys_info.h"
48 #include "chrome/browser/chromeos/boot_times_recorder.h" 48 #include "chrome/browser/chromeos/boot_times_recorder.h"
49 #include "chrome/browser/chromeos/settings/cros_settings.h"
49 #include "chromeos/dbus/dbus_thread_manager.h" 50 #include "chromeos/dbus/dbus_thread_manager.h"
50 #include "chromeos/dbus/power_policy_controller.h" 51 #include "chromeos/dbus/power_policy_controller.h"
51 #include "chromeos/dbus/session_manager_client.h" 52 #include "chromeos/dbus/session_manager_client.h"
52 #include "chromeos/dbus/update_engine_client.h" 53 #include "chromeos/dbus/update_engine_client.h"
54 #include "chromeos/settings/cros_settings_names.h"
55 #include "ui/base/l10n/l10n_util.h"
53 #endif 56 #endif
54 57
55 #if defined(OS_WIN) 58 #if defined(OS_WIN)
56 #include "base/win/win_util.h" 59 #include "base/win/win_util.h"
57 #include "chrome/browser/metrics/chrome_metrics_service_accessor.h" 60 #include "chrome/browser/metrics/chrome_metrics_service_accessor.h"
58 #endif 61 #endif
59 62
60 namespace chrome { 63 namespace chrome {
61 namespace { 64 namespace {
62 65
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 #if defined(OS_CHROMEOS) 164 #if defined(OS_CHROMEOS)
162 VLOG(1) << "AttemptUserExit"; 165 VLOG(1) << "AttemptUserExit";
163 browser_shutdown::StartShutdownTracing(); 166 browser_shutdown::StartShutdownTracing();
164 chromeos::BootTimesRecorder::Get()->AddLogoutTimeMarker("LogoutStarted", 167 chromeos::BootTimesRecorder::Get()->AddLogoutTimeMarker("LogoutStarted",
165 false); 168 false);
166 169
167 PrefService* state = g_browser_process->local_state(); 170 PrefService* state = g_browser_process->local_state();
168 if (state) { 171 if (state) {
169 chromeos::BootTimesRecorder::Get()->OnLogoutStarted(state); 172 chromeos::BootTimesRecorder::Get()->OnLogoutStarted(state);
170 173
174 bool commit_pending_write = false;
175
171 // Login screen should show up in owner's locale. 176 // Login screen should show up in owner's locale.
172 std::string owner_locale = state->GetString(prefs::kOwnerLocale); 177 std::string owner_locale = state->GetString(prefs::kOwnerLocale);
173 if (!owner_locale.empty() && 178 if (!owner_locale.empty() &&
174 state->GetString(prefs::kApplicationLocale) != owner_locale && 179 state->GetString(prefs::kApplicationLocale) != owner_locale &&
175 !state->IsManagedPreference(prefs::kApplicationLocale)) { 180 !state->IsManagedPreference(prefs::kApplicationLocale)) {
176 state->SetString(prefs::kApplicationLocale, owner_locale); 181 state->SetString(prefs::kApplicationLocale, owner_locale);
182 commit_pending_write = true;
183 }
184
185 // If a policy mandates the login screen locale, use it.
186 chromeos::CrosSettings* cros_settings = chromeos::CrosSettings::Get();
187 const base::ListValue* login_screen_locales = nullptr;
188 std::string login_screen_locale;
189 if (cros_settings->GetList(chromeos::kDeviceLoginScreenLocales,
190 &login_screen_locales) &&
191 !login_screen_locales->empty() &&
192 login_screen_locales->GetString(0, &login_screen_locale)) {
193 state->SetString(prefs::kApplicationLocale, login_screen_locale);
194 commit_pending_write = true;
195 }
196
197 if (commit_pending_write) {
177 TRACE_EVENT0("shutdown", "CommitPendingWrite"); 198 TRACE_EVENT0("shutdown", "CommitPendingWrite");
178 state->CommitPendingWrite(); 199 state->CommitPendingWrite();
179 } 200 }
180 } 201 }
181 g_send_stop_request_to_session_manager = true; 202 g_send_stop_request_to_session_manager = true;
182 // On ChromeOS, always terminate the browser, regardless of the result of 203 // On ChromeOS, always terminate the browser, regardless of the result of
183 // AreAllBrowsersCloseable(). See crbug.com/123107. 204 // AreAllBrowsersCloseable(). See crbug.com/123107.
184 chrome::NotifyAndTerminate(true); 205 chrome::NotifyAndTerminate(true);
185 #else 206 #else
186 // Reset the restart bit that might have been set in cancelled restart 207 // Reset the restart bit that might have been set in cancelled restart
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
408 void OnAppExiting() { 429 void OnAppExiting() {
409 static bool notified = false; 430 static bool notified = false;
410 if (notified) 431 if (notified)
411 return; 432 return;
412 notified = true; 433 notified = true;
413 HandleAppExitingForPlatform(); 434 HandleAppExitingForPlatform();
414 } 435 }
415 #endif // !defined(OS_ANDROID) 436 #endif // !defined(OS_ANDROID)
416 437
417 } // namespace chrome 438 } // namespace chrome
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698