summaryrefslogtreecommitdiffstats
path: root/chrome/browser
diff options
context:
space:
mode:
authorerg@google.com <erg@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-11-07 00:08:26 +0000
committererg@google.com <erg@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-11-07 00:08:26 +0000
commitb96813156ed29c2e8ffa20e462b8487383e2f667 (patch)
tree1061558c10fce176683c8bbbaafbe25aac02336e /chrome/browser
parent49a90249dc26805a1d0c80fdf5bd6b88e1548b55 (diff)
downloadchromium_src-b96813156ed29c2e8ffa20e462b8487383e2f667.zip
chromium_src-b96813156ed29c2e8ffa20e462b8487383e2f667.tar.gz
chromium_src-b96813156ed29c2e8ffa20e462b8487383e2f667.tar.bz2
Prevent window.close() working from Javascript when a blocked popup notification exists. This is a copy of Firefox's behaviour.
BUG=crbug.com/4007 Review URL: http://codereview.chromium.org/9656 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@4934 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
-rw-r--r--chrome/browser/tab_contents.cc5
-rw-r--r--chrome/browser/tab_contents.h5
-rw-r--r--chrome/browser/web_contents.cc7
3 files changed, 15 insertions, 2 deletions
diff --git a/chrome/browser/tab_contents.cc b/chrome/browser/tab_contents.cc
index 0215ec7..ec3c8af 100644
--- a/chrome/browser/tab_contents.cc
+++ b/chrome/browser/tab_contents.cc
@@ -516,3 +516,8 @@ void TabContents::RepositionSupressedPopupsToFit(const gfx::Size& new_size) {
void TabContents::ReleaseDownloadShelfView() {
download_shelf_view_.release();
}
+
+bool TabContents::ShowingBlockedPopupNotification() const {
+ return blocked_popups_ != NULL &&
+ blocked_popups_->GetTabContentsCount() != 0;
+}
diff --git a/chrome/browser/tab_contents.h b/chrome/browser/tab_contents.h
index f4d981e..6f7f592 100644
--- a/chrome/browser/tab_contents.h
+++ b/chrome/browser/tab_contents.h
@@ -465,6 +465,11 @@ class TabContents : public PageNavigator {
typedef std::vector<ConstrainedWindow*> ConstrainedWindowList;
ConstrainedWindowList child_windows_;
+ // Whether we have a notification AND the notification owns popups windows.
+ // (We keep the notification object around even when it's not shown since it
+ // determines whether to show itself).
+ bool ShowingBlockedPopupNotification() const;
+
private:
// Data ----------------------------------------------------------------------
diff --git a/chrome/browser/web_contents.cc b/chrome/browser/web_contents.cc
index cedb58c..507b33a 100644
--- a/chrome/browser/web_contents.cc
+++ b/chrome/browser/web_contents.cc
@@ -837,8 +837,11 @@ void WebContents::UpdateThumbnail(const GURL& url,
}
void WebContents::Close(RenderViewHost* rvh) {
- // Ignore this if it comes from a RenderViewHost that we aren't showing.
- if (delegate() && rvh == render_view_host())
+ // Ignore this if it comes from a RenderViewHost that we aren't showing, and
+ // refuse to allow javascript to close this window if we have a blocked popup
+ // notification.
+ if (delegate() && rvh == render_view_host() &&
+ !ShowingBlockedPopupNotification())
delegate()->CloseContents(this);
}