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) { |