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 "ash/shell.h" | 7 #include "ash/shell.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
11 #include "base/message_loop.h" | 11 #include "base/message_loop.h" |
12 #include "base/prefs/pref_service.h" | 12 #include "base/prefs/pref_service.h" |
13 #include "build/build_config.h" | 13 #include "build/build_config.h" |
14 #include "chrome/browser/browser_process.h" | 14 #include "chrome/browser/browser_process.h" |
| 15 #include "chrome/browser/browser_process_platform_part.h" |
15 #include "chrome/browser/browser_shutdown.h" | 16 #include "chrome/browser/browser_shutdown.h" |
16 #include "chrome/browser/download/download_service.h" | 17 #include "chrome/browser/download/download_service.h" |
17 #include "chrome/browser/metrics/thread_watcher.h" | 18 #include "chrome/browser/metrics/thread_watcher.h" |
18 #include "chrome/browser/profiles/profile.h" | 19 #include "chrome/browser/profiles/profile.h" |
19 #include "chrome/browser/profiles/profile_manager.h" | 20 #include "chrome/browser/profiles/profile_manager.h" |
20 #include "chrome/browser/ui/browser.h" | 21 #include "chrome/browser/ui/browser.h" |
21 #include "chrome/browser/ui/browser_finder.h" | 22 #include "chrome/browser/ui/browser_finder.h" |
22 #include "chrome/browser/ui/browser_iterator.h" | 23 #include "chrome/browser/ui/browser_iterator.h" |
23 #include "chrome/browser/ui/browser_tabstrip.h" | 24 #include "chrome/browser/ui/browser_tabstrip.h" |
24 #include "chrome/browser/ui/browser_window.h" | 25 #include "chrome/browser/ui/browser_window.h" |
25 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 26 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
26 #include "chrome/common/chrome_notification_types.h" | 27 #include "chrome/common/chrome_notification_types.h" |
27 #include "chrome/common/chrome_switches.h" | 28 #include "chrome/common/chrome_switches.h" |
28 #include "chrome/common/pref_names.h" | 29 #include "chrome/common/pref_names.h" |
29 #include "content/public/browser/browser_shutdown.h" | 30 #include "content/public/browser/browser_shutdown.h" |
30 #include "content/public/browser/browser_thread.h" | 31 #include "content/public/browser/browser_thread.h" |
31 #include "content/public/browser/navigation_details.h" | 32 #include "content/public/browser/navigation_details.h" |
32 #include "content/public/browser/notification_service.h" | 33 #include "content/public/browser/notification_service.h" |
33 | 34 |
34 #if defined(OS_ANDROID) | |
35 #include "chrome/browser/lifetime/application_lifetime_android.h" | |
36 #endif | |
37 | |
38 #if defined(OS_MACOSX) | |
39 #include "chrome/browser/chrome_browser_application_mac.h" | |
40 #endif | |
41 | |
42 #if defined(OS_CHROMEOS) | 35 #if defined(OS_CHROMEOS) |
43 #include "base/chromeos/chromeos_version.h" | 36 #include "base/chromeos/chromeos_version.h" |
44 #include "chrome/browser/chromeos/boot_times_loader.h" | 37 #include "chrome/browser/chromeos/boot_times_loader.h" |
45 #include "chrome/browser/chromeos/login/user_manager.h" | 38 #include "chrome/browser/chromeos/login/user_manager.h" |
46 #include "chromeos/dbus/dbus_thread_manager.h" | 39 #include "chromeos/dbus/dbus_thread_manager.h" |
47 #include "chromeos/dbus/session_manager_client.h" | 40 #include "chromeos/dbus/session_manager_client.h" |
48 #include "chromeos/dbus/update_engine_client.h" | 41 #include "chromeos/dbus/update_engine_client.h" |
49 #endif | 42 #endif |
50 | 43 |
51 namespace chrome { | 44 namespace chrome { |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 for (chrome::BrowserIterator it; !it.done(); it.Next()) | 78 for (chrome::BrowserIterator it; !it.done(); it.Next()) |
86 it->profile()->SetExitType(Profile::EXIT_NORMAL); | 79 it->profile()->SetExitType(Profile::EXIT_NORMAL); |
87 } | 80 } |
88 | 81 |
89 void AttemptExitInternal() { | 82 void AttemptExitInternal() { |
90 content::NotificationService::current()->Notify( | 83 content::NotificationService::current()->Notify( |
91 chrome::NOTIFICATION_CLOSE_ALL_BROWSERS_REQUEST, | 84 chrome::NOTIFICATION_CLOSE_ALL_BROWSERS_REQUEST, |
92 content::NotificationService::AllSources(), | 85 content::NotificationService::AllSources(), |
93 content::NotificationService::NoDetails()); | 86 content::NotificationService::NoDetails()); |
94 | 87 |
95 #if defined(OS_ANDROID) | 88 g_browser_process->platform_part()->AttemptExit(); |
96 // Tell the Java code to finish() the Activity. | |
97 TerminateAndroid(); | |
98 #elif defined(OS_MACOSX) | |
99 // On the Mac, the application continues to run once all windows are closed. | |
100 // Terminate will result in a CloseAllBrowsers() call, and once (and if) | |
101 // that is done, will cause the application to exit cleanly. | |
102 chrome_browser_application_mac::Terminate(); | |
103 #else | |
104 // On most platforms, closing all windows causes the application to exit. | |
105 CloseAllBrowsers(); | |
106 #endif | |
107 } | 89 } |
108 | 90 |
109 void CloseAllBrowsers() { | 91 void CloseAllBrowsers() { |
110 bool session_ending = | 92 bool session_ending = |
111 browser_shutdown::GetShutdownType() == browser_shutdown::END_SESSION; | 93 browser_shutdown::GetShutdownType() == browser_shutdown::END_SESSION; |
112 // Tell everyone that we are shutting down. | 94 // Tell everyone that we are shutting down. |
113 browser_shutdown::SetTryingToQuit(true); | 95 browser_shutdown::SetTryingToQuit(true); |
114 | 96 |
115 #if defined(ENABLE_SESSION_SERVICE) | 97 #if defined(ENABLE_SESSION_SERVICE) |
116 // Before we close the browsers shutdown all session services. That way an | 98 // Before we close the browsers shutdown all session services. That way an |
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
398 // environment is still active. | 380 // environment is still active. |
399 if (browser->host_desktop_type() == chrome::HOST_DESKTOP_TYPE_NATIVE) | 381 if (browser->host_desktop_type() == chrome::HOST_DESKTOP_TYPE_NATIVE) |
400 return !ash::Shell::HasInstance(); | 382 return !ash::Shell::HasInstance(); |
401 else if (browser->host_desktop_type() == chrome::HOST_DESKTOP_TYPE_ASH) | 383 else if (browser->host_desktop_type() == chrome::HOST_DESKTOP_TYPE_ASH) |
402 return BrowserList::GetInstance(chrome::HOST_DESKTOP_TYPE_NATIVE)->empty(); | 384 return BrowserList::GetInstance(chrome::HOST_DESKTOP_TYPE_NATIVE)->empty(); |
403 #endif | 385 #endif |
404 return true; | 386 return true; |
405 } | 387 } |
406 | 388 |
407 } // namespace chrome | 389 } // namespace chrome |
OLD | NEW |