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

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

Issue 2803633004: Revert of Keep track in the browser of which frames have onunload and onbeforeunload handlers. (Closed)
Patch Set: Created 3 years, 8 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 | content/browser/browser_side_navigation_browsertest.cc » ('j') | no next file with comments »
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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 browser->ResetTryToCloseWindow(); 65 browser->ResetTryToCloseWindow();
66 } 66 }
67 67
68 void BrowserCloseManager::TryToCloseBrowsers() { 68 void BrowserCloseManager::TryToCloseBrowsers() {
69 // If all browser windows can immediately be closed, fall out of this loop and 69 // If all browser windows can immediately be closed, fall out of this loop and
70 // close the browsers. If any browser window cannot be closed, temporarily 70 // close the browsers. If any browser window cannot be closed, temporarily
71 // stop closing. CallBeforeUnloadHandlers prompts the user and calls 71 // stop closing. CallBeforeUnloadHandlers prompts the user and calls
72 // OnBrowserReportCloseable with the result. If the user confirms the close, 72 // OnBrowserReportCloseable with the result. If the user confirms the close,
73 // this will trigger TryToCloseBrowsers to try again. 73 // this will trigger TryToCloseBrowsers to try again.
74 for (auto* browser : *BrowserList::GetInstance()) { 74 for (auto* browser : *BrowserList::GetInstance()) {
75 // Set current_browser_ here since if there are no unload handlers, it might
76 // get used synchronously inside TryToCloseWindow.
77 current_browser_ = browser;
78 if (browser->TryToCloseWindow( 75 if (browser->TryToCloseWindow(
79 false, 76 false,
80 base::Bind(&BrowserCloseManager::OnBrowserReportCloseable, this))) { 77 base::Bind(&BrowserCloseManager::OnBrowserReportCloseable, this))) {
78 current_browser_ = browser;
81 return; 79 return;
82 } 80 }
83 } 81 }
84 current_browser_ = NULL;
85 CheckForDownloadsInProgress(); 82 CheckForDownloadsInProgress();
86 } 83 }
87 84
88 void BrowserCloseManager::OnBrowserReportCloseable(bool proceed) { 85 void BrowserCloseManager::OnBrowserReportCloseable(bool proceed) {
89 if (!current_browser_) 86 if (!current_browser_)
90 return; 87 return;
91 88
92 current_browser_ = NULL; 89 current_browser_ = NULL;
93 90
94 if (proceed) 91 if (proceed)
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 browser->window()->DestroyBrowser(); 180 browser->window()->DestroyBrowser();
184 // Destroying the browser should have removed it from the browser list. 181 // Destroying the browser should have removed it from the browser list.
185 DCHECK(BrowserList::GetInstance()->end() == 182 DCHECK(BrowserList::GetInstance()->end() ==
186 std::find(BrowserList::GetInstance()->begin(), 183 std::find(BrowserList::GetInstance()->begin(),
187 BrowserList::GetInstance()->end(), browser)); 184 BrowserList::GetInstance()->end(), browser));
188 } 185 }
189 } 186 }
190 187
191 g_browser_process->notification_ui_manager()->CancelAll(); 188 g_browser_process->notification_ui_manager()->CancelAll();
192 } 189 }
OLDNEW
« no previous file with comments | « no previous file | content/browser/browser_side_navigation_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698