| 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/autocomplete_history_manager.h" | 9 #include "chrome/browser/autocomplete_history_manager.h" |
| 10 #include "chrome/browser/autofill/autofill_external_delegate.h" | 10 #include "chrome/browser/autofill/autofill_external_delegate.h" |
| (...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 201 WebContents* new_web_contents = web_contents()->Clone(); | 201 WebContents* new_web_contents = web_contents()->Clone(); |
| 202 TabContents* new_tab_contents = new TabContents(new_web_contents); | 202 TabContents* new_tab_contents = new TabContents(new_web_contents); |
| 203 | 203 |
| 204 // TODO(avi): Can we generalize this so that knowledge of the functionings of | 204 // TODO(avi): Can we generalize this so that knowledge of the functionings of |
| 205 // the tab helpers isn't required here? | 205 // the tab helpers isn't required here? |
| 206 new_tab_contents->extension_tab_helper()->CopyStateFrom( | 206 new_tab_contents->extension_tab_helper()->CopyStateFrom( |
| 207 *extension_tab_helper_.get()); | 207 *extension_tab_helper_.get()); |
| 208 return new_tab_contents; | 208 return new_tab_contents; |
| 209 } | 209 } |
| 210 | 210 |
| 211 // static deprecated | |
| 212 TabContents* TabContents::GetCurrentWrapperForContents( | |
| 213 WebContents* contents) { | |
| 214 return FromWebContents(contents); | |
| 215 } | |
| 216 | |
| 217 // static deprecated | |
| 218 const TabContents* TabContents::GetCurrentWrapperForContents( | |
| 219 const WebContents* contents) { | |
| 220 return FromWebContents(contents); | |
| 221 } | |
| 222 | |
| 223 // static | 211 // static |
| 224 TabContents* TabContents::FromWebContents(WebContents* contents) { | 212 TabContents* TabContents::FromWebContents(WebContents* contents) { |
| 225 TabContents** tab_contents = | 213 TabContents** tab_contents = |
| 226 property_accessor()->GetProperty(contents->GetPropertyBag()); | 214 property_accessor()->GetProperty(contents->GetPropertyBag()); |
| 227 | 215 |
| 228 return tab_contents ? *tab_contents : NULL; | 216 return tab_contents ? *tab_contents : NULL; |
| 229 } | 217 } |
| 230 | 218 |
| 231 // static | 219 // static |
| 232 const TabContents* TabContents::FromWebContents(const WebContents* contents) { | 220 const TabContents* TabContents::FromWebContents(const WebContents* contents) { |
| (...skipping 13 matching lines...) Expand all Loading... |
| 246 | 234 |
| 247 //////////////////////////////////////////////////////////////////////////////// | 235 //////////////////////////////////////////////////////////////////////////////// |
| 248 // WebContentsObserver overrides | 236 // WebContentsObserver overrides |
| 249 | 237 |
| 250 void TabContents::WebContentsDestroyed(WebContents* tab) { | 238 void TabContents::WebContentsDestroyed(WebContents* tab) { |
| 251 // Destruction of the WebContents should only be done by us from our | 239 // Destruction of the WebContents should only be done by us from our |
| 252 // destructor. Otherwise it's very likely we (or one of the helpers we own) | 240 // destructor. Otherwise it's very likely we (or one of the helpers we own) |
| 253 // will attempt to access the WebContents and we'll crash. | 241 // will attempt to access the WebContents and we'll crash. |
| 254 DCHECK(in_destructor_); | 242 DCHECK(in_destructor_); |
| 255 } | 243 } |
| OLD | NEW |