blob: ec26ac19c07801af29e8f755fcbc9f71be17dee1 [file] [log] [blame]
Avi Drissman4a8573c2022-09-09 19:35:541// Copyright 2014 The Chromium Authors
[email protected]27e5b3912012-12-16 00:45:372// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
[email protected]e0bc75d52014-01-30 23:42:595#ifndef CHROME_BROWSER_UI_TAB_HELPERS_H_
6#define CHROME_BROWSER_UI_TAB_HELPERS_H_
[email protected]27e5b3912012-12-16 00:45:377
Collin Baker06abf002020-09-24 19:20:128#include "build/build_config.h"
9
Xiaohan Wange9439fd2022-01-18 21:00:3110#if BUILDFLAG(IS_ANDROID)
Collin Baker06abf002020-09-24 19:20:1211
thestig74056f862016-10-05 22:35:4812namespace android {
13class TabWebContentsDelegateAndroid;
14}
15
Shakti Sahu704b7792020-03-10 05:28:1116namespace thin_webview {
17namespace android {
Shakti Sahub9f0b502020-08-18 22:21:1018class ChromeThinWebViewInitializer;
Shakti Sahu704b7792020-03-10 05:28:1119}
20} // namespace thin_webview
21
Collin Baker06abf002020-09-24 19:20:1222#else
23
24namespace chrome {
25class BrowserTabStripModelDelegate;
Miyoung Shin637a59fb2024-01-18 14:50:1726} // namespace chrome
27
keno7904d3452023-11-02 06:50:4728class PreviewTab;
Collin Baker06abf002020-09-24 19:20:1229
Xiaohan Wange9439fd2022-01-18 21:00:3130#endif // BUILDFLAG(IS_ANDROID)
Collin Baker06abf002020-09-24 19:20:1231
32namespace content {
33class WebContents;
34}
35
36namespace prerender {
Hiroki Nakagawa7230e3412021-01-22 10:08:2937class ChromeNoStatePrefetchContentsDelegate;
Collin Baker06abf002020-09-24 19:20:1238}
39
Erik Chen0118f762024-08-30 05:50:0440namespace tabs {
41class TabModel;
42} // namespace tabs
43
[email protected]e0bc75d52014-01-30 23:42:5944// A "tab contents" is a WebContents that is used as a tab in a browser window
45// (or the equivalent on Android). The TabHelpers class allows specific classes
46// to attach the set of tab helpers that is used for tab contents.
[email protected]27e5b3912012-12-16 00:45:3747//
John Palmer1a445622021-05-20 02:11:4948// https://chromium.googlesource.com/chromium/src/+/main/docs/tab_helpers.md
avie9a1df62015-08-01 22:39:0749//
Erik Chen50f7634b2024-04-29 21:14:2250// WARNING: Do not use this class for desktop chrome. Use TabFeatures instead.
dljames8f6142e2025-05-19 20:14:4651// WARNING: For Android, consider using TabFeatures instead of this class.
Erik Chen50f7634b2024-04-29 21:14:2252// See
53// https://chromium.googlesource.com/chromium/src/+/main/docs/chrome_browser_design_principles.md
54
[email protected]e0bc75d52014-01-30 23:42:5955class TabHelpers {
[email protected]27e5b3912012-12-16 00:45:3756 private:
Xiaohan Wange9439fd2022-01-18 21:00:3157#if BUILDFLAG(IS_ANDROID)
Collin Baker06abf002020-09-24 19:20:1258 // ThinWebView is used to host WebContents on non-tab UIs in Android. Most
59 // clients of ThinWebView will need a major subset of the tab helpers.
60 friend class thin_webview::android::ChromeThinWebViewInitializer;
[email protected]e0bc75d52014-01-30 23:42:5961
[email protected]27e5b3912012-12-16 00:45:3762 friend class TabAndroid;
thestig74056f862016-10-05 22:35:4863 friend class android::TabWebContentsDelegateAndroid;
Collin Baker06abf002020-09-24 19:20:1264#else
65 friend class Browser;
66 friend class chrome::BrowserTabStripModelDelegate;
Erik Chen0118f762024-08-30 05:50:0467 friend class tabs::TabModel;
Xiaohan Wange9439fd2022-01-18 21:00:3168#endif // BUILDFLAG(IS_ANDROID)
[email protected]27e5b3912012-12-16 00:45:3769
70 // chrome::Navigate creates WebContents that are destined for the tab strip,
71 // and that might have WebUI that immediately calls back into random tab
72 // helpers.
73 friend class BrowserNavigatorWebContentsAdoption;
74
Hiroki Nakagawade49bd62023-10-05 07:58:5875 // NoStatePrefetch and Prerendering load pages that have arbitrary external
76 // content; they need the full set of tab helpers to deal with it.
Hiroki Nakagawa7230e3412021-01-22 10:08:2977 friend class prerender::ChromeNoStatePrefetchContentsDelegate;
Hiroki Nakagawade49bd62023-10-05 07:58:5878 friend class PrerenderWebContentsDelegateImpl;
[email protected]27e5b3912012-12-16 00:45:3779
keno7904d3452023-11-02 06:50:4780 // Link Preview shows a preview of a page, then promote it as a new tab.
81 friend class PreviewTab;
82
avie9a1df62015-08-01 22:39:0783 // FYI: Do NOT add any more friends here. The functions above are the ONLY
84 // ones that need to call AttachTabHelpers; if you think you do, re-read the
85 // design document linked above, especially the section "Reusing tab helpers".
86
[email protected]27e5b3912012-12-16 00:45:3787 // Adopts the specified WebContents as a full-fledged browser tab, attaching
88 // all the associated tab helpers that are needed for the WebContents to
89 // serve in that role. It is safe to call this on a WebContents that was
90 // already adopted.
Bryan McQuaded2b93c02017-07-14 22:26:3191 static void AttachTabHelpers(content::WebContents* web_contents);
[email protected]27e5b3912012-12-16 00:45:3792};
93
[email protected]e0bc75d52014-01-30 23:42:5994#endif // CHROME_BROWSER_UI_TAB_HELPERS_H_