Avi Drissman | 4a8573c | 2022-09-09 19:35:54 | [diff] [blame] | 1 | // Copyright 2014 The Chromium Authors |
[email protected] | 27e5b391 | 2012-12-16 00:45:37 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
3 | // found in the LICENSE file. | ||||
4 | |||||
[email protected] | e0bc75d5 | 2014-01-30 23:42:59 | [diff] [blame] | 5 | #ifndef CHROME_BROWSER_UI_TAB_HELPERS_H_ |
6 | #define CHROME_BROWSER_UI_TAB_HELPERS_H_ | ||||
[email protected] | 27e5b391 | 2012-12-16 00:45:37 | [diff] [blame] | 7 | |
Collin Baker | 06abf00 | 2020-09-24 19:20:12 | [diff] [blame] | 8 | #include "build/build_config.h" |
9 | |||||
Xiaohan Wang | e9439fd | 2022-01-18 21:00:31 | [diff] [blame] | 10 | #if BUILDFLAG(IS_ANDROID) |
Collin Baker | 06abf00 | 2020-09-24 19:20:12 | [diff] [blame] | 11 | |
thestig | 74056f86 | 2016-10-05 22:35:48 | [diff] [blame] | 12 | namespace android { |
13 | class TabWebContentsDelegateAndroid; | ||||
14 | } | ||||
15 | |||||
Shakti Sahu | 704b779 | 2020-03-10 05:28:11 | [diff] [blame] | 16 | namespace thin_webview { |
17 | namespace android { | ||||
Shakti Sahu | b9f0b50 | 2020-08-18 22:21:10 | [diff] [blame] | 18 | class ChromeThinWebViewInitializer; |
Shakti Sahu | 704b779 | 2020-03-10 05:28:11 | [diff] [blame] | 19 | } |
20 | } // namespace thin_webview | ||||
21 | |||||
Collin Baker | 06abf00 | 2020-09-24 19:20:12 | [diff] [blame] | 22 | #else |
23 | |||||
24 | namespace chrome { | ||||
25 | class BrowserTabStripModelDelegate; | ||||
Miyoung Shin | 637a59fb | 2024-01-18 14:50:17 | [diff] [blame] | 26 | } // namespace chrome |
27 | |||||
keno | 7904d345 | 2023-11-02 06:50:47 | [diff] [blame] | 28 | class PreviewTab; |
Collin Baker | 06abf00 | 2020-09-24 19:20:12 | [diff] [blame] | 29 | |
Xiaohan Wang | e9439fd | 2022-01-18 21:00:31 | [diff] [blame] | 30 | #endif // BUILDFLAG(IS_ANDROID) |
Collin Baker | 06abf00 | 2020-09-24 19:20:12 | [diff] [blame] | 31 | |
32 | namespace content { | ||||
33 | class WebContents; | ||||
34 | } | ||||
35 | |||||
36 | namespace prerender { | ||||
Hiroki Nakagawa | 7230e341 | 2021-01-22 10:08:29 | [diff] [blame] | 37 | class ChromeNoStatePrefetchContentsDelegate; |
Collin Baker | 06abf00 | 2020-09-24 19:20:12 | [diff] [blame] | 38 | } |
39 | |||||
Erik Chen | 0118f76 | 2024-08-30 05:50:04 | [diff] [blame] | 40 | namespace tabs { |
41 | class TabModel; | ||||
42 | } // namespace tabs | ||||
43 | |||||
[email protected] | e0bc75d5 | 2014-01-30 23:42:59 | [diff] [blame] | 44 | // 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] | 27e5b391 | 2012-12-16 00:45:37 | [diff] [blame] | 47 | // |
John Palmer | 1a44562 | 2021-05-20 02:11:49 | [diff] [blame] | 48 | // https://chromium.googlesource.com/chromium/src/+/main/docs/tab_helpers.md |
avi | e9a1df6 | 2015-08-01 22:39:07 | [diff] [blame] | 49 | // |
Erik Chen | 50f7634b | 2024-04-29 21:14:22 | [diff] [blame] | 50 | // WARNING: Do not use this class for desktop chrome. Use TabFeatures instead. |
dljames | 8f6142e | 2025-05-19 20:14:46 | [diff] [blame] | 51 | // WARNING: For Android, consider using TabFeatures instead of this class. |
Erik Chen | 50f7634b | 2024-04-29 21:14:22 | [diff] [blame] | 52 | // See |
53 | // https://chromium.googlesource.com/chromium/src/+/main/docs/chrome_browser_design_principles.md | ||||
54 | |||||
[email protected] | e0bc75d5 | 2014-01-30 23:42:59 | [diff] [blame] | 55 | class TabHelpers { |
[email protected] | 27e5b391 | 2012-12-16 00:45:37 | [diff] [blame] | 56 | private: |
Xiaohan Wang | e9439fd | 2022-01-18 21:00:31 | [diff] [blame] | 57 | #if BUILDFLAG(IS_ANDROID) |
Collin Baker | 06abf00 | 2020-09-24 19:20:12 | [diff] [blame] | 58 | // 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] | e0bc75d5 | 2014-01-30 23:42:59 | [diff] [blame] | 61 | |
[email protected] | 27e5b391 | 2012-12-16 00:45:37 | [diff] [blame] | 62 | friend class TabAndroid; |
thestig | 74056f86 | 2016-10-05 22:35:48 | [diff] [blame] | 63 | friend class android::TabWebContentsDelegateAndroid; |
Collin Baker | 06abf00 | 2020-09-24 19:20:12 | [diff] [blame] | 64 | #else |
65 | friend class Browser; | ||||
66 | friend class chrome::BrowserTabStripModelDelegate; | ||||
Erik Chen | 0118f76 | 2024-08-30 05:50:04 | [diff] [blame] | 67 | friend class tabs::TabModel; |
Xiaohan Wang | e9439fd | 2022-01-18 21:00:31 | [diff] [blame] | 68 | #endif // BUILDFLAG(IS_ANDROID) |
[email protected] | 27e5b391 | 2012-12-16 00:45:37 | [diff] [blame] | 69 | |
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 Nakagawa | de49bd6 | 2023-10-05 07:58:58 | [diff] [blame] | 75 | // NoStatePrefetch and Prerendering load pages that have arbitrary external |
76 | // content; they need the full set of tab helpers to deal with it. | ||||
Hiroki Nakagawa | 7230e341 | 2021-01-22 10:08:29 | [diff] [blame] | 77 | friend class prerender::ChromeNoStatePrefetchContentsDelegate; |
Hiroki Nakagawa | de49bd6 | 2023-10-05 07:58:58 | [diff] [blame] | 78 | friend class PrerenderWebContentsDelegateImpl; |
[email protected] | 27e5b391 | 2012-12-16 00:45:37 | [diff] [blame] | 79 | |
keno | 7904d345 | 2023-11-02 06:50:47 | [diff] [blame] | 80 | // Link Preview shows a preview of a page, then promote it as a new tab. |
81 | friend class PreviewTab; | ||||
82 | |||||
avi | e9a1df6 | 2015-08-01 22:39:07 | [diff] [blame] | 83 | // 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] | 27e5b391 | 2012-12-16 00:45:37 | [diff] [blame] | 87 | // 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 McQuade | d2b93c0 | 2017-07-14 22:26:31 | [diff] [blame] | 91 | static void AttachTabHelpers(content::WebContents* web_contents); |
[email protected] | 27e5b391 | 2012-12-16 00:45:37 | [diff] [blame] | 92 | }; |
93 | |||||
[email protected] | e0bc75d5 | 2014-01-30 23:42:59 | [diff] [blame] | 94 | #endif // CHROME_BROWSER_UI_TAB_HELPERS_H_ |