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

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

Issue 1931793002: Stop using nested message loop for alert() and other JS dialogs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: updated comments and removed unused declaration Created 4 years, 7 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 | « chrome/browser/ui/unload_controller.h ('k') | chrome/browser/unload_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 (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/location.h" 7 #include "base/location.h"
8 #include "base/single_thread_task_runner.h" 8 #include "base/single_thread_task_runner.h"
9 #include "base/threading/thread_task_runner_handle.h" 9 #include "base/threading/thread_task_runner_handle.h"
10 #include "chrome/browser/chrome_notification_types.h" 10 #include "chrome/browser/chrome_notification_types.h"
(...skipping 25 matching lines...) Expand all
36 36
37 bool UnloadController::CanCloseContents(content::WebContents* contents) { 37 bool UnloadController::CanCloseContents(content::WebContents* contents) {
38 // Don't try to close the tab when the whole browser is being closed, since 38 // Don't try to close the tab when the whole browser is being closed, since
39 // that avoids the fast shutdown path where we just kill all the renderers. 39 // that avoids the fast shutdown path where we just kill all the renderers.
40 if (is_attempting_to_close_browser_) 40 if (is_attempting_to_close_browser_)
41 ClearUnloadState(contents, true); 41 ClearUnloadState(contents, true);
42 return !is_attempting_to_close_browser_ || 42 return !is_attempting_to_close_browser_ ||
43 is_calling_before_unload_handlers(); 43 is_calling_before_unload_handlers();
44 } 44 }
45 45
46 // static
47 bool UnloadController::ShouldRunUnloadEventsHelper( 46 bool UnloadController::ShouldRunUnloadEventsHelper(
48 content::WebContents* contents) { 47 content::WebContents* contents) {
49 // If |contents| is being inspected, devtools needs to intercept beforeunload 48 // If |contents| is being inspected, devtools needs to intercept beforeunload
50 // events. 49 // events.
51 return DevToolsWindow::GetInstanceForInspectedWebContents(contents) != NULL; 50 return DevToolsWindow::GetInstanceForInspectedWebContents(contents) != NULL;
52 } 51 }
53 52
54 // static
55 bool UnloadController::RunUnloadEventsHelper(content::WebContents* contents) { 53 bool UnloadController::RunUnloadEventsHelper(content::WebContents* contents) {
54 // Special case for when we quit an application. The devtools window can
55 // close if it's beforeunload event has already fired which will happen due
56 // to the interception of it's content's beforeunload.
57 if (browser_->is_devtools() &&
58 DevToolsWindow::HasFiredBeforeUnloadEventForDevToolsBrowser(browser_))
59 return false;
60
56 // If there's a devtools window attached to |contents|, 61 // If there's a devtools window attached to |contents|,
57 // we would like devtools to call its own beforeunload handlers first, 62 // we would like devtools to call its own beforeunload handlers first,
58 // and then call beforeunload handlers for |contents|. 63 // and then call beforeunload handlers for |contents|.
59 // See DevToolsWindow::InterceptPageBeforeUnload for details. 64 // See DevToolsWindow::InterceptPageBeforeUnload for details.
60 if (DevToolsWindow::InterceptPageBeforeUnload(contents)) { 65 if (DevToolsWindow::InterceptPageBeforeUnload(contents)) {
61 return true; 66 return true;
62 } 67 }
63 // If the WebContents is not connected yet, then there's no unload 68 // If the WebContents is not connected yet, then there's no unload
64 // handler we can fire even if the WebContents has an unload listener. 69 // handler we can fire even if the WebContents has an unload listener.
65 // One case where we hit this is in a tab that has an infinite loop 70 // One case where we hit this is in a tab that has an infinite loop
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after
359 ProcessPendingTabs(); 364 ProcessPendingTabs();
360 } else { 365 } else {
361 base::ThreadTaskRunnerHandle::Get()->PostTask( 366 base::ThreadTaskRunnerHandle::Get()->PostTask(
362 FROM_HERE, base::Bind(&UnloadController::ProcessPendingTabs, 367 FROM_HERE, base::Bind(&UnloadController::ProcessPendingTabs,
363 weak_factory_.GetWeakPtr())); 368 weak_factory_.GetWeakPtr()));
364 } 369 }
365 } 370 }
366 } 371 }
367 372
368 } // namespace chrome 373 } // namespace chrome
OLDNEW
« no previous file with comments | « chrome/browser/ui/unload_controller.h ('k') | chrome/browser/unload_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698