| 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/browser_tabstrip.h" | 5 #include "chrome/browser/ui/browser_tabstrip.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "chrome/browser/profiles/profile.h" | 8 #include "chrome/browser/profiles/profile.h" |
| 9 #include "chrome/browser/ui/blocked_content/blocked_content_tab_helper.h" | 9 #include "chrome/browser/ui/blocked_content/blocked_content_tab_helper.h" |
| 10 #include "chrome/browser/ui/browser.h" | 10 #include "chrome/browser/ui/browser.h" |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 content::WebContents* new_contents, | 99 content::WebContents* new_contents, |
| 100 WindowOpenDisposition disposition, | 100 WindowOpenDisposition disposition, |
| 101 const gfx::Rect& initial_pos, | 101 const gfx::Rect& initial_pos, |
| 102 bool user_gesture, | 102 bool user_gesture, |
| 103 bool* was_blocked) { | 103 bool* was_blocked) { |
| 104 // No code for this yet. | 104 // No code for this yet. |
| 105 DCHECK(disposition != SAVE_TO_DISK); | 105 DCHECK(disposition != SAVE_TO_DISK); |
| 106 // Can't create a new contents for the current tab - invalid case. | 106 // Can't create a new contents for the current tab - invalid case. |
| 107 DCHECK(disposition != CURRENT_TAB); | 107 DCHECK(disposition != CURRENT_TAB); |
| 108 | 108 |
| 109 TabContents* source_tab_contents = NULL; | 109 // TODO(avi): Use browser tab contents adoption here. |
| 110 BlockedContentTabHelper* source_blocked_content = NULL; | |
| 111 TabContents* new_tab_contents = TabContents::FromWebContents(new_contents); | 110 TabContents* new_tab_contents = TabContents::FromWebContents(new_contents); |
| 112 if (!new_tab_contents) { | 111 if (!new_tab_contents) { |
| 113 new_tab_contents = | 112 new_tab_contents = |
| 114 BrowserTabstripTabContentsCreator::CreateTabContents(new_contents); | 113 BrowserTabstripTabContentsCreator::CreateTabContents(new_contents); |
| 115 } | 114 } |
| 115 |
| 116 BlockedContentTabHelper* source_blocked_content = NULL; |
| 116 if (source_contents) { | 117 if (source_contents) { |
| 117 source_tab_contents = TabContents::FromWebContents(source_contents); | 118 source_blocked_content = |
| 118 source_blocked_content = source_tab_contents->blocked_content_tab_helper(); | 119 BlockedContentTabHelper::FromWebContents(source_contents); |
| 119 } | 120 } |
| 120 | 121 |
| 121 if (source_tab_contents) { | 122 if (source_contents) { |
| 122 // Handle blocking of tabs. | 123 // Handle blocking of tabs. |
| 123 if (source_blocked_content->all_contents_blocked()) { | 124 if (source_blocked_content->all_contents_blocked()) { |
| 124 source_blocked_content->AddTabContents( | 125 source_blocked_content->AddWebContents( |
| 125 new_tab_contents, disposition, initial_pos, user_gesture); | 126 new_contents, disposition, initial_pos, user_gesture); |
| 126 if (was_blocked) | 127 if (was_blocked) |
| 127 *was_blocked = true; | 128 *was_blocked = true; |
| 128 return; | 129 return; |
| 129 } | 130 } |
| 130 | 131 |
| 131 // Handle blocking of popups. | 132 // Handle blocking of popups. |
| 132 if ((disposition == NEW_POPUP || disposition == NEW_FOREGROUND_TAB) && | 133 if ((disposition == NEW_POPUP || disposition == NEW_FOREGROUND_TAB) && |
| 133 !user_gesture && | 134 !user_gesture && |
| 134 !CommandLine::ForCurrentProcess()->HasSwitch( | 135 !CommandLine::ForCurrentProcess()->HasSwitch( |
| 135 switches::kDisablePopupBlocking)) { | 136 switches::kDisablePopupBlocking)) { |
| 136 // Unrequested popups from normal pages are constrained unless they're in | 137 // Unrequested popups from normal pages are constrained unless they're in |
| 137 // the white list. The popup owner will handle checking this. | 138 // the white list. The popup owner will handle checking this. |
| 138 source_blocked_content->AddPopup( | 139 source_blocked_content->AddPopup( |
| 139 new_tab_contents, disposition, initial_pos, user_gesture); | 140 new_contents, disposition, initial_pos, user_gesture); |
| 140 if (was_blocked) | 141 if (was_blocked) |
| 141 *was_blocked = true; | 142 *was_blocked = true; |
| 142 return; | 143 return; |
| 143 } | 144 } |
| 144 | 145 |
| 145 new_contents->GetRenderViewHost()->DisassociateFromPopupCount(); | 146 new_contents->GetRenderViewHost()->DisassociateFromPopupCount(); |
| 146 } | 147 } |
| 147 | 148 |
| 148 NavigateParams params(browser, new_tab_contents); | 149 NavigateParams params(browser, new_tab_contents); |
| 149 params.source_contents = source_contents ? | 150 params.source_contents = source_contents ? |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 191 return BrowserTabstripTabContentsCreator::CreateTabContents( | 192 return BrowserTabstripTabContentsCreator::CreateTabContents( |
| 192 content::WebContents::CreateWithSessionStorage( | 193 content::WebContents::CreateWithSessionStorage( |
| 193 profile, | 194 profile, |
| 194 site_instance, | 195 site_instance, |
| 195 routing_id, | 196 routing_id, |
| 196 base_web_contents, | 197 base_web_contents, |
| 197 session_storage_namespace_map)); | 198 session_storage_namespace_map)); |
| 198 } | 199 } |
| 199 | 200 |
| 200 } // namespace chrome | 201 } // namespace chrome |
| OLD | NEW |