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

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

Issue 25603004: Leave apps running on Windows and Linux when quitting Chrome from the wrench menu. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 7 years, 1 month 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/browser_close_manager.h" 5 #include "chrome/browser/lifetime/browser_close_manager.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "chrome/browser/background/background_mode_manager.h"
8 #include "chrome/browser/browser_process.h" 9 #include "chrome/browser/browser_process.h"
9 #include "chrome/browser/browser_shutdown.h" 10 #include "chrome/browser/browser_shutdown.h"
10 #include "chrome/browser/download/download_service.h" 11 #include "chrome/browser/download/download_service.h"
11 #include "chrome/browser/download/download_service_factory.h" 12 #include "chrome/browser/download/download_service_factory.h"
12 #include "chrome/browser/profiles/profile_manager.h" 13 #include "chrome/browser/profiles/profile_manager.h"
13 #include "chrome/browser/ui/browser.h" 14 #include "chrome/browser/ui/browser.h"
14 #include "chrome/browser/ui/browser_finder.h" 15 #include "chrome/browser/ui/browser_finder.h"
15 #include "chrome/browser/ui/browser_iterator.h" 16 #include "chrome/browser/ui/browser_iterator.h"
16 #include "chrome/browser/ui/browser_list.h" 17 #include "chrome/browser/ui/browser_list.h"
17 #include "chrome/browser/ui/browser_window.h" 18 #include "chrome/browser/ui/browser_window.h"
18 #include "chrome/browser/ui/chrome_pages.h" 19 #include "chrome/browser/ui/chrome_pages.h"
19 #include "chrome/browser/ui/tabs/tab_strip_model.h" 20 #include "chrome/browser/ui/tabs/tab_strip_model.h"
20 #include "chrome/common/chrome_switches.h" 21 #include "chrome/common/chrome_switches.h"
21 #include "content/public/browser/web_contents.h" 22 #include "content/public/browser/web_contents.h"
22 23
23 BrowserCloseManager::BrowserCloseManager() : current_browser_(NULL) {} 24 BrowserCloseManager::BrowserCloseManager() : current_browser_(NULL) {}
24 25
25 BrowserCloseManager::~BrowserCloseManager() {} 26 BrowserCloseManager::~BrowserCloseManager() {}
26 27
27 void BrowserCloseManager::StartClosingBrowsers() { 28 void BrowserCloseManager::StartClosingBrowsers() {
28 // If the session is ending or batch browser shutdown is disabled, skip 29 // If the session is ending or batch browser shutdown is disabled, skip
29 // straight to closing the browsers. In the former case, there's no time to 30 // straight to closing the browsers. In the former case, there's no time to
30 // wait for beforeunload dialogs; in the latter, the windows will manage 31 // wait for beforeunload dialogs; in the latter, the windows will manage
31 // showing their own dialogs. 32 // showing their own dialogs.
32 if (browser_shutdown::GetShutdownType() == browser_shutdown::END_SESSION || 33 if (browser_shutdown::GetShutdownType() == browser_shutdown::END_SESSION ||
33 CommandLine::ForCurrentProcess()->HasSwitch( 34 CommandLine::ForCurrentProcess()->HasSwitch(
34 switches::kDisableBatchedShutdown)) { 35 switches::kDisableBatchedShutdown)) {
36 // Tell everyone that we are shutting down.
37 browser_shutdown::SetTryingToQuit(true);
35 CloseBrowsers(); 38 CloseBrowsers();
36 return; 39 return;
37 } 40 }
38 TryToCloseBrowsers(); 41 TryToCloseBrowsers();
39 } 42 }
40 43
41 void BrowserCloseManager::CancelBrowserClose() { 44 void BrowserCloseManager::CancelBrowserClose() {
42 browser_shutdown::SetTryingToQuit(false); 45 browser_shutdown::SetTryingToQuit(false);
43 for (chrome::BrowserIterator it; !it.done(); it.Next()) { 46 for (chrome::BrowserIterator it; !it.done(); it.Next()) {
44 it->ResetBeforeUnloadHandlers(); 47 it->ResetBeforeUnloadHandlers();
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 if (download_service->NonMaliciousDownloadCount() > 0) { 119 if (download_service->NonMaliciousDownloadCount() > 0) {
117 Browser* browser = 120 Browser* browser =
118 chrome::FindOrCreateTabbedBrowser(*it, chrome::GetActiveDesktop()); 121 chrome::FindOrCreateTabbedBrowser(*it, chrome::GetActiveDesktop());
119 DCHECK(browser); 122 DCHECK(browser);
120 chrome::ShowDownloads(browser); 123 chrome::ShowDownloads(browser);
121 } 124 }
122 } 125 }
123 } 126 }
124 127
125 void BrowserCloseManager::CloseBrowsers() { 128 void BrowserCloseManager::CloseBrowsers() {
126 // Tell everyone that we are shutting down.
127 browser_shutdown::SetTryingToQuit(true);
128
129 #if defined(ENABLE_SESSION_SERVICE) 129 #if defined(ENABLE_SESSION_SERVICE)
130 // Before we close the browsers shutdown all session services. That way an 130 // Before we close the browsers shutdown all session services. That way an
131 // exit can restore all browsers open before exiting. 131 // exit can restore all browsers open before exiting.
132 ProfileManager::ShutdownSessionServices(); 132 ProfileManager::ShutdownSessionServices();
133 #endif 133 #endif
134 if (!browser_shutdown::IsTryingToQuit()) {
135 BackgroundModeManager* background_mode_manager =
136 g_browser_process->background_mode_manager();
137 if (background_mode_manager)
138 background_mode_manager->SuspendBackgroundMode();
139 }
134 140
135 bool session_ending = 141 bool session_ending =
136 browser_shutdown::GetShutdownType() == browser_shutdown::END_SESSION; 142 browser_shutdown::GetShutdownType() == browser_shutdown::END_SESSION;
137 for (scoped_ptr<chrome::BrowserIterator> it_ptr( 143 for (scoped_ptr<chrome::BrowserIterator> it_ptr(
138 new chrome::BrowserIterator()); 144 new chrome::BrowserIterator());
139 !it_ptr->done();) { 145 !it_ptr->done();) {
140 Browser* browser = **it_ptr; 146 Browser* browser = **it_ptr;
141 browser->window()->Close(); 147 browser->window()->Close();
142 if (!session_ending) { 148 if (!session_ending) {
143 it_ptr->Next(); 149 it_ptr->Next();
(...skipping 11 matching lines...) Expand all
155 it_ptr.reset(new chrome::BrowserIterator()); 161 it_ptr.reset(new chrome::BrowserIterator());
156 if (!it_ptr->done() && browser == **it_ptr) { 162 if (!it_ptr->done() && browser == **it_ptr) {
157 // Destroying the browser should have removed it from the browser list. 163 // Destroying the browser should have removed it from the browser list.
158 // We should never get here. 164 // We should never get here.
159 NOTREACHED(); 165 NOTREACHED();
160 return; 166 return;
161 } 167 }
162 } 168 }
163 } 169 }
164 } 170 }
OLDNEW
« no previous file with comments | « chrome/browser/lifetime/application_lifetime.cc ('k') | chrome/browser/lifetime/browser_close_manager_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698