OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/ui/browser_list.h" | 5 #include "chrome/browser/ui/browser_list.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
9 #include "base/metrics/histogram.h" | 9 #include "base/metrics/histogram.h" |
10 #include "build/build_config.h" | 10 #include "build/build_config.h" |
(...skipping 17 matching lines...) Expand all Loading... |
28 #if defined(OS_MACOSX) | 28 #if defined(OS_MACOSX) |
29 #include "chrome/browser/chrome_browser_application_mac.h" | 29 #include "chrome/browser/chrome_browser_application_mac.h" |
30 #endif | 30 #endif |
31 | 31 |
32 #if defined(OS_CHROMEOS) | 32 #if defined(OS_CHROMEOS) |
33 #include "chrome/browser/chromeos/boot_times_loader.h" | 33 #include "chrome/browser/chromeos/boot_times_loader.h" |
34 #include "chrome/browser/chromeos/cros/cros_library.h" | 34 #include "chrome/browser/chromeos/cros/cros_library.h" |
35 #include "chrome/browser/chromeos/cros/update_library.h" | 35 #include "chrome/browser/chromeos/cros/update_library.h" |
36 #include "chrome/browser/chromeos/dbus/dbus_thread_manager.h" | 36 #include "chrome/browser/chromeos/dbus/dbus_thread_manager.h" |
37 #include "chrome/browser/chromeos/dbus/session_manager_client.h" | 37 #include "chrome/browser/chromeos/dbus/session_manager_client.h" |
| 38 #include "chrome/browser/chromeos/system/runtime_environment.h" |
38 #if defined(TOOLKIT_USES_GTK) | 39 #if defined(TOOLKIT_USES_GTK) |
39 #include "chrome/browser/chromeos/legacy_window_manager/wm_ipc.h" | 40 #include "chrome/browser/chromeos/legacy_window_manager/wm_ipc.h" |
40 #endif | 41 #endif |
41 #endif | 42 #endif |
42 | 43 |
43 namespace { | 44 namespace { |
44 | 45 |
45 // This object is instantiated when the first Browser object is added to the | 46 // This object is instantiated when the first Browser object is added to the |
46 // list and delete when the last one is removed. It watches for loads and | 47 // list and delete when the last one is removed. It watches for loads and |
47 // creates histograms of some global object counts. | 48 // creates histograms of some global object counts. |
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
236 | 237 |
237 #if defined(OS_CHROMEOS) | 238 #if defined(OS_CHROMEOS) |
238 | 239 |
239 // Whether a session manager requested to shutdown. | 240 // Whether a session manager requested to shutdown. |
240 bool g_session_manager_requested_shutdown = true; | 241 bool g_session_manager_requested_shutdown = true; |
241 | 242 |
242 // Fast shutdown for ChromeOS. It tells session manager to start | 243 // Fast shutdown for ChromeOS. It tells session manager to start |
243 // shutdown process when closing browser windows won't be canceled. | 244 // shutdown process when closing browser windows won't be canceled. |
244 // Returns true if fast shutdown is successfully started. | 245 // Returns true if fast shutdown is successfully started. |
245 bool FastShutdown() { | 246 bool FastShutdown() { |
246 if (chromeos::CrosLibrary::Get()->EnsureLoaded() | 247 if (chromeos::system::runtime_environment::IsRunningOnChromeOS() |
247 && AreAllBrowsersCloseable()) { | 248 && AreAllBrowsersCloseable()) { |
248 BrowserList::NotifyAndTerminate(true); | 249 BrowserList::NotifyAndTerminate(true); |
249 return true; | 250 return true; |
250 } | 251 } |
251 return false; | 252 return false; |
252 } | 253 } |
253 | 254 |
254 void NotifyWindowManagerAboutSignout() { | 255 void NotifyWindowManagerAboutSignout() { |
255 #if defined(TOOLKIT_USES_GTK) | 256 #if defined(TOOLKIT_USES_GTK) |
256 static bool notified = false; | 257 static bool notified = false; |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
324 if (notified || g_session_manager_requested_shutdown) | 325 if (notified || g_session_manager_requested_shutdown) |
325 return; | 326 return; |
326 notified = true; | 327 notified = true; |
327 #endif | 328 #endif |
328 | 329 |
329 if (fast_path) | 330 if (fast_path) |
330 NotifyAppTerminating(); | 331 NotifyAppTerminating(); |
331 | 332 |
332 #if defined(OS_CHROMEOS) | 333 #if defined(OS_CHROMEOS) |
333 NotifyWindowManagerAboutSignout(); | 334 NotifyWindowManagerAboutSignout(); |
334 chromeos::CrosLibrary* cros_library = chromeos::CrosLibrary::Get(); | 335 if (chromeos::system::runtime_environment::IsRunningOnChromeOS()) { |
335 if (cros_library->EnsureLoaded()) { | |
336 // If update has been installed, reboot, otherwise, sign out. | 336 // If update has been installed, reboot, otherwise, sign out. |
| 337 chromeos::CrosLibrary* cros_library = chromeos::CrosLibrary::Get(); |
337 if (cros_library->GetUpdateLibrary()->status().status == | 338 if (cros_library->GetUpdateLibrary()->status().status == |
338 chromeos::UPDATE_STATUS_UPDATED_NEED_REBOOT) { | 339 chromeos::UPDATE_STATUS_UPDATED_NEED_REBOOT) { |
339 cros_library->GetUpdateLibrary()->RebootAfterUpdate(); | 340 cros_library->GetUpdateLibrary()->RebootAfterUpdate(); |
340 } else { | 341 } else { |
341 chromeos::DBusThreadManager::Get()->GetSessionManagerClient() | 342 chromeos::DBusThreadManager::Get()->GetSessionManagerClient() |
342 ->StopSession(); | 343 ->StopSession(); |
343 } | 344 } |
344 return; | 345 return; |
345 } | 346 } |
346 // If running the Chrome OS build, but we're not on the device, fall through | 347 // If running the Chrome OS build, but we're not on the device, fall through |
(...skipping 508 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
855 // If no more TabContents from Browsers, check the BackgroundPrintingManager. | 856 // If no more TabContents from Browsers, check the BackgroundPrintingManager. |
856 while (bg_printing_iterator_ != GetBackgroundPrintingManager()->end()) { | 857 while (bg_printing_iterator_ != GetBackgroundPrintingManager()->end()) { |
857 cur_ = *bg_printing_iterator_; | 858 cur_ = *bg_printing_iterator_; |
858 CHECK(cur_); | 859 CHECK(cur_); |
859 ++bg_printing_iterator_; | 860 ++bg_printing_iterator_; |
860 return; | 861 return; |
861 } | 862 } |
862 // Reached the end - no more TabContents. | 863 // Reached the end - no more TabContents. |
863 cur_ = NULL; | 864 cur_ = NULL; |
864 } | 865 } |
OLD | NEW |