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

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

Issue 2681203002: Add Browser::SkipCallBeforeUnload so that the browser windows can be closed regardless of beforeunl… (Closed)
Patch Set: rebase from master Created 3 years, 9 months 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
« no previous file with comments | « no previous file | chrome/browser/profiles/profile_manager.cc » ('j') | chrome/browser/ui/browser.h » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <algorithm> 7 #include <algorithm>
8 #include <iterator> 8 #include <iterator>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 // Tell everyone that we are shutting down. 54 // Tell everyone that we are shutting down.
55 browser_shutdown::SetTryingToQuit(true); 55 browser_shutdown::SetTryingToQuit(true);
56 CloseBrowsers(); 56 CloseBrowsers();
57 return; 57 return;
58 } 58 }
59 TryToCloseBrowsers(); 59 TryToCloseBrowsers();
60 } 60 }
61 61
62 void BrowserCloseManager::CancelBrowserClose() { 62 void BrowserCloseManager::CancelBrowserClose() {
63 browser_shutdown::SetTryingToQuit(false); 63 browser_shutdown::SetTryingToQuit(false);
64 for (auto* browser : *BrowserList::GetInstance()) { 64 for (auto* browser : *BrowserList::GetInstance()) {
sky 2017/03/14 00:04:05 no {}
zmin 2017/03/14 17:46:47 Done.
65 browser->ResetBeforeUnloadHandlers(); 65 browser->ResetTryToCloseWindow();
66 } 66 }
67 } 67 }
68 68
69 void BrowserCloseManager::TryToCloseBrowsers() { 69 void BrowserCloseManager::TryToCloseBrowsers() {
70 // If all browser windows can immediately be closed, fall out of this loop and 70 // If all browser windows can immediately be closed, fall out of this loop and
71 // close the browsers. If any browser window cannot be closed, temporarily 71 // close the browsers. If any browser window cannot be closed, temporarily
72 // stop closing. CallBeforeUnloadHandlers prompts the user and calls 72 // stop closing. CallBeforeUnloadHandlers prompts the user and calls
73 // OnBrowserReportCloseable with the result. If the user confirms the close, 73 // OnBrowserReportCloseable with the result. If the user confirms the close,
74 // this will trigger TryToCloseBrowsers to try again. 74 // this will trigger TryToCloseBrowsers to try again.
75 for (auto* browser : *BrowserList::GetInstance()) { 75 for (auto* browser : *BrowserList::GetInstance()) {
76 if (browser->CallBeforeUnloadHandlers( 76 if (browser->TryToCloseWindow(
77 false,
77 base::Bind(&BrowserCloseManager::OnBrowserReportCloseable, this))) { 78 base::Bind(&BrowserCloseManager::OnBrowserReportCloseable, this))) {
78 current_browser_ = browser; 79 current_browser_ = browser;
79 return; 80 return;
80 } 81 }
81 } 82 }
82 CheckForDownloadsInProgress(); 83 CheckForDownloadsInProgress();
83 } 84 }
84 85
85 void BrowserCloseManager::OnBrowserReportCloseable(bool proceed) { 86 void BrowserCloseManager::OnBrowserReportCloseable(bool proceed) {
86 if (!current_browser_) 87 if (!current_browser_)
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 browser->window()->DestroyBrowser(); 181 browser->window()->DestroyBrowser();
181 // Destroying the browser should have removed it from the browser list. 182 // Destroying the browser should have removed it from the browser list.
182 DCHECK(BrowserList::GetInstance()->end() == 183 DCHECK(BrowserList::GetInstance()->end() ==
183 std::find(BrowserList::GetInstance()->begin(), 184 std::find(BrowserList::GetInstance()->begin(),
184 BrowserList::GetInstance()->end(), browser)); 185 BrowserList::GetInstance()->end(), browser));
185 } 186 }
186 } 187 }
187 188
188 g_browser_process->notification_ui_manager()->CancelAll(); 189 g_browser_process->notification_ui_manager()->CancelAll();
189 } 190 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/profiles/profile_manager.cc » ('j') | chrome/browser/ui/browser.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698