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_wrapper.h" | 5 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.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 27 matching lines...) Expand all Loading... |
38 #include "chrome/browser/ui/hung_plugin_tab_helper.h" | 38 #include "chrome/browser/ui/hung_plugin_tab_helper.h" |
39 #include "chrome/browser/ui/intents/web_intent_picker_controller.h" | 39 #include "chrome/browser/ui/intents/web_intent_picker_controller.h" |
40 #include "chrome/browser/ui/pdf/pdf_tab_observer.h" | 40 #include "chrome/browser/ui/pdf/pdf_tab_observer.h" |
41 #include "chrome/browser/ui/prefs/prefs_tab_helper.h" | 41 #include "chrome/browser/ui/prefs/prefs_tab_helper.h" |
42 #include "chrome/browser/ui/sad_tab_helper.h" | 42 #include "chrome/browser/ui/sad_tab_helper.h" |
43 #include "chrome/browser/ui/search_engines/search_engine_tab_helper.h" | 43 #include "chrome/browser/ui/search_engines/search_engine_tab_helper.h" |
44 #include "chrome/browser/ui/snapshot_tab_helper.h" | 44 #include "chrome/browser/ui/snapshot_tab_helper.h" |
45 #include "chrome/browser/ui/sync/one_click_signin_helper.h" | 45 #include "chrome/browser/ui/sync/one_click_signin_helper.h" |
46 #include "chrome/browser/ui/sync/tab_contents_wrapper_synced_tab_delegate.h" | 46 #include "chrome/browser/ui/sync/tab_contents_wrapper_synced_tab_delegate.h" |
47 #include "chrome/browser/ui/tab_contents/core_tab_helper.h" | 47 #include "chrome/browser/ui/tab_contents/core_tab_helper.h" |
| 48 #include "chrome/browser/view_type_utils.h" |
48 #include "chrome/common/chrome_switches.h" | 49 #include "chrome/common/chrome_switches.h" |
49 #include "chrome/common/chrome_view_type.h" | |
50 #include "content/public/browser/web_contents.h" | 50 #include "content/public/browser/web_contents.h" |
51 | 51 |
52 using content::WebContents; | 52 using content::WebContents; |
53 | 53 |
54 namespace { | 54 namespace { |
55 | 55 |
56 static base::LazyInstance<base::PropertyAccessor<TabContentsWrapper*> > | 56 static base::LazyInstance<base::PropertyAccessor<TabContentsWrapper*> > |
57 g_tab_contents_wrapper_property_accessor = LAZY_INSTANCE_INITIALIZER; | 57 g_tab_contents_wrapper_property_accessor = LAZY_INSTANCE_INITIALIZER; |
58 | 58 |
59 } // namespace | 59 } // namespace |
60 | 60 |
61 //////////////////////////////////////////////////////////////////////////////// | 61 //////////////////////////////////////////////////////////////////////////////// |
62 // TabContentsWrapper, public: | 62 // TabContentsWrapper, public: |
63 | 63 |
64 TabContentsWrapper::TabContentsWrapper(WebContents* contents) | 64 TabContentsWrapper::TabContentsWrapper(WebContents* contents) |
65 : content::WebContentsObserver(contents), | 65 : content::WebContentsObserver(contents), |
66 in_destructor_(false), | 66 in_destructor_(false), |
67 web_contents_(contents) { | 67 web_contents_(contents) { |
68 DCHECK(contents); | 68 DCHECK(contents); |
69 DCHECK(!GetCurrentWrapperForContents(contents)); | 69 DCHECK(!GetCurrentWrapperForContents(contents)); |
70 | 70 |
71 web_contents_->SetViewType(chrome::VIEW_TYPE_TAB_CONTENTS); | 71 chrome::SetViewType(contents, chrome::VIEW_TYPE_TAB_CONTENTS); |
72 | 72 |
73 // Stash this in the property bag so it can be retrieved without having to | 73 // Stash this in the property bag so it can be retrieved without having to |
74 // go to a Browser. | 74 // go to a Browser. |
75 property_accessor()->SetProperty(contents->GetPropertyBag(), this); | 75 property_accessor()->SetProperty(contents->GetPropertyBag(), this); |
76 | 76 |
77 // Create the tab helpers. | 77 // Create the tab helpers. |
78 autocomplete_history_manager_.reset(new AutocompleteHistoryManager(contents)); | 78 autocomplete_history_manager_.reset(new AutocompleteHistoryManager(contents)); |
79 autofill_manager_ = new AutofillManager(this); | 79 autofill_manager_ = new AutofillManager(this); |
80 if (CommandLine::ForCurrentProcess()->HasSwitch( | 80 if (CommandLine::ForCurrentProcess()->HasSwitch( |
81 switches::kExternalAutofillPopup)) { | 81 switches::kExternalAutofillPopup)) { |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
206 | 206 |
207 //////////////////////////////////////////////////////////////////////////////// | 207 //////////////////////////////////////////////////////////////////////////////// |
208 // WebContentsObserver overrides | 208 // WebContentsObserver overrides |
209 | 209 |
210 void TabContentsWrapper::WebContentsDestroyed(WebContents* tab) { | 210 void TabContentsWrapper::WebContentsDestroyed(WebContents* tab) { |
211 // Destruction of the WebContents should only be done by us from our | 211 // Destruction of the WebContents should only be done by us from our |
212 // destructor. Otherwise it's very likely we (or one of the helpers we own) | 212 // destructor. Otherwise it's very likely we (or one of the helpers we own) |
213 // will attempt to access the WebContents and we'll crash. | 213 // will attempt to access the WebContents and we'll crash. |
214 DCHECK(in_destructor_); | 214 DCHECK(in_destructor_); |
215 } | 215 } |
OLD | NEW |