Persist JavaScript dialog state across page navigations.
This prevents a single WebContents from annoying the user with JavaScript alert loops, no matter what the page does in-between (e.g. reload, switch sites).
BUG=265475
TEST=as in bug
[email protected]
Review URL: https://chromiumcodereview.appspot.com/21111002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@214697 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/content/browser/web_contents/web_contents_impl.cc b/content/browser/web_contents/web_contents_impl.cc
index 72c6bd0..152eceb 100644
--- a/content/browser/web_contents/web_contents_impl.cc
+++ b/content/browser/web_contents/web_contents_impl.cc
@@ -377,7 +377,7 @@
// Clear out any JavaScript state.
if (dialog_manager_)
- dialog_manager_->ResetJavaScriptState(this);
+ dialog_manager_->WebContentsDestroyed(this);
if (color_chooser_)
color_chooser_->End();
@@ -2702,13 +2702,9 @@
RenderViewHost* render_view_host,
const LoadCommittedDetails& details,
const ViewHostMsg_FrameNavigate_Params& params) {
- // If we navigate off the page, reset JavaScript state. This does nothing
- // to prevent a malicious script from spamming messages, since the script
- // could just reload the page to stop blocking.
- if (dialog_manager_ && !details.is_in_page) {
- dialog_manager_->ResetJavaScriptState(this);
- dialog_manager_ = NULL;
- }
+ // If we navigate off the page, close all JavaScript dialogs.
+ if (dialog_manager_ && !details.is_in_page)
+ dialog_manager_->CancelActiveAndPendingDialogs(this);
// Notify observers about navigation.
FOR_EACH_OBSERVER(WebContentsObserver, observers_,