Avi Drissman | 4e1b7bc3 | 2022-09-15 14:03:50 | [diff] [blame] | 1 | // Copyright 2012 The Chromium Authors |
[email protected] | 6934a70 | 2011-12-20 00:04:51 | [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] | 58f5d56 | 2011-12-20 17:13:03 | [diff] [blame] | 5 | #ifndef CONTENT_PUBLIC_BROWSER_WEB_CONTENTS_H_ |
| 6 | #define CONTENT_PUBLIC_BROWSER_WEB_CONTENTS_H_ |
[email protected] | 6934a70 | 2011-12-20 00:04:51 | [diff] [blame] | 7 | |
Lei Zhang | fcf7167 | 2021-05-14 16:28:20 | [diff] [blame] | 8 | #include <stddef.h> |
avi | 652869c | 2015-12-25 01:48:45 | [diff] [blame] | 9 | #include <stdint.h> |
| 10 | |
avi | e865b1d | 2016-10-24 19:42:59 | [diff] [blame] | 11 | #include <memory> |
Arthur Sonzogni | c686e8f | 2024-01-11 08:36:37 | [diff] [blame] | 12 | #include <optional> |
Lukasz Anforowicz | e9ae372 | 2017-09-29 17:37:38 | [diff] [blame] | 13 | #include <string> |
| 14 | #include <vector> |
[email protected] | c3c10f2 | 2013-07-25 14:21:12 | [diff] [blame] | 15 | |
Avi Drissman | adac2199 | 2023-01-11 23:46:39 | [diff] [blame] | 16 | #include "base/functional/callback_forward.h" |
| 17 | #include "base/functional/callback_helpers.h" |
Daniel Cheng | 982f2b2 | 2022-08-25 23:46:16 | [diff] [blame] | 18 | #include "base/functional/function_ref.h" |
Lukasz Anforowicz | 2c1573a | 2021-09-21 18:58:18 | [diff] [blame] | 19 | #include "base/location.h" |
Keishi Hattori | 0e45c02 | 2021-11-27 09:25:52 | [diff] [blame] | 20 | #include "base/memory/raw_ptr.h" |
mikt | 24c7462 | 2023-11-28 05:46:31 | [diff] [blame] | 21 | #include "base/memory/safety_checks.h" |
Lei Zhang | fcf7167 | 2021-05-14 16:28:20 | [diff] [blame] | 22 | #include "base/memory/scoped_refptr.h" |
Claudio DeSouza | 2be02d4 | 2021-08-12 23:23:40 | [diff] [blame] | 23 | #include "base/memory/weak_ptr.h" |
[email protected] | c3c10f2 | 2013-07-25 14:21:12 | [diff] [blame] | 24 | #include "base/process/kill.h" |
[email protected] | 36a22c4 | 2012-08-23 00:03:11 | [diff] [blame] | 25 | #include "base/supports_user_data.h" |
Sebastien Marchand | 28cf2318 | 2018-06-20 02:39:35 | [diff] [blame] | 26 | #include "base/time/time.h" |
avi | 652869c | 2015-12-25 01:48:45 | [diff] [blame] | 27 | #include "build/build_config.h" |
Yoshisato Yanagisawa | 607a7cca | 2021-10-14 02:45:36 | [diff] [blame] | 28 | #include "cc/input/browser_controls_state.h" |
[email protected] | 6934a70 | 2011-12-20 00:04:51 | [diff] [blame] | 29 | #include "content/common/content_export.h" |
[email protected] | 7f92483 | 2014-08-09 05:57:22 | [diff] [blame] | 30 | #include "content/public/browser/invalidate_type.h" |
Angel Alvarez | 90249668 | 2019-08-27 22:58:42 | [diff] [blame] | 31 | #include "content/public/browser/mhtml_generation_result.h" |
[email protected] | d1198fd | 2012-08-13 22:50:19 | [diff] [blame] | 32 | #include "content/public/browser/navigation_controller.h" |
Sreeja Kamishetty | 3dde631 | 2021-06-22 14:05:29 | [diff] [blame] | 33 | #include "content/public/browser/page.h" |
[email protected] | e5d549d | 2011-12-28 01:29:20 | [diff] [blame] | 34 | #include "content/public/browser/page_navigator.h" |
Domenic Denicola | bb5d843c | 2023-07-18 01:47:33 | [diff] [blame] | 35 | #include "content/public/browser/preloading.h" |
Kouhei Ueno | 3f37992b | 2023-11-09 23:29:02 | [diff] [blame] | 36 | #include "content/public/browser/preloading_trigger_type.h" |
Robert Lin | c37fb58 | 2021-11-11 03:18:47 | [diff] [blame] | 37 | #include "content/public/browser/prerender_handle.h" |
[email protected] | a53209b | 2012-01-20 16:48:16 | [diff] [blame] | 38 | #include "content/public/browser/save_page_type.h" |
Francois Doray | fe4a177 | 2018-02-17 04:17:09 | [diff] [blame] | 39 | #include "content/public/browser/visibility.h" |
[email protected] | 36ec24f | 2014-01-09 00:32:08 | [diff] [blame] | 40 | #include "content/public/common/stop_find_action.h" |
Avi Drissman | 0b2a20d | 2021-12-08 00:59:16 | [diff] [blame] | 41 | #include "services/network/public/mojom/web_sandbox_flags.mojom-shared.h" |
Hans Wennborg | 3e67bab | 2021-04-08 11:34:31 | [diff] [blame] | 42 | #include "third_party/blink/public/mojom/favicon/favicon_url.mojom-forward.h" |
Takuto Ikuta | aa3b796c | 2019-02-06 02:54:56 | [diff] [blame] | 43 | #include "third_party/blink/public/mojom/frame/find_in_page.mojom-forward.h" |
Lei Zhang | 96fce97 | 2022-08-05 23:15:07 | [diff] [blame] | 44 | #include "third_party/blink/public/mojom/frame/remote_frame.mojom-forward.h" |
James Hollyer | d5c9de46 | 2020-03-10 19:02:45 | [diff] [blame] | 45 | #include "third_party/blink/public/mojom/input/pointer_lock_result.mojom.h" |
Lei Zhang | 3ee2b78a | 2021-05-18 20:58:44 | [diff] [blame] | 46 | #include "third_party/blink/public/mojom/media/capture_handle_config.mojom-forward.h" |
Bryant Chandler | 490c6de | 2024-01-02 22:08:36 | [diff] [blame] | 47 | #include "third_party/blink/public/mojom/mediastream/media_stream.mojom-forward.h" |
Tommy Steimel | 57eafde | 2023-01-27 17:33:24 | [diff] [blame] | 48 | #include "third_party/blink/public/mojom/picture_in_picture_window_options/picture_in_picture_window_options.mojom.h" |
Alexander Timin | e9f413e8 | 2021-03-12 14:06:44 | [diff] [blame] | 49 | #include "third_party/perfetto/include/perfetto/tracing/traced_value_forward.h" |
[email protected] | da854376 | 2012-03-20 08:52:20 | [diff] [blame] | 50 | #include "third_party/skia/include/core/SkColor.h" |
Dominic Mazzoni | 9050148 | 2018-09-05 22:43:31 | [diff] [blame] | 51 | #include "ui/accessibility/ax_mode.h" |
Nektarios Paisios | 8e9da98 | 2024-02-20 23:14:22 | [diff] [blame] | 52 | #include "ui/accessibility/ax_node.h" |
Jacques Newman | e313e14 | 2024-03-13 18:47:22 | [diff] [blame] | 53 | #include "ui/accessibility/platform/inspect/ax_api_type.h" |
Andy Paicu | 5608bda8 | 2023-03-03 15:09:20 | [diff] [blame] | 54 | #include "ui/base/cursor/mojom/cursor_type.mojom-shared.h" |
Sean Kau | fc4c41c | 2023-06-22 16:21:54 | [diff] [blame] | 55 | #include "ui/color/color_provider_key.h" |
Mike Wasserman | b6bc015 | 2020-08-25 22:46:20 | [diff] [blame] | 56 | #include "ui/display/types/display_constants.h" |
tfarina | 3b0452d | 2014-12-31 15:20:09 | [diff] [blame] | 57 | #include "ui/gfx/geometry/rect.h" |
Lei Zhang | fcf7167 | 2021-05-14 16:28:20 | [diff] [blame] | 58 | #include "ui/gfx/geometry/size.h" |
[email protected] | 0bfbf88 | 2011-12-22 18:19:27 | [diff] [blame] | 59 | #include "ui/gfx/native_widget_types.h" |
Lei Zhang | fcf7167 | 2021-05-14 16:28:20 | [diff] [blame] | 60 | #include "url/gurl.h" |
[email protected] | 6934a70 | 2011-12-20 00:04:51 | [diff] [blame] | 61 | |
Xiaohan Wang | 6099ccb | 2022-01-13 22:09:42 | [diff] [blame] | 62 | #if BUILDFLAG(IS_ANDROID) |
[email protected] | 155c7f2 | 2013-12-09 17:07:18 | [diff] [blame] | 63 | #include "base/android/scoped_java_ref.h" |
| 64 | #endif |
| 65 | |
Lei Zhang | 1757508 | 2021-05-10 20:19:18 | [diff] [blame] | 66 | namespace base { |
| 67 | class FilePath; |
Lei Zhang | 1757508 | 2021-05-10 20:19:18 | [diff] [blame] | 68 | } // namespace base |
| 69 | |
Dmitry Gozman | 88ca5a99 | 2018-05-18 00:13:33 | [diff] [blame] | 70 | namespace blink { |
Gyuyoung Kim | 1ac4ca78 | 2020-09-11 03:32:51 | [diff] [blame] | 71 | namespace web_pref { |
| 72 | struct WebPreferences; |
| 73 | } |
Takashi Toyoshima | d72a465a | 2024-03-11 23:37:31 | [diff] [blame] | 74 | class WebInputEvent; |
Maks Orlovich | 73f374d | 2020-04-02 12:46:13 | [diff] [blame] | 75 | struct UserAgentOverride; |
Mario Sanchez Prada | 0bd8b8c | 2020-10-21 17:49:23 | [diff] [blame] | 76 | struct RendererPreferences; |
Leon Han | c819dc6 | 2019-01-28 04:30:19 | [diff] [blame] | 77 | } // namespace blink |
Dmitry Gozman | 88ca5a99 | 2018-05-18 00:13:33 | [diff] [blame] | 78 | |
ke.he | 98b761e | 2017-05-09 05:59:17 | [diff] [blame] | 79 | namespace device { |
| 80 | namespace mojom { |
| 81 | class WakeLockContext; |
| 82 | } |
| 83 | } |
| 84 | |
[email protected] | be1f56ab | 2011-12-22 06:55:31 | [diff] [blame] | 85 | namespace net { |
| 86 | struct LoadStateWithParam; |
[email protected] | 6934a70 | 2011-12-20 00:04:51 | [diff] [blame] | 87 | } |
| 88 | |
rockot | 400ea35b | 2016-10-15 19:15:32 | [diff] [blame] | 89 | namespace service_manager { |
sammc | f5f1b0f | 2016-09-20 23:05:11 | [diff] [blame] | 90 | class InterfaceProvider; |
| 91 | } |
| 92 | |
Alexander Surkov | be2878f | 2020-11-03 18:25:25 | [diff] [blame] | 93 | namespace ui { |
| 94 | struct AXPropertyFilter; |
Lei Zhang | fcf7167 | 2021-05-14 16:28:20 | [diff] [blame] | 95 | struct AXTreeUpdate; |
Tom Lukaszewicz | 63b3da5 | 2022-01-26 01:37:57 | [diff] [blame] | 96 | class ColorProvider; |
tom | 855c4bf3 | 2021-09-30 00:27:26 | [diff] [blame] | 97 | class ColorProviderSource; |
Alexander Surkov | be2878f | 2020-11-03 18:25:25 | [diff] [blame] | 98 | } |
| 99 | |
[email protected] | 6934a70 | 2011-12-20 00:04:51 | [diff] [blame] | 100 | namespace content { |
| 101 | |
William Liu | 6cf58fe | 2024-01-19 21:29:32 | [diff] [blame] | 102 | class BackForwardTransitionAnimationManager; |
[email protected] | 627e051 | 2011-12-21 22:55:30 | [diff] [blame] | 103 | class BrowserContext; |
[email protected] | 4858e43 | 2014-06-23 18:14:17 | [diff] [blame] | 104 | class BrowserPluginGuestDelegate; |
[email protected] | 60eca4eb | 2013-12-06 00:02:16 | [diff] [blame] | 105 | class RenderFrameHost; |
[email protected] | eaabba2 | 2012-03-07 15:02:11 | [diff] [blame] | 106 | class RenderViewHost; |
[email protected] | 5626b089 | 2012-02-20 14:46:58 | [diff] [blame] | 107 | class RenderWidgetHostView; |
Lei Zhang | fcf7167 | 2021-05-14 16:28:20 | [diff] [blame] | 108 | class ScreenOrientationDelegate; |
| 109 | class SiteInstance; |
[email protected] | adbfb8df | 2012-02-24 01:19:43 | [diff] [blame] | 110 | class WebContentsDelegate; |
Lei Zhang | 4b21e9c | 2020-02-28 00:32:02 | [diff] [blame] | 111 | class WebUI; |
[email protected] | fc2b46b | 2014-05-03 16:33:45 | [diff] [blame] | 112 | struct DropData; |
dewittj | 6dc5747a | 2016-05-17 01:48:47 | [diff] [blame] | 113 | struct MHTMLGenerationParams; |
Sreeja Kamishetty | ac12140e | 2022-07-14 22:16:51 | [diff] [blame] | 114 | class PreloadingAttempt; |
[email protected] | 674bc59 | 2011-12-20 23:00:42 | [diff] [blame] | 115 | |
[email protected] | a906995f | 2012-12-17 23:30:48 | [diff] [blame] | 116 | // WebContents is the core class in content/. A WebContents renders web content |
| 117 | // (usually HTML) in a rectangular area. |
| 118 | // |
| 119 | // Instantiating one is simple: |
dcheng | 6003e0b | 2016-04-09 18:42:34 | [diff] [blame] | 120 | // std::unique_ptr<content::WebContents> web_contents( |
[email protected] | a906995f | 2012-12-17 23:30:48 | [diff] [blame] | 121 | // content::WebContents::Create( |
| 122 | // content::WebContents::CreateParams(browser_context))); |
[email protected] | fc2b46b | 2014-05-03 16:33:45 | [diff] [blame] | 123 | // gfx::NativeView view = web_contents->GetNativeView(); |
Nick Diego Yamane | ee67b3c | 2019-07-01 23:20:37 | [diff] [blame] | 124 | // // |view| is an HWND, NSView*, etc.; insert it into the view hierarchy |
| 125 | // // wherever it needs to go. |
[email protected] | a906995f | 2012-12-17 23:30:48 | [diff] [blame] | 126 | // |
| 127 | // That's it; go to your kitchen, grab a scone, and chill. WebContents will do |
| 128 | // all the multi-process stuff behind the scenes. More details are at |
Adam Langley | 4463fb83 | 2018-01-28 22:42:26 | [diff] [blame] | 129 | // https://www.chromium.org/developers/design-documents/multi-process-architecture |
dcheng | 6003e0b | 2016-04-09 18:42:34 | [diff] [blame] | 130 | // . |
[email protected] | a906995f | 2012-12-17 23:30:48 | [diff] [blame] | 131 | // |
Lukasz Anforowicz | 7a0381c | 2022-12-07 20:23:08 | [diff] [blame] | 132 | // The owner of `std::unique_ptr<content::WebContents> web_contents` is |
| 133 | // responsible for ensuring that `web_contents` are destroyed (e.g. closed) |
| 134 | // *before* the corresponding `browser_context` is destroyed. |
| 135 | // |
Kevin McNee | 88bf224 | 2022-11-23 00:27:34 | [diff] [blame] | 136 | // Each WebContents has a `NavigationController`, which can be obtained from |
| 137 | // `GetController()`, and is used to load URLs into the WebContents, navigate |
| 138 | // it backwards/forwards, etc. |
| 139 | // See navigation_controller.h for more details. |
[email protected] | 36a22c4 | 2012-08-23 00:03:11 | [diff] [blame] | 140 | class WebContents : public PageNavigator, |
[email protected] | 36a22c4 | 2012-08-23 00:03:11 | [diff] [blame] | 141 | public base::SupportsUserData { |
mikt | 24c7462 | 2023-11-28 05:46:31 | [diff] [blame] | 142 | // Do not remove this macro! |
| 143 | // The macro is maintained by the memory safety team. |
| 144 | ADVANCED_MEMORY_SAFETY_CHECKS(); |
| 145 | |
[email protected] | 6934a70 | 2011-12-20 00:04:51 | [diff] [blame] | 146 | public: |
[email protected] | 54944cde | 2012-12-09 09:24:59 | [diff] [blame] | 147 | struct CONTENT_EXPORT CreateParams { |
Lukasz Anforowicz | 2c1573a | 2021-09-21 18:58:18 | [diff] [blame] | 148 | explicit CreateParams( |
| 149 | BrowserContext* context, |
| 150 | base::Location creator_location = base::Location::Current()); |
Lukasz Anforowicz | 2c1573a | 2021-09-21 18:58:18 | [diff] [blame] | 151 | CreateParams(BrowserContext* context, |
| 152 | scoped_refptr<SiteInstance> site, |
| 153 | base::Location creator_location = base::Location::Current()); |
Avi Drissman | 0b2a20d | 2021-12-08 00:59:16 | [diff] [blame] | 154 | CreateParams(const CreateParams& other); |
| 155 | ~CreateParams(); |
[email protected] | 54944cde | 2012-12-09 09:24:59 | [diff] [blame] | 156 | |
Keishi Hattori | 0e45c02 | 2021-11-27 09:25:52 | [diff] [blame] | 157 | raw_ptr<BrowserContext> browser_context; |
[email protected] | a902d9a | 2013-08-08 16:05:09 | [diff] [blame] | 158 | |
| 159 | // Specifying a SiteInstance here is optional. It can be set to avoid an |
| 160 | // extra process swap if the first navigation is expected to require a |
| 161 | // privileged process. |
dcheng | bccd6b8 | 2016-03-30 16:24:19 | [diff] [blame] | 162 | scoped_refptr<SiteInstance> site_instance; |
[email protected] | a902d9a | 2013-08-08 16:05:09 | [diff] [blame] | 163 | |
alexmos | e201c7cd | 2015-06-10 17:14:21 | [diff] [blame] | 164 | // The process id of the frame initiating the open. |
Avi Drissman | 0b2a20d | 2021-12-08 00:59:16 | [diff] [blame] | 165 | int opener_render_process_id = content::ChildProcessHost::kInvalidUniqueID; |
alexmos | e201c7cd | 2015-06-10 17:14:21 | [diff] [blame] | 166 | |
| 167 | // The routing id of the frame initiating the open. |
Avi Drissman | 0b2a20d | 2021-12-08 00:59:16 | [diff] [blame] | 168 | int opener_render_frame_id = MSG_ROUTING_NONE; |
[email protected] | 50d326e | 2014-05-20 17:59:06 | [diff] [blame] | 169 | |
| 170 | // If the opener is suppressed, then the new WebContents doesn't hold a |
| 171 | // reference to its opener. |
Avi Drissman | 0b2a20d | 2021-12-08 00:59:16 | [diff] [blame] | 172 | bool opener_suppressed = false; |
avi | c2c29d78 | 2014-12-12 00:23:54 | [diff] [blame] | 173 | |
Rakina Zata Amni | c7ffea88 | 2021-08-16 10:04:28 | [diff] [blame] | 174 | // Indicates whether this WebContents was created by another window. |
alexmos | 090fae8e | 2015-05-28 17:09:28 | [diff] [blame] | 175 | // This is used when determining whether the WebContents is allowed to be |
| 176 | // closed via window.close(). This may be true even with a null |opener| |
Rakina Zata Amni | c7ffea88 | 2021-08-16 10:04:28 | [diff] [blame] | 177 | // (e.g., for blocked popups), or when the window is opened with "noopener". |
Avi Drissman | 0b2a20d | 2021-12-08 00:59:16 | [diff] [blame] | 178 | bool opened_by_another_window = false; |
alexmos | 090fae8e | 2015-05-28 17:09:28 | [diff] [blame] | 179 | |
nasko | c9f51dd | 2015-05-13 00:39:28 | [diff] [blame] | 180 | // The name of the top-level frame of the new window. It is non-empty |
| 181 | // when creating a named window (e.g. <a target="foo"> or |
| 182 | // window.open('', 'bar')). |
| 183 | std::string main_frame_name; |
| 184 | |
arthursonzogni | 034bb9c | 2020-10-01 08:29:56 | [diff] [blame] | 185 | // New window starts from the initial empty document. When created by an |
| 186 | // opener, the latter can request an initial navigation attempt to be made. |
| 187 | // This is the url specified in: `window.open(initial_popup_url, ...)`. |
| 188 | // This is empty otherwise. |
| 189 | GURL initial_popup_url; |
| 190 | |
[email protected] | 1ac10dca | 2013-08-20 20:47:04 | [diff] [blame] | 191 | // True if the contents should be initially hidden. |
Avi Drissman | 0b2a20d | 2021-12-08 00:59:16 | [diff] [blame] | 192 | bool initially_hidden = false; |
[email protected] | 1ac10dca | 2013-08-20 20:47:04 | [diff] [blame] | 193 | |
[email protected] | 4858e43 | 2014-06-23 18:14:17 | [diff] [blame] | 194 | // If non-null then this WebContents will be hosted by a BrowserPlugin. |
Avi Drissman | 0b2a20d | 2021-12-08 00:59:16 | [diff] [blame] | 195 | raw_ptr<BrowserPluginGuestDelegate> guest_delegate = nullptr; |
[email protected] | 83100cd | 2014-05-10 11:50:06 | [diff] [blame] | 196 | |
[email protected] | 54944cde | 2012-12-09 09:24:59 | [diff] [blame] | 197 | // Used to specify the location context which display the new view should |
Avi Drissman | dad01b0e | 2023-06-16 22:55:46 | [diff] [blame] | 198 | // belong. This can be unset if not needed. |
| 199 | gfx::NativeView context = gfx::NativeView(); |
nasko | b21fe487 | 2015-02-24 14:15:56 | [diff] [blame] | 200 | |
| 201 | // Used to specify that the new WebContents creation is driven by the |
| 202 | // renderer process. In this case, the renderer-side objects, such as |
| 203 | // RenderFrame, have already been created on the renderer side, and |
| 204 | // WebContents construction should take this into account. |
Avi Drissman | 0b2a20d | 2021-12-08 00:59:16 | [diff] [blame] | 205 | bool renderer_initiated_creation = false; |
lof84 | 501da08 | 2016-05-23 21:22:54 | [diff] [blame] | 206 | |
Lukasz Anforowicz | 3caa837 | 2018-06-05 17:22:07 | [diff] [blame] | 207 | // Used to specify how far WebContents::Create can initialize a renderer |
| 208 | // process. |
| 209 | // |
| 210 | // This is useful in two scenarios: |
| 211 | // - Conserving resources - e.g. tab discarding and session restore do not |
| 212 | // want to use an actual renderer process before the WebContents are |
| 213 | // loaded or reloaded. This can be accomplished via kNoRendererProcess. |
| 214 | // - Avoiding the latency of the first navigation |
| 215 | // - kInitializeAndWarmupRendererProcess is most aggressive in avoiding |
| 216 | // the latency, but may be incompatible with scenarios that require |
| 217 | // manipulating the freshly created WebContents prior to initializing |
| 218 | // renderer-side objects (e.g. in scenarios like |
| 219 | // WebContentsImpl::CreateNewWindow which needs to copy the |
| 220 | // SessionStorageNamespace) |
| 221 | // - kOkayToHaveRendererProcess is the default latency-conserving mode. |
| 222 | // In this mode a spare, pre-spawned RenderProcessHost may be claimed |
| 223 | // by the newly created WebContents, but no renderer-side objects will |
| 224 | // be initialized from within WebContents::Create method. |
| 225 | // |
lof84 | 501da08 | 2016-05-23 21:22:54 | [diff] [blame] | 226 | // Note that the pre-created renderer process may not be used if the first |
| 227 | // navigation requires a dedicated or privileged process, such as a WebUI. |
Lukasz Anforowicz | 3caa837 | 2018-06-05 17:22:07 | [diff] [blame] | 228 | // This can be avoided by ensuring that |site_instance| matches the first |
| 229 | // navigation's destination. |
| 230 | enum RendererInitializationState { |
| 231 | // Creation of WebContents should not spawn a new OS process and should |
| 232 | // not reuse a RenderProcessHost that might be associated with an existing |
| 233 | // OS process (as in the case of SpareRenderProcessHostManager). |
| 234 | kNoRendererProcess, |
| 235 | |
| 236 | // Created WebContents may or may not be associated with an actual OS |
| 237 | // process. |
| 238 | kOkayToHaveRendererProcess, |
| 239 | |
| 240 | // Ensures that the created WebContents are backed by an OS process which |
Dave Tapuska | 2cf1f53 | 2022-08-10 15:30:49 | [diff] [blame] | 241 | // has an initialized `blink::WebView`. |
Lukasz Anforowicz | 3caa837 | 2018-06-05 17:22:07 | [diff] [blame] | 242 | // |
| 243 | // TODO(lukasza): https://crbug.com/848366: Remove |
| 244 | // kInitializeAndWarmupRendererProcess value - warming up the renderer by |
Dave Tapuska | 2cf1f53 | 2022-08-10 15:30:49 | [diff] [blame] | 245 | // initializing the `blink::WebView` is redundant with the warm-up that |
| 246 | // can be |
Lukasz Anforowicz | 3caa837 | 2018-06-05 17:22:07 | [diff] [blame] | 247 | // achieved by either 1) warming up the spare renderer before creating |
| 248 | // WebContents and/or 2) speculative RenderFrameHost used internally |
| 249 | // during a navigation. |
| 250 | kInitializeAndWarmupRendererProcess, |
Avi Drissman | 0b2a20d | 2021-12-08 00:59:16 | [diff] [blame] | 251 | } desired_renderer_state = kOkayToHaveRendererProcess; |
mark a. foltz | ef394fce | 2017-10-21 09:11:02 | [diff] [blame] | 252 | |
| 253 | // Sandboxing flags set on the new WebContents. |
Avi Drissman | 0b2a20d | 2021-12-08 00:59:16 | [diff] [blame] | 254 | network::mojom::WebSandboxFlags starting_sandbox_flags = |
| 255 | network::mojom::WebSandboxFlags::kNone; |
Sebastien Marchand | 28cf2318 | 2018-06-20 02:39:35 | [diff] [blame] | 256 | |
| 257 | // Value used to set the last time the WebContents was made active, this is |
| 258 | // the value that'll be returned by GetLastActiveTime(). If this is left |
| 259 | // default initialized then the value is not passed on to the WebContents |
| 260 | // and GetLastActiveTime() will return the WebContents' creation time. |
| 261 | base::TimeTicks last_active_time; |
Albert J. Wong | e76bf0b8 | 2019-09-27 07:47:06 | [diff] [blame] | 262 | |
Lukasz Anforowicz | 2c1573a | 2021-09-21 18:58:18 | [diff] [blame] | 263 | // Code location responsible for creating the CreateParams. This is used |
| 264 | // mostly for debugging (e.g. to help attribute specific scenarios or |
| 265 | // invariant violations to a particular flavor of WebContents). |
| 266 | base::Location creator_location; |
Thoren Paulson | d344c0a | 2021-10-14 19:20:31 | [diff] [blame] | 267 | |
Nicolas Ouellet-Payeur | 177a6c4 | 2023-01-25 20:25:07 | [diff] [blame] | 268 | #if BUILDFLAG(IS_ANDROID) |
| 269 | // Same as `creator_location`, for WebContents created via Java. This |
| 270 | // java.lang.Throwable contains the entire |
| 271 | // WebContentsCreator.createWebContents() stack trace. |
| 272 | base::android::ScopedJavaGlobalRef<jthrowable> java_creator_location; |
| 273 | #endif // BUILDFLAG(IS_ANDROID) |
| 274 | |
Thoren Paulson | d344c0a | 2021-10-14 19:20:31 | [diff] [blame] | 275 | // Enables contents to hold wake locks, for example, to keep the screen on |
| 276 | // while playing video. |
Avi Drissman | 0b2a20d | 2021-12-08 00:59:16 | [diff] [blame] | 277 | bool enable_wake_locks = true; |
Tommy Steimel | 991916c4 | 2022-06-24 20:59:57 | [diff] [blame] | 278 | |
| 279 | // Options specific to WebContents created for picture-in-picture windows. |
Arthur Sonzogni | c686e8f | 2024-01-11 08:36:37 | [diff] [blame] | 280 | std::optional<blink::mojom::PictureInPictureWindowOptions> |
Tommy Steimel | 57eafde | 2023-01-27 17:33:24 | [diff] [blame] | 281 | picture_in_picture_options; |
Takashi Toyoshima | 881f4d7 | 2023-11-09 05:07:43 | [diff] [blame] | 282 | |
Takashi Toyoshima | 8dfc05c | 2024-01-29 21:03:51 | [diff] [blame] | 283 | // Enable preview mode that shows a page with a capability restriction |
| 284 | // for previewing the page. |
| 285 | bool preview_mode = false; |
[email protected] | 54944cde | 2012-12-09 09:24:59 | [diff] [blame] | 286 | }; |
| 287 | |
Frank Liberato | e837b36 | 2023-10-20 23:31:15 | [diff] [blame] | 288 | // Token that causes input to be blocked on this WebContents for at least as |
| 289 | // long as it exists. |
| 290 | class CONTENT_EXPORT ScopedIgnoreInputEvents { |
| 291 | public: |
| 292 | ~ScopedIgnoreInputEvents(); |
| 293 | |
| 294 | ScopedIgnoreInputEvents(ScopedIgnoreInputEvents&&); |
| 295 | ScopedIgnoreInputEvents& operator=(ScopedIgnoreInputEvents&&); |
| 296 | |
| 297 | private: |
| 298 | friend class WebContentsImpl; |
| 299 | explicit ScopedIgnoreInputEvents(base::OnceClosure on_destruction_cb); |
| 300 | |
| 301 | base::ScopedClosureRunner on_destruction_cb_; |
| 302 | }; |
| 303 | |
[email protected] | 54944cde | 2012-12-09 09:24:59 | [diff] [blame] | 304 | // Creates a new WebContents. |
Lukasz Anforowicz | 7a0381c | 2022-12-07 20:23:08 | [diff] [blame] | 305 | // |
| 306 | // The caller is responsible for ensuring that the returned WebContents is |
| 307 | // destroyed (e.g. closed) *before* the BrowserContext associated with |
Lukasz Anforowicz | 16eddbc7 | 2022-12-19 20:08:43 | [diff] [blame] | 308 | // `params` is destroyed. It is a security bug if WebContents haven't been |
| 309 | // destroyed when the destructor of BrowserContext starts running. It is not |
Lukasz Anforowicz | 7a0381c | 2022-12-07 20:23:08 | [diff] [blame] | 310 | // necessarily a bug if WebContents haven't been destroyed when |
| 311 | // BrowserContext::NotifyWillBeDestroyed starts running. |
Lukasz Anforowicz | 16eddbc7 | 2022-12-19 20:08:43 | [diff] [blame] | 312 | // |
| 313 | // Best practices for managing the lifetime of `WebContents` and |
| 314 | // `BrowserContext` will vary across different //content embedders. For |
| 315 | // example, for information specific to the //chrome layer, please see the |
| 316 | // "Managing lifetime of a Profile" section in |
| 317 | // //chrome/browser/profiles/README.md. |
Erik Chen | bb8e738e | 2018-04-28 14:10:43 | [diff] [blame] | 318 | CONTENT_EXPORT static std::unique_ptr<WebContents> Create( |
| 319 | const CreateParams& params); |
[email protected] | d1198fd | 2012-08-13 22:50:19 | [diff] [blame] | 320 | |
[email protected] | fdac6ade | 2013-07-20 01:06:30 | [diff] [blame] | 321 | // Similar to Create() above but should be used when you need to prepopulate |
| 322 | // the SessionStorageNamespaceMap of the WebContents. This can happen if |
[email protected] | d1198fd | 2012-08-13 22:50:19 | [diff] [blame] | 323 | // you duplicate a WebContents, try to reconstitute it from a saved state, |
| 324 | // or when you create a new WebContents based on another one (eg., when |
| 325 | // servicing a window.open() call). |
| 326 | // |
| 327 | // You do not want to call this. If you think you do, make sure you completely |
| 328 | // understand when SessionStorageNamespace objects should be cloned, why |
| 329 | // they should not be shared by multiple WebContents, and what bad things |
| 330 | // can happen if you share the object. |
erikchen | ade1fef | 2018-05-02 22:07:57 | [diff] [blame] | 331 | CONTENT_EXPORT static std::unique_ptr<WebContents> CreateWithSessionStorage( |
[email protected] | 54944cde | 2012-12-09 09:24:59 | [diff] [blame] | 332 | const CreateParams& params, |
[email protected] | fdac6ade | 2013-07-20 01:06:30 | [diff] [blame] | 333 | const SessionStorageNamespaceMap& session_storage_namespace_map); |
[email protected] | a81343d23 | 2011-12-27 07:39:20 | [diff] [blame] | 334 | |
Matt Falkenhagen | c70a9d10 | 2021-09-08 04:49:00 | [diff] [blame] | 335 | // Returns the WebContents that owns the RenderViewHost. |
| 336 | // |
| 337 | // WARNING: `rvh` may belong to a prerendered page, a page in the back/forward |
| 338 | // cache, or a pending deletion page, so it might be inappropriate for it to |
| 339 | // to trigger changes to the WebContents. See also the below comments for |
| 340 | // FromRenderFrameHost(). |
avi | df38c95 | 2015-10-27 13:45:13 | [diff] [blame] | 341 | CONTENT_EXPORT static WebContents* FromRenderViewHost(RenderViewHost* rvh); |
[email protected] | 746d305 | 2012-05-22 15:15:47 | [diff] [blame] | 342 | |
Xiaohan Wang | 009c084 | 2020-09-17 05:43:24 | [diff] [blame] | 343 | // Returns the WebContents for the RenderFrameHost. It is unsafe to call this |
| 344 | // function with an invalid (e.g. destructed) `rfh`. |
Matt Falkenhagen | c70a9d10 | 2021-09-08 04:49:00 | [diff] [blame] | 345 | // |
| 346 | // WARNING: It might be inappropriate for `rfh` to trigger changes to the |
| 347 | // WebContents, so be careful when calling this. Some cases to be aware of |
| 348 | // are: |
| 349 | // * Pages/documents which are not active are not observable by the user |
| 350 | // and therefore should not show UI elements (e.g., a colour picker). These |
| 351 | // features should use `rfh->IsActive()` to determine whether `rfh` is |
| 352 | // active. See the comments there for more information. |
| 353 | // * Pages/documents which are not primary generally should not update |
| 354 | // per-WebContents state (e.g., theme colour). Use |
| 355 | // `rfh->GetPage().IsPrimary()` to check for primary. Fenced frames are |
| 356 | // one case where a RenderFrameHost can be active but not primary. |
[email protected] | a86c0e96 | 2013-12-17 17:10:39 | [diff] [blame] | 357 | CONTENT_EXPORT static WebContents* FromRenderFrameHost(RenderFrameHost* rfh); |
| 358 | |
John Abd-El-Malek | 2ea0554 | 2020-03-04 00:03:36 | [diff] [blame] | 359 | // Returns the WebContents associated with the |frame_tree_node_id|. This may |
| 360 | // return nullptr if the RenderFrameHost is shutting down. |
ananta | 4b7467a5 | 2016-09-23 01:42:38 | [diff] [blame] | 361 | CONTENT_EXPORT static WebContents* FromFrameTreeNodeId( |
| 362 | int frame_tree_node_id); |
| 363 | |
John Abd-El-Malek | 92bf360 | 2019-07-31 02:25:48 | [diff] [blame] | 364 | // A callback that returns a pointer to a WebContents. The callback can |
| 365 | // always be used, but it may return nullptr: if the info used to |
| 366 | // instantiate the callback can no longer be used to return a WebContents, |
| 367 | // nullptr will be returned instead. |
| 368 | // The callback should only run on the UI thread and it should always be |
| 369 | // non-null. |
Erik Chen | 540d7194 | 2024-01-12 00:00:50 | [diff] [blame] | 370 | // Most uses of Getter and OnceGetter can likely be safety replaced with |
| 371 | // base::WeakPtr<WebContents>. |
danakj | f4b9e94 | 2019-11-29 15:43:04 | [diff] [blame] | 372 | using Getter = base::RepeatingCallback<WebContents*(void)>; |
| 373 | // Use this variant for instances that will only run the callback a single |
| 374 | // time. |
| 375 | using OnceGetter = base::OnceCallback<WebContents*(void)>; |
John Abd-El-Malek | 92bf360 | 2019-07-31 02:25:48 | [diff] [blame] | 376 | |
leon.han | 552e9de | 2017-02-09 14:37:30 | [diff] [blame] | 377 | // Sets delegate for platform specific screen orientation functionality. |
| 378 | CONTENT_EXPORT static void SetScreenOrientationDelegate( |
| 379 | ScreenOrientationDelegate* delegate); |
| 380 | |
Avi Drissman | 0b2a20d | 2021-12-08 00:59:16 | [diff] [blame] | 381 | ~WebContents() override = default; |
[email protected] | 36fc039 | 2011-12-25 03:59:51 | [diff] [blame] | 382 | |
[email protected] | 6934a70 | 2011-12-20 00:04:51 | [diff] [blame] | 383 | // Intrinsic tab state ------------------------------------------------------- |
| 384 | |
[email protected] | 674bc59 | 2011-12-20 23:00:42 | [diff] [blame] | 385 | // Gets/Sets the delegate. |
| 386 | virtual WebContentsDelegate* GetDelegate() = 0; |
| 387 | virtual void SetDelegate(WebContentsDelegate* delegate) = 0; |
[email protected] | 6934a70 | 2011-12-20 00:04:51 | [diff] [blame] | 388 | |
Matt Falkenhagen | 91a8043 | 2021-07-05 03:32:44 | [diff] [blame] | 389 | // Gets the NavigationController for primary frame tree of this WebContents. |
| 390 | // See comments on NavigationController for more details. |
[email protected] | cdcb1dee | 2012-01-04 00:46:20 | [diff] [blame] | 391 | virtual NavigationController& GetController() = 0; |
[email protected] | f5fa20e | 2011-12-21 22:35:56 | [diff] [blame] | 392 | |
[email protected] | 627e051 | 2011-12-21 22:55:30 | [diff] [blame] | 393 | // Returns the user browser context associated with this WebContents (via the |
| 394 | // NavigationController). |
Lucas Furukawa Gadani | e1c5dfda | 2018-11-29 17:57:41 | [diff] [blame] | 395 | virtual content::BrowserContext* GetBrowserContext() = 0; |
[email protected] | 627e051 | 2011-12-21 22:55:30 | [diff] [blame] | 396 | |
Claudio DeSouza | 2be02d4 | 2021-08-12 23:23:40 | [diff] [blame] | 397 | // Returns a weak pointer. |
| 398 | virtual base::WeakPtr<WebContents> GetWeakPtr() = 0; |
| 399 | |
[email protected] | ea049a0 | 2011-12-25 21:37:09 | [diff] [blame] | 400 | // Gets the URL that is currently being displayed, if there is one. |
[email protected] | a093ce0 | 2013-07-22 20:53:14 | [diff] [blame] | 401 | // This method is deprecated. DO NOT USE! Pick either |GetVisibleURL| or |
[email protected] | c854a7e | 2013-05-21 16:42:24 | [diff] [blame] | 402 | // |GetLastCommittedURL| as appropriate. |
Lucas Furukawa Gadani | e1c5dfda | 2018-11-29 17:57:41 | [diff] [blame] | 403 | virtual const GURL& GetURL() = 0; |
[email protected] | f5fa20e | 2011-12-21 22:35:56 | [diff] [blame] | 404 | |
dominickn | 319d693 | 2016-06-21 00:59:26 | [diff] [blame] | 405 | // Gets the virtual URL currently being displayed in the URL bar, if there is |
| 406 | // one. This URL might be a pending navigation that hasn't committed yet, so |
Carlos IL | 07f282f | 2020-05-15 22:58:29 | [diff] [blame] | 407 | // it is not guaranteed to match the current page in this WebContents. |
Lucas Furukawa Gadani | e1c5dfda | 2018-11-29 17:57:41 | [diff] [blame] | 408 | virtual const GURL& GetVisibleURL() = 0; |
[email protected] | c854a7e | 2013-05-21 16:42:24 | [diff] [blame] | 409 | |
dominickn | 319d693 | 2016-06-21 00:59:26 | [diff] [blame] | 410 | // Gets the virtual URL of the last committed page in this WebContents. |
| 411 | // Virtual URLs are meant to be displayed to the user (e.g., they include the |
| 412 | // "view-source:" prefix for view source URLs, unlike NavigationEntry::GetURL |
| 413 | // and NavigationHandle::GetURL). The last committed page is the current |
| 414 | // security context and the content that is actually displayed within the tab. |
Rakina Zata Amni | afd3c658 | 2021-11-30 06:19:17 | [diff] [blame] | 415 | // See also GetVisibleURL above, which may differ from this URL. Note that |
| 416 | // this might return an empty GURL if no navigation has committed in the |
| 417 | // WebContents' main frame. |
Lucas Furukawa Gadani | e1c5dfda | 2018-11-29 17:57:41 | [diff] [blame] | 418 | virtual const GURL& GetLastCommittedURL() = 0; |
[email protected] | c854a7e | 2013-05-21 16:42:24 | [diff] [blame] | 419 | |
Dave Tapuska | 1d5e577 | 2022-06-02 17:26:01 | [diff] [blame] | 420 | // Returns the primary main frame for the currently active page. Always |
| 421 | // non-null except during WebContents destruction. This WebContents may |
| 422 | // have additional main frames for prerendered pages, bfcached pages, etc. |
Kevin McNee | 88bf224 | 2022-11-23 00:27:34 | [diff] [blame] | 423 | // See docs/frame_trees.md for more details. |
Peter Kasting | 2caacff6 | 2023-05-24 16:06:53 | [diff] [blame] | 424 | virtual const RenderFrameHost* GetPrimaryMainFrame() const = 0; |
Dave Tapuska | 1d5e577 | 2022-06-02 17:26:01 | [diff] [blame] | 425 | virtual RenderFrameHost* GetPrimaryMainFrame() = 0; |
| 426 | |
Sreeja Kamishetty | 3dde631 | 2021-06-22 14:05:29 | [diff] [blame] | 427 | // Returns the current page in the primary frame tree of this WebContents. |
| 428 | // If this WebContents is associated with an omnibox, usually the URL of the |
| 429 | // main document of this page will be displayed in it. |
| 430 | // |
| 431 | // Primary page can change as a result of a navigation, both to a new page |
| 432 | // (navigation loading a new main document) and an existing one (when |
| 433 | // restoring the page from back/forward cache or activating a prerendering |
| 434 | // page). This change can be observed using |
| 435 | // WebContentsObserver::PrimaryPageChanged, see the comments there for more |
| 436 | // details. |
| 437 | // |
| 438 | // The primary page's lifetime corresponds to its main document's lifetime |
| 439 | // and may differ from a RenderFrameHost's lifetime (for cross-document same |
| 440 | // RenderFrameHost navigations). |
| 441 | // |
| 442 | // Apart from the primary page, additional pages might be associated with this |
| 443 | // WebContents: |
| 444 | // - Pending commit pages (which will become primary after-and-if the ongoing |
| 445 | // main frame navigation successfully commits). |
| 446 | // - Pending deletion pages (pages the user has navigated from, but which are |
| 447 | // still alive as they are running unload handlers in background). |
| 448 | // - Pages in back/forward cache (which can be navigated to later). |
| 449 | // - Prerendered pages (pages which are loading in the background in |
| 450 | // anticipation of user navigating to them). |
| 451 | // |
| 452 | // Given the existence of multiple pages, in many cases (especially when |
| 453 | // handling IPCs from the renderer process), calling GetPrimaryPage would not |
| 454 | // be appropriate as it might return a wrong page. If the code already has a |
| 455 | // reference to RenderFrameHost or a Page (e.g. each IPC from the renderer |
| 456 | // process should be associated with a particular RenderFrameHost), it should |
| 457 | // be used instead of getting the primary page from the WebContents. |
Kevin McNee | 88bf224 | 2022-11-23 00:27:34 | [diff] [blame] | 458 | // See docs/frame_trees.md for more details. |
Sreeja Kamishetty | 3dde631 | 2021-06-22 14:05:29 | [diff] [blame] | 459 | virtual Page& GetPrimaryPage() = 0; |
| 460 | |
Kevin McNee | 61927b3 | 2022-07-05 16:35:38 | [diff] [blame] | 461 | // Returns the focused frame for the primary page or an inner page thereof. |
| 462 | // Might be nullptr if nothing is focused. |
[email protected] | 9c9343b | 2014-03-08 02:56:07 | [diff] [blame] | 463 | virtual RenderFrameHost* GetFocusedFrame() = 0; |
| 464 | |
Kevin McNee | 07c67ec9 | 2021-08-11 16:18:33 | [diff] [blame] | 465 | // Returns true if |frame_tree_node_id| refers to a frame in a prerendered |
| 466 | // page. |
| 467 | // TODO(1196715, 1232528): This will be extended to also return true if it is |
| 468 | // in an inner page of a prerendered page. |
| 469 | virtual bool IsPrerenderedFrame(int frame_tree_node_id) = 0; |
| 470 | |
Kevin McNee | d1fa70a5 | 2021-07-16 21:43:01 | [diff] [blame] | 471 | // NOTE: This is generally unsafe to use. A frame's RenderFrameHost may |
| 472 | // change over its lifetime, such as during cross-process navigation (and |
| 473 | // thus privilege change). Use RenderFrameHost::FromID instead wherever |
| 474 | // possible. |
| 475 | // |
Kunihiko Sakamoto | 1c5a09e | 2021-08-10 02:40:39 | [diff] [blame] | 476 | // Given a FrameTreeNode ID that belongs to this WebContents, returns the |
| 477 | // current RenderFrameHost regardless of which FrameTree it is in. |
Kevin McNee | d1fa70a5 | 2021-07-16 21:43:01 | [diff] [blame] | 478 | // |
creis | f71a263 | 2017-05-04 19:03:50 | [diff] [blame] | 479 | // See RenderFrameHost::GetFrameTreeNodeId for documentation on this ID. |
| 480 | virtual RenderFrameHost* UnsafeFindFrameByFrameTreeNodeId( |
rob | 3e2a073 | 2016-01-06 21:22:09 | [diff] [blame] | 481 | int frame_tree_node_id) = 0; |
| 482 | |
Kevin McNee | c9d0fda | 2021-05-19 15:55:17 | [diff] [blame] | 483 | // Calls |on_frame| for every RenderFrameHost in this WebContents. Note that |
| 484 | // this includes RenderFrameHosts that are not descended from the primary main |
| 485 | // frame (e.g. bfcached pages and prerendered pages). The order of traversal |
| 486 | // for RenderFrameHosts within a page is consistent with |
| 487 | // |RenderFrameHost::ForEachRenderFrameHost|'s order, however no order is |
| 488 | // guaranteed between pages. |
| 489 | // For callers only interested in the primary page, |
| 490 | // |GetMainFrame()->ForEachRenderFrameHost()| can be used. |
| 491 | // See |RenderFrameHost::ForEachRenderFrameHost| for details. |
Daniel Cheng | 982f2b2 | 2022-08-25 23:46:16 | [diff] [blame] | 492 | using FrameIterationAction = RenderFrameHost::FrameIterationAction; |
| 493 | virtual void ForEachRenderFrameHostWithAction( |
| 494 | base::FunctionRef<FrameIterationAction(RenderFrameHost*)> on_frame) = 0; |
Kevin McNee | c9d0fda | 2021-05-19 15:55:17 | [diff] [blame] | 495 | virtual void ForEachRenderFrameHost( |
Daniel Cheng | 982f2b2 | 2022-08-25 23:46:16 | [diff] [blame] | 496 | base::FunctionRef<void(RenderFrameHost*)> on_frame) = 0; |
Kevin McNee | c9d0fda | 2021-05-19 15:55:17 | [diff] [blame] | 497 | |
[email protected] | 151a63d | 2011-12-20 22:32:52 | [diff] [blame] | 498 | // Gets the current RenderViewHost for this tab. |
Lucas Furukawa Gadani | e1c5dfda | 2018-11-29 17:57:41 | [diff] [blame] | 499 | virtual RenderViewHost* GetRenderViewHost() = 0; |
[email protected] | d487beefe | 2011-12-21 05:41:21 | [diff] [blame] | 500 | |
| 501 | // Returns the currently active RenderWidgetHostView. This may change over |
mlamouri | 8c61ffc | 2015-01-13 16:17:59 | [diff] [blame] | 502 | // time and can be nullptr (during setup and teardown). |
Lucas Furukawa Gadani | e1c5dfda | 2018-11-29 17:57:41 | [diff] [blame] | 503 | virtual RenderWidgetHostView* GetRenderWidgetHostView() = 0; |
[email protected] | 4aebbcaa | 2013-09-17 22:26:49 | [diff] [blame] | 504 | |
lfg | 265a267 | 2016-04-23 03:11:02 | [diff] [blame] | 505 | // Returns the outermost RenderWidgetHostView. This will return the platform |
| 506 | // specific RenderWidgetHostView (as opposed to |
| 507 | // RenderWidgetHostViewChildFrame), which can be used to create context |
| 508 | // menus. |
| 509 | virtual RenderWidgetHostView* GetTopLevelRenderWidgetHostView() = 0; |
| 510 | |
muyuanli | c693ba1 | 2017-04-27 19:12:40 | [diff] [blame] | 511 | // Request a one-time snapshot of the accessibility tree without changing |
Dominic Mazzoni | 77d0aba | 2021-01-14 09:42:16 | [diff] [blame] | 512 | // the accessibility mode. See RenderFrame::AXTreeSnapshotter for |
| 513 | // definitions of |ax_mode|, |max_nodes|, and |timeout|. |
Avi Drissman | b30851c | 2018-03-08 20:34:33 | [diff] [blame] | 514 | using AXTreeSnapshotCallback = |
| 515 | base::OnceCallback<void(const ui::AXTreeUpdate&)>; |
Avi Drissman | 1e620f3 | 2018-03-16 13:57:29 | [diff] [blame] | 516 | virtual void RequestAXTreeSnapshot(AXTreeSnapshotCallback callback, |
Dominic Mazzoni | 77d0aba | 2021-01-14 09:42:16 | [diff] [blame] | 517 | ui::AXMode ax_mode, |
Dominic Mazzoni | 77d0aba | 2021-01-14 09:42:16 | [diff] [blame] | 518 | size_t max_nodes, |
| 519 | base::TimeDelta timeout) = 0; |
muyuanli | c693ba1 | 2017-04-27 19:12:40 | [diff] [blame] | 520 | |
nasko | c0fceff | 2015-04-30 15:53:52 | [diff] [blame] | 521 | // Causes the current page to be closed, including running its onunload event |
| 522 | // handler. |
| 523 | virtual void ClosePage() = 0; |
| 524 | |
yusufo | d41c5f9 | 2015-03-06 00:14:28 | [diff] [blame] | 525 | // Returns the theme color for the underlying content as set by the |
Alan Cutter | 92d5925 | 2019-03-29 02:32:33 | [diff] [blame] | 526 | // theme-color meta tag if any. |
Arthur Sonzogni | c686e8f | 2024-01-11 08:36:37 | [diff] [blame] | 527 | virtual std::optional<SkColor> GetThemeColor() = 0; |
yusufo | d41c5f9 | 2015-03-06 00:14:28 | [diff] [blame] | 528 | |
Alan Cutter | d73a15d9 | 2020-08-21 07:12:45 | [diff] [blame] | 529 | // Returns the background color for the underlying content as set by CSS if |
| 530 | // any. |
Arthur Sonzogni | c686e8f | 2024-01-11 08:36:37 | [diff] [blame] | 531 | virtual std::optional<SkColor> GetBackgroundColor() = 0; |
Alan Cutter | d73a15d9 | 2020-08-21 07:12:45 | [diff] [blame] | 532 | |
Bo Liu | b5e79d9 | 2021-06-12 01:40:41 | [diff] [blame] | 533 | // Sets the renderer-side default background color of the page. This is used |
| 534 | // when the page has not loaded enough to know a background color or if the |
| 535 | // page does not set a background color. |
| 536 | // Pass in nullopt to reset back to the default. |
| 537 | // Note there are situations where the base background color is not used, such |
| 538 | // as fullscreen. |
| 539 | // Note currently this is sent directly to the renderer, so does not interact |
| 540 | // directly with `RenderWidgetHostView::SetBackgroundColor`. There is pending |
| 541 | // refactor to remove `RenderWidgetHostView::SetBackgroundColor` and merge its |
| 542 | // functionality here, which will be more consistent and simpler to |
| 543 | // understand. |
Arthur Sonzogni | c686e8f | 2024-01-11 08:36:37 | [diff] [blame] | 544 | virtual void SetPageBaseBackgroundColor(std::optional<SkColor> color) = 0; |
Bo Liu | b5e79d9 | 2021-06-12 01:40:41 | [diff] [blame] | 545 | |
tom | 855c4bf3 | 2021-09-30 00:27:26 | [diff] [blame] | 546 | // Sets the ColorProviderSource for the WebContents. The WebContents will |
| 547 | // maintain an observation of `source` until a new source is set or the |
| 548 | // current source is destroyed. WebContents will receive updates when the |
| 549 | // source's ColorProvider changes. |
| 550 | virtual void SetColorProviderSource(ui::ColorProviderSource* source) = 0; |
| 551 | |
Tom Lukaszewicz | 63b3da5 | 2022-01-26 01:37:57 | [diff] [blame] | 552 | // Returns the ColorProvider instance for this WebContents object. This will |
| 553 | // always return a valid ColorProvider instance. |
| 554 | virtual const ui::ColorProvider& GetColorProvider() const = 0; |
| 555 | |
Thomas Lukaszewicz | c6b1f22d | 2023-06-13 18:24:50 | [diff] [blame] | 556 | // Gets the color mode for the ColorProvider associated with this WebContents. |
Sean Kau | fc4c41c | 2023-06-22 16:21:54 | [diff] [blame] | 557 | virtual ui::ColorProviderKey::ColorMode GetColorMode() const = 0; |
Thomas Lukaszewicz | c6b1f22d | 2023-06-13 18:24:50 | [diff] [blame] | 558 | |
Charlie Reis | 4589bf3 | 2021-07-20 00:36:23 | [diff] [blame] | 559 | // Returns the committed WebUI if one exists. |
Lucas Furukawa Gadani | e1c5dfda | 2018-11-29 17:57:41 | [diff] [blame] | 560 | virtual WebUI* GetWebUI() = 0; |
[email protected] | be1f56ab | 2011-12-22 06:55:31 | [diff] [blame] | 561 | |
Scott Violet | 2a6c5bff | 2020-04-29 23:59:06 | [diff] [blame] | 562 | // Sets the user-agent that may be used for navigations in this WebContents. |
| 563 | // The user-agent is *only* used when |
| 564 | // NavigationEntry::SetIsOverridingUserAgent(true) is used (the value of |
| 565 | // is-overriding-user-agent may be specified in LoadURLParams). If |
| 566 | // |override_in_new_tabs| is true, and the first navigation in the tab is |
| 567 | // renderer initiated, then is-overriding-user-agent is set to true for the |
| 568 | // NavigationEntry. See SetRendererInitiatedUserAgentOverrideOption() for |
| 569 | // details on how renderer initiated navigations are configured. |
David Van Cleve | de398a5 | 2020-12-28 21:33:03 | [diff] [blame] | 570 | // |
| 571 | // If nonempty, |ua_override|'s value must not contain '\0', '\r', or '\n' (in |
| 572 | // other words, it must be a valid HTTP header value). |
Maks Orlovich | 73f374d | 2020-04-02 12:46:13 | [diff] [blame] | 573 | virtual void SetUserAgentOverride(const blink::UserAgentOverride& ua_override, |
Changwan Ryu | c1134a8 | 2018-03-07 02:10:14 | [diff] [blame] | 574 | bool override_in_new_tabs) = 0; |
Scott Violet | 2a6c5bff | 2020-04-29 23:59:06 | [diff] [blame] | 575 | |
| 576 | // Configures the value of is-overriding-user-agent for renderer initiated |
| 577 | // navigations. The default is UA_OVERRIDE_INHERIT. This value does not apply |
| 578 | // to the first renderer initiated navigation if the tab has no navigations. |
| 579 | // See SetUserAgentOverride() for details on that. |
| 580 | virtual void SetRendererInitiatedUserAgentOverrideOption( |
| 581 | NavigationController::UserAgentOverrideOption option) = 0; |
| 582 | |
Maks Orlovich | 73f374d | 2020-04-02 12:46:13 | [diff] [blame] | 583 | virtual const blink::UserAgentOverride& GetUserAgentOverride() = 0; |
[email protected] | 86ef6a39 | 2012-05-11 22:03:11 | [diff] [blame] | 584 | |
Aman Verma | a4b33cf | 2023-06-13 19:32:33 | [diff] [blame] | 585 | // Updates all renderers to start sending subresource notifications since a |
| 586 | // certificate error or HTTP exception has been allowed by the user. |
| 587 | virtual void SetAlwaysSendSubresourceNotifications() = 0; |
| 588 | virtual bool GetSendSubresourceNotification() = 0; |
| 589 | |
dmazzoni | dd3d51a7 | 2016-12-14 18:41:01 | [diff] [blame] | 590 | // Returns true only if the WebContentsObserver accessibility mode is |
| 591 | // enabled. |
Lucas Furukawa Gadani | e1c5dfda | 2018-11-29 17:57:41 | [diff] [blame] | 592 | virtual bool IsWebContentsOnlyAccessibilityModeForTesting() = 0; |
[email protected] | 9564021 | 2014-07-26 18:14:30 | [diff] [blame] | 593 | |
| 594 | // Returns true only if complete accessibility mode is on, meaning there's |
| 595 | // both renderer accessibility, and a native browser accessibility tree. |
Lucas Furukawa Gadani | e1c5dfda | 2018-11-29 17:57:41 | [diff] [blame] | 596 | virtual bool IsFullAccessibilityModeForTesting() = 0; |
[email protected] | 9564021 | 2014-07-26 18:14:30 | [diff] [blame] | 597 | |
Lucas Furukawa Gadani | e1c5dfda | 2018-11-29 17:57:41 | [diff] [blame] | 598 | virtual ui::AXMode GetAccessibilityMode() = 0; |
James Wallace-Lee | eafc94cb9 | 2018-07-23 21:35:09 | [diff] [blame] | 599 | |
Greg Thompson | f855bf88 | 2024-01-30 10:39:45 | [diff] [blame] | 600 | // Forces a reset of accessibility state in the instance's renderers. |
| 601 | // Observers will receive a new accessibility tree. |
| 602 | virtual void ResetAccessibility() = 0; |
James Wallace-Lee | eafc94cb9 | 2018-07-23 21:35:09 | [diff] [blame] | 603 | |
Nektarios Paisios | 8e9da98 | 2024-02-20 23:14:22 | [diff] [blame] | 604 | // Returns a pointer to the root node of the live accessibility tree for the |
| 605 | // main frame, if accessibility is turned on. Otherwise, returns nullptr. |
| 606 | virtual ui::AXNode* GetAccessibilityRootNode() = 0; |
| 607 | |
Alexander Surkov | 2ab5162 | 2020-09-02 12:01:42 | [diff] [blame] | 608 | virtual std::string DumpAccessibilityTree( |
Abigail Klein | abb42833 | 2019-09-13 18:26:21 | [diff] [blame] | 609 | bool internal, |
Alexander Surkov | 9048288 | 2020-10-12 16:30:38 | [diff] [blame] | 610 | std::vector<ui::AXPropertyFilter> property_filters) = 0; |
James Wallace-Lee | eafc94cb9 | 2018-07-23 21:35:09 | [diff] [blame] | 611 | |
Jacques Newman | e313e14 | 2024-03-13 18:47:22 | [diff] [blame] | 612 | virtual std::string DumpAccessibilityTree( |
| 613 | ui::AXApiType::Type api_type, |
| 614 | std::vector<ui::AXPropertyFilter> property_filters) = 0; |
| 615 | |
Abigail Klein | aa89874 | 2019-11-01 02:31:25 | [diff] [blame] | 616 | // A callback that takes a string which contains accessibility event |
| 617 | // information. |
| 618 | using AccessibilityEventCallback = |
| 619 | base::RepeatingCallback<void(const std::string&)>; |
| 620 | |
Abigail Klein | bb8304bd | 2020-05-18 21:44:18 | [diff] [blame] | 621 | // Starts or stops recording accessibility events. |start_recording| is true |
| 622 | // when recording should start and false when recording should stop. |
| 623 | // |callback| is an optional function which is called when an accessibility |
| 624 | // event is received while accessibility events are being recorded. When |
| 625 | // |start_recording| is true, it is expected that |callback| has a value; when |
| 626 | // |start_recording| is false, it is expected that |callback| does not. |
| 627 | virtual void RecordAccessibilityEvents( |
| 628 | bool start_recording, |
Arthur Sonzogni | c686e8f | 2024-01-11 08:36:37 | [diff] [blame] | 629 | std::optional<AccessibilityEventCallback> callback) = 0; |
Abigail Klein | aa89874 | 2019-11-01 02:31:25 | [diff] [blame] | 630 | |
Jacques Newman | e313e14 | 2024-03-13 18:47:22 | [diff] [blame] | 631 | virtual void RecordAccessibilityEvents( |
| 632 | ui::AXApiType::Type api_type, |
| 633 | bool start_recording, |
| 634 | std::optional<AccessibilityEventCallback> callback) = 0; |
[email protected] | be1f56ab | 2011-12-22 06:55:31 | [diff] [blame] | 635 | // Tab navigation state ------------------------------------------------------ |
| 636 | |
| 637 | // Returns the current navigation properties, which if a navigation is |
| 638 | // pending may be provisional (e.g., the navigation could result in a |
| 639 | // download, in which case the URL would revert to what it was previously). |
Jan Wilken Dörrie | aace0cfef | 2021-03-11 22:01:58 | [diff] [blame] | 640 | virtual const std::u16string& GetTitle() = 0; |
[email protected] | be1f56ab | 2011-12-22 06:55:31 | [diff] [blame] | 641 | |
afakhry | 6f0c1ec2 | 2016-07-14 13:55:13 | [diff] [blame] | 642 | // Saves the given title to the navigation entry and does associated work. It |
| 643 | // will update history and the view with the new title, and also synthesize |
| 644 | // titles for file URLs that have none. Thus |entry| must have a URL set. |
| 645 | virtual void UpdateTitleForEntry(NavigationEntry* entry, |
Jan Wilken Dörrie | aace0cfef | 2021-03-11 22:01:58 | [diff] [blame] | 646 | const std::u16string& title) = 0; |
afakhry | 6f0c1ec2 | 2016-07-14 13:55:13 | [diff] [blame] | 647 | |
Haben Foto | 533aa35 | 2024-01-09 22:01:16 | [diff] [blame] | 648 | // Returns app title of the current navigation entry. The apptitle is |
| 649 | // an alternative title text that can be used by app windows. |
| 650 | // See |
| 651 | // https://github.com/MicrosoftEdge/MSEdgeExplainers/blob/main/DocumentSubtitle/explainer.md |
| 652 | virtual const std::u16string& GetAppTitle() = 0; |
| 653 | |
[email protected] | be1f56ab | 2011-12-22 06:55:31 | [diff] [blame] | 654 | // Returns the SiteInstance associated with the current page. |
Lucas Furukawa Gadani | e1c5dfda | 2018-11-29 17:57:41 | [diff] [blame] | 655 | virtual SiteInstance* GetSiteInstance() = 0; |
[email protected] | be1f56ab | 2011-12-22 06:55:31 | [diff] [blame] | 656 | |
[email protected] | 6dfed69 | 2014-05-22 04:18:03 | [diff] [blame] | 657 | // Returns whether this WebContents is loading a resource. |
Lucas Furukawa Gadani | e1c5dfda | 2018-11-29 17:57:41 | [diff] [blame] | 658 | virtual bool IsLoading() = 0; |
[email protected] | be1f56ab | 2011-12-22 06:55:31 | [diff] [blame] | 659 | |
Peter Boström | 18a40fa | 2018-10-31 19:03:50 | [diff] [blame] | 660 | // Returns the current load progress. |
Lucas Furukawa Gadani | e1c5dfda | 2018-11-29 17:57:41 | [diff] [blame] | 661 | virtual double GetLoadProgress() = 0; |
Peter Boström | 18a40fa | 2018-10-31 19:03:50 | [diff] [blame] | 662 | |
Nate Chapin | 9aabf5f | 2021-11-12 00:31:19 | [diff] [blame] | 663 | // Returns whether a navigation is currently in progress that should show |
| 664 | // loading UI if such UI exists (progress bar, loading spinner, stop button, |
Domenic Denicola | 3081074 | 2022-03-17 20:11:23 | [diff] [blame] | 665 | // etc.) True for different-document navigations and the navigation API's |
Nate Chapin | 2429525 | 2022-09-27 18:31:08 | [diff] [blame] | 666 | // intercept(). This being true implies that IsLoading() is also true. |
Nate Chapin | 9aabf5f | 2021-11-12 00:31:19 | [diff] [blame] | 667 | virtual bool ShouldShowLoadingUI() = 0; |
[email protected] | 6dfed69 | 2014-05-22 04:18:03 | [diff] [blame] | 668 | |
Sreeja Kamishetty | 6b55ecc | 2021-12-10 11:28:17 | [diff] [blame] | 669 | // Returns whether the current primary main document has reached and finished |
Alexander Timin | dd0fa0c5 | 2019-11-06 13:03:37 | [diff] [blame] | 670 | // executing its onload() handler. Corresponds to |
Sreeja Kamishetty | 8134758 | 2022-01-06 12:46:33 | [diff] [blame] | 671 | // WebContentsObserver::DocumentOnLoadCompletedInPrimaryMainFrame() and see |
| 672 | // comments there for more details. |
| 673 | virtual bool IsDocumentOnLoadCompletedInPrimaryMainFrame() = 0; |
Alexander Timin | dd0fa0c5 | 2019-11-06 13:03:37 | [diff] [blame] | 674 | |
[email protected] | ca13a44 | 2012-04-17 14:00:12 | [diff] [blame] | 675 | // Returns whether this WebContents is waiting for a first-response for the |
[email protected] | be1f56ab | 2011-12-22 06:55:31 | [diff] [blame] | 676 | // main resource of the page. |
Lucas Furukawa Gadani | e1c5dfda | 2018-11-29 17:57:41 | [diff] [blame] | 677 | virtual bool IsWaitingForResponse() = 0; |
[email protected] | be1f56ab | 2011-12-22 06:55:31 | [diff] [blame] | 678 | |
Lijin Shen | 8c0f436 | 2024-03-25 20:05:09 | [diff] [blame] | 679 | // Returns whether this WebContents's primary frame tree node is navigating, |
| 680 | // i.e. it has an associated NavigationRequest. |
| 681 | virtual bool HasUncommittedNavigationInPrimaryMainFrame() = 0; |
| 682 | |
[email protected] | 6dfed69 | 2014-05-22 04:18:03 | [diff] [blame] | 683 | // Returns the current load state and the URL associated with it. |
andresantoso | 9d01994 | 2015-05-27 17:01:08 | [diff] [blame] | 684 | // The load state is only updated while IsLoading() is true. |
Lucas Furukawa Gadani | e1c5dfda | 2018-11-29 17:57:41 | [diff] [blame] | 685 | virtual const net::LoadStateWithParam& GetLoadState() = 0; |
Jan Wilken Dörrie | aace0cfef | 2021-03-11 22:01:58 | [diff] [blame] | 686 | virtual const std::u16string& GetLoadStateHost() = 0; |
[email protected] | be1f56ab | 2011-12-22 06:55:31 | [diff] [blame] | 687 | |
[email protected] | 6dfed69 | 2014-05-22 04:18:03 | [diff] [blame] | 688 | // Returns the upload progress. |
Lucas Furukawa Gadani | e1c5dfda | 2018-11-29 17:57:41 | [diff] [blame] | 689 | virtual uint64_t GetUploadSize() = 0; |
| 690 | virtual uint64_t GetUploadPosition() = 0; |
[email protected] | be1f56ab | 2011-12-22 06:55:31 | [diff] [blame] | 691 | |
[email protected] | 6dfed69 | 2014-05-22 04:18:03 | [diff] [blame] | 692 | // Returns the character encoding of the page. |
Lucas Furukawa Gadani | e1c5dfda | 2018-11-29 17:57:41 | [diff] [blame] | 693 | virtual const std::string& GetEncoding() = 0; |
[email protected] | be1f56ab | 2011-12-22 06:55:31 | [diff] [blame] | 694 | |
Shubhie Panicker | ddf2a4e | 2018-03-06 00:09:06 | [diff] [blame] | 695 | // Indicates that the tab was previously discarded. |
| 696 | // wasDiscarded is exposed on Document after discard, see: |
| 697 | // https://github.com/WICG/web-lifecycle |
| 698 | // When a tab is discarded, WebContents sets was_discarded on its |
| 699 | // root FrameTreeNode. |
| 700 | // In addition, when a child frame is created, this bit is passed on from |
| 701 | // parent to child. |
| 702 | // When a navigation request is created, was_discarded is passed on to the |
| 703 | // request and reset to false in FrameTreeNode. |
Charles Zhao | d72f99d | 2018-09-17 14:18:27 | [diff] [blame] | 704 | virtual bool WasDiscarded() = 0; |
Shubhie Panicker | ddf2a4e | 2018-03-06 00:09:06 | [diff] [blame] | 705 | virtual void SetWasDiscarded(bool was_discarded) = 0; |
| 706 | |
Anthony Vallee-Dubois | aa02652 | 2022-12-07 17:24:28 | [diff] [blame] | 707 | // Notifies observers that this WebContents is about to be discarded, and |
| 708 | // replaced with `new_contents`. See the comment on |
| 709 | // WebContentsObserver::AboutToBeDiscarded. |
| 710 | virtual void AboutToBeDiscarded(WebContents* new_contents) = 0; |
| 711 | |
[email protected] | be1f56ab | 2011-12-22 06:55:31 | [diff] [blame] | 712 | // Internal state ------------------------------------------------------------ |
| 713 | |
Yuri Wiitala | ba4a68e | 2021-01-07 23:32:19 | [diff] [blame] | 714 | // Indicates whether the WebContents is being captured (e.g., for screenshots, |
| 715 | // or mirroring video and/or audio). Each IncrementCapturerCount() call must |
| 716 | // be balanced with a corresponding DecrementCapturerCount() call. |
| 717 | // |
| 718 | // Both internal-to-content and embedders must increment the capturer count |
| 719 | // while capturing to ensure "hidden rendering" optimizations are disabled. |
| 720 | // For example, renderers will be configured to produce compositor frames |
| 721 | // regardless of their "backgrounded" or on-screen occlusion state. |
| 722 | // |
| 723 | // Embedders can detect whether a WebContents is being captured (see |
| 724 | // IsBeingCaptured() below) and use this, for example, to provide an |
| 725 | // alternative user interface. So, developers should be careful to understand |
| 726 | // the side-effects from using or changing these APIs, both upstream and |
| 727 | // downstream of this API layer. |
| 728 | // |
Dale Curtis | 7030f25 | 2021-04-07 14:05:31 | [diff] [blame] | 729 | // Callers must hold onto the returned base::ScopedClosureRunner until they |
| 730 | // are done capturing. |
| 731 | // |
Yuri Wiitala | ba4a68e | 2021-01-07 23:32:19 | [diff] [blame] | 732 | // |capture_size| is only used in the case of mirroring (i.e., screen capture |
| 733 | // video); otherwise, an empty gfx::Size should be provided. This specifies |
| 734 | // the capturer's target video resolution, but can be empty to mean |
| 735 | // "unspecified." This becomes a temporary override to GetPreferredSize(), |
| 736 | // allowing embedders to size the WebContents on-screen views for optimal |
| 737 | // capture quality. |
| 738 | // |
| 739 | // |stay_hidden| affects the page visibility state of the renderers (i.e., a |
| 740 | // web page can be made aware of whether it is actually user-visible). If |
| 741 | // true, the show/hide state of the WebContents will be passed to the |
| 742 | // renderers, like normal. If false, the renderers will always be told they |
| 743 | // are user-visible while being captured. |
Dale Curtis | 7030f25 | 2021-04-07 14:05:31 | [diff] [blame] | 744 | // |
| 745 | // |stay_awake| will cause a WakeLock to be held which prevents system sleep. |
Elad Alon | 0feb660 | 2021-10-14 09:26:36 | [diff] [blame] | 746 | // |
| 747 | // |is_activity| means the capture will cause the last active time to be |
| 748 | // updated. |
Daniel Cheng | 9c9fa1a | 2022-01-14 03:42:11 | [diff] [blame] | 749 | [[nodiscard]] virtual base::ScopedClosureRunner IncrementCapturerCount( |
Dale Curtis | 7030f25 | 2021-04-07 14:05:31 | [diff] [blame] | 750 | const gfx::Size& capture_size, |
| 751 | bool stay_hidden, |
Elad Alon | 0feb660 | 2021-10-14 09:26:36 | [diff] [blame] | 752 | bool stay_awake, |
Daniel Cheng | 9c9fa1a | 2022-01-14 03:42:11 | [diff] [blame] | 753 | bool is_activity = true) = 0; |
Yuri Wiitala | ba4a68e | 2021-01-07 23:32:19 | [diff] [blame] | 754 | |
Elad Alon | f156eb6 | 2021-05-17 22:02:37 | [diff] [blame] | 755 | // Getter for the capture handle, which allows a captured application to |
| 756 | // opt-in to exposing information to its capturer(s). |
| 757 | virtual const blink::mojom::CaptureHandleConfig& GetCaptureHandleConfig() = 0; |
| 758 | |
Yuri Wiitala | ba4a68e | 2021-01-07 23:32:19 | [diff] [blame] | 759 | // Returns true if audio/screenshot/video is being captured by the embedder, |
| 760 | // as indicated by calls to IncrementCapturerCount(). |
Lucas Furukawa Gadani | e1c5dfda | 2018-11-29 17:57:41 | [diff] [blame] | 761 | virtual bool IsBeingCaptured() = 0; |
Yuri Wiitala | ba4a68e | 2021-01-07 23:32:19 | [diff] [blame] | 762 | |
| 763 | // Returns true if audio/screenshot/video is being captured by the embedder |
| 764 | // and renderers are being told they are always user-visible, as indicated by |
| 765 | // calls to IncrementCapturerCount(). |
Xianzhu Wang | c61434c | 2020-08-21 19:17:30 | [diff] [blame] | 766 | virtual bool IsBeingVisiblyCaptured() = 0; |
[email protected] | be1f56ab | 2011-12-22 06:55:31 | [diff] [blame] | 767 | |
miu | 50f9789 | 2014-09-22 22:49:52 | [diff] [blame] | 768 | // Indicates/Sets whether all audio output from this WebContents is muted. |
Yuri Wiitala | ba4a68e | 2021-01-07 23:32:19 | [diff] [blame] | 769 | // This does not affect audio capture, just local/system output. |
Lucas Furukawa Gadani | e1c5dfda | 2018-11-29 17:57:41 | [diff] [blame] | 770 | virtual bool IsAudioMuted() = 0; |
miu | 50f9789 | 2014-09-22 22:49:52 | [diff] [blame] | 771 | virtual void SetAudioMuted(bool mute) = 0; |
| 772 | |
Jan Rucka | 442c83f | 2017-08-08 13:27:54 | [diff] [blame] | 773 | // Returns true if the audio is currently audible. |
| 774 | virtual bool IsCurrentlyAudible() = 0; |
| 775 | |
ortuno | df4d798 | 2016-04-08 02:33:35 | [diff] [blame] | 776 | // Indicates whether any frame in the WebContents is connected to a Bluetooth |
| 777 | // Device. |
Lucas Furukawa Gadani | e1c5dfda | 2018-11-29 17:57:41 | [diff] [blame] | 778 | virtual bool IsConnectedToBluetoothDevice() = 0; |
ortuno | 32e7db3c | 2016-03-29 16:14:20 | [diff] [blame] | 779 | |
Ovidio Henriquez | 76696f6 | 2020-07-08 03:06:59 | [diff] [blame] | 780 | // Indicates whether any frame in the WebContents is scanning for Bluetooth |
| 781 | // devices. |
| 782 | virtual bool IsScanningForBluetoothDevices() = 0; |
| 783 | |
Reilly Grant | 5e7c79b2 | 2019-04-09 17:26:20 | [diff] [blame] | 784 | // Indicates whether any frame in the WebContents is connected to a serial |
| 785 | // port. |
Lucas Furukawa Gadani | 4b4eed0 | 2019-06-04 23:12:04 | [diff] [blame] | 786 | virtual bool IsConnectedToSerialPort() = 0; |
Reilly Grant | 5e7c79b2 | 2019-04-09 17:26:20 | [diff] [blame] | 787 | |
Matt Reynolds | e8c6c1f | 2019-11-02 09:53:53 | [diff] [blame] | 788 | // Indicates whether any frame in the WebContents is connected to a HID |
| 789 | // device. |
| 790 | virtual bool IsConnectedToHidDevice() = 0; |
| 791 | |
Matt Reynolds | ed00ca7e7 | 2022-08-18 20:56:20 | [diff] [blame] | 792 | // Indicates whether any frame in the WebContents is connected to a USB |
| 793 | // device. |
| 794 | virtual bool IsConnectedToUsbDevice() = 0; |
| 795 | |
Austin Sullivan | afefb72 | 2021-01-14 01:26:39 | [diff] [blame] | 796 | // Indicates whether any frame in the WebContents has File System Access |
Marijn Kruisselbrink | 2905104 | 2019-08-06 22:56:55 | [diff] [blame] | 797 | // handles. |
Austin Sullivan | afefb72 | 2021-01-14 01:26:39 | [diff] [blame] | 798 | virtual bool HasFileSystemAccessHandles() = 0; |
Marijn Kruisselbrink | 2905104 | 2019-08-06 22:56:55 | [diff] [blame] | 799 | |
sawtelle | a7333a8 | 2018-05-31 02:36:36 | [diff] [blame] | 800 | // Indicates whether a video is in Picture-in-Picture for |this|. |
Lucas Furukawa Gadani | e1c5dfda | 2018-11-29 17:57:41 | [diff] [blame] | 801 | virtual bool HasPictureInPictureVideo() = 0; |
sawtelle | a7333a8 | 2018-05-31 02:36:36 | [diff] [blame] | 802 | |
Klaus Weidner | d821943 | 2022-02-08 21:50:59 | [diff] [blame] | 803 | // Indicates whether a document is in Picture-in-Picture for |this|. |
| 804 | virtual bool HasPictureInPictureDocument() = 0; |
| 805 | |
danakj | cdab6ed5 | 2021-02-10 23:44:13 | [diff] [blame] | 806 | // Indicates whether this tab should be considered crashed. This becomes false |
| 807 | // again when the renderer process is recreated after a crash in order to |
| 808 | // recreate the main frame. |
Lucas Furukawa Gadani | e1c5dfda | 2018-11-29 17:57:41 | [diff] [blame] | 809 | virtual bool IsCrashed() = 0; |
[email protected] | be1f56ab | 2011-12-22 06:55:31 | [diff] [blame] | 810 | |
Lucas Furukawa Gadani | e1c5dfda | 2018-11-29 17:57:41 | [diff] [blame] | 811 | virtual base::TerminationStatus GetCrashedStatus() = 0; |
| 812 | virtual int GetCrashedErrorCode() = 0; |
[email protected] | be1f56ab | 2011-12-22 06:55:31 | [diff] [blame] | 813 | |
| 814 | // Whether the tab is in the process of being destroyed. |
Lucas Furukawa Gadani | e1c5dfda | 2018-11-29 17:57:41 | [diff] [blame] | 815 | virtual bool IsBeingDestroyed() = 0; |
[email protected] | be1f56ab | 2011-12-22 06:55:31 | [diff] [blame] | 816 | |
| 817 | // Convenience method for notifying the delegate of a navigation state |
[email protected] | 7f92483 | 2014-08-09 05:57:22 | [diff] [blame] | 818 | // change. |
| 819 | virtual void NotifyNavigationStateChanged(InvalidateTypes changed_flags) = 0; |
[email protected] | be1f56ab | 2011-12-22 06:55:31 | [diff] [blame] | 820 | |
Chris Hamilton | df0d72cd | 2018-05-29 16:23:53 | [diff] [blame] | 821 | // Notifies the WebContents that audio state has changed. The contents is |
| 822 | // aware of all of its potential sources of audio and needs to poll them |
| 823 | // directly to determine its aggregate audio state. |
| 824 | virtual void OnAudioStateChanged() = 0; |
altimin | d8bd26c | 2016-11-04 11:44:54 | [diff] [blame] | 825 | |
georgesak | 5582cbe | 2015-05-22 22:08:07 | [diff] [blame] | 826 | // Get/Set the last time that the WebContents was made active (either when it |
| 827 | // was created or shown with WasShown()). |
Lucas Furukawa Gadani | e1c5dfda | 2018-11-29 17:57:41 | [diff] [blame] | 828 | virtual base::TimeTicks GetLastActiveTime() = 0; |
[email protected] | be1f56ab | 2011-12-22 06:55:31 | [diff] [blame] | 829 | |
Francois Doray | 1880097 | 2017-08-25 22:38:58 | [diff] [blame] | 830 | // Invoked when the WebContents becomes shown/hidden. A hidden WebContents |
| 831 | // isn't painted on the screen. |
[email protected] | 9e2e463 | 2012-07-27 16:38:41 | [diff] [blame] | 832 | virtual void WasShown() = 0; |
[email protected] | 3e32414 | 2012-06-25 18:26:33 | [diff] [blame] | 833 | virtual void WasHidden() = 0; |
[email protected] | be1f56ab | 2011-12-22 06:55:31 | [diff] [blame] | 834 | |
Francois Doray | e616115 | 2018-03-27 22:05:37 | [diff] [blame] | 835 | // Invoked when the WebContents becomes occluded. An occluded WebContents |
| 836 | // isn't painted on the screen, except in a window switching feature (e.g. |
| 837 | // Alt-Tab). |
Francois Doray | 1880097 | 2017-08-25 22:38:58 | [diff] [blame] | 838 | virtual void WasOccluded() = 0; |
Francois Doray | 1880097 | 2017-08-25 22:38:58 | [diff] [blame] | 839 | |
Francois Doray | fe4a177 | 2018-02-17 04:17:09 | [diff] [blame] | 840 | // Returns the visibility of the WebContents' view. |
Lucas Furukawa Gadani | e1c5dfda | 2018-11-29 17:57:41 | [diff] [blame] | 841 | virtual Visibility GetVisibility() = 0; |
Francois Doray | fe4a177 | 2018-02-17 04:17:09 | [diff] [blame] | 842 | |
Sreeja Kamishetty | 1c1ca7a | 2023-05-12 16:36:40 | [diff] [blame] | 843 | // Sets the visibility of the WebContents' view and notifies the WebContents |
| 844 | // observers about Visibility change. Call UpdateWebContentsVisibility instead |
| 845 | // of WasShown() if you are setting Visibility to VISIBLE for the first time. |
Alison Gale | 53c77f6 | 2024-04-22 15:16:27 | [diff] [blame] | 846 | // TODO(crbug.com/40911760): Make updating Visibility more robust. |
Sreeja Kamishetty | 1c1ca7a | 2023-05-12 16:36:40 | [diff] [blame] | 847 | virtual void UpdateWebContentsVisibility(Visibility visibility) = 0; |
| 848 | |
Alex Moshchuk | 5bcd7c1 | 2019-11-12 22:55:31 | [diff] [blame] | 849 | // This function checks *all* frames in this WebContents (not just the main |
| 850 | // frame) and returns true if at least one frame has either a beforeunload or |
Rakina Zata Amni | 26e8d8a | 2020-08-05 06:06:06 | [diff] [blame] | 851 | // an unload/pagehide/visibilitychange handler. |
Alex Moshchuk | 5bcd7c1 | 2019-11-12 22:55:31 | [diff] [blame] | 852 | // |
| 853 | // The value of this may change over time. For example, if true and the |
| 854 | // beforeunload listener is executed and allows the user to exit, then this |
[email protected] | be1f56ab | 2011-12-22 06:55:31 | [diff] [blame] | 855 | // returns false. |
Rakina Zata Amni | 26e8d8a | 2020-08-05 06:06:06 | [diff] [blame] | 856 | virtual bool NeedToFireBeforeUnloadOrUnloadEvents() = 0; |
[email protected] | be1f56ab | 2011-12-22 06:55:31 | [diff] [blame] | 857 | |
Alex Moshchuk | 6fcaca75 | 2018-07-14 02:13:59 | [diff] [blame] | 858 | // Runs the beforeunload handler for the main frame and all its subframes. |
| 859 | // See also ClosePage in RenderViewHostImpl, which runs the unload handler. |
Chris Hamilton | 3b3e315d | 2018-09-19 13:16:21 | [diff] [blame] | 860 | // If |auto_cancel| is true, and the beforeunload handler returns a non-empty |
| 861 | // string (indicating the page wants to present a confirmation dialog), then |
| 862 | // the beforeunload operation will automatically return with |proceed=false| |
| 863 | // and no dialog will be shown to the user. This is used to interrupt a |
| 864 | // potential discard without causing the dialog to appear. |
| 865 | virtual void DispatchBeforeUnload(bool auto_cancel) = 0; |
[email protected] | 1c3f80bd | 2014-04-08 23:02:06 | [diff] [blame] | 866 | |
Lucas Furukawa Gadani | 6e5b4f3 | 2019-03-02 04:18:50 | [diff] [blame] | 867 | // Attaches |inner_web_contents| to the container frame |render_frame_host|, |
Kevin McNee | 9bec6a3d | 2021-05-13 22:19:02 | [diff] [blame] | 868 | // which must be in a FrameTree for this WebContents. This outer WebContents |
Lucas Furukawa Gadani | 6e5b4f3 | 2019-03-02 04:18:50 | [diff] [blame] | 869 | // takes ownership of |inner_web_contents|. |
| 870 | // Note: |render_frame_host| will be swapped out and destroyed during the |
Ehsan Karamad | 44fc7211 | 2019-02-26 18:15:47 | [diff] [blame] | 871 | // process. Generally a frame same-process with its parent is the right choice |
| 872 | // but ideally it should be "about:blank" to avoid problems with beforeunload. |
| 873 | // To ensure sane usage of this API users first should call the async API |
| 874 | // RenderFrameHost::PrepareForInnerWebContentsAttach first. |
W. James MacLean | 6288398 | 2019-11-12 20:39:00 | [diff] [blame] | 875 | // Note: If |is_full_page| is true, focus will be given to the inner |
| 876 | // WebContents. |
Lucas Furukawa Gadani | 6e5b4f3 | 2019-03-02 04:18:50 | [diff] [blame] | 877 | virtual void AttachInnerWebContents( |
| 878 | std::unique_ptr<WebContents> inner_web_contents, |
W. James MacLean | 6288398 | 2019-11-12 20:39:00 | [diff] [blame] | 879 | RenderFrameHost* render_frame_host, |
Dave Tapuska | 82b5401 | 2022-07-15 23:26:10 | [diff] [blame] | 880 | mojo::PendingAssociatedRemote<blink::mojom::RemoteFrame> remote_frame, |
| 881 | mojo::PendingAssociatedReceiver<blink::mojom::RemoteFrameHost> |
| 882 | remote_frame_host_receiver, |
W. James MacLean | 6288398 | 2019-11-12 20:39:00 | [diff] [blame] | 883 | bool is_full_page) = 0; |
lazyboy | 6ec48b2a | 2015-06-29 15:18:14 | [diff] [blame] | 884 | |
W. James MacLean | 2539adb3 | 2019-12-13 00:40:44 | [diff] [blame] | 885 | // Returns whether this WebContents is an inner WebContents for a guest. |
| 886 | // Important: please avoid using this in new callsites, and use |
| 887 | // GetOuterWebContents instead. |
| 888 | virtual bool IsInnerWebContentsForGuest() = 0; |
| 889 | |
Lucas Furukawa Gadani | 2ec00c8 | 2018-12-14 15:53:16 | [diff] [blame] | 890 | // Returns the outer WebContents frame, the same frame that this WebContents |
| 891 | // was attached in AttachToOuterWebContentsFrame(). |
| 892 | virtual RenderFrameHost* GetOuterWebContentsFrame() = 0; |
| 893 | |
Wei Li | 5c0b4d1 | 2018-03-22 15:05:22 | [diff] [blame] | 894 | // Returns the outer WebContents of this WebContents if any. |
| 895 | // Otherwise, return nullptr. |
Lucas Furukawa Gadani | e1c5dfda | 2018-11-29 17:57:41 | [diff] [blame] | 896 | virtual WebContents* GetOuterWebContents() = 0; |
Wei Li | 5c0b4d1 | 2018-03-22 15:05:22 | [diff] [blame] | 897 | |
W. James MacLean | 3f9fba23 | 2018-08-16 15:20:36 | [diff] [blame] | 898 | // Returns the root WebContents of the WebContents tree. Always returns |
| 899 | // non-null value. |
| 900 | virtual WebContents* GetOutermostWebContents() = 0; |
| 901 | |
Lucas Furukawa Gadani | 2ec00c8 | 2018-12-14 15:53:16 | [diff] [blame] | 902 | // Returns a vector to the inner WebContents within this WebContents. |
| 903 | virtual std::vector<WebContents*> GetInnerWebContents() = 0; |
| 904 | |
Jeremy Roman | 7e70bf95 | 2020-01-07 23:23:58 | [diff] [blame] | 905 | // Returns the user-visible WebContents that is responsible for the UI |
| 906 | // activity in the provided WebContents. For example, this delegate may be |
| 907 | // aware that the contents is embedded in some other contents, or hosts |
| 908 | // background activity on behalf of a user-visible tab which should be used to |
| 909 | // display dialogs and similar affordances to the user. |
| 910 | // |
| 911 | // This may be distinct from the outer web contents (for example, the |
| 912 | // responsible contents may logically "own" a contents but not currently embed |
| 913 | // it for rendering). |
| 914 | // |
| 915 | // Always returns a non-null value. |
Jeremy Roman | c0c69be | 2023-11-21 19:14:52 | [diff] [blame] | 916 | // |
Alison Gale | 81f4f2c7 | 2024-04-22 19:33:31 | [diff] [blame] | 917 | // TODO(crbug.com/40939539): Consider replacing this with |
Jeremy Roman | c0c69be | 2023-11-21 19:14:52 | [diff] [blame] | 918 | // GuestViewBase::GetTopLevelWebContents, since that is now the only case |
| 919 | // where this would return a contents other than |this|. |
Jeremy Roman | 7e70bf95 | 2020-01-07 23:23:58 | [diff] [blame] | 920 | virtual WebContents* GetResponsibleWebContents() = 0; |
| 921 | |
dalecurtis | 6c58ed0 | 2016-10-28 23:02:37 | [diff] [blame] | 922 | // Invoked when visible security state changes. |
| 923 | virtual void DidChangeVisibleSecurityState() = 0; |
| 924 | |
Bruce Long | 1e3e1f54 | 2019-10-16 17:56:28 | [diff] [blame] | 925 | // Sends the current preferences to all renderer processes for the current |
| 926 | // page. |
| 927 | virtual void SyncRendererPrefs() = 0; |
| 928 | |
[email protected] | 0bfbf88 | 2011-12-22 18:19:27 | [diff] [blame] | 929 | // Commands ------------------------------------------------------------------ |
| 930 | |
| 931 | // Stop any pending navigation. |
| 932 | virtual void Stop() = 0; |
| 933 | |
Francois Doray | 47f759d | 2018-06-11 18:13:51 | [diff] [blame] | 934 | // Freezes or unfreezes the current page. A frozen page runs as few tasks as |
| 935 | // possible. This cannot be called when the page is visible. If the page is |
| 936 | // made visible after this is called, it is automatically unfrozen. |
| 937 | virtual void SetPageFrozen(bool frozen) = 0; |
Fadi Meawad | a6573e0 | 2018-03-10 00:52:11 | [diff] [blame] | 938 | |
[email protected] | d908348 | 2012-01-06 00:38:46 | [diff] [blame] | 939 | // Creates a new WebContents with the same state as this one. The returned |
[email protected] | 0bfbf88 | 2011-12-22 18:19:27 | [diff] [blame] | 940 | // heap-allocated pointer is owned by the caller. |
erikchen | 6c7df7f7a | 2018-05-03 18:13:59 | [diff] [blame] | 941 | virtual std::unique_ptr<WebContents> Clone() = 0; |
[email protected] | 0bfbf88 | 2011-12-22 18:19:27 | [diff] [blame] | 942 | |
[email protected] | 1f3fc1d | 2014-04-03 14:50:17 | [diff] [blame] | 943 | // Reloads the focused frame. |
arthursonzogni | 818c264 | 2019-09-27 12:18:10 | [diff] [blame] | 944 | virtual void ReloadFocusedFrame() = 0; |
[email protected] | 4fed370 | 2014-04-01 09:08:00 | [diff] [blame] | 945 | |
[email protected] | 1f3fc1d | 2014-04-03 14:50:17 | [diff] [blame] | 946 | // Editing commands ---------------------------------------------------------- |
| 947 | |
[email protected] | 959be4c | 2014-04-08 15:01:33 | [diff] [blame] | 948 | virtual void Undo() = 0; |
| 949 | virtual void Redo() = 0; |
| 950 | virtual void Cut() = 0; |
| 951 | virtual void Copy() = 0; |
| 952 | virtual void CopyToFindPboard() = 0; |
Leonard Grey | c2bc800 | 2023-03-08 17:53:06 | [diff] [blame] | 953 | virtual void CenterSelection() = 0; |
[email protected] | 959be4c | 2014-04-08 15:01:33 | [diff] [blame] | 954 | virtual void Paste() = 0; |
| 955 | virtual void PasteAndMatchStyle() = 0; |
| 956 | virtual void Delete() = 0; |
| 957 | virtual void SelectAll() = 0; |
yabinh | 351e7ec | 2017-03-10 02:43:24 | [diff] [blame] | 958 | virtual void CollapseSelection() = 0; |
Leonard Grey | f378e7d | 2021-03-25 20:53:50 | [diff] [blame] | 959 | virtual void ScrollToTopOfDocument() = 0; |
| 960 | virtual void ScrollToBottomOfDocument() = 0; |
[email protected] | 959be4c | 2014-04-08 15:01:33 | [diff] [blame] | 961 | |
aurimas | ab031902 | 2015-07-10 21:57:38 | [diff] [blame] | 962 | // Adjust the selection starting and ending points in the focused frame by |
| 963 | // the given amounts. A negative amount moves the selection towards the |
| 964 | // beginning of the document, a positive amount moves the selection towards |
| 965 | // the end of the document. |
| 966 | virtual void AdjustSelectionByCharacterOffset(int start_adjust, |
Shimi Zhang | 37deeb2 | 2017-09-28 00:59:01 | [diff] [blame] | 967 | int end_adjust, |
| 968 | bool show_selection_menu) = 0; |
aurimas | ab031902 | 2015-07-10 21:57:38 | [diff] [blame] | 969 | |
[email protected] | 1f3fc1d | 2014-04-03 14:50:17 | [diff] [blame] | 970 | // Replaces the currently selected word or a word around the cursor. |
Jan Wilken Dörrie | aace0cfef | 2021-03-11 22:01:58 | [diff] [blame] | 971 | virtual void Replace(const std::u16string& word) = 0; |
[email protected] | 1f3fc1d | 2014-04-03 14:50:17 | [diff] [blame] | 972 | |
| 973 | // Replaces the misspelling in the current selection. |
Jan Wilken Dörrie | aace0cfef | 2021-03-11 22:01:58 | [diff] [blame] | 974 | virtual void ReplaceMisspelling(const std::u16string& word) = 0; |
[email protected] | 1f3fc1d | 2014-04-03 14:50:17 | [diff] [blame] | 975 | |
[email protected] | 959be4c | 2014-04-08 15:01:33 | [diff] [blame] | 976 | // Let the renderer know that the menu has been closed. |
Gyuyoung Kim | 1bc1ba8 | 2021-02-08 23:32:44 | [diff] [blame] | 977 | virtual void NotifyContextMenuClosed(const GURL& link_followed) = 0; |
[email protected] | 959be4c | 2014-04-08 15:01:33 | [diff] [blame] | 978 | |
| 979 | // Executes custom context menu action that was provided from Blink. |
Gyuyoung Kim | 1bc1ba8 | 2021-02-08 23:32:44 | [diff] [blame] | 980 | virtual void ExecuteCustomContextMenuCommand(int action, |
| 981 | const GURL& link_followed) = 0; |
[email protected] | 959be4c | 2014-04-08 15:01:33 | [diff] [blame] | 982 | |
[email protected] | 0bfbf88 | 2011-12-22 18:19:27 | [diff] [blame] | 983 | // Views and focus ----------------------------------------------------------- |
[email protected] | 4fed370 | 2014-04-01 09:08:00 | [diff] [blame] | 984 | |
[email protected] | fc2b46b | 2014-05-03 16:33:45 | [diff] [blame] | 985 | // Returns the native widget that contains the contents of the tab. |
| 986 | virtual gfx::NativeView GetNativeView() = 0; |
| 987 | |
| 988 | // Returns the native widget with the main content of the tab (i.e. the main |
| 989 | // render view host, though there may be many popups in the tab as children of |
| 990 | // the container). |
| 991 | virtual gfx::NativeView GetContentNativeView() = 0; |
| 992 | |
| 993 | // Returns the outermost native view. This will be used as the parent for |
| 994 | // dialog boxes. |
| 995 | virtual gfx::NativeWindow GetTopLevelNativeWindow() = 0; |
| 996 | |
| 997 | // Computes the rectangle for the native widget that contains the contents of |
| 998 | // the tab in the screen coordinate system. |
| 999 | virtual gfx::Rect GetContainerBounds() = 0; |
| 1000 | |
Takashi Toyoshima | ec7f2672 | 2024-02-16 05:47:26 | [diff] [blame] | 1001 | // Get the bounds of the View in the global screen position. |
[email protected] | fc2b46b | 2014-05-03 16:33:45 | [diff] [blame] | 1002 | virtual gfx::Rect GetViewBounds() = 0; |
| 1003 | |
Mugdha Lakhani | 0a0d786 | 2020-07-29 09:58:45 | [diff] [blame] | 1004 | // Resize a WebContents to |new_bounds|. |
| 1005 | virtual void Resize(const gfx::Rect& new_bounds) = 0; |
| 1006 | |
| 1007 | // Get the size of a WebContents. |
| 1008 | virtual gfx::Size GetSize() = 0; |
| 1009 | |
[email protected] | fc2b46b | 2014-05-03 16:33:45 | [diff] [blame] | 1010 | // Returns the current drop data, if any. |
| 1011 | virtual DropData* GetDropData() = 0; |
| 1012 | |
| 1013 | // Sets focus to the native widget for this tab. |
| 1014 | virtual void Focus() = 0; |
| 1015 | |
| 1016 | // Sets focus to the appropriate element when the WebContents is shown the |
| 1017 | // first time. |
| 1018 | virtual void SetInitialFocus() = 0; |
| 1019 | |
| 1020 | // Stores the currently focused view. |
| 1021 | virtual void StoreFocus() = 0; |
| 1022 | |
| 1023 | // Restores focus to the last focus view. If StoreFocus has not yet been |
| 1024 | // invoked, SetInitialFocus is invoked. |
| 1025 | virtual void RestoreFocus() = 0; |
| 1026 | |
[email protected] | 0bfbf88 | 2011-12-22 18:19:27 | [diff] [blame] | 1027 | // Focuses the first (last if |reverse| is true) element in the page. |
| 1028 | // Invoked when this tab is getting the focus through tab traversal (|reverse| |
| 1029 | // is true when using Shift-Tab). |
| 1030 | virtual void FocusThroughTabTraversal(bool reverse) = 0; |
| 1031 | |
[email protected] | 0bfbf88 | 2011-12-22 18:19:27 | [diff] [blame] | 1032 | // Misc state & callbacks ---------------------------------------------------- |
| 1033 | |
[email protected] | a53209b | 2012-01-20 16:48:16 | [diff] [blame] | 1034 | // Check whether we can do the saving page operation this page given its MIME |
| 1035 | // type. |
| 1036 | virtual bool IsSavable() = 0; |
| 1037 | |
[email protected] | 0bfbf88 | 2011-12-22 18:19:27 | [diff] [blame] | 1038 | // Prepare for saving the current web page to disk. |
| 1039 | virtual void OnSavePage() = 0; |
| 1040 | |
| 1041 | // Save page with the main HTML file path, the directory for saving resources, |
| 1042 | // and the save type: HTML only or complete web page. Returns true if the |
| 1043 | // saving process has been initiated successfully. |
[email protected] | c42de73 | 2013-02-16 06:26:31 | [diff] [blame] | 1044 | virtual bool SavePage(const base::FilePath& main_file, |
| 1045 | const base::FilePath& dir_path, |
[email protected] | a53209b | 2012-01-20 16:48:16 | [diff] [blame] | 1046 | SavePageType save_type) = 0; |
[email protected] | 0bfbf88 | 2011-12-22 18:19:27 | [diff] [blame] | 1047 | |
Yao Xiao | e500704 | 2021-02-26 02:32:09 | [diff] [blame] | 1048 | // Saves the given frame's URL to the local filesystem. If `rfh` is provided, |
| 1049 | // the saving is performed in its context. For example, the associated |
| 1050 | // navigation isolation info will be used for making the network request. |
[email protected] | 3c71576ce | 2013-07-23 02:00:01 | [diff] [blame] | 1051 | virtual void SaveFrame(const GURL& url, |
Yao Xiao | e500704 | 2021-02-26 02:32:09 | [diff] [blame] | 1052 | const Referrer& referrer, |
| 1053 | RenderFrameHost* rfh) = 0; |
[email protected] | 3c71576ce | 2013-07-23 02:00:01 | [diff] [blame] | 1054 | |
kundaji | 6c7f969 | 2015-03-09 18:00:37 | [diff] [blame] | 1055 | // Saves the given frame's URL to the local filesystem. The headers, if |
| 1056 | // provided, is used to make a request to the URL rather than using cache. |
| 1057 | // Format of |headers| is a new line separated list of key value pairs: |
Jeremy Roman | cfa82c65 | 2021-07-06 21:43:27 | [diff] [blame] | 1058 | // "<key1>: <value1>\r\n<key2>: <value2>". The saving is performed in the |
| 1059 | // context of `rfh`. For example, the associated navigation isolation info |
Jeremy Roman | 4d408d8a | 2024-01-10 02:27:21 | [diff] [blame] | 1060 | // will be used for making the network request. If `is_subresource` is true, |
| 1061 | // the URL is assumed to correspond to a subresource loaded in the frame, |
| 1062 | // as opposed to the main (generally, document) resource. |
Yao Xiao | e500704 | 2021-02-26 02:32:09 | [diff] [blame] | 1063 | virtual void SaveFrameWithHeaders(const GURL& url, |
| 1064 | const Referrer& referrer, |
| 1065 | const std::string& headers, |
Jan Wilken Dörrie | aace0cfef | 2021-03-11 22:01:58 | [diff] [blame] | 1066 | const std::u16string& suggested_filename, |
Jeremy Roman | 4d408d8a | 2024-01-10 02:27:21 | [diff] [blame] | 1067 | RenderFrameHost* rfh, |
| 1068 | bool is_subresource) = 0; |
kundaji | 6c7f969 | 2015-03-09 18:00:37 | [diff] [blame] | 1069 | |
Angel Alvarez | 90249668 | 2019-08-27 22:58:42 | [diff] [blame] | 1070 | // Generate an MHTML representation of the current page conforming to the |
| 1071 | // settings provided by |params| and returning final status information via |
| 1072 | // the callback. See MHTMLGenerationParams for details on generation settings. |
| 1073 | // A resulting |file_size| of -1 represents a failure. Any other value |
| 1074 | // represents the size of the successfully generated file. |
| 1075 | // |
| 1076 | // TODO(https://crbug.com/915966): GenerateMHTML will eventually be removed |
| 1077 | // and GenerateMHTMLWithResult will be renamed to GenerateMHTML to replace it. |
| 1078 | // Both GenerateMHTML and GenerateMHTMLWithResult perform the same operation. |
| 1079 | // however, GenerateMHTMLWithResult provides a struct as output, that contains |
| 1080 | // the file size and more. |
[email protected] | aa4f397 | 2012-03-01 18:12:12 | [diff] [blame] | 1081 | virtual void GenerateMHTML( |
dewittj | 6dc5747a | 2016-05-17 01:48:47 | [diff] [blame] | 1082 | const MHTMLGenerationParams& params, |
Tsuyoshi Horo | b0d8d90 | 2020-03-12 00:09:39 | [diff] [blame] | 1083 | base::OnceCallback<void(int64_t /* file_size */)> callback) = 0; |
Angel Alvarez | 90249668 | 2019-08-27 22:58:42 | [diff] [blame] | 1084 | virtual void GenerateMHTMLWithResult( |
| 1085 | const MHTMLGenerationParams& params, |
| 1086 | MHTMLGenerationResult::GenerateMHTMLCallback callback) = 0; |
[email protected] | aa4f397 | 2012-03-01 18:12:12 | [diff] [blame] | 1087 | |
Takashi Toyoshima | 6c58bbd | 2023-05-19 09:41:35 | [diff] [blame] | 1088 | // Returns the MIME type bound to the primary page contents after a primary |
| 1089 | // page navigation. |
Lucas Furukawa Gadani | e1c5dfda | 2018-11-29 17:57:41 | [diff] [blame] | 1090 | virtual const std::string& GetContentsMimeType() = 0; |
[email protected] | 0bfbf88 | 2011-12-22 18:19:27 | [diff] [blame] | 1091 | |
[email protected] | 0bfbf88 | 2011-12-22 18:19:27 | [diff] [blame] | 1092 | // Returns the settings which get passed to the renderer. |
Mario Sanchez Prada | 0bd8b8c | 2020-10-21 17:49:23 | [diff] [blame] | 1093 | virtual blink::RendererPreferences* GetMutableRendererPrefs() = 0; |
[email protected] | 0bfbf88 | 2011-12-22 18:19:27 | [diff] [blame] | 1094 | |
[email protected] | e35ccd55 | 2012-05-23 16:22:47 | [diff] [blame] | 1095 | // Tells the tab to close now. The tab will take care not to close until it's |
gab | 2998ee7 | 2017-05-05 16:23:50 | [diff] [blame] | 1096 | // out of nested run loops. |
[email protected] | e35ccd55 | 2012-05-23 16:22:47 | [diff] [blame] | 1097 | virtual void Close() = 0; |
| 1098 | |
[email protected] | 0bfbf88 | 2011-12-22 18:19:27 | [diff] [blame] | 1099 | // Indicates if this tab was explicitly closed by the user (control-w, close |
| 1100 | // tab menu item...). This is false for actions that indirectly close the tab, |
| 1101 | // such as closing the window. The setter is maintained by TabStripModel, and |
| 1102 | // the getter only useful from within TAB_CLOSED notification |
| 1103 | virtual void SetClosedByUserGesture(bool value) = 0; |
Lucas Furukawa Gadani | e1c5dfda | 2018-11-29 17:57:41 | [diff] [blame] | 1104 | virtual bool GetClosedByUserGesture() = 0; |
[email protected] | 0bfbf88 | 2011-12-22 18:19:27 | [diff] [blame] | 1105 | |
[email protected] | 0bfbf88 | 2011-12-22 18:19:27 | [diff] [blame] | 1106 | // Gets the minimum/maximum zoom percent. |
Lucas Furukawa Gadani | e1c5dfda | 2018-11-29 17:57:41 | [diff] [blame] | 1107 | virtual int GetMinimumZoomPercent() = 0; |
| 1108 | virtual int GetMaximumZoomPercent() = 0; |
[email protected] | 0bfbf88 | 2011-12-22 18:19:27 | [diff] [blame] | 1109 | |
mcnee | 432e47d | 2015-11-09 19:37:46 | [diff] [blame] | 1110 | // Set the renderer's page scale to the given factor. |
| 1111 | virtual void SetPageScale(float page_scale_factor) = 0; |
ccameron | b7c1d6c | 2015-03-09 17:08:24 | [diff] [blame] | 1112 | |
[email protected] | bcd281560 | 2012-01-14 18:17:23 | [diff] [blame] | 1113 | // Gets the preferred size of the contents. |
Lucas Furukawa Gadani | e1c5dfda | 2018-11-29 17:57:41 | [diff] [blame] | 1114 | virtual gfx::Size GetPreferredSize() = 0; |
[email protected] | bcd281560 | 2012-01-14 18:17:23 | [diff] [blame] | 1115 | |
Takumi Fujimoto | 4661871d | 2024-01-25 02:04:18 | [diff] [blame] | 1116 | // Called when the response to a pending pointer lock request has arrived. |
[email protected] | 0bfbf88 | 2011-12-22 18:19:27 | [diff] [blame] | 1117 | // Returns true if |allowed| is true and the mouse has been successfully |
| 1118 | // locked. |
Takumi Fujimoto | 4661871d | 2024-01-25 02:04:18 | [diff] [blame] | 1119 | virtual bool GotResponseToPointerLockRequest( |
James Hollyer | d5c9de46 | 2020-03-10 19:02:45 | [diff] [blame] | 1120 | blink::mojom::PointerLockResult result) = 0; |
| 1121 | |
Takumi Fujimoto | 4661871d | 2024-01-25 02:04:18 | [diff] [blame] | 1122 | // Wrapper around GotResponseToPointerLockRequest to fit into |
James Hollyer | d5c9de46 | 2020-03-10 19:02:45 | [diff] [blame] | 1123 | // ChromeWebViewPermissionHelperDelegate's structure. |
Takumi Fujimoto | 4661871d | 2024-01-25 02:04:18 | [diff] [blame] | 1124 | virtual void GotPointerLockPermissionResponse(bool allowed) = 0; |
[email protected] | bb81f38 | 2012-01-03 22:45:44 | [diff] [blame] | 1125 | |
Dave Tapuska | b499878 | 2020-10-08 17:22:47 | [diff] [blame] | 1126 | // Drop the mouse lock if it is currently locked, or reject an |
| 1127 | // outstanding request if it is pending. |
Takumi Fujimoto | 4661871d | 2024-01-25 02:04:18 | [diff] [blame] | 1128 | virtual void DropPointerLockForTesting() = 0; |
Dave Tapuska | b499878 | 2020-10-08 17:22:47 | [diff] [blame] | 1129 | |
Joe Downing | 13dd76b | 2018-04-09 18:32:15 | [diff] [blame] | 1130 | // Called when the response to a keyboard mouse lock request has arrived. |
| 1131 | // Returns false if the request is no longer valid, otherwise true. |
| 1132 | virtual bool GotResponseToKeyboardLockRequest(bool allowed) = 0; |
| 1133 | |
Julie Jeongeun Kim | 88ce9ec | 2023-07-28 02:25:40 | [diff] [blame] | 1134 | #if BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_APPLE) |
[email protected] | da854376 | 2012-03-20 08:52:20 | [diff] [blame] | 1135 | // Called when the user has selected a color in the color chooser. |
[email protected] | cb80545 | 2013-05-22 15:16:21 | [diff] [blame] | 1136 | virtual void DidChooseColorInColorChooser(SkColor color) = 0; |
[email protected] | da854376 | 2012-03-20 08:52:20 | [diff] [blame] | 1137 | |
| 1138 | // Called when the color chooser has ended. |
[email protected] | cb80545 | 2013-05-22 15:16:21 | [diff] [blame] | 1139 | virtual void DidEndColorChooser() = 0; |
Julie Jeongeun Kim | 88ce9ec | 2023-07-28 02:25:40 | [diff] [blame] | 1140 | #endif |
[email protected] | da854376 | 2012-03-20 08:52:20 | [diff] [blame] | 1141 | |
[email protected] | bb81f38 | 2012-01-03 22:45:44 | [diff] [blame] | 1142 | // Returns true if the location bar should be focused by default rather than |
| 1143 | // the page contents. The view calls this function when the tab is focused |
| 1144 | // to see what it should do. |
| 1145 | virtual bool FocusLocationBarByDefault() = 0; |
| 1146 | |
jochen | 6004a36 | 2017-02-04 00:11:40 | [diff] [blame] | 1147 | // Does this have an opener (corresponding to window.opener in JavaScript) |
| 1148 | // associated with it? |
Lucas Furukawa Gadani | e1c5dfda | 2018-11-29 17:57:41 | [diff] [blame] | 1149 | virtual bool HasOpener() = 0; |
[email protected] | 795c2897 | 2012-12-06 06:13:39 | [diff] [blame] | 1150 | |
mlamouri | 8c61ffc | 2015-01-13 16:17:59 | [diff] [blame] | 1151 | // Returns the opener if HasOpener() is true, or nullptr otherwise. |
Lucas Furukawa Gadani | e1c5dfda | 2018-11-29 17:57:41 | [diff] [blame] | 1152 | virtual RenderFrameHost* GetOpener() = 0; |
jochen | 55ff350 | 2014-12-18 20:52:57 | [diff] [blame] | 1153 | |
jochen | 6004a36 | 2017-02-04 00:11:40 | [diff] [blame] | 1154 | // Returns true if this WebContents was opened by another WebContents, even |
| 1155 | // if the opener was suppressed. In contrast to HasOpener/GetOpener, the |
Rakina Zata Amni | 3a48ae4 | 2022-05-05 03:39:56 | [diff] [blame] | 1156 | // "original opener chain" doesn't reflect window.opener which can be |
| 1157 | // suppressed or updated. The "original opener" is the main frame of the |
| 1158 | // actual opener of this frame. This traces the all the way back, so if the |
| 1159 | // original opener was closed (deleted or severed due to COOP), but _it_ had |
| 1160 | // an original opener, this will return the original opener's original opener, |
| 1161 | // etc. |
| 1162 | virtual bool HasLiveOriginalOpenerChain() = 0; |
jochen | 6004a36 | 2017-02-04 00:11:40 | [diff] [blame] | 1163 | |
Rakina Zata Amni | 3a48ae4 | 2022-05-05 03:39:56 | [diff] [blame] | 1164 | // Returns the "original opener WebContents" if HasLiveOriginalOpenerChain() |
| 1165 | // is true, or nullptr otherwise. See the comment for |
| 1166 | // `HasLiveOriginalOpenerChain()` for more details. |
| 1167 | virtual WebContents* GetFirstWebContentsInLiveOriginalOpenerChain() = 0; |
jochen | 6004a36 | 2017-02-04 00:11:40 | [diff] [blame] | 1168 | |
ke.he | 98b761e | 2017-05-09 05:59:17 | [diff] [blame] | 1169 | // Returns the WakeLockContext accociated with this WebContents. |
| 1170 | virtual device::mojom::WakeLockContext* GetWakeLockContext() = 0; |
| 1171 | |
Alan Cutter | 1c0d373 | 2020-03-04 14:56:21 | [diff] [blame] | 1172 | // |http_status_code| can be 0 e.g. for data: URLs. |
| 1173 | // |bitmaps| will be empty on download failure. |
| 1174 | // |sizes| are the sizes in pixels of the bitmaps before they were resized due |
| 1175 | // to the max bitmap size passed to DownloadImage(). Each entry in the bitmaps |
Mikel Astiz | 034ba14e | 2021-04-30 07:23:49 | [diff] [blame] | 1176 | // vector corresponds to an entry in the sizes vector (both vector sizes are |
| 1177 | // guaranteed to be equal). If a bitmap was resized, there should be a single |
| 1178 | // returned bitmap. |
Alan Cutter | 1c0d373 | 2020-03-04 14:56:21 | [diff] [blame] | 1179 | using ImageDownloadCallback = |
| 1180 | base::OnceCallback<void(int id, |
| 1181 | int http_status_code, |
| 1182 | const GURL& image_url, |
| 1183 | const std::vector<SkBitmap>& bitmaps, |
| 1184 | const std::vector<gfx::Size>& sizes)>; |
[email protected] | 795c2897 | 2012-12-06 06:13:39 | [diff] [blame] | 1185 | |
[email protected] | 41225fe | 2013-03-29 05:32:02 | [diff] [blame] | 1186 | // Sends a request to download the given image |url| and returns the unique |
[email protected] | 795c2897 | 2012-12-06 06:13:39 | [diff] [blame] | 1187 | // id of the download request. When the download is finished, |callback| will |
pkotwicz | fd77355 | 2015-03-16 00:29:14 | [diff] [blame] | 1188 | // be called with the bitmaps received from the renderer. |
| 1189 | // If |is_favicon| is true, the cookies are not sent and not accepted during |
| 1190 | // download. |
Eric Seckler | faddda8c | 2022-08-11 18:05:49 | [diff] [blame] | 1191 | // If there are no bitmap results <= |max_bitmap_size|, the smallest bitmap |
| 1192 | // is resized to |max_bitmap_size| and is the only result. |
Dibyajyoti Pal | 328a175 | 2022-07-22 16:33:45 | [diff] [blame] | 1193 | // A |max_bitmap_size| of 0 means unlimited. |
Fredrik Söderquist | b2b39eb9 | 2019-11-18 16:16:50 | [diff] [blame] | 1194 | // For vector images, |preferred_size| will serve as a viewport into which |
| 1195 | // the image will be rendered. This would usually be the dimensions of the |
Rouslan Solomakhin | db19343e | 2021-09-15 15:34:55 | [diff] [blame] | 1196 | // rectangle where the bitmap will be rendered. If |preferred_size| is empty, |
| 1197 | // any existing intrinsic dimensions of the image will be used. If |
Fredrik Söderquist | b2b39eb9 | 2019-11-18 16:16:50 | [diff] [blame] | 1198 | // |max_bitmap_size| is non-zero it will also impose an upper bound on the |
Rouslan Solomakhin | db19343e | 2021-09-15 15:34:55 | [diff] [blame] | 1199 | // longest edge of |preferred_size| (|preferred_size| will be scaled down). |
pkotwicz | fd77355 | 2015-03-16 00:29:14 | [diff] [blame] | 1200 | // If |bypass_cache| is true, |url| is requested from the server even if it |
| 1201 | // is present in the browser cache. |
[email protected] | 41225fe | 2013-03-29 05:32:02 | [diff] [blame] | 1202 | virtual int DownloadImage(const GURL& url, |
| 1203 | bool is_favicon, |
Rouslan Solomakhin | db19343e | 2021-09-15 15:34:55 | [diff] [blame] | 1204 | const gfx::Size& preferred_size, |
[email protected] | 263cb08f | 2013-09-18 00:26:30 | [diff] [blame] | 1205 | uint32_t max_bitmap_size, |
pkotwicz | fd77355 | 2015-03-16 00:29:14 | [diff] [blame] | 1206 | bool bypass_cache, |
Avi Drissman | a5a52dd | 2018-03-27 03:39:02 | [diff] [blame] | 1207 | ImageDownloadCallback callback) = 0; |
[email protected] | 795c2897 | 2012-12-06 06:13:39 | [diff] [blame] | 1208 | |
Danyao Wang | a78f3dd2 | 2020-03-05 05:31:27 | [diff] [blame] | 1209 | // Same as DownloadImage(), but uses the ImageDownloader from the specified |
| 1210 | // frame instead of the main frame. |
| 1211 | virtual int DownloadImageInFrame( |
Alexander Timin | 8690530c | 2021-06-19 00:34:32 | [diff] [blame] | 1212 | const GlobalRenderFrameHostId& initiator_frame_routing_id, |
Danyao Wang | a78f3dd2 | 2020-03-05 05:31:27 | [diff] [blame] | 1213 | const GURL& url, |
| 1214 | bool is_favicon, |
Rouslan Solomakhin | db19343e | 2021-09-15 15:34:55 | [diff] [blame] | 1215 | const gfx::Size& preferred_size, |
Danyao Wang | a78f3dd2 | 2020-03-05 05:31:27 | [diff] [blame] | 1216 | uint32_t max_bitmap_size, |
| 1217 | bool bypass_cache, |
| 1218 | ImageDownloadCallback callback) = 0; |
| 1219 | |
Joey Arhar | cac45bf | 2022-01-07 21:59:31 | [diff] [blame] | 1220 | // Finds text on a page. |search_text| should not be empty. |skip_delay| |
| 1221 | // indicates that the find request should be sent to the renderer immediately |
| 1222 | // instead of waiting for privacy/performance mitigations. |
[email protected] | 36ec24f | 2014-01-09 00:32:08 | [diff] [blame] | 1223 | virtual void Find(int request_id, |
Jan Wilken Dörrie | aace0cfef | 2021-03-11 22:01:58 | [diff] [blame] | 1224 | const std::u16string& search_text, |
Joey Arhar | cac45bf | 2022-01-07 21:59:31 | [diff] [blame] | 1225 | blink::mojom::FindOptionsPtr options, |
| 1226 | bool skip_delay = false) = 0; |
[email protected] | 36ec24f | 2014-01-09 00:32:08 | [diff] [blame] | 1227 | |
| 1228 | // Notifies the renderer that the user has closed the FindInPage window |
| 1229 | // (and what action to take regarding the selection). |
| 1230 | virtual void StopFinding(StopFindAction action) = 0; |
| 1231 | |
Tommy Steimel | 1836051 | 2017-11-01 00:38:19 | [diff] [blame] | 1232 | // Returns true if audio has been audible from the WebContents since the last |
| 1233 | // navigation. |
| 1234 | virtual bool WasEverAudible() = 0; |
| 1235 | |
avi | 0720b02e | 2017-06-13 03:22:13 | [diff] [blame] | 1236 | // Returns whether the renderer is in fullscreen mode. |
Avi Drissman | 97aef04 | 2020-06-30 21:04:48 | [diff] [blame] | 1237 | virtual bool IsFullscreen() = 0; |
avi | 0720b02e | 2017-06-13 03:22:13 | [diff] [blame] | 1238 | |
Rakina Zata Amni | 347b7090 | 2020-07-22 10:49:04 | [diff] [blame] | 1239 | // Returns a copy of the current WebPreferences associated with this |
| 1240 | // WebContents. If it does not exist, this will create one and send the newly |
| 1241 | // computed value to all renderers. |
| 1242 | // Note that this will not trigger a recomputation of WebPreferences if it |
| 1243 | // already exists - this will return the last computed/set value of |
| 1244 | // WebPreferences. If we want to guarantee that the value reflects the current |
| 1245 | // state of the WebContents, NotifyPreferencesChanged() should be called |
| 1246 | // before calling this. |
Gyuyoung Kim | 1ac4ca78 | 2020-09-11 03:32:51 | [diff] [blame] | 1247 | virtual const blink::web_pref::WebPreferences& |
| 1248 | GetOrCreateWebPreferences() = 0; |
Rakina Zata Amni | 347b7090 | 2020-07-22 10:49:04 | [diff] [blame] | 1249 | |
| 1250 | // Notify this WebContents that the preferences have changed, so it needs to |
| 1251 | // recompute the current WebPreferences based on the current state of the |
| 1252 | // WebContents, etc. This will send an IPC to all the renderer processes |
| 1253 | // associated with this WebContents. |
Rakina Zata Amni | 4029b6d | 2020-07-28 02:36:20 | [diff] [blame] | 1254 | // Note that this will do this by creating a new WebPreferences with default |
| 1255 | // values, then recomputing some of the attributes based on current states. |
| 1256 | // This means if there's any value previously set through SetWebPreferences |
| 1257 | // which does not have special recomputation logic in either |
| 1258 | // WebContentsImpl::ComputeWebPreferences or |
| 1259 | // ContentBrowserClient::OverrideWebkitPrefs, it will return back to its |
| 1260 | // default value whenever this function is called. |
Rakina Zata Amni | 347b7090 | 2020-07-22 10:49:04 | [diff] [blame] | 1261 | virtual void NotifyPreferencesChanged() = 0; |
| 1262 | |
| 1263 | // Sets the WebPreferences to |prefs|. This will send an IPC to all the |
| 1264 | // renderer processes associated with this WebContents. |
| 1265 | // Note that this is different from NotifyPreferencesChanged, which recomputes |
| 1266 | // the WebPreferences based on the current state of things. Instead, we're |
| 1267 | // setting this to a specific value. This also means that if we trigger a |
| 1268 | // recomputation of WebPreferences after this, the WebPreferences value will |
Rakina Zata Amni | 4029b6d | 2020-07-28 02:36:20 | [diff] [blame] | 1269 | // be overridden. if there's any value previously set through |
| 1270 | // SetWebPreferences which does not have special recomputation logic in either |
| 1271 | // WebContentsImpl::ComputeWebPreferences or |
| 1272 | // ContentBrowserClient::OverrideWebkitPrefs, it will return back to its |
| 1273 | // default value, which might be different from the value we set it to here. |
| 1274 | // If you want to use this function outside of tests, consider adding |
| 1275 | // recomputation logic in either of those functions. |
| 1276 | // TODO(rakina): Try to make values set through this function stick even after |
| 1277 | // recomputations. |
Gyuyoung Kim | 1ac4ca78 | 2020-09-11 03:32:51 | [diff] [blame] | 1278 | virtual void SetWebPreferences( |
| 1279 | const blink::web_pref::WebPreferences& prefs) = 0; |
Rakina Zata Amni | 347b7090 | 2020-07-22 10:49:04 | [diff] [blame] | 1280 | |
Rakina Zata Amni | 4029b6d | 2020-07-28 02:36:20 | [diff] [blame] | 1281 | // Passes current web preferences to all renderer in this WebContents after |
| 1282 | // possibly recomputing them as follows: all "fast" preferences (those not |
| 1283 | // requiring slow platform/device polling) are recomputed unconditionally; the |
| 1284 | // remaining "slow" ones are recomputed only if they have not been computed |
| 1285 | // before. |
| 1286 | // |
| 1287 | // This method must be called if any state that affects web preferences has |
| 1288 | // changed so that it can be recomputed and sent to the renderer. |
| 1289 | virtual void OnWebPreferencesChanged() = 0; |
| 1290 | |
Muyao Xu | db226be5 | 2023-12-01 04:23:09 | [diff] [blame] | 1291 | // Requests the renderer to exit fullscreen. |
| 1292 | // |will_cause_resize| indicates whether the fullscreen change causes a |
| 1293 | // view resize. e.g. This will be false when going from tab fullscreen to |
| 1294 | // browser fullscreen. |
| 1295 | virtual void ExitFullscreen(bool will_cause_resize) = 0; |
mlamouri | 7a78d6fd | 2015-01-17 13:23:53 | [diff] [blame] | 1296 | |
Avi Drissman | ced52b6 | 2019-08-14 21:25:46 | [diff] [blame] | 1297 | // The WebContents is trying to take some action that would cause user |
| 1298 | // confusion if taken while in fullscreen. If this WebContents or any outer |
| 1299 | // WebContents is in fullscreen, drop it. |
Avi Drissman | 1a55a9d6 | 2020-03-10 18:56:45 | [diff] [blame] | 1300 | // |
| 1301 | // Returns a ScopedClosureRunner, and for the lifetime of that closure, this |
| 1302 | // (and other related) WebContentses will not enter fullscreen. If the action |
| 1303 | // should cause a one-time dropping of fullscreen (e.g. a UI element not |
| 1304 | // attached to the WebContents), invoke RunAndReset() on the returned |
| 1305 | // base::ScopedClosureRunner to release the fullscreen block immediately. |
| 1306 | // Otherwise, if the action should cause fullscreen to be prohibited for a |
| 1307 | // span of time (e.g. a UI element attached to the WebContents), keep the |
| 1308 | // closure alive for that duration. |
Mike Wasserman | b6bc015 | 2020-08-25 22:46:20 | [diff] [blame] | 1309 | // |
| 1310 | // If |display_id| is valid, only WebContentses on that specific screen will |
| 1311 | // exit fullscreen; the scoped prohibition will still apply to all displays. |
| 1312 | // This supports sites using cross-screen window placement capabilities to |
| 1313 | // retain fullscreen and open or place a window on another screen. |
Daniel Cheng | 9c9fa1a | 2022-01-14 03:42:11 | [diff] [blame] | 1314 | [[nodiscard]] virtual base::ScopedClosureRunner ForSecurityDropFullscreen( |
| 1315 | int64_t display_id = display::kInvalidDisplayId) = 0; |
Avi Drissman | ced52b6 | 2019-08-14 21:25:46 | [diff] [blame] | 1316 | |
mariakhomenko | 44bdc473 | 2015-04-29 01:55:38 | [diff] [blame] | 1317 | // Unblocks requests from renderer for a newly created window. This is |
| 1318 | // used in showCreatedWindow() or sometimes later in cases where |
| 1319 | // delegate->ShouldResumeRequestsForCreatedWindow() indicated the requests |
| 1320 | // should not yet be resumed. Then the client is responsible for calling this |
| 1321 | // as soon as they are ready. |
| 1322 | virtual void ResumeLoadingCreatedWebContents() = 0; |
| 1323 | |
qinmin | 72e8bd0 | 2016-10-21 19:35:37 | [diff] [blame] | 1324 | // Sets whether the WebContents is for overlaying content on a page. |
| 1325 | virtual void SetIsOverlayContent(bool is_overlay_content) = 0; |
| 1326 | |
billorr | 21c005d | 2016-11-17 03:57:04 | [diff] [blame] | 1327 | virtual int GetCurrentlyPlayingVideoCount() = 0; |
peconn | 25795152 | 2017-06-09 18:24:59 | [diff] [blame] | 1328 | |
Arthur Sonzogni | c686e8f | 2024-01-11 08:36:37 | [diff] [blame] | 1329 | virtual std::optional<gfx::Size> GetFullscreenVideoSize() = 0; |
billorr | 21c005d | 2016-11-17 03:57:04 | [diff] [blame] | 1330 | |
ekaramad | 5c1f939 | 2017-01-25 02:05:23 | [diff] [blame] | 1331 | // Tells the renderer to clear the focused element (if any). |
| 1332 | virtual void ClearFocusedElement() = 0; |
| 1333 | |
| 1334 | // Returns true if the current focused element is editable. |
| 1335 | virtual bool IsFocusedElementEditable() = 0; |
| 1336 | |
ekaramad | f6750aa | 2017-06-06 18:29:42 | [diff] [blame] | 1337 | // Returns true if a context menu is showing on the page. |
Lucas Furukawa Gadani | e1c5dfda | 2018-11-29 17:57:41 | [diff] [blame] | 1338 | virtual bool IsShowingContextMenu() = 0; |
ekaramad | f6750aa | 2017-06-06 18:29:42 | [diff] [blame] | 1339 | |
| 1340 | // Tells the WebContents whether the context menu is showing. |
| 1341 | virtual void SetShowingContextMenu(bool showing) = 0; |
| 1342 | |
Xiaohan Wang | 6099ccb | 2022-01-13 22:09:42 | [diff] [blame] | 1343 | #if BUILDFLAG(IS_ANDROID) |
[email protected] | 155c7f2 | 2013-12-09 17:07:18 | [diff] [blame] | 1344 | CONTENT_EXPORT static WebContents* FromJavaWebContents( |
torne | b5fe8a6 | 2016-09-08 12:00:54 | [diff] [blame] | 1345 | const base::android::JavaRef<jobject>& jweb_contents_android); |
[email protected] | 155c7f2 | 2013-12-09 17:07:18 | [diff] [blame] | 1346 | virtual base::android::ScopedJavaLocalRef<jobject> GetJavaWebContents() = 0; |
paulmeyer | c0b762b | 2016-04-13 11:55:17 | [diff] [blame] | 1347 | |
Nicolas Ouellet-Payeur | 177a6c4 | 2023-01-25 20:25:07 | [diff] [blame] | 1348 | // Returns the value from CreateParams::java_creator_location. |
| 1349 | virtual base::android::ScopedJavaLocalRef<jthrowable> |
| 1350 | GetJavaCreatorLocation() = 0; |
| 1351 | |
paulmeyer | c0b762b | 2016-04-13 11:55:17 | [diff] [blame] | 1352 | // Selects and zooms to the find result nearest to the point (x,y) defined in |
| 1353 | // find-in-page coordinates. |
| 1354 | virtual void ActivateNearestFindResult(float x, float y) = 0; |
| 1355 | |
| 1356 | // Requests the rects of the current find matches from the renderer |
| 1357 | // process. |current_version| is the version of find rects that the caller |
| 1358 | // already knows about. This version will be compared to the current find |
| 1359 | // rects version in the renderer process (which is updated whenever the rects |
| 1360 | // change), to see which new rect data will need to be sent back. |
| 1361 | // |
| 1362 | // TODO(paulmeyer): This process will change slightly once multi-process |
| 1363 | // find-in-page is implemented. This comment should be updated at that time. |
| 1364 | virtual void RequestFindMatchRects(int current_version) = 0; |
sammc | f5f1b0f | 2016-09-20 23:05:11 | [diff] [blame] | 1365 | |
| 1366 | // Returns an InterfaceProvider for Java-implemented interfaces that are |
| 1367 | // scoped to this WebContents. This provides access to interfaces implemented |
| 1368 | // in Java in the browser process to C++ code in the browser process. |
rockot | 400ea35b | 2016-10-15 19:15:32 | [diff] [blame] | 1369 | virtual service_manager::InterfaceProvider* GetJavaInterfaces() = 0; |
Xiaohan Wang | f9beb2ea1d | 2022-01-15 22:14:54 | [diff] [blame] | 1370 | #endif // BUILDFLAG(IS_ANDROID) |
[email protected] | 155c7f2 | 2013-12-09 17:07:18 | [diff] [blame] | 1371 | |
Francois Doray | 6c26f334 | 2018-08-24 17:17:22 | [diff] [blame] | 1372 | // Returns true if the WebContents has completed its first meaningful paint |
| 1373 | // since the last navigation. |
Lucas Furukawa Gadani | e1c5dfda | 2018-11-29 17:57:41 | [diff] [blame] | 1374 | virtual bool CompletedFirstVisuallyNonEmptyPaint() = 0; |
Francois Doray | 6c26f334 | 2018-08-24 17:17:22 | [diff] [blame] | 1375 | |
Alison Gale | 923a33e | 2024-04-22 23:34:28 | [diff] [blame^] | 1376 | // TODO(crbug.com/41379215): This is a simple mitigation to validate |
Min Qin | 7b7cbbbf | 2018-06-04 21:49:31 | [diff] [blame] | 1377 | // that an action that requires a user gesture actually has one in the |
| 1378 | // trustworthy browser process, rather than relying on the untrustworthy |
| 1379 | // renderer. This should be eventually merged into and accounted for in the |
Evan Stade | 6decc97 | 2022-10-24 19:42:18 | [diff] [blame] | 1380 | // user activation work: crbug.com/848778 |
| 1381 | virtual bool HasRecentInteraction() = 0; |
Min Qin | 7b7cbbbf | 2018-06-04 21:49:31 | [diff] [blame] | 1382 | |
Frank Liberato | e837b36 | 2023-10-20 23:31:15 | [diff] [blame] | 1383 | // Causes the WebContents to ignore input events for at least as long as the |
Takashi Toyoshima | d72a465a | 2024-03-11 23:37:31 | [diff] [blame] | 1384 | // token exists. In the event of multiple calls, input events will be ignored |
Frank Liberato | e837b36 | 2023-10-20 23:31:15 | [diff] [blame] | 1385 | // until all tokens have been destroyed. |
Takashi Toyoshima | d72a465a | 2024-03-11 23:37:31 | [diff] [blame] | 1386 | // If WebInputEventAuditCallback is given, it can audits WebInputEvent based |
| 1387 | // input events and ignore only events that the callback returns false for the |
| 1388 | // event. Other kind of events, such as focus event or ui::Events will be |
| 1389 | // always ignored without asking the callback. The given callback will be |
| 1390 | // invoked only while the returned ScopedIgnoreInputEvents alives. |
| 1391 | using WebInputEventAuditCallback = |
| 1392 | base::RepeatingCallback<bool(const blink::WebInputEvent&)>; |
| 1393 | [[nodiscard]] virtual ScopedIgnoreInputEvents IgnoreInputEvents( |
| 1394 | std::optional<WebInputEventAuditCallback> audit_callback) = 0; |
Avi Drissman | 738ea19 | 2018-08-29 20:24:16 | [diff] [blame] | 1395 | |
Aidan Wolter | 52bcc12a | 2018-11-14 03:27:29 | [diff] [blame] | 1396 | // Returns the group id for all audio streams that correspond to a single |
| 1397 | // WebContents. This can be used to determine if a AudioOutputStream was |
| 1398 | // created from a renderer that originated from this WebContents. |
| 1399 | virtual base::UnguessableToken GetAudioGroupId() = 0; |
| 1400 | |
Mounir Lamouri | 7b4a1f23 | 2019-12-23 16:32:10 | [diff] [blame] | 1401 | // Returns the raw list of favicon candidates as reported to observers via |
| 1402 | // WebContentsObserver::DidUpdateFaviconURL() since the last navigation start. |
| 1403 | // Consider using FaviconDriver in components/favicon if possible for more |
| 1404 | // reliable favicon-related state. |
Miyoung Shin | 5709ab0 | 2020-02-19 06:50:41 | [diff] [blame] | 1405 | virtual const std::vector<blink::mojom::FaviconURLPtr>& GetFaviconURLs() = 0; |
Mounir Lamouri | 7b4a1f23 | 2019-12-23 16:32:10 | [diff] [blame] | 1406 | |
Amanda Baker | 228ec48 | 2021-03-24 19:50:08 | [diff] [blame] | 1407 | // Intended for desktop PWAs with manifest entry of window-controls-overlay, |
| 1408 | // This sends the available title bar area bounds to the renderer process. |
| 1409 | virtual void UpdateWindowControlsOverlay(const gfx::Rect& bounding_rect) = 0; |
Hassan Talat | d96dbc0 | 2021-01-20 08:02:04 | [diff] [blame] | 1410 | |
Amanda Baker | cee4f7f | 2021-07-02 01:53:47 | [diff] [blame] | 1411 | // Returns the Window Control Overlay rectangle. Only applies to an |
| 1412 | // outermost main frame's widget. Other widgets always returns an empty rect. |
| 1413 | virtual gfx::Rect GetWindowsControlsOverlayRect() const = 0; |
| 1414 | |
Sebastien Marchand | c38e5ae | 2021-02-18 20:28:13 | [diff] [blame] | 1415 | // Whether the WebContents has an active player that is effectively |
| 1416 | // fullscreen. That means that the video is either fullscreen or it is the |
| 1417 | // content of a fullscreen page (in other words, a fullscreen video with |
| 1418 | // custom controls). |
| 1419 | virtual bool HasActiveEffectivelyFullscreenVideo() = 0; |
| 1420 | |
Alexander Timin | e9f413e8 | 2021-03-12 14:06:44 | [diff] [blame] | 1421 | // Serialise this object into a trace. |
Alexander Timin | bebb200 | 2021-04-20 15:42:24 | [diff] [blame] | 1422 | virtual void WriteIntoTrace(perfetto::TracedValue context) = 0; |
Alexander Timin | e9f413e8 | 2021-03-12 14:06:44 | [diff] [blame] | 1423 | |
Lukasz Anforowicz | 2c1573a | 2021-09-21 18:58:18 | [diff] [blame] | 1424 | // Returns the value from CreateParams::creator_location. |
| 1425 | virtual const base::Location& GetCreatorLocation() = 0; |
| 1426 | |
Tommy Steimel | 57eafde | 2023-01-27 17:33:24 | [diff] [blame] | 1427 | // Returns the parameters associated with PictureInPicture WebContents |
Arthur Sonzogni | c686e8f | 2024-01-11 08:36:37 | [diff] [blame] | 1428 | virtual const std::optional<blink::mojom::PictureInPictureWindowOptions>& |
Tommy Steimel | 57eafde | 2023-01-27 17:33:24 | [diff] [blame] | 1429 | GetPictureInPictureOptions() const = 0; |
Tommy Steimel | 991916c4 | 2022-06-24 20:59:57 | [diff] [blame] | 1430 | |
Yoshisato Yanagisawa | 607a7cca | 2021-10-14 02:45:36 | [diff] [blame] | 1431 | // Hide or show the browser controls for the given WebContents, based on |
| 1432 | // allowed states, desired state and whether the transition should be animated |
| 1433 | // or not. |
| 1434 | virtual void UpdateBrowserControlsState(cc::BrowserControlsState constraints, |
| 1435 | cc::BrowserControlsState current, |
| 1436 | bool animate) = 0; |
| 1437 | |
Marja Hölttä | 2019e9d | 2023-09-07 14:07:35 | [diff] [blame] | 1438 | // Transmits data to V8CrowdsourcedCompileHintsConsumer in the renderer. The |
| 1439 | // data is a model describing which JavaScript functions on the page should be |
| 1440 | // eagerly parsed & compiled by the JS engine. |
| 1441 | virtual void SetV8CompileHints(base::ReadOnlySharedMemoryRegion data) = 0; |
| 1442 | |
Joe Mason | 7ae0e2b | 2021-11-01 12:30:36 | [diff] [blame] | 1443 | // Sets the last time a tab switch made this WebContents visible. |
| 1444 | // `start_time` is the timestamp of the input event that triggered the tab |
| 1445 | // switch. `destination_is_loaded` is true when |
| 1446 | // ResourceCoordinatorTabHelper::IsLoaded() is true for the new tab contents. |
| 1447 | // These will be used to record metrics with the latency between the input |
| 1448 | // event and the time when the WebContents is painted. |
| 1449 | virtual void SetTabSwitchStartTime(base::TimeTicks start_time, |
| 1450 | bool destination_is_loaded) = 0; |
| 1451 | |
Takashi Toyoshima | 8dfc05c | 2024-01-29 21:03:51 | [diff] [blame] | 1452 | // Checks if the WebContents host pages in preview mode. |
| 1453 | virtual bool IsInPreviewMode() const = 0; |
| 1454 | |
| 1455 | // Called before ActivatePreviewPage() to prepare the activation. This will |
| 1456 | // end the preview mode and IsInPreviewMode() will start returning false after |
| 1457 | // the call. This allows embedders to run preparation steps on the activating |
| 1458 | // WebContents (e.g. attach TabHelpers) before activating the page shown by |
| 1459 | // the WebContents through ActivatePreviewPage(). |
| 1460 | virtual void WillActivatePreviewPage() = 0; |
| 1461 | |
Takashi Toyoshima | 9ca8210 | 2023-10-24 02:13:27 | [diff] [blame] | 1462 | // Activates the primary page that is shown in preview mode. This will relax |
| 1463 | // capability restriction in the browser process, and notify the renderer to |
| 1464 | // process the prerendering activation algorithm. |
Takashi Toyoshima | 138cf44a | 2023-11-02 10:33:25 | [diff] [blame] | 1465 | // This all processes happens asynchronously, and |
| 1466 | // `WebContentsDelegate::DidActivatePreviewedPage` will be called once it's |
| 1467 | // done. |
Takashi Toyoshima | 138cf44a | 2023-11-02 10:33:25 | [diff] [blame] | 1468 | virtual void ActivatePreviewPage() = 0; |
Takashi Toyoshima | 9ca8210 | 2023-10-24 02:13:27 | [diff] [blame] | 1469 | |
Robert Lin | c37fb58 | 2021-11-11 03:18:47 | [diff] [blame] | 1470 | // Starts an embedder triggered (browser-initiated) prerendering page and |
| 1471 | // returns the unique_ptr<PrerenderHandle>, which cancels prerendering on its |
| 1472 | // destruction. If the prerendering failed to start (e.g. if prerendering is |
| 1473 | // disabled, failure happened or because this URL is already being |
| 1474 | // prerendered), this function returns a nullptr. |
Sreeja Kamishetty | ac12140e | 2022-07-14 22:16:51 | [diff] [blame] | 1475 | // PreloadingAttempt helps us to log various metrics associated with |
| 1476 | // particular prerendering attempt. `url_match_predicate` allows embedders to |
| 1477 | // define their own predicates for matching same-origin URLs during |
| 1478 | // prerendering activation; it would be useful if embedders want Prerender2 to |
| 1479 | // ignore some parameter mismatches. Note that if the mismatched prerender URL |
| 1480 | // will be activated due to the predicate returning true, the last committed |
| 1481 | // URL in the prerendered RenderFrameHost will be activated. |
HuanPo Lin | 2ebb36c | 2023-10-06 01:48:48 | [diff] [blame] | 1482 | // `prerender_navigation_handle_callback` allows embedders to attach their own |
| 1483 | // NavigationHandleUserData when prerender starts, and the user data can be |
| 1484 | // used for identifying the types of embedder for metrics logging. |
Robert Lin | c37fb58 | 2021-11-11 03:18:47 | [diff] [blame] | 1485 | virtual std::unique_ptr<PrerenderHandle> StartPrerendering( |
Asami Doi | cf0f164 | 2021-11-25 05:00:26 | [diff] [blame] | 1486 | const GURL& prerendering_url, |
Kouhei Ueno | 3f37992b | 2023-11-09 23:29:02 | [diff] [blame] | 1487 | PreloadingTriggerType trigger_type, |
Robert Lin | 125720c04 | 2022-01-21 01:14:58 | [diff] [blame] | 1488 | const std::string& embedder_histogram_suffix, |
Lingqi Chi | 21d9feb | 2022-02-02 09:42:18 | [diff] [blame] | 1489 | ui::PageTransition page_transition, |
Domenic Denicola | bb5d843c | 2023-07-18 01:47:33 | [diff] [blame] | 1490 | PreloadingHoldbackStatus holdback_status_override, |
Sreeja Kamishetty | ac12140e | 2022-07-14 22:16:51 | [diff] [blame] | 1491 | PreloadingAttempt* preloading_attempt, |
Taiyo Mizuhashi | 72be964 | 2024-03-21 13:45:37 | [diff] [blame] | 1492 | base::RepeatingCallback<bool(const GURL&)> url_match_predicate, |
Arthur Sonzogni | fd1e08d | 2024-03-05 15:59:36 | [diff] [blame] | 1493 | base::RepeatingCallback<void(NavigationHandle&)> |
Taiyo Mizuhashi | 72be964 | 2024-03-21 13:45:37 | [diff] [blame] | 1494 | prerender_navigation_handle_callback) = 0; |
Robert Lin | c37fb58 | 2021-11-11 03:18:47 | [diff] [blame] | 1495 | |
Kevin McNee | 097680d | 2023-04-05 22:14:51 | [diff] [blame] | 1496 | // May be called when the embedder believes that it is likely that the user |
| 1497 | // will perform a back navigation due to the trigger indicated by `predictor` |
| 1498 | // (e.g. they're hovering over a back button). `disposition` indicates where |
| 1499 | // the navigation is predicted to happen (which could differ from where the |
| 1500 | // navigation actually happens). |
| 1501 | virtual void BackNavigationLikely(PreloadingPredictor predictor, |
| 1502 | WindowOpenDisposition disposition) = 0; |
| 1503 | |
Andy Paicu | 5608bda8 | 2023-03-03 15:09:20 | [diff] [blame] | 1504 | // Returns a scope object that needs to be owned by caller in order to |
Jan Keitel | 1d8d51d | 2023-08-22 05:53:47 | [diff] [blame] | 1505 | // disallow custom cursors. Custom cursors whose width or height are larger |
| 1506 | // than `max_dimension_dips` are diallowed in this web contents for as long as |
| 1507 | // any of the returned `ScopedClosureRunner` objects is alive. |
Andy Paicu | 5608bda8 | 2023-03-03 15:09:20 | [diff] [blame] | 1508 | [[nodiscard]] virtual base::ScopedClosureRunner |
Jan Keitel | 1d8d51d | 2023-08-22 05:53:47 | [diff] [blame] | 1509 | CreateDisallowCustomCursorScope(int max_dimension_dips = 0) = 0; |
Andy Paicu | 5608bda8 | 2023-03-03 15:09:20 | [diff] [blame] | 1510 | |
Charles Meng | c2cca37e | 2023-08-15 18:14:30 | [diff] [blame] | 1511 | // Enables overscroll history navigation. |
| 1512 | virtual void SetOverscrollNavigationEnabled(bool enabled) = 0; |
| 1513 | |
Bo Liu | d4ced69 | 2023-09-18 21:17:14 | [diff] [blame] | 1514 | // Tag `WebContents` with its owner. Used purely for debugging purposes so it |
| 1515 | // does not need to be exhaustive or perfectly correct. |
Alison Gale | 81f4f2c7 | 2024-04-22 19:33:31 | [diff] [blame] | 1516 | // TODO(crbug.com/40062641): Remove after bug is fixed. |
Bo Liu | d4ced69 | 2023-09-18 21:17:14 | [diff] [blame] | 1517 | virtual void SetOwnerLocationForDebug( |
Arthur Sonzogni | c686e8f | 2024-01-11 08:36:37 | [diff] [blame] | 1518 | std::optional<base::Location> owner_location) = 0; |
Bo Liu | d4ced69 | 2023-09-18 21:17:14 | [diff] [blame] | 1519 | |
Joanne de Abreu | 7cbed87 | 2023-10-30 23:25:26 | [diff] [blame] | 1520 | // Sends the attribution support state to all renderer processes for the |
| 1521 | // current page. |
| 1522 | virtual void UpdateAttributionSupportRenderer() = 0; |
| 1523 | |
Bryant Chandler | 490c6de | 2024-01-02 22:08:36 | [diff] [blame] | 1524 | // Return all currently streaming devices of `type` via `callback`. |
| 1525 | virtual void GetMediaCaptureRawDeviceIdsOpened( |
| 1526 | blink::mojom::MediaStreamType type, |
| 1527 | base::OnceCallback<void(std::vector<std::string>)> callback) = 0; |
| 1528 | |
William Liu | 6cf58fe | 2024-01-19 21:29:32 | [diff] [blame] | 1529 | // Returns an animation manager that displays a preview of the history page |
| 1530 | // during a session history navigation gesture. Only non-null if |
| 1531 | // `features::kBackForwardTransitions` is enabled for the supported platform. |
| 1532 | virtual BackForwardTransitionAnimationManager* |
| 1533 | GetBackForwardTransitionAnimationManager() = 0; |
| 1534 | |
[email protected] | 7f4a04c | 2013-03-11 23:04:20 | [diff] [blame] | 1535 | private: |
| 1536 | // This interface should only be implemented inside content. |
| 1537 | friend class WebContentsImpl; |
Avi Drissman | 0b2a20d | 2021-12-08 00:59:16 | [diff] [blame] | 1538 | WebContents() = default; |
[email protected] | 6934a70 | 2011-12-20 00:04:51 | [diff] [blame] | 1539 | }; |
| 1540 | |
| 1541 | } // namespace content |
| 1542 | |
[email protected] | 58f5d56 | 2011-12-20 17:13:03 | [diff] [blame] | 1543 | #endif // CONTENT_PUBLIC_BROWSER_WEB_CONTENTS_H_ |