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

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: 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..cf2cbf74c46301b4217db963efbda6844ca7aba0 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()
+ : proceed_beforeunload_default_(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 (proceed_beforeunload_default_)
+ 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) {

Powered by Google App Engine
This is Rietveld 408576698