| 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 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 content::PageTransition type) { | 92 content::PageTransition type) { |
| 93 browser->tab_strip_model()->AddTabContents(tab_contents, -1, type, | 93 browser->tab_strip_model()->AddTabContents(tab_contents, -1, type, |
| 94 TabStripModel::ADD_ACTIVE); | 94 TabStripModel::ADD_ACTIVE); |
| 95 } | 95 } |
| 96 | 96 |
| 97 void AddWebContents(Browser* browser, | 97 void AddWebContents(Browser* browser, |
| 98 content::WebContents* source_contents, | 98 content::WebContents* source_contents, |
| 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 // No code for this yet. | 104 // No code for this yet. |
| 104 DCHECK(disposition != SAVE_TO_DISK); | 105 DCHECK(disposition != SAVE_TO_DISK); |
| 105 // 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. |
| 106 DCHECK(disposition != CURRENT_TAB); | 107 DCHECK(disposition != CURRENT_TAB); |
| 107 | 108 |
| 108 TabContents* source_tab_contents = NULL; | 109 TabContents* source_tab_contents = NULL; |
| 109 BlockedContentTabHelper* source_blocked_content = NULL; | 110 BlockedContentTabHelper* source_blocked_content = NULL; |
| 110 TabContents* new_tab_contents = TabContents::FromWebContents(new_contents); | 111 TabContents* new_tab_contents = TabContents::FromWebContents(new_contents); |
| 111 if (!new_tab_contents) { | 112 if (!new_tab_contents) { |
| 112 new_tab_contents = | 113 new_tab_contents = |
| 113 BrowserTabstripTabContentsCreator::CreateTabContents(new_contents); | 114 BrowserTabstripTabContentsCreator::CreateTabContents(new_contents); |
| 114 } | 115 } |
| 115 if (source_contents) { | 116 if (source_contents) { |
| 116 source_tab_contents = TabContents::FromWebContents(source_contents); | 117 source_tab_contents = TabContents::FromWebContents(source_contents); |
| 117 source_blocked_content = source_tab_contents->blocked_content_tab_helper(); | 118 source_blocked_content = source_tab_contents->blocked_content_tab_helper(); |
| 118 } | 119 } |
| 119 | 120 |
| 120 if (source_tab_contents) { | 121 if (source_tab_contents) { |
| 121 // Handle blocking of all contents. | 122 // Handle blocking of tabs. |
| 122 if (source_blocked_content->all_contents_blocked()) { | 123 if (source_blocked_content->all_contents_blocked()) { |
| 123 source_blocked_content->AddTabContents(new_tab_contents, | 124 source_blocked_content->AddTabContents( |
| 124 disposition, | 125 new_tab_contents, disposition, initial_pos, user_gesture); |
| 125 initial_pos, | 126 if (was_blocked) |
| 126 user_gesture); | 127 *was_blocked = true; |
| 127 return; | 128 return; |
| 128 } | 129 } |
| 129 | 130 |
| 130 // Handle blocking of popups. | 131 // Handle blocking of popups. |
| 131 if ((disposition == NEW_POPUP) && !user_gesture && | 132 if ((disposition == NEW_POPUP || disposition == NEW_FOREGROUND_TAB) && |
| 133 !user_gesture && |
| 132 !CommandLine::ForCurrentProcess()->HasSwitch( | 134 !CommandLine::ForCurrentProcess()->HasSwitch( |
| 133 switches::kDisablePopupBlocking)) { | 135 switches::kDisablePopupBlocking)) { |
| 134 // Unrequested popups from normal pages are constrained unless they're in | 136 // Unrequested popups from normal pages are constrained unless they're in |
| 135 // the white list. The popup owner will handle checking this. | 137 // the white list. The popup owner will handle checking this. |
| 136 source_tab_contents->blocked_content_tab_helper()-> | 138 source_blocked_content->AddPopup( |
| 137 AddPopup(new_tab_contents, initial_pos, user_gesture); | 139 new_tab_contents, disposition, initial_pos, user_gesture); |
| 140 if (was_blocked) |
| 141 *was_blocked = true; |
| 138 return; | 142 return; |
| 139 } | 143 } |
| 140 | 144 |
| 141 new_contents->GetRenderViewHost()->DisassociateFromPopupCount(); | 145 new_contents->GetRenderViewHost()->DisassociateFromPopupCount(); |
| 142 } | 146 } |
| 143 | 147 |
| 144 NavigateParams params(browser, new_tab_contents); | 148 NavigateParams params(browser, new_tab_contents); |
| 145 params.source_contents = source_contents ? | 149 params.source_contents = source_contents ? |
| 146 GetTabContentsAt(browser, GetIndexOfTab(browser, source_contents)) : NULL; | 150 GetTabContentsAt(browser, GetIndexOfTab(browser, source_contents)) : NULL; |
| 147 params.disposition = disposition; | 151 params.disposition = disposition; |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 187 return BrowserTabstripTabContentsCreator::CreateTabContents( | 191 return BrowserTabstripTabContentsCreator::CreateTabContents( |
| 188 content::WebContents::CreateWithSessionStorage( | 192 content::WebContents::CreateWithSessionStorage( |
| 189 profile, | 193 profile, |
| 190 site_instance, | 194 site_instance, |
| 191 routing_id, | 195 routing_id, |
| 192 base_web_contents, | 196 base_web_contents, |
| 193 session_storage_namespace_map)); | 197 session_storage_namespace_map)); |
| 194 } | 198 } |
| 195 | 199 |
| 196 } // namespace chrome | 200 } // namespace chrome |
| OLD | NEW |