| 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/tab_contents/tab_contents.h" | 5 #include "chrome/browser/ui/tab_contents/tab_contents.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/lazy_instance.h" | 8 #include "base/lazy_instance.h" |
| 9 #include "chrome/browser/autofill/autocomplete_history_manager.h" | 9 #include "chrome/browser/autofill/autocomplete_history_manager.h" |
| 10 #include "chrome/browser/autofill/autofill_external_delegate.h" | 10 #include "chrome/browser/autofill/autofill_external_delegate.h" |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 131 blocked_content_tab_helper_.reset(new BlockedContentTabHelper(this)); | 131 blocked_content_tab_helper_.reset(new BlockedContentTabHelper(this)); |
| 132 bookmark_tab_helper_.reset(new BookmarkTabHelper(this)); | 132 bookmark_tab_helper_.reset(new BookmarkTabHelper(this)); |
| 133 load_time_stats_tab_helper_.reset( | 133 load_time_stats_tab_helper_.reset( |
| 134 new chrome_browser_net::LoadTimeStatsTabHelper(this)); | 134 new chrome_browser_net::LoadTimeStatsTabHelper(this)); |
| 135 #if defined(ENABLE_CAPTIVE_PORTAL_DETECTION) | 135 #if defined(ENABLE_CAPTIVE_PORTAL_DETECTION) |
| 136 captive_portal_tab_helper_.reset( | 136 captive_portal_tab_helper_.reset( |
| 137 new captive_portal::CaptivePortalTabHelper(profile(), web_contents())); | 137 new captive_portal::CaptivePortalTabHelper(profile(), web_contents())); |
| 138 #endif | 138 #endif |
| 139 constrained_window_tab_helper_.reset(new ConstrainedWindowTabHelper(this)); | 139 constrained_window_tab_helper_.reset(new ConstrainedWindowTabHelper(this)); |
| 140 core_tab_helper_.reset(new CoreTabHelper(contents)); | 140 core_tab_helper_.reset(new CoreTabHelper(contents)); |
| 141 extension_tab_helper_.reset(new extensions::TabHelper(this)); | 141 extensions::TabHelper::CreateForWebContents(contents); |
| 142 favicon_tab_helper_.reset(new FaviconTabHelper(contents)); | 142 favicon_tab_helper_.reset(new FaviconTabHelper(contents)); |
| 143 find_tab_helper_.reset(new FindTabHelper(contents)); | 143 find_tab_helper_.reset(new FindTabHelper(contents)); |
| 144 history_tab_helper_.reset(new HistoryTabHelper(contents)); | 144 history_tab_helper_.reset(new HistoryTabHelper(contents)); |
| 145 hung_plugin_tab_helper_.reset(new HungPluginTabHelper(contents)); | 145 hung_plugin_tab_helper_.reset(new HungPluginTabHelper(contents)); |
| 146 infobar_tab_helper_.reset(new InfoBarTabHelper(contents)); | 146 infobar_tab_helper_.reset(new InfoBarTabHelper(contents)); |
| 147 MetroPinTabHelper::CreateForWebContents(contents); | 147 MetroPinTabHelper::CreateForWebContents(contents); |
| 148 password_manager_delegate_.reset(new PasswordManagerDelegateImpl(this)); | 148 password_manager_delegate_.reset(new PasswordManagerDelegateImpl(this)); |
| 149 password_manager_.reset( | 149 password_manager_.reset( |
| 150 new PasswordManager(contents, password_manager_delegate_.get())); | 150 new PasswordManager(contents, password_manager_delegate_.get())); |
| 151 prefs_tab_helper_.reset(new PrefsTabHelper(contents)); | 151 prefs_tab_helper_.reset(new PrefsTabHelper(contents)); |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 215 content::Source<TabContents>(this), | 215 content::Source<TabContents>(this), |
| 216 content::NotificationService::NoDetails()); | 216 content::NotificationService::NoDetails()); |
| 217 | 217 |
| 218 // Need to tear down infobars before the WebContents goes away. | 218 // Need to tear down infobars before the WebContents goes away. |
| 219 // TODO(avi): Can we get this handled by the tab helper itself? | 219 // TODO(avi): Can we get this handled by the tab helper itself? |
| 220 infobar_tab_helper_.reset(); | 220 infobar_tab_helper_.reset(); |
| 221 } | 221 } |
| 222 | 222 |
| 223 TabContents* TabContents::Clone() { | 223 TabContents* TabContents::Clone() { |
| 224 WebContents* new_web_contents = web_contents()->Clone(); | 224 WebContents* new_web_contents = web_contents()->Clone(); |
| 225 TabContents* new_tab_contents = new TabContents(new_web_contents); | 225 return new TabContents(new_web_contents); |
| 226 | |
| 227 // TODO(avi): Can we generalize this so that knowledge of the functionings of | |
| 228 // the tab helpers isn't required here? | |
| 229 new_tab_contents->extension_tab_helper()->CopyStateFrom( | |
| 230 *extension_tab_helper_.get()); | |
| 231 return new_tab_contents; | |
| 232 } | 226 } |
| 233 | 227 |
| 234 // static | 228 // static |
| 235 TabContents* TabContents::FromWebContents(WebContents* contents) { | 229 TabContents* TabContents::FromWebContents(WebContents* contents) { |
| 236 TabContentsUserData* user_data = static_cast<TabContentsUserData*>( | 230 TabContentsUserData* user_data = static_cast<TabContentsUserData*>( |
| 237 contents->GetUserData(&kTabContentsUserDataKey)); | 231 contents->GetUserData(&kTabContentsUserDataKey)); |
| 238 | 232 |
| 239 return user_data ? user_data->tab_contents() : NULL; | 233 return user_data ? user_data->tab_contents() : NULL; |
| 240 } | 234 } |
| 241 | 235 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 257 | 251 |
| 258 //////////////////////////////////////////////////////////////////////////////// | 252 //////////////////////////////////////////////////////////////////////////////// |
| 259 // WebContentsObserver overrides | 253 // WebContentsObserver overrides |
| 260 | 254 |
| 261 void TabContents::WebContentsDestroyed(WebContents* tab) { | 255 void TabContents::WebContentsDestroyed(WebContents* tab) { |
| 262 // Destruction of the WebContents should only be done by us from our | 256 // Destruction of the WebContents should only be done by us from our |
| 263 // destructor. Otherwise it's very likely we (or one of the helpers we own) | 257 // destructor. Otherwise it's very likely we (or one of the helpers we own) |
| 264 // will attempt to access the WebContents and we'll crash. | 258 // will attempt to access the WebContents and we'll crash. |
| 265 DCHECK(in_destructor_); | 259 DCHECK(in_destructor_); |
| 266 } | 260 } |
| OLD | NEW |