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

Unified Diff: content/shell/browser/shell_javascript_dialog_manager.cc

Issue 1825523002: Do not reset navigation state when BeforeUnload is cancelled by a commit (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase + addressed nit Created 4 years, 9 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 side-by-side diff with in-line comments
Download patch
Index: content/shell/browser/shell_javascript_dialog_manager.cc
diff --git a/content/shell/browser/shell_javascript_dialog_manager.cc b/content/shell/browser/shell_javascript_dialog_manager.cc
index fdd57253c5ac48338859c303bf901a1af60a0440..2ed26848f9946e735ed3dcc0045777845ecff49f 100644
--- a/content/shell/browser/shell_javascript_dialog_manager.cc
+++ b/content/shell/browser/shell_javascript_dialog_manager.cc
@@ -15,8 +15,8 @@
namespace content {
-ShellJavaScriptDialogManager::ShellJavaScriptDialogManager() {
-}
+ShellJavaScriptDialogManager::ShellJavaScriptDialogManager()
+ : should_proceed_on_beforeunload_(true) {}
ShellJavaScriptDialogManager::~ShellJavaScriptDialogManager() {
}
@@ -68,9 +68,14 @@ void ShellJavaScriptDialogManager::RunBeforeUnloadDialog(
WebContents* web_contents,
bool is_reload,
const DialogClosedCallback& callback) {
+ // During tests, if the BeforeUnload should not proceed automatically, store
+ // the callback and return.
if (!dialog_request_callback_.is_null()) {
dialog_request_callback_.Run();
- callback.Run(true, base::string16());
+ if (should_proceed_on_beforeunload_)
+ callback.Run(true, base::string16());
+ else
+ before_unload_callback_ = callback;
dialog_request_callback_.Reset();
return;
}
@@ -113,6 +118,10 @@ void ShellJavaScriptDialogManager::CancelActiveAndPendingDialogs(
}
void ShellJavaScriptDialogManager::ResetDialogState(WebContents* web_contents) {
+ if (before_unload_callback_.is_null())
+ return;
+ before_unload_callback_.Run(false, base::string16());
+ before_unload_callback_.Reset();
}
void ShellJavaScriptDialogManager::DialogClosed(ShellJavaScriptDialog* dialog) {
« no previous file with comments | « content/shell/browser/shell_javascript_dialog_manager.h ('k') | content/test/content_browser_test_utils_internal.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698