|
17 | 17 | override_bounds_(params.initial_bounds),
|
18 | 18 | initial_show_state_(params.initial_show_state),
|
19 | 19 | initial_workspace_(params.initial_workspace),
|
20 |
| -@@ -852,12 +855,14 @@ bool Browser::TryToCloseWindow( |
21 |
| - bool skip_beforeunload, |
22 |
| - const base::RepeatingCallback<void(bool)>& on_close_confirmed) { |
23 |
| - cancel_download_confirmation_state_ = RESPONSE_RECEIVED; |
24 |
| -+ close_multitab_confirmation_state_ = RESPONSE_RECEIVED; |
25 |
| - return unload_controller_.TryToCloseWindow(skip_beforeunload, |
26 |
| - on_close_confirmed); |
27 |
| - } |
| 20 | +@@ -828,7 +831,7 @@ Browser::WarnBeforeClosingResult Browser |
| 21 | + // If the browser can close right away (there are no pending downloads we need |
| 22 | + // to prompt about) then there's no need to warn. In the future, we might need |
| 23 | + // to check other conditions as well. |
| 24 | +- if (CanCloseWithInProgressDownloads()) |
| 25 | ++ if (CanCloseWithInProgressDownloads() && CanCloseWithMultipleTabs()) |
| 26 | + return WarnBeforeClosingResult::kOkToClose; |
| 27 | + |
| 28 | + DCHECK(!warn_before_closing_callback_) |
| 29 | +@@ -858,6 +861,7 @@ bool Browser::TryToCloseWindow( |
28 | 30 |
|
29 | 31 | void Browser::ResetTryToCloseWindow() {
|
30 | 32 | cancel_download_confirmation_state_ = NOT_PROMPTED;
|
31 | 33 | + close_multitab_confirmation_state_ = NOT_PROMPTED;
|
32 | 34 | unload_controller_.ResetTryToCloseWindow();
|
33 | 35 | }
|
34 | 36 |
|
35 |
| -@@ -1741,6 +1746,13 @@ void Browser::BeforeUnloadFired(WebConte |
36 |
| - if (is_type_devtools() && DevToolsWindow::HandleBeforeUnload( |
37 |
| - web_contents, proceed, proceed_to_fire_unload)) |
38 |
| - return; |
39 |
| -+ if (proceed && |
40 |
| -+ (IsAttemptingToCloseBrowser() || this->tab_strip_model()->count() <= 1) && |
41 |
| -+ !CanCloseWithMultipleTabs()) { |
42 |
| -+ proceed = false; |
43 |
| -+ warn_before_closing_callback_ = base::BindOnce( |
44 |
| -+ &Browser::FinishWarnBeforeClosing, weak_factory_.GetWeakPtr()); |
45 |
| -+ } |
46 |
| - |
47 |
| - *proceed_to_fire_unload = |
48 |
| - unload_controller_.BeforeUnloadFired(web_contents, proceed); |
49 |
| -@@ -2696,6 +2708,59 @@ bool Browser::CanCloseWithInProgressDown |
| 37 | +@@ -2696,6 +2700,62 @@ bool Browser::CanCloseWithInProgressDown |
50 | 38 | return false;
|
51 | 39 | }
|
52 | 40 |
|
|
81 | 69 | + if (show_confirmation_last_window) {
|
82 | 70 | + if (total_window_count >= 1 || this->tab_strip_model()->count() <= 1)
|
83 | 71 | + return true;
|
84 |
| -+ } else if (total_window_count == 0) { |
85 |
| -+ return true; |
| 72 | ++ } else { |
| 73 | ++ if (total_window_count == 0 && this->tab_strip_model()->count() <= 1) |
| 74 | ++ return true; |
| 75 | ++ if (this->tab_strip_model()->count() == 0) |
| 76 | ++ tab_strip_model_delegate_->AddTabAt(GURL(), -1, true); |
86 | 77 | + }
|
87 | 78 | +
|
88 | 79 | + close_multitab_confirmation_state_ = WAITING_FOR_RESPONSE;
|
|
106 | 97 | void Browser::InProgressDownloadResponse(bool cancel_downloads) {
|
107 | 98 | if (cancel_downloads) {
|
108 | 99 | cancel_download_confirmation_state_ = RESPONSE_RECEIVED;
|
109 |
| -@@ -2714,6 +2779,22 @@ void Browser::InProgressDownloadResponse |
| 100 | +@@ -2714,6 +2774,22 @@ void Browser::InProgressDownloadResponse |
110 | 101 |
|
111 | 102 | std::move(warn_before_closing_callback_)
|
112 | 103 | .Run(WarnBeforeClosingResult::kDoNotClose);
|
|
0 commit comments