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 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
66 } // namespace | 66 } // namespace |
67 | 67 |
68 //////////////////////////////////////////////////////////////////////////////// | 68 //////////////////////////////////////////////////////////////////////////////// |
69 // TabContents, public: | 69 // TabContents, public: |
70 | 70 |
71 TabContents::TabContents(WebContents* contents) | 71 TabContents::TabContents(WebContents* contents) |
72 : content::WebContentsObserver(contents), | 72 : content::WebContentsObserver(contents), |
73 in_destructor_(false), | 73 in_destructor_(false), |
74 web_contents_(contents) { | 74 web_contents_(contents) { |
75 DCHECK(contents); | 75 DCHECK(contents); |
76 DCHECK(!GetOwningTabContentsForWebContents(contents)); | 76 DCHECK(!FromWebContents(contents)); |
77 | 77 |
78 chrome::SetViewType(contents, chrome::VIEW_TYPE_TAB_CONTENTS); | 78 chrome::SetViewType(contents, chrome::VIEW_TYPE_TAB_CONTENTS); |
79 | 79 |
80 // Stash this in the property bag so it can be retrieved without having to | 80 // Stash this in the property bag so it can be retrieved without having to |
81 // go to a Browser. | 81 // go to a Browser. |
82 property_accessor()->SetProperty(contents->GetPropertyBag(), this); | 82 property_accessor()->SetProperty(contents->GetPropertyBag(), this); |
83 | 83 |
84 // Create the tab helpers. | 84 // Create the tab helpers. |
85 autocomplete_history_manager_.reset(new AutocompleteHistoryManager(contents)); | 85 autocomplete_history_manager_.reset(new AutocompleteHistoryManager(contents)); |
86 autofill_manager_ = new AutofillManager(this); | 86 autofill_manager_ = new AutofillManager(this); |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
213 WebContents* contents) { | 213 WebContents* contents) { |
214 return FromWebContents(contents); | 214 return FromWebContents(contents); |
215 } | 215 } |
216 | 216 |
217 // static deprecated | 217 // static deprecated |
218 const TabContents* TabContents::GetCurrentWrapperForContents( | 218 const TabContents* TabContents::GetCurrentWrapperForContents( |
219 const WebContents* contents) { | 219 const WebContents* contents) { |
220 return FromWebContents(contents); | 220 return FromWebContents(contents); |
221 } | 221 } |
222 | 222 |
223 // static deprecated | |
224 TabContents* TabContents::GetOwningTabContentsForWebContents( | |
225 WebContents* contents) { | |
226 return FromWebContents(contents); | |
227 } | |
228 | |
229 // static deprecated | |
230 const TabContents* TabContents::GetOwningTabContentsForWebContents( | |
231 const WebContents* contents) { | |
232 return FromWebContents(contents); | |
233 } | |
234 | |
235 // static | 223 // static |
236 TabContents* TabContents::FromWebContents(WebContents* contents) { | 224 TabContents* TabContents::FromWebContents(WebContents* contents) { |
237 TabContents** tab_contents = | 225 TabContents** tab_contents = |
238 property_accessor()->GetProperty(contents->GetPropertyBag()); | 226 property_accessor()->GetProperty(contents->GetPropertyBag()); |
239 | 227 |
240 return tab_contents ? *tab_contents : NULL; | 228 return tab_contents ? *tab_contents : NULL; |
241 } | 229 } |
242 | 230 |
243 // static | 231 // static |
244 const TabContents* TabContents::FromWebContents(const WebContents* contents) { | 232 const TabContents* TabContents::FromWebContents(const WebContents* contents) { |
(...skipping 13 matching lines...) Expand all Loading... |
258 | 246 |
259 //////////////////////////////////////////////////////////////////////////////// | 247 //////////////////////////////////////////////////////////////////////////////// |
260 // WebContentsObserver overrides | 248 // WebContentsObserver overrides |
261 | 249 |
262 void TabContents::WebContentsDestroyed(WebContents* tab) { | 250 void TabContents::WebContentsDestroyed(WebContents* tab) { |
263 // Destruction of the WebContents should only be done by us from our | 251 // Destruction of the WebContents should only be done by us from our |
264 // destructor. Otherwise it's very likely we (or one of the helpers we own) | 252 // destructor. Otherwise it's very likely we (or one of the helpers we own) |
265 // will attempt to access the WebContents and we'll crash. | 253 // will attempt to access the WebContents and we'll crash. |
266 DCHECK(in_destructor_); | 254 DCHECK(in_destructor_); |
267 } | 255 } |
OLD | NEW |