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

Side by Side Diff: chrome/browser/ui/fast_unload_controller.cc

Issue 2783723002: Keep track in the browser of which frames have onunload and onbeforeunload handlers. (Closed)
Patch Set: fix tests 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
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/ui/fast_unload_controller.h" 5 #include "chrome/browser/ui/fast_unload_controller.h"
6 6
7 #include "base/location.h" 7 #include "base/location.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "base/single_thread_task_runner.h" 10 #include "base/single_thread_task_runner.h"
(...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after
400 tab_needing_before_unload_ack_ = contents; 400 tab_needing_before_unload_ack_ = contents;
401 401
402 CoreTabHelper* core_tab_helper = 402 CoreTabHelper* core_tab_helper =
403 CoreTabHelper::FromWebContents(contents); 403 CoreTabHelper::FromWebContents(contents);
404 core_tab_helper->OnCloseStarted(); 404 core_tab_helper->OnCloseStarted();
405 405
406 // If there's a devtools window attached to |contents|, 406 // If there's a devtools window attached to |contents|,
407 // we would like devtools to call its own beforeunload handlers first, 407 // we would like devtools to call its own beforeunload handlers first,
408 // and then call beforeunload handlers for |contents|. 408 // and then call beforeunload handlers for |contents|.
409 // See DevToolsWindow::InterceptPageBeforeUnload for details. 409 // See DevToolsWindow::InterceptPageBeforeUnload for details.
410 if (!DevToolsWindow::InterceptPageBeforeUnload(contents)) 410 if (!DevToolsWindow::InterceptPageBeforeUnload(contents)) {
411 contents->DispatchBeforeUnload(); 411 if (contents->NeedToFireBeforeUnload()) {
412 contents->DispatchBeforeUnload();
413 } else {
414 ProcessPendingTabs(skip_beforeunload);
415 }
416 }
412 } else { 417 } else {
413 ProcessPendingTabs(skip_beforeunload); 418 ProcessPendingTabs(skip_beforeunload);
414 } 419 }
415 return; 420 return;
416 } 421 }
417 } 422 }
418 423
419 if (is_calling_before_unload_handlers()) { 424 if (is_calling_before_unload_handlers()) {
420 if (!skip_beforeunload) 425 if (!skip_beforeunload)
421 on_close_confirmed_.Run(true); 426 on_close_confirmed_.Run(true);
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
489 } 494 }
490 } 495 }
491 496
492 void FastUnloadController::PostTaskForProcessPendingTabs() { 497 void FastUnloadController::PostTaskForProcessPendingTabs() {
493 base::ThreadTaskRunnerHandle::Get()->PostTask( 498 base::ThreadTaskRunnerHandle::Get()->PostTask(
494 FROM_HERE, base::Bind(&FastUnloadController::ProcessPendingTabs, 499 FROM_HERE, base::Bind(&FastUnloadController::ProcessPendingTabs,
495 weak_factory_.GetWeakPtr(), false)); 500 weak_factory_.GetWeakPtr(), false));
496 } 501 }
497 502
498 } // namespace chrome 503 } // namespace chrome
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698