diff options
author | stevenjb@google.com <stevenjb@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-04-19 22:52:35 +0000 |
---|---|---|
committer | stevenjb@google.com <stevenjb@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-04-19 22:52:35 +0000 |
commit | 47317494db5a0041f8a32ce4a654f8209166e96e (patch) | |
tree | 0645fe30e46c8fd18532e731f0b4beeea96b5744 /content | |
parent | 4989165972ff27ee66abd7e83b521db24593a3cc (diff) | |
download | chromium_src-47317494db5a0041f8a32ce4a654f8209166e96e.zip chromium_src-47317494db5a0041f8a32ce4a654f8209166e96e.tar.gz chromium_src-47317494db5a0041f8a32ce4a654f8209166e96e.tar.bz2 |
Fix for blocked popups crash (issue 79777).
BUG=chromium:79777
TEST=See issue
TBR=avi
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@82176 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content')
-rw-r--r-- | content/browser/tab_contents/tab_contents.cc | 40 | ||||
-rw-r--r-- | content/browser/tab_contents/tab_contents.h | 19 | ||||
-rw-r--r-- | content/browser/tab_contents/tab_contents_view.cc | 4 |
3 files changed, 43 insertions, 20 deletions
diff --git a/content/browser/tab_contents/tab_contents.cc b/content/browser/tab_contents/tab_contents.cc index ef69769..b3ecf53 100644 --- a/content/browser/tab_contents/tab_contents.cc +++ b/content/browser/tab_contents/tab_contents.cc @@ -811,10 +811,11 @@ void TabContents::BlockTabContent(bool blocked) { delegate_->SetTabContentBlocked(this, blocked); } -void TabContents::AddNewContents(TabContents* new_contents, - WindowOpenDisposition disposition, - const gfx::Rect& initial_pos, - bool user_gesture) { + +void TabContents::AddOrBlockNewContents(TabContents* new_contents, + WindowOpenDisposition disposition, + const gfx::Rect& initial_pos, + bool user_gesture) { if (all_contents_blocked_) { if (!blocked_contents_) blocked_contents_ = new BlockedContentContainer(this); @@ -834,13 +835,7 @@ void TabContents::AddNewContents(TabContents* new_contents, delegate_->GetConstrainingContents(this)->AddPopup( new_contents, initial_pos, user_gesture); } else { - new_contents->DisassociateFromPopupCount(); - delegate_->AddNewContents(this, new_contents, disposition, initial_pos, - user_gesture); - NotificationService::current()->Notify( - NotificationType::TAB_ADDED, - Source<TabContentsDelegate>(delegate_), - Details<TabContents>(this)); + AddNewContents(new_contents, disposition, initial_pos, user_gesture); } // TODO(pkasting): Why is this necessary? @@ -1405,6 +1400,19 @@ void TabContents::SetIsLoading(bool is_loading, det); } +void TabContents::AddNewContents(TabContents* new_contents, + WindowOpenDisposition disposition, + const gfx::Rect& initial_pos, + bool user_gesture) { + new_contents->DisassociateFromPopupCount(); + delegate_->AddNewContents(this, new_contents, disposition, initial_pos, + user_gesture); + NotificationService::current()->Notify( + NotificationType::TAB_ADDED, + Source<TabContentsDelegate>(delegate_), + Details<TabContents>(this)); +} + void TabContents::AddPopup(TabContents* new_contents, const gfx::Rect& initial_pos, bool user_gesture) { @@ -1425,8 +1433,14 @@ void TabContents::AddPopup(TabContents* new_contents, } else { if (!blocked_contents_) blocked_contents_ = new BlockedContentContainer(this); - blocked_contents_->AddTabContents(new_contents, NEW_POPUP, initial_pos, - user_gesture); + // Call blocked_contents_->AddTabContents with user_gesture == true + // so that the contents will not get blocked again. + // TODO(stevenjb): Remove user_gesture parameter from + // BlockedContentContainer::AddTabContents()? + blocked_contents_->AddTabContents(new_contents, + NEW_POPUP, + initial_pos, + true); // user gesture content_settings_delegate_->OnContentBlocked(CONTENT_SETTINGS_TYPE_POPUPS, std::string()); } diff --git a/content/browser/tab_contents/tab_contents.h b/content/browser/tab_contents/tab_contents.h index 3f6c1fe..43f9259 100644 --- a/content/browser/tab_contents/tab_contents.h +++ b/content/browser/tab_contents/tab_contents.h @@ -347,11 +347,13 @@ class TabContents : public PageNavigator, ConstrainedWindow* CreateConstrainedDialog( ConstrainedWindowDelegate* delegate); - // Adds a new tab or window with the given already-created contents - void AddNewContents(TabContents* new_contents, - WindowOpenDisposition disposition, - const gfx::Rect& initial_pos, - bool user_gesture); + // Adds a new tab or window with the given already-created contents. + // If disposition is NEW_POPUP and user_gesture is false, contents may + // be blocked. + void AddOrBlockNewContents(TabContents* new_contents, + WindowOpenDisposition disposition, + const gfx::Rect& initial_pos, + bool user_gesture); // Called when the blocked popup notification is shown or hidden. virtual void PopupNotificationVisibilityChanged(bool visible); @@ -692,6 +694,13 @@ class TabContents : public PageNavigator, void SetIsLoading(bool is_loading, LoadNotificationDetails* details); + // Adds a new tab or window with the given already-created contents. + // Called from AddOrBlockNewContents or AddPopup. + void AddNewContents(TabContents* new_contents, + WindowOpenDisposition disposition, + const gfx::Rect& initial_pos, + bool user_gesture); + // Adds the incoming |new_contents| to the |blocked_contents_| container. void AddPopup(TabContents* new_contents, const gfx::Rect& initial_pos, diff --git a/content/browser/tab_contents/tab_contents_view.cc b/content/browser/tab_contents/tab_contents_view.cc index 09db402..ab398d7 100644 --- a/content/browser/tab_contents/tab_contents_view.cc +++ b/content/browser/tab_contents/tab_contents_view.cc @@ -68,8 +68,8 @@ void TabContentsView::ShowCreatedWindow(int route_id, bool user_gesture) { TabContents* contents = delegate_view_helper_.GetCreatedWindow(route_id); if (contents) { - tab_contents()->AddNewContents(contents, disposition, initial_pos, - user_gesture); + tab_contents()->AddOrBlockNewContents( + contents, disposition, initial_pos, user_gesture); } } |