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

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

Issue 11434013: In Chrome ASH on Windows 8 make sure that the browser object is closed before destroying it. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years 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 | Annotate | Revision Log
OLDNEW
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/ui/browser_list.h" 5 #include "chrome/browser/ui/browser_list.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/message_loop.h" 9 #include "base/message_loop.h"
10 #include "build/build_config.h" 10 #include "build/build_config.h"
11 #include "chrome/browser/browser_process.h" 11 #include "chrome/browser/browser_process.h"
12 #include "chrome/browser/browser_shutdown.h" 12 #include "chrome/browser/browser_shutdown.h"
13 #include "chrome/browser/download/download_service.h" 13 #include "chrome/browser/download/download_service.h"
14 #include "chrome/browser/metrics/thread_watcher.h" 14 #include "chrome/browser/metrics/thread_watcher.h"
15 #include "chrome/browser/prefs/pref_service.h" 15 #include "chrome/browser/prefs/pref_service.h"
16 #include "chrome/browser/profiles/profile.h" 16 #include "chrome/browser/profiles/profile.h"
17 #include "chrome/browser/profiles/profile_manager.h" 17 #include "chrome/browser/profiles/profile_manager.h"
18 #include "chrome/browser/ui/browser.h" 18 #include "chrome/browser/ui/browser.h"
19 #include "chrome/browser/ui/browser_list_impl.h"
19 #include "chrome/browser/ui/browser_tabstrip.h" 20 #include "chrome/browser/ui/browser_tabstrip.h"
20 #include "chrome/browser/ui/browser_window.h" 21 #include "chrome/browser/ui/browser_window.h"
21 #include "chrome/browser/ui/tab_contents/tab_contents.h" 22 #include "chrome/browser/ui/tab_contents/tab_contents.h"
22 #include "chrome/browser/ui/tabs/tab_strip_model.h" 23 #include "chrome/browser/ui/tabs/tab_strip_model.h"
23 #include "chrome/common/chrome_notification_types.h" 24 #include "chrome/common/chrome_notification_types.h"
24 #include "chrome/common/chrome_switches.h" 25 #include "chrome/common/chrome_switches.h"
25 #include "chrome/common/pref_names.h" 26 #include "chrome/common/pref_names.h"
26 #include "content/public/browser/browser_shutdown.h" 27 #include "content/public/browser/browser_shutdown.h"
27 #include "content/public/browser/browser_thread.h" 28 #include "content/public/browser/browser_thread.h"
28 #include "content/public/browser/navigation_details.h" 29 #include "content/public/browser/navigation_details.h"
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 if (i != BrowserList::end() && browser == *i) { 200 if (i != BrowserList::end() && browser == *i) {
200 // Destroying the browser should have removed it from the browser list. 201 // Destroying the browser should have removed it from the browser list.
201 // We should never get here. 202 // We should never get here.
202 NOTREACHED(); 203 NOTREACHED();
203 return; 204 return;
204 } 205 }
205 } 206 }
206 } 207 }
207 } 208 }
208 209
210 void CloseAllBrowsersOfType(chrome::HostDesktopType type) {
sky 2012/11/29 20:28:03 I'm worried that keeping this here means other fol
ananta 2012/11/29 21:55:42 Done. Added a local function CloseOpenAshBrowsers
211 chrome::BrowserListImpl* browser_list =
212 chrome::BrowserListImpl::GetInstance(type);
213 if (browser_list) {
214 for (chrome::BrowserListImpl::const_iterator i = browser_list->begin();
215 i != browser_list->end(); ++i) {
216 Browser* browser = *i;
217 browser->window()->Close();
218 // If the attempt to Close the browser fails due to unload handlers on
219 // the page or in progress downloads, etc, destroy all tabs on the page.
220 while (browser->tab_count())
221 delete browser->tab_strip_model()->GetTabContentsAt(0);
222 }
223 }
224 }
225
209 void AttemptUserExit() { 226 void AttemptUserExit() {
210 #if defined(OS_CHROMEOS) 227 #if defined(OS_CHROMEOS)
211 chromeos::BootTimesLoader::Get()->AddLogoutTimeMarker("LogoutStarted", false); 228 chromeos::BootTimesLoader::Get()->AddLogoutTimeMarker("LogoutStarted", false);
212 // Write /tmp/uptime-logout-started as well. 229 // Write /tmp/uptime-logout-started as well.
213 const char kLogoutStarted[] = "logout-started"; 230 const char kLogoutStarted[] = "logout-started";
214 chromeos::BootTimesLoader::Get()->RecordCurrentStats(kLogoutStarted); 231 chromeos::BootTimesLoader::Get()->RecordCurrentStats(kLogoutStarted);
215 232
216 // Login screen should show up in owner's locale. 233 // Login screen should show up in owner's locale.
217 PrefService* state = g_browser_process->local_state(); 234 PrefService* state = g_browser_process->local_state();
218 if (state) { 235 if (state) {
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
363 MessageLoop::current()) 380 MessageLoop::current())
364 CloseAllBrowsers(); 381 CloseAllBrowsers();
365 } 382 }
366 } 383 }
367 384
368 bool WillKeepAlive() { 385 bool WillKeepAlive() {
369 return g_keep_alive_count > 0; 386 return g_keep_alive_count > 0;
370 } 387 }
371 388
372 } // namespace browser 389 } // namespace browser
OLDNEW
« no previous file with comments | « chrome/browser/lifetime/application_lifetime.h ('k') | chrome/browser/metro_viewer/metro_viewer_process_host_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698