| Index: chrome/browser/ui/blocked_content/blocked_content_tab_helper.cc
|
| diff --git a/chrome/browser/ui/blocked_content/blocked_content_tab_helper.cc b/chrome/browser/ui/blocked_content/blocked_content_tab_helper.cc
|
| index 986d0d76874c2ff78910a7cec662ce7fd618a055..0ffce7a1853fa6337c1b23b6cc3a09e7862e9024 100644
|
| --- a/chrome/browser/ui/blocked_content/blocked_content_tab_helper.cc
|
| +++ b/chrome/browser/ui/blocked_content/blocked_content_tab_helper.cc
|
| @@ -23,11 +23,13 @@
|
|
|
| using content::NavigationEntry;
|
|
|
| -BlockedContentTabHelper::BlockedContentTabHelper(TabContents* tab_contents)
|
| - : content::WebContentsObserver(tab_contents->web_contents()),
|
| - blocked_contents_(new BlockedContentContainer(tab_contents)),
|
| +int BlockedContentTabHelper::kUserDataKey;
|
| +
|
| +BlockedContentTabHelper::BlockedContentTabHelper(
|
| + content::WebContents* web_contents)
|
| + : content::WebContentsObserver(web_contents),
|
| + blocked_contents_(new BlockedContentContainer(web_contents)),
|
| all_contents_blocked_(false),
|
| - tab_contents_(tab_contents),
|
| delegate_(NULL) {
|
| }
|
|
|
| @@ -50,15 +52,17 @@ void BlockedContentTabHelper::DidNavigateMainFrame(
|
|
|
| void BlockedContentTabHelper::PopupNotificationVisibilityChanged(
|
| bool visible) {
|
| - if (!tab_contents_->in_destructor())
|
| - tab_contents_->content_settings()->SetPopupsBlocked(visible);
|
| + if (!web_contents()->IsBeingDestroyed()) {
|
| + TabContents* tab_contents = TabContents::FromWebContents(web_contents());
|
| + tab_contents->content_settings()->SetPopupsBlocked(visible);
|
| + }
|
| }
|
|
|
| -void BlockedContentTabHelper::SendNotification(TabContents* contents,
|
| +void BlockedContentTabHelper::SendNotification(content::WebContents* contents,
|
| bool blocked_state) {
|
| content::NotificationService::current()->Notify(
|
| chrome::NOTIFICATION_CONTENT_BLOCKED_STATE_CHANGED,
|
| - content::Source<content::WebContents>(contents->web_contents()),
|
| + content::Source<content::WebContents>(contents),
|
| content::Details<const bool>(&blocked_state));
|
| }
|
|
|
| @@ -68,7 +72,7 @@ void BlockedContentTabHelper::SetAllContentsBlocked(bool value) {
|
|
|
| all_contents_blocked_ = value;
|
| if (!all_contents_blocked_ && blocked_contents_->GetBlockedContentsCount()) {
|
| - std::vector<TabContents*> blocked;
|
| + std::vector<content::WebContents*> blocked;
|
| blocked_contents_->GetBlockedContents(&blocked);
|
| for (size_t i = 0; i < blocked.size(); ++i) {
|
| SendNotification(blocked[i], false);
|
| @@ -77,18 +81,18 @@ void BlockedContentTabHelper::SetAllContentsBlocked(bool value) {
|
| }
|
| }
|
|
|
| -void BlockedContentTabHelper::AddTabContents(TabContents* new_contents,
|
| +void BlockedContentTabHelper::AddWebContents(content::WebContents* new_contents,
|
| WindowOpenDisposition disposition,
|
| const gfx::Rect& initial_pos,
|
| bool user_gesture) {
|
| if (!blocked_contents_->GetBlockedContentsCount())
|
| PopupNotificationVisibilityChanged(true);
|
| SendNotification(new_contents, true);
|
| - blocked_contents_->AddTabContents(
|
| + blocked_contents_->AddWebContents(
|
| new_contents, disposition, initial_pos, user_gesture);
|
| }
|
|
|
| -void BlockedContentTabHelper::AddPopup(TabContents* new_contents,
|
| +void BlockedContentTabHelper::AddPopup(content::WebContents* new_contents,
|
| WindowOpenDisposition disposition,
|
| const gfx::Rect& initial_pos,
|
| bool user_gesture) {
|
| @@ -114,29 +118,30 @@ void BlockedContentTabHelper::AddPopup(TabContents* new_contents,
|
| content::WebContentsDelegate* delegate = web_contents()->GetDelegate();
|
| if (delegate) {
|
| delegate->AddNewContents(web_contents(),
|
| - new_contents->web_contents(),
|
| + new_contents,
|
| disposition,
|
| initial_pos,
|
| true, // user_gesture
|
| NULL);
|
| }
|
| } else {
|
| - // Call blocked_contents_->AddTabContents with user_gesture == true
|
| + // Call blocked_contents_->AddWebContents with user_gesture == true
|
| // so that the contents will not get blocked again.
|
| SendNotification(new_contents, true);
|
| - blocked_contents_->AddTabContents(new_contents,
|
| + blocked_contents_->AddWebContents(new_contents,
|
| disposition,
|
| initial_pos,
|
| true); // user_gesture
|
| - tab_contents_->content_settings()->OnContentBlocked(
|
| + TabContents* tab_contents = TabContents::FromWebContents(web_contents());
|
| + tab_contents->content_settings()->OnContentBlocked(
|
| CONTENT_SETTINGS_TYPE_POPUPS, std::string());
|
| }
|
| }
|
|
|
| void BlockedContentTabHelper::LaunchForContents(
|
| - TabContents* tab_contents) {
|
| - SendNotification(tab_contents, false);
|
| - blocked_contents_->LaunchForContents(tab_contents);
|
| + content::WebContents* web_contents) {
|
| + SendNotification(web_contents, false);
|
| + blocked_contents_->LaunchForContents(web_contents);
|
| if (!blocked_contents_->GetBlockedContentsCount())
|
| PopupNotificationVisibilityChanged(false);
|
| }
|
| @@ -146,6 +151,6 @@ size_t BlockedContentTabHelper::GetBlockedContentsCount() const {
|
| }
|
|
|
| void BlockedContentTabHelper::GetBlockedContents(
|
| - std::vector<TabContents*>* blocked_contents) const {
|
| + std::vector<content::WebContents*>* blocked_contents) const {
|
| blocked_contents_->GetBlockedContents(blocked_contents);
|
| }
|
|
|