| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/ui/blocked_content/blocked_content_container.h" | 5 #include "chrome/browser/ui/blocked_content/blocked_content_container.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "chrome/browser/ui/blocked_content/blocked_content_tab_helper.h" | 8 #include "chrome/browser/ui/blocked_content/blocked_content_tab_helper.h" |
| 9 #include "chrome/browser/ui/tab_contents/tab_contents.h" | 9 #include "chrome/browser/ui/tab_contents/tab_contents.h" |
| 10 #include "content/public/browser/web_contents.h" | 10 #include "content/public/browser/web_contents.h" |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 if (i->tab_contents == tab_contents) { | 68 if (i->tab_contents == tab_contents) { |
| 69 // To support the owner blocking the content again we copy and erase | 69 // To support the owner blocking the content again we copy and erase |
| 70 // before attempting to add. | 70 // before attempting to add. |
| 71 BlockedContent content(*i); | 71 BlockedContent content(*i); |
| 72 blocked_contents_.erase(i); | 72 blocked_contents_.erase(i); |
| 73 i = blocked_contents_.end(); | 73 i = blocked_contents_.end(); |
| 74 tab_contents->web_contents()->SetDelegate(NULL); | 74 tab_contents->web_contents()->SetDelegate(NULL); |
| 75 tab_contents->blocked_content_tab_helper()->set_delegate(NULL); | 75 tab_contents->blocked_content_tab_helper()->set_delegate(NULL); |
| 76 // We needn't call WasShown to change its status because the | 76 // We needn't call WasShown to change its status because the |
| 77 // WebContents::AddNewContents will do it. | 77 // WebContents::AddNewContents will do it. |
| 78 owner_->web_contents()->AddNewContents( | 78 WebContentsDelegate* delegate = owner_->web_contents()->GetDelegate(); |
| 79 tab_contents->web_contents(), | 79 if (delegate) { |
| 80 content.disposition, | 80 delegate->AddNewContents(owner_->web_contents(), |
| 81 content.bounds, | 81 tab_contents->web_contents(), |
| 82 content.user_gesture); | 82 content.disposition, |
| 83 content.bounds, |
| 84 content.user_gesture, |
| 85 NULL); |
| 86 } |
| 83 break; | 87 break; |
| 84 } | 88 } |
| 85 } | 89 } |
| 86 } | 90 } |
| 87 | 91 |
| 88 size_t BlockedContentContainer::GetBlockedContentsCount() const { | 92 size_t BlockedContentContainer::GetBlockedContentsCount() const { |
| 89 return blocked_contents_.size(); | 93 return blocked_contents_.size(); |
| 90 } | 94 } |
| 91 | 95 |
| 92 void BlockedContentContainer::GetBlockedContents( | 96 void BlockedContentContainer::GetBlockedContents( |
| (...skipping 20 matching lines...) Expand all Loading... |
| 113 WebContents* BlockedContentContainer::OpenURLFromTab( | 117 WebContents* BlockedContentContainer::OpenURLFromTab( |
| 114 WebContents* source, | 118 WebContents* source, |
| 115 const OpenURLParams& params) { | 119 const OpenURLParams& params) { |
| 116 return owner_->web_contents()->OpenURL(params); | 120 return owner_->web_contents()->OpenURL(params); |
| 117 } | 121 } |
| 118 | 122 |
| 119 void BlockedContentContainer::AddNewContents(WebContents* source, | 123 void BlockedContentContainer::AddNewContents(WebContents* source, |
| 120 WebContents* new_contents, | 124 WebContents* new_contents, |
| 121 WindowOpenDisposition disposition, | 125 WindowOpenDisposition disposition, |
| 122 const gfx::Rect& initial_position, | 126 const gfx::Rect& initial_position, |
| 123 bool user_gesture) { | 127 bool user_gesture, |
| 124 owner_->web_contents()->AddNewContents( | 128 bool* was_blocked) { |
| 125 new_contents, disposition, initial_position, user_gesture); | 129 WebContentsDelegate* delegate = owner_->web_contents()->GetDelegate(); |
| 130 if (delegate) { |
| 131 delegate->AddNewContents(owner_->web_contents(), new_contents, disposition, |
| 132 initial_position, user_gesture, was_blocked); |
| 133 } |
| 126 } | 134 } |
| 127 | 135 |
| 128 void BlockedContentContainer::CloseContents(WebContents* source) { | 136 void BlockedContentContainer::CloseContents(WebContents* source) { |
| 129 for (BlockedContents::iterator i(blocked_contents_.begin()); | 137 for (BlockedContents::iterator i(blocked_contents_.begin()); |
| 130 i != blocked_contents_.end(); ++i) { | 138 i != blocked_contents_.end(); ++i) { |
| 131 TabContents* tab_contents = i->tab_contents; | 139 TabContents* tab_contents = i->tab_contents; |
| 132 if (tab_contents->web_contents() == source) { | 140 if (tab_contents->web_contents() == source) { |
| 133 tab_contents->web_contents()->SetDelegate(NULL); | 141 tab_contents->web_contents()->SetDelegate(NULL); |
| 134 tab_contents->blocked_content_tab_helper()->set_delegate(NULL); | 142 tab_contents->blocked_content_tab_helper()->set_delegate(NULL); |
| 135 blocked_contents_.erase(i); | 143 blocked_contents_.erase(i); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 160 bool BlockedContentContainer::ShouldSuppressDialogs() { | 168 bool BlockedContentContainer::ShouldSuppressDialogs() { |
| 161 // Suppress JavaScript dialogs when inside a constrained popup window (because | 169 // Suppress JavaScript dialogs when inside a constrained popup window (because |
| 162 // that activates them and breaks them out of the constrained window jail). | 170 // that activates them and breaks them out of the constrained window jail). |
| 163 return true; | 171 return true; |
| 164 } | 172 } |
| 165 | 173 |
| 166 TabContents* BlockedContentContainer::GetConstrainingTabContents( | 174 TabContents* BlockedContentContainer::GetConstrainingTabContents( |
| 167 TabContents* source) { | 175 TabContents* source) { |
| 168 return owner_; | 176 return owner_; |
| 169 } | 177 } |
| OLD | NEW |