OLD | NEW |
---|---|
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 Loading... | |
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 13 matching lines...) Expand all Loading... | |
76 // Check TabsNeedBeforeUnloadFired(). | 79 // Check TabsNeedBeforeUnloadFired(). |
77 for (auto* browser : *BrowserList::GetInstance()) { | 80 for (auto* browser : *BrowserList::GetInstance()) { |
78 if (browser->TabsNeedBeforeUnloadFired()) | 81 if (browser->TabsNeedBeforeUnloadFired()) |
79 return false; | 82 return false; |
80 } | 83 } |
81 return true; | 84 return true; |
82 } | 85 } |
83 #endif // !defined(OS_ANDROID) | 86 #endif // !defined(OS_ANDROID) |
84 | 87 |
85 #if defined(OS_CHROMEOS) | 88 #if defined(OS_CHROMEOS) |
89 // Sets kApplicationLocale in |local_state| for the login screen on the next | |
90 // application start, if it is forced to a specific value due to enterprise | |
91 // policy or the owner's locale. Returns true if any pref has been modified. | |
92 bool SetLocaleForNextStart(PrefService* local_state) { | |
93 // If a policy mandates the login screen locale, use it. | |
94 chromeos::CrosSettings* cros_settings = chromeos::CrosSettings::Get(); | |
95 const base::ListValue* login_screen_locales = nullptr; | |
96 std::string login_screen_locale; | |
97 if (cros_settings->GetList(chromeos::kDeviceLoginScreenLocales, | |
98 &login_screen_locales) && | |
99 !login_screen_locales->empty() && | |
100 login_screen_locales->GetString(0, &login_screen_locale)) { | |
101 local_state->SetString(prefs::kApplicationLocale, login_screen_locale); | |
102 return true; | |
103 } | |
104 | |
105 // Login screen should show up in owner's locale. | |
106 std::string owner_locale = local_state->GetString(prefs::kOwnerLocale); | |
107 if (!owner_locale.empty() && | |
108 local_state->GetString(prefs::kApplicationLocale) != owner_locale && | |
109 !local_state->IsManagedPreference(prefs::kApplicationLocale)) { | |
110 local_state->SetString(prefs::kApplicationLocale, owner_locale); | |
111 return true; | |
112 } | |
113 | |
114 return false; | |
115 } | |
116 #endif | |
Nico
2017/02/07 15:14:22
this does #if cros #endif #if cros #endif -- remov
pmarko
2017/02/08 07:02:02
Done.
| |
117 | |
118 #if defined(OS_CHROMEOS) | |
86 // Whether chrome should send stop request to a session manager. | 119 // Whether chrome should send stop request to a session manager. |
87 bool g_send_stop_request_to_session_manager = false; | 120 bool g_send_stop_request_to_session_manager = false; |
88 #endif | 121 #endif |
89 | 122 |
90 } // namespace | 123 } // namespace |
91 | 124 |
92 #if !defined(OS_ANDROID) | 125 #if !defined(OS_ANDROID) |
93 void MarkAsCleanShutdown() { | 126 void MarkAsCleanShutdown() { |
94 // TODO(beng): Can this use ProfileManager::GetLoadedProfiles() instead? | 127 // TODO(beng): Can this use ProfileManager::GetLoadedProfiles() instead? |
95 for (auto* browser : *BrowserList::GetInstance()) | 128 for (auto* browser : *BrowserList::GetInstance()) |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
161 #if defined(OS_CHROMEOS) | 194 #if defined(OS_CHROMEOS) |
162 VLOG(1) << "AttemptUserExit"; | 195 VLOG(1) << "AttemptUserExit"; |
163 browser_shutdown::StartShutdownTracing(); | 196 browser_shutdown::StartShutdownTracing(); |
164 chromeos::BootTimesRecorder::Get()->AddLogoutTimeMarker("LogoutStarted", | 197 chromeos::BootTimesRecorder::Get()->AddLogoutTimeMarker("LogoutStarted", |
165 false); | 198 false); |
166 | 199 |
167 PrefService* state = g_browser_process->local_state(); | 200 PrefService* state = g_browser_process->local_state(); |
168 if (state) { | 201 if (state) { |
169 chromeos::BootTimesRecorder::Get()->OnLogoutStarted(state); | 202 chromeos::BootTimesRecorder::Get()->OnLogoutStarted(state); |
170 | 203 |
171 // Login screen should show up in owner's locale. | 204 if (SetLocaleForNextStart(state)) { |
172 std::string owner_locale = state->GetString(prefs::kOwnerLocale); | |
173 if (!owner_locale.empty() && | |
174 state->GetString(prefs::kApplicationLocale) != owner_locale && | |
175 !state->IsManagedPreference(prefs::kApplicationLocale)) { | |
176 state->SetString(prefs::kApplicationLocale, owner_locale); | |
177 TRACE_EVENT0("shutdown", "CommitPendingWrite"); | 205 TRACE_EVENT0("shutdown", "CommitPendingWrite"); |
178 state->CommitPendingWrite(); | 206 state->CommitPendingWrite(); |
179 } | 207 } |
180 } | 208 } |
181 g_send_stop_request_to_session_manager = true; | 209 g_send_stop_request_to_session_manager = true; |
182 // On ChromeOS, always terminate the browser, regardless of the result of | 210 // On ChromeOS, always terminate the browser, regardless of the result of |
183 // AreAllBrowsersCloseable(). See crbug.com/123107. | 211 // AreAllBrowsersCloseable(). See crbug.com/123107. |
184 chrome::NotifyAndTerminate(true); | 212 chrome::NotifyAndTerminate(true); |
185 #else | 213 #else |
186 // Reset the restart bit that might have been set in cancelled restart | 214 // Reset the restart bit that might have been set in cancelled restart |
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
408 void OnAppExiting() { | 436 void OnAppExiting() { |
409 static bool notified = false; | 437 static bool notified = false; |
410 if (notified) | 438 if (notified) |
411 return; | 439 return; |
412 notified = true; | 440 notified = true; |
413 HandleAppExitingForPlatform(); | 441 HandleAppExitingForPlatform(); |
414 } | 442 } |
415 #endif // !defined(OS_ANDROID) | 443 #endif // !defined(OS_ANDROID) |
416 | 444 |
417 } // namespace chrome | 445 } // namespace chrome |
OLD | NEW |