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/autofill_external_delegate.h" | 9 #include "chrome/browser/autofill/autofill_external_delegate.h" |
10 #include "chrome/browser/autofill/autofill_manager.h" | 10 #include "chrome/browser/autofill/autofill_manager.h" |
(...skipping 21 matching lines...) Expand all Loading... |
32 #include "chrome/browser/thumbnails/thumbnail_tab_helper.h" | 32 #include "chrome/browser/thumbnails/thumbnail_tab_helper.h" |
33 #include "chrome/browser/translate/translate_tab_helper.h" | 33 #include "chrome/browser/translate/translate_tab_helper.h" |
34 #include "chrome/browser/ui/alternate_error_tab_observer.h" | 34 #include "chrome/browser/ui/alternate_error_tab_observer.h" |
35 #include "chrome/browser/ui/autofill/tab_autofill_manager_delegate.h" | 35 #include "chrome/browser/ui/autofill/tab_autofill_manager_delegate.h" |
36 #include "chrome/browser/ui/blocked_content/blocked_content_tab_helper.h" | 36 #include "chrome/browser/ui/blocked_content/blocked_content_tab_helper.h" |
37 #include "chrome/browser/ui/bookmarks/bookmark_tab_helper.h" | 37 #include "chrome/browser/ui/bookmarks/bookmark_tab_helper.h" |
38 #include "chrome/browser/ui/constrained_window_tab_helper.h" | 38 #include "chrome/browser/ui/constrained_window_tab_helper.h" |
39 #include "chrome/browser/ui/find_bar/find_tab_helper.h" | 39 #include "chrome/browser/ui/find_bar/find_tab_helper.h" |
40 #include "chrome/browser/ui/hung_plugin_tab_helper.h" | 40 #include "chrome/browser/ui/hung_plugin_tab_helper.h" |
41 #include "chrome/browser/ui/intents/web_intent_picker_controller.h" | 41 #include "chrome/browser/ui/intents/web_intent_picker_controller.h" |
42 #include "chrome/browser/ui/metro_pin_tab_helper.h" | |
43 #include "chrome/browser/ui/pdf/pdf_tab_helper.h" | 42 #include "chrome/browser/ui/pdf/pdf_tab_helper.h" |
44 #include "chrome/browser/ui/prefs/prefs_tab_helper.h" | 43 #include "chrome/browser/ui/prefs/prefs_tab_helper.h" |
45 #include "chrome/browser/ui/sad_tab_helper.h" | 44 #include "chrome/browser/ui/sad_tab_helper.h" |
46 #include "chrome/browser/ui/search/search_tab_helper.h" | 45 #include "chrome/browser/ui/search/search_tab_helper.h" |
47 #include "chrome/browser/ui/search_engines/search_engine_tab_helper.h" | 46 #include "chrome/browser/ui/search_engines/search_engine_tab_helper.h" |
48 #include "chrome/browser/ui/snapshot_tab_helper.h" | 47 #include "chrome/browser/ui/snapshot_tab_helper.h" |
49 #include "chrome/browser/ui/sync/one_click_signin_helper.h" | 48 #include "chrome/browser/ui/sync/one_click_signin_helper.h" |
50 #include "chrome/browser/ui/sync/tab_contents_synced_tab_delegate.h" | 49 #include "chrome/browser/ui/sync/tab_contents_synced_tab_delegate.h" |
51 #include "chrome/browser/ui/tab_contents/core_tab_helper.h" | 50 #include "chrome/browser/ui/tab_contents/core_tab_helper.h" |
52 #include "chrome/browser/ui/zoom/zoom_controller.h" | 51 #include "chrome/browser/ui/zoom/zoom_controller.h" |
53 #include "chrome/browser/view_type_utils.h" | 52 #include "chrome/browser/view_type_utils.h" |
54 #include "chrome/common/chrome_notification_types.h" | 53 #include "chrome/common/chrome_notification_types.h" |
55 #include "chrome/common/chrome_switches.h" | 54 #include "chrome/common/chrome_switches.h" |
56 #include "content/public/browser/notification_service.h" | 55 #include "content/public/browser/notification_service.h" |
57 #include "content/public/browser/web_contents.h" | 56 #include "content/public/browser/web_contents.h" |
58 | 57 |
59 #if defined(ENABLE_CAPTIVE_PORTAL_DETECTION) | 58 #if defined(ENABLE_CAPTIVE_PORTAL_DETECTION) |
60 #include "chrome/browser/captive_portal/captive_portal_tab_helper.h" | 59 #include "chrome/browser/captive_portal/captive_portal_tab_helper.h" |
61 #endif | 60 #endif |
62 | 61 |
| 62 #if defined(OS_WIN) |
| 63 #include "chrome/browser/ui/metro_pin_tab_helper_win.h" |
| 64 #endif |
| 65 |
63 using content::WebContents; | 66 using content::WebContents; |
64 | 67 |
65 namespace { | 68 namespace { |
66 | 69 |
67 const char kTabContentsUserDataKey[] = "TabContentsUserData"; | 70 const char kTabContentsUserDataKey[] = "TabContentsUserData"; |
68 | 71 |
69 class TabContentsUserData : public base::SupportsUserData::Data { | 72 class TabContentsUserData : public base::SupportsUserData::Data { |
70 public: | 73 public: |
71 explicit TabContentsUserData(TabContents* tab_contents) | 74 explicit TabContentsUserData(TabContents* tab_contents) |
72 : tab_contents_(tab_contents) {} | 75 : tab_contents_(tab_contents) {} |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
128 ConstrainedWindowTabHelper::CreateForWebContents(contents); | 131 ConstrainedWindowTabHelper::CreateForWebContents(contents); |
129 CoreTabHelper::CreateForWebContents(contents); | 132 CoreTabHelper::CreateForWebContents(contents); |
130 extensions::TabHelper::CreateForWebContents(contents); | 133 extensions::TabHelper::CreateForWebContents(contents); |
131 extensions::WebNavigationTabObserver::CreateForWebContents(contents); | 134 extensions::WebNavigationTabObserver::CreateForWebContents(contents); |
132 ExternalProtocolObserver::CreateForWebContents(contents); | 135 ExternalProtocolObserver::CreateForWebContents(contents); |
133 FaviconTabHelper::CreateForWebContents(contents); | 136 FaviconTabHelper::CreateForWebContents(contents); |
134 FindTabHelper::CreateForWebContents(contents); | 137 FindTabHelper::CreateForWebContents(contents); |
135 HistoryTabHelper::CreateForWebContents(contents); | 138 HistoryTabHelper::CreateForWebContents(contents); |
136 HungPluginTabHelper::CreateForWebContents(contents); | 139 HungPluginTabHelper::CreateForWebContents(contents); |
137 InfoBarTabHelper::CreateForWebContents(contents); | 140 InfoBarTabHelper::CreateForWebContents(contents); |
138 MetroPinTabHelper::CreateForWebContents(contents); | |
139 NavigationMetricsRecorder::CreateForWebContents(contents); | 141 NavigationMetricsRecorder::CreateForWebContents(contents); |
140 PasswordManagerDelegateImpl::CreateForWebContents(contents); | 142 PasswordManagerDelegateImpl::CreateForWebContents(contents); |
141 PasswordManager::CreateForWebContentsAndDelegate( | 143 PasswordManager::CreateForWebContentsAndDelegate( |
142 contents, PasswordManagerDelegateImpl::FromWebContents(contents)); | 144 contents, PasswordManagerDelegateImpl::FromWebContents(contents)); |
143 PepperBrokerObserver::CreateForWebContents(contents); | 145 PepperBrokerObserver::CreateForWebContents(contents); |
144 PluginObserver::CreateForWebContents(contents); | 146 PluginObserver::CreateForWebContents(contents); |
145 PrefsTabHelper::CreateForWebContents(contents); | 147 PrefsTabHelper::CreateForWebContents(contents); |
146 prerender::PrerenderTabHelper::CreateForWebContents(contents); | 148 prerender::PrerenderTabHelper::CreateForWebContents(contents); |
147 safe_browsing::SafeBrowsingTabObserver::CreateForWebContents(contents); | 149 safe_browsing::SafeBrowsingTabObserver::CreateForWebContents(contents); |
148 SearchEngineTabHelper::CreateForWebContents(contents); | 150 SearchEngineTabHelper::CreateForWebContents(contents); |
(...skipping 29 matching lines...) Expand all Loading... |
178 | 180 |
179 #if defined(ENABLE_ONE_CLICK_SIGNIN) | 181 #if defined(ENABLE_ONE_CLICK_SIGNIN) |
180 // If this is not an incognito window, setup to handle one-click login. | 182 // If this is not an incognito window, setup to handle one-click login. |
181 // We don't want to check that the profile is already connected at this time | 183 // We don't want to check that the profile is already connected at this time |
182 // because the connected state may change while this tab is open. Having a | 184 // because the connected state may change while this tab is open. Having a |
183 // one-click signin helper attached does not cause problems if the profile | 185 // one-click signin helper attached does not cause problems if the profile |
184 // happens to be already connected. | 186 // happens to be already connected. |
185 if (OneClickSigninHelper::CanOffer(contents, "", false)) | 187 if (OneClickSigninHelper::CanOffer(contents, "", false)) |
186 OneClickSigninHelper::CreateForWebContents(contents); | 188 OneClickSigninHelper::CreateForWebContents(contents); |
187 #endif | 189 #endif |
| 190 |
| 191 #if defined(OS_WIN) |
| 192 MetroPinTabHelper::CreateForWebContents(contents); |
| 193 #endif |
188 } | 194 } |
189 | 195 |
190 TabContents::~TabContents() { | 196 TabContents::~TabContents() { |
191 in_destructor_ = true; | 197 in_destructor_ = true; |
192 } | 198 } |
193 | 199 |
194 TabContents* TabContents::Clone() { | 200 TabContents* TabContents::Clone() { |
195 WebContents* new_web_contents = web_contents()->Clone(); | 201 WebContents* new_web_contents = web_contents()->Clone(); |
196 return new TabContents(new_web_contents); | 202 return new TabContents(new_web_contents); |
197 } | 203 } |
(...skipping 24 matching lines...) Expand all Loading... |
222 | 228 |
223 //////////////////////////////////////////////////////////////////////////////// | 229 //////////////////////////////////////////////////////////////////////////////// |
224 // WebContentsObserver overrides | 230 // WebContentsObserver overrides |
225 | 231 |
226 void TabContents::WebContentsDestroyed(WebContents* tab) { | 232 void TabContents::WebContentsDestroyed(WebContents* tab) { |
227 // Destruction of the WebContents should only be done by us from our | 233 // Destruction of the WebContents should only be done by us from our |
228 // destructor. Otherwise it's very likely we (or one of the helpers we own) | 234 // destructor. Otherwise it's very likely we (or one of the helpers we own) |
229 // will attempt to access the WebContents and we'll crash. | 235 // will attempt to access the WebContents and we'll crash. |
230 DCHECK(in_destructor_); | 236 DCHECK(in_destructor_); |
231 } | 237 } |
OLD | NEW |