OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_helpers.h" | 5 #include "chrome/browser/ui/tab_helpers.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 #include "components/dom_distiller/core/dom_distiller_switches.h" | 57 #include "components/dom_distiller/core/dom_distiller_switches.h" |
58 #include "components/history/content/browser/web_contents_top_sites_observer.h" | 58 #include "components/history/content/browser/web_contents_top_sites_observer.h" |
59 #include "components/history/core/browser/top_sites.h" | 59 #include "components/history/core/browser/top_sites.h" |
60 #include "components/password_manager/core/browser/password_manager.h" | 60 #include "components/password_manager/core/browser/password_manager.h" |
61 #include "components/subresource_filter/content/browser/content_subresource_filt
er_driver_factory.h" | 61 #include "components/subresource_filter/content/browser/content_subresource_filt
er_driver_factory.h" |
62 #include "components/tracing/common/tracing_switches.h" | 62 #include "components/tracing/common/tracing_switches.h" |
63 #include "content/public/browser/web_contents.h" | 63 #include "content/public/browser/web_contents.h" |
64 #include "extensions/features/features.h" | 64 #include "extensions/features/features.h" |
65 #include "printing/features/features.h" | 65 #include "printing/features/features.h" |
66 | 66 |
67 #if BUILDFLAG(ANDROID_JAVA_UI) | 67 #if defined(OS_ANDROID) |
68 #include "chrome/browser/android/banners/app_banner_manager_android.h" | 68 #include "chrome/browser/android/banners/app_banner_manager_android.h" |
69 #include "chrome/browser/android/data_usage/data_use_tab_helper.h" | 69 #include "chrome/browser/android/data_usage/data_use_tab_helper.h" |
70 #include "chrome/browser/android/offline_pages/offline_page_tab_helper.h" | 70 #include "chrome/browser/android/offline_pages/offline_page_tab_helper.h" |
71 #include "chrome/browser/android/offline_pages/recent_tab_helper.h" | 71 #include "chrome/browser/android/offline_pages/recent_tab_helper.h" |
72 #include "chrome/browser/android/search_geolocation/search_geolocation_disclosur
e_tab_helper.h" | 72 #include "chrome/browser/android/search_geolocation/search_geolocation_disclosur
e_tab_helper.h" |
73 #include "chrome/browser/android/voice_search_tab_helper.h" | 73 #include "chrome/browser/android/voice_search_tab_helper.h" |
74 #include "chrome/browser/android/webapps/single_tab_mode_tab_helper.h" | 74 #include "chrome/browser/android/webapps/single_tab_mode_tab_helper.h" |
75 #include "chrome/browser/ui/android/context_menu_helper.h" | 75 #include "chrome/browser/ui/android/context_menu_helper.h" |
76 #include "chrome/browser/ui/android/view_android_helper.h" | 76 #include "chrome/browser/ui/android/view_android_helper.h" |
77 #else | 77 #else |
78 #include "chrome/browser/banners/app_banner_manager_desktop.h" | 78 #include "chrome/browser/banners/app_banner_manager_desktop.h" |
79 #include "chrome/browser/plugins/plugin_observer.h" | 79 #include "chrome/browser/plugins/plugin_observer.h" |
80 #include "chrome/browser/safe_browsing/safe_browsing_navigation_observer.h" | 80 #include "chrome/browser/safe_browsing/safe_browsing_navigation_observer.h" |
81 #include "chrome/browser/safe_browsing/safe_browsing_tab_observer.h" | 81 #include "chrome/browser/safe_browsing/safe_browsing_tab_observer.h" |
82 #include "chrome/browser/thumbnails/thumbnail_tab_helper.h" | 82 #include "chrome/browser/thumbnails/thumbnail_tab_helper.h" |
83 #include "chrome/browser/ui/bookmarks/bookmark_tab_helper.h" | 83 #include "chrome/browser/ui/bookmarks/bookmark_tab_helper.h" |
84 #include "chrome/browser/ui/hung_plugin_tab_helper.h" | 84 #include "chrome/browser/ui/hung_plugin_tab_helper.h" |
85 #include "chrome/browser/ui/javascript_dialogs/javascript_dialog_tab_helper.h" | 85 #include "chrome/browser/ui/javascript_dialogs/javascript_dialog_tab_helper.h" |
86 #include "chrome/browser/ui/sad_tab_helper.h" | 86 #include "chrome/browser/ui/sad_tab_helper.h" |
87 #include "chrome/browser/ui/sync/tab_contents_synced_tab_delegate.h" | 87 #include "chrome/browser/ui/sync/tab_contents_synced_tab_delegate.h" |
88 #include "components/pdf/browser/pdf_web_contents_helper.h" | 88 #include "components/pdf/browser/pdf_web_contents_helper.h" |
89 #include "components/web_modal/web_contents_modal_dialog_manager.h" | 89 #include "components/web_modal/web_contents_modal_dialog_manager.h" |
90 #include "components/zoom/zoom_controller.h" | 90 #include "components/zoom/zoom_controller.h" |
91 #endif // BUILDFLAG(ANDROID_JAVA_UI) | 91 #endif // defined(OS_ANDROID) |
92 | 92 |
93 #if BUILDFLAG(ENABLE_CAPTIVE_PORTAL_DETECTION) | 93 #if BUILDFLAG(ENABLE_CAPTIVE_PORTAL_DETECTION) |
94 #include "chrome/browser/captive_portal/captive_portal_tab_helper.h" | 94 #include "chrome/browser/captive_portal/captive_portal_tab_helper.h" |
95 #endif | 95 #endif |
96 | 96 |
97 #if BUILDFLAG(ENABLE_EXTENSIONS) | 97 #if BUILDFLAG(ENABLE_EXTENSIONS) |
98 #include "chrome/browser/extensions/api/web_navigation/web_navigation_api.h" | 98 #include "chrome/browser/extensions/api/web_navigation/web_navigation_api.h" |
99 #include "chrome/browser/extensions/chrome_extension_web_contents_observer.h" | 99 #include "chrome/browser/extensions/chrome_extension_web_contents_observer.h" |
100 #include "chrome/browser/extensions/tab_helper.h" | 100 #include "chrome/browser/extensions/tab_helper.h" |
101 #include "extensions/browser/view_type_utils.h" | 101 #include "extensions/browser/view_type_utils.h" |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
138 #if BUILDFLAG(ENABLE_EXTENSIONS) | 138 #if BUILDFLAG(ENABLE_EXTENSIONS) |
139 // Set the view type. | 139 // Set the view type. |
140 extensions::SetViewType(web_contents, extensions::VIEW_TYPE_TAB_CONTENTS); | 140 extensions::SetViewType(web_contents, extensions::VIEW_TYPE_TAB_CONTENTS); |
141 #endif | 141 #endif |
142 | 142 |
143 // Create all the tab helpers. | 143 // Create all the tab helpers. |
144 | 144 |
145 // SessionTabHelper comes first because it sets up the tab ID, and other | 145 // SessionTabHelper comes first because it sets up the tab ID, and other |
146 // helpers may rely on that. | 146 // helpers may rely on that. |
147 SessionTabHelper::CreateForWebContents(web_contents); | 147 SessionTabHelper::CreateForWebContents(web_contents); |
148 #if !BUILDFLAG(ANDROID_JAVA_UI) | 148 #if !defined(OS_ANDROID) |
149 // ZoomController comes before common tab helpers since ChromeAutofillClient | 149 // ZoomController comes before common tab helpers since ChromeAutofillClient |
150 // may want to register as a ZoomObserver with it. | 150 // may want to register as a ZoomObserver with it. |
151 zoom::ZoomController::CreateForWebContents(web_contents); | 151 zoom::ZoomController::CreateForWebContents(web_contents); |
152 #endif | 152 #endif |
153 | 153 |
154 // --- Common tab helpers --- | 154 // --- Common tab helpers --- |
155 | 155 |
156 autofill::ChromeAutofillClient::CreateForWebContents(web_contents); | 156 autofill::ChromeAutofillClient::CreateForWebContents(web_contents); |
157 autofill::ContentAutofillDriverFactory::CreateForWebContentsAndDelegate( | 157 autofill::ContentAutofillDriverFactory::CreateForWebContentsAndDelegate( |
158 web_contents, | 158 web_contents, |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
196 std::unique_ptr<ChromeSubresourceFilterClient> subresource_filter_client( | 196 std::unique_ptr<ChromeSubresourceFilterClient> subresource_filter_client( |
197 new ChromeSubresourceFilterClient(web_contents)); | 197 new ChromeSubresourceFilterClient(web_contents)); |
198 subresource_filter::ContentSubresourceFilterDriverFactory:: | 198 subresource_filter::ContentSubresourceFilterDriverFactory:: |
199 CreateForWebContents(web_contents, std::move(subresource_filter_client)); | 199 CreateForWebContents(web_contents, std::move(subresource_filter_client)); |
200 // TODO(vabr): Remove TabSpecificContentSettings from here once their function | 200 // TODO(vabr): Remove TabSpecificContentSettings from here once their function |
201 // is taken over by ChromeContentSettingsClient. http://crbug.com/387075 | 201 // is taken over by ChromeContentSettingsClient. http://crbug.com/387075 |
202 TabSpecificContentSettings::CreateForWebContents(web_contents); | 202 TabSpecificContentSettings::CreateForWebContents(web_contents); |
203 | 203 |
204 // --- Platform-specific tab helpers --- | 204 // --- Platform-specific tab helpers --- |
205 | 205 |
206 #if BUILDFLAG(ANDROID_JAVA_UI) | 206 #if defined(OS_ANDROID) |
207 banners::AppBannerManagerAndroid::CreateForWebContents(web_contents); | 207 banners::AppBannerManagerAndroid::CreateForWebContents(web_contents); |
208 ContextMenuHelper::CreateForWebContents(web_contents); | 208 ContextMenuHelper::CreateForWebContents(web_contents); |
209 DataUseTabHelper::CreateForWebContents(web_contents); | 209 DataUseTabHelper::CreateForWebContents(web_contents); |
210 | 210 |
211 offline_pages::OfflinePageTabHelper::CreateForWebContents(web_contents); | 211 offline_pages::OfflinePageTabHelper::CreateForWebContents(web_contents); |
212 offline_pages::RecentTabHelper::CreateForWebContents(web_contents); | 212 offline_pages::RecentTabHelper::CreateForWebContents(web_contents); |
213 | 213 |
214 SearchGeolocationDisclosureTabHelper::CreateForWebContents(web_contents); | 214 SearchGeolocationDisclosureTabHelper::CreateForWebContents(web_contents); |
215 SingleTabModeTabHelper::CreateForWebContents(web_contents); | 215 SingleTabModeTabHelper::CreateForWebContents(web_contents); |
216 ViewAndroidHelper::CreateForWebContents(web_contents); | 216 ViewAndroidHelper::CreateForWebContents(web_contents); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
251 #endif | 251 #endif |
252 | 252 |
253 #if BUILDFLAG(ENABLE_EXTENSIONS) | 253 #if BUILDFLAG(ENABLE_EXTENSIONS) |
254 extensions::TabHelper::CreateForWebContents(web_contents); | 254 extensions::TabHelper::CreateForWebContents(web_contents); |
255 #endif | 255 #endif |
256 | 256 |
257 #if BUILDFLAG(ENABLE_SUPERVISED_USERS) | 257 #if BUILDFLAG(ENABLE_SUPERVISED_USERS) |
258 SupervisedUserNavigationObserver::CreateForWebContents(web_contents); | 258 SupervisedUserNavigationObserver::CreateForWebContents(web_contents); |
259 #endif | 259 #endif |
260 | 260 |
261 #if BUILDFLAG(ENABLE_PRINTING) && !BUILDFLAG(ANDROID_JAVA_UI) | 261 #if BUILDFLAG(ENABLE_PRINTING) && !defined(OS_ANDROID) |
262 #if BUILDFLAG(ENABLE_PRINT_PREVIEW) | 262 #if BUILDFLAG(ENABLE_PRINT_PREVIEW) |
263 printing::PrintViewManager::CreateForWebContents(web_contents); | 263 printing::PrintViewManager::CreateForWebContents(web_contents); |
264 printing::PrintPreviewMessageHandler::CreateForWebContents(web_contents); | 264 printing::PrintPreviewMessageHandler::CreateForWebContents(web_contents); |
265 #else | 265 #else |
266 printing::PrintViewManagerBasic::CreateForWebContents(web_contents); | 266 printing::PrintViewManagerBasic::CreateForWebContents(web_contents); |
267 #endif // BUILDFLAG(ENABLE_PRINT_PREVIEW) | 267 #endif // BUILDFLAG(ENABLE_PRINT_PREVIEW) |
268 #endif // BUILDFLAG(ENABLE_PRINTING) && !BUILDFLAG(ANDROID_JAVA_UI) | 268 #endif // BUILDFLAG(ENABLE_PRINTING) && !defined(OS_ANDROID) |
269 | 269 |
270 bool enabled_distiller = base::CommandLine::ForCurrentProcess()->HasSwitch( | 270 bool enabled_distiller = base::CommandLine::ForCurrentProcess()->HasSwitch( |
271 switches::kEnableDomDistiller); | 271 switches::kEnableDomDistiller); |
272 if (enabled_distiller) { | 272 if (enabled_distiller) { |
273 dom_distiller::WebContentsMainFrameObserver::CreateForWebContents( | 273 dom_distiller::WebContentsMainFrameObserver::CreateForWebContents( |
274 web_contents); | 274 web_contents); |
275 } | 275 } |
276 | 276 |
277 if (predictors::ResourcePrefetchPredictorFactory::GetForProfile( | 277 if (predictors::ResourcePrefetchPredictorFactory::GetForProfile( |
278 web_contents->GetBrowserContext())) { | 278 web_contents->GetBrowserContext())) { |
279 predictors::ResourcePrefetchPredictorTabHelper::CreateForWebContents( | 279 predictors::ResourcePrefetchPredictorTabHelper::CreateForWebContents( |
280 web_contents); | 280 web_contents); |
281 } | 281 } |
282 | 282 |
283 if (tracing::NavigationTracingObserver::IsEnabled()) | 283 if (tracing::NavigationTracingObserver::IsEnabled()) |
284 tracing::NavigationTracingObserver::CreateForWebContents(web_contents); | 284 tracing::NavigationTracingObserver::CreateForWebContents(web_contents); |
285 } | 285 } |
OLD | NEW |