| OLD | NEW |
| 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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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()) { |
| 65 browser->ResetBeforeUnloadHandlers(); | 65 browser->ResetCloseWindow(); |
| 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 Loading... |
| 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 } |
| OLD | NEW |