OLD | NEW |
---|---|
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/unload_controller.h" | 5 #include "chrome/browser/ui/unload_controller.h" |
6 | 6 |
7 #include "base/message_loop/message_loop.h" | 7 #include "base/message_loop/message_loop.h" |
8 #include "chrome/browser/chrome_notification_types.h" | 8 #include "chrome/browser/chrome_notification_types.h" |
9 #include "chrome/browser/devtools/devtools_window.h" | 9 #include "chrome/browser/devtools/devtools_window.h" |
10 #include "chrome/browser/ui/browser.h" | 10 #include "chrome/browser/ui/browser.h" |
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
293 // If there's a devtools window attached to |web_contents|, | 293 // If there's a devtools window attached to |web_contents|, |
294 // we would like devtools to call its own beforeunload handlers first, | 294 // we would like devtools to call its own beforeunload handlers first, |
295 // and then call beforeunload handlers for |web_contents|. | 295 // and then call beforeunload handlers for |web_contents|. |
296 // See DevToolsWindow::InterceptPageBeforeUnload for details. | 296 // See DevToolsWindow::InterceptPageBeforeUnload for details. |
297 if (!DevToolsWindow::InterceptPageBeforeUnload(web_contents)) | 297 if (!DevToolsWindow::InterceptPageBeforeUnload(web_contents)) |
298 web_contents->DispatchBeforeUnload(false); | 298 web_contents->DispatchBeforeUnload(false); |
299 } else { | 299 } else { |
300 ClearUnloadState(web_contents, true); | 300 ClearUnloadState(web_contents, true); |
301 } | 301 } |
302 } else if (is_calling_before_unload_handlers()) { | 302 } else if (is_calling_before_unload_handlers()) { |
303 on_close_confirmed_.Run(true); | 303 base::Callback<void(bool)> on_close_confirmed = on_close_confirmed_; |
304 if (tabs_needing_unload_fired_.empty()) | |
305 on_close_confirmed_.Reset(); | |
Peter Kasting
2014/08/28 18:46:13
Clearly order is important here; add comments expl
Mike Lerman
2014/08/29 18:02:21
Done.
| |
306 on_close_confirmed.Run(true); | |
304 } else if (!tabs_needing_unload_fired_.empty()) { | 307 } else if (!tabs_needing_unload_fired_.empty()) { |
305 // We've finished firing all beforeunload events and can proceed with unload | 308 // We've finished firing all beforeunload events and can proceed with unload |
306 // events. | 309 // events. |
307 // TODO(ojan): We should add a call to browser_shutdown::OnShutdownStarting | 310 // TODO(ojan): We should add a call to browser_shutdown::OnShutdownStarting |
308 // somewhere around here so that we have accurate measurements of shutdown | 311 // somewhere around here so that we have accurate measurements of shutdown |
309 // time. | 312 // time. |
310 // TODO(ojan): We can probably fire all the unload events in parallel and | 313 // TODO(ojan): We can probably fire all the unload events in parallel and |
311 // get a perf benefit from that in the cases where the tab hangs in it's | 314 // get a perf benefit from that in the cases where the tab hangs in it's |
312 // unload handler or takes a long time to page in. | 315 // unload handler or takes a long time to page in. |
313 content::WebContents* web_contents = *(tabs_needing_unload_fired_.begin()); | 316 content::WebContents* web_contents = *(tabs_needing_unload_fired_.begin()); |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
352 } else { | 355 } else { |
353 base::MessageLoop::current()->PostTask( | 356 base::MessageLoop::current()->PostTask( |
354 FROM_HERE, | 357 FROM_HERE, |
355 base::Bind(&UnloadController::ProcessPendingTabs, | 358 base::Bind(&UnloadController::ProcessPendingTabs, |
356 weak_factory_.GetWeakPtr())); | 359 weak_factory_.GetWeakPtr())); |
357 } | 360 } |
358 } | 361 } |
359 } | 362 } |
360 | 363 |
361 } // namespace chrome | 364 } // namespace chrome |
OLD | NEW |