| 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 |
| 86 // Whether chrome should send stop request to a session manager. | 117 // Whether chrome should send stop request to a session manager. |
| 87 bool g_send_stop_request_to_session_manager = false; | 118 bool g_send_stop_request_to_session_manager = false; |
| 88 #endif | 119 #endif |
| 89 | 120 |
| 90 } // namespace | 121 } // namespace |
| 91 | 122 |
| 92 #if !defined(OS_ANDROID) | 123 #if !defined(OS_ANDROID) |
| 93 void MarkAsCleanShutdown() { | 124 void MarkAsCleanShutdown() { |
| 94 // TODO(beng): Can this use ProfileManager::GetLoadedProfiles() instead? | 125 // TODO(beng): Can this use ProfileManager::GetLoadedProfiles() instead? |
| 95 for (auto* browser : *BrowserList::GetInstance()) | 126 for (auto* browser : *BrowserList::GetInstance()) |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 161 #if defined(OS_CHROMEOS) | 192 #if defined(OS_CHROMEOS) |
| 162 VLOG(1) << "AttemptUserExit"; | 193 VLOG(1) << "AttemptUserExit"; |
| 163 browser_shutdown::StartShutdownTracing(); | 194 browser_shutdown::StartShutdownTracing(); |
| 164 chromeos::BootTimesRecorder::Get()->AddLogoutTimeMarker("LogoutStarted", | 195 chromeos::BootTimesRecorder::Get()->AddLogoutTimeMarker("LogoutStarted", |
| 165 false); | 196 false); |
| 166 | 197 |
| 167 PrefService* state = g_browser_process->local_state(); | 198 PrefService* state = g_browser_process->local_state(); |
| 168 if (state) { | 199 if (state) { |
| 169 chromeos::BootTimesRecorder::Get()->OnLogoutStarted(state); | 200 chromeos::BootTimesRecorder::Get()->OnLogoutStarted(state); |
| 170 | 201 |
| 171 // Login screen should show up in owner's locale. | 202 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"); | 203 TRACE_EVENT0("shutdown", "CommitPendingWrite"); |
| 178 state->CommitPendingWrite(); | 204 state->CommitPendingWrite(); |
| 179 } | 205 } |
| 180 } | 206 } |
| 181 g_send_stop_request_to_session_manager = true; | 207 g_send_stop_request_to_session_manager = true; |
| 182 // On ChromeOS, always terminate the browser, regardless of the result of | 208 // On ChromeOS, always terminate the browser, regardless of the result of |
| 183 // AreAllBrowsersCloseable(). See crbug.com/123107. | 209 // AreAllBrowsersCloseable(). See crbug.com/123107. |
| 184 chrome::NotifyAndTerminate(true); | 210 chrome::NotifyAndTerminate(true); |
| 185 #else | 211 #else |
| 186 // Reset the restart bit that might have been set in cancelled restart | 212 // 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() { | 434 void OnAppExiting() { |
| 409 static bool notified = false; | 435 static bool notified = false; |
| 410 if (notified) | 436 if (notified) |
| 411 return; | 437 return; |
| 412 notified = true; | 438 notified = true; |
| 413 HandleAppExitingForPlatform(); | 439 HandleAppExitingForPlatform(); |
| 414 } | 440 } |
| 415 #endif // !defined(OS_ANDROID) | 441 #endif // !defined(OS_ANDROID) |
| 416 | 442 |
| 417 } // namespace chrome | 443 } // namespace chrome |
| OLD | NEW |