diff options
author | sky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-12-06 18:11:50 +0000 |
---|---|---|
committer | sky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-12-06 18:11:50 +0000 |
commit | 8f55e8087439851d78245881a8acd62b24251801 (patch) | |
tree | 5647921d79785873857b41601b8861bbb6f31c53 /chrome/browser | |
parent | 2c1a82846a04cb8277d4ddf514f9e0ff122da0d1 (diff) | |
download | chromium_src-8f55e8087439851d78245881a8acd62b24251801.zip chromium_src-8f55e8087439851d78245881a8acd62b24251801.tar.gz chromium_src-8f55e8087439851d78245881a8acd62b24251801.tar.bz2 |
Stops javascript alerts and unload dialogs from showing during
instant.
BUG=65206
TEST=see bug
Review URL: http://codereview.chromium.org/5631001
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@68354 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
-rw-r--r-- | chrome/browser/instant/instant_loader.cc | 4 | ||||
-rw-r--r-- | chrome/browser/tab_contents/tab_contents.cc | 11 | ||||
-rw-r--r-- | chrome/browser/tab_contents/tab_contents_delegate.cc | 4 | ||||
-rw-r--r-- | chrome/browser/tab_contents/tab_contents_delegate.h | 4 |
4 files changed, 21 insertions, 2 deletions
diff --git a/chrome/browser/instant/instant_loader.cc b/chrome/browser/instant/instant_loader.cc index c3c62d2..af76f34 100644 --- a/chrome/browser/instant/instant_loader.cc +++ b/chrome/browser/instant/instant_loader.cc @@ -276,6 +276,10 @@ class InstantLoader::TabContentsDelegateImpl : public TabContentsDelegate { virtual bool CanReloadContents(TabContents* source) const { return true; } virtual void ShowHtmlDialog(HtmlDialogUIDelegate* delegate, gfx::NativeWindow parent_window) {} + virtual bool ShouldSuppressDialogs() { + // Any message shown during instant cancels instant, so we suppress them. + return true; + } virtual void BeforeUnloadFired(TabContents* tab, bool proceed, bool* proceed_to_fire_unload) {} diff --git a/chrome/browser/tab_contents/tab_contents.cc b/chrome/browser/tab_contents/tab_contents.cc index 371e221..54e62d2 100644 --- a/chrome/browser/tab_contents/tab_contents.cc +++ b/chrome/browser/tab_contents/tab_contents.cc @@ -2754,8 +2754,10 @@ void TabContents::RunJavaScriptMessage( // Also suppress messages when showing an interstitial. The interstitial is // shown over the previous page, we don't want the hidden page dialogs to // interfere with the interstitial. - bool suppress_this_message = suppress_javascript_messages_ || - showing_interstitial_page(); + bool suppress_this_message = + suppress_javascript_messages_ || + showing_interstitial_page() || + (delegate() && delegate()->ShouldSuppressDialogs()); if (delegate()) suppress_this_message |= (delegate()->GetConstrainingContents(this) != this); @@ -2783,6 +2785,11 @@ void TabContents::RunJavaScriptMessage( void TabContents::RunBeforeUnloadConfirm(const std::wstring& message, IPC::Message* reply_msg) { + if (delegate() && delegate()->ShouldSuppressDialogs()) { + render_view_host()->JavaScriptMessageBoxClosed(reply_msg, true, + std::wstring()); + return; + } is_showing_before_unload_dialog_ = true; RunBeforeUnloadDialog(this, message, reply_msg); } diff --git a/chrome/browser/tab_contents/tab_contents_delegate.cc b/chrome/browser/tab_contents/tab_contents_delegate.cc index 6c54933..28630e3 100644 --- a/chrome/browser/tab_contents/tab_contents_delegate.cc +++ b/chrome/browser/tab_contents/tab_contents_delegate.cc @@ -45,6 +45,10 @@ void TabContentsDelegate::ShowHtmlDialog(HtmlDialogUIDelegate* delegate, gfx::NativeWindow parent_window) { } +bool TabContentsDelegate::ShouldSuppressDialogs() { + return false; +} + void TabContentsDelegate::BeforeUnloadFired(TabContents* tab, bool proceed, bool* proceed_to_fire_unload) { diff --git a/chrome/browser/tab_contents/tab_contents_delegate.h b/chrome/browser/tab_contents/tab_contents_delegate.h index e748229..4f24098 100644 --- a/chrome/browser/tab_contents/tab_contents_delegate.h +++ b/chrome/browser/tab_contents/tab_contents_delegate.h @@ -154,6 +154,10 @@ class TabContentsDelegate : public AutomationResourceRoutingDelegate { virtual void ShowHtmlDialog(HtmlDialogUIDelegate* delegate, gfx::NativeWindow parent_window); + // Returns true if javascript dialogs and unload alerts are suppressed. + // Default is false. + virtual bool ShouldSuppressDialogs(); + // Tells us that we've finished firing this tab's beforeunload event. // The proceed bool tells us whether the user chose to proceed closing the // tab. Returns true if the tab can continue on firing it's unload event. |