blob: 8ae956ce13ae0be1436875228bc5f2915caf9f91 [file] [log] [blame]
Avi Drissman4e1b7bc32022-09-15 14:03:501// Copyright 2012 The Chromium Authors
[email protected]0dd3a0ab2011-02-18 08:17:442// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
[email protected]93ddb3c2012-04-11 21:44:295#ifndef CONTENT_BROWSER_WEB_CONTENTS_WEB_CONTENTS_IMPL_H_
6#define CONTENT_BROWSER_WEB_CONTENTS_WEB_CONTENTS_IMPL_H_
[email protected]0dd3a0ab2011-02-18 08:17:447
avib7348942015-12-25 20:57:108#include <stdint.h>
9
lfgdb5c4ed2016-03-04 23:09:0710#include <functional>
[email protected]0dd3a0ab2011-02-18 08:17:4411#include <map>
dcheng59716272016-04-09 05:19:0812#include <memory>
Arthur Sonzognic686e8f2024-01-11 08:36:3713#include <optional>
[email protected]b24b68a2012-09-24 21:57:2614#include <set>
[email protected]0dd3a0ab2011-02-18 08:17:4415#include <string>
Lukasz Anforowicze9ae3722017-09-29 17:37:3816#include <utility>
17#include <vector>
[email protected]0dd3a0ab2011-02-18 08:17:4418
David Sanders6f0eeb02025-01-30 06:48:5019#include "base/auto_reset.h"
Elly Fong-Jones564de6262022-07-28 21:11:1620#include "base/callback_list.h"
Lei Zhang6410ec1a2019-01-31 21:38:5821#include "base/containers/flat_map.h"
Avi Drissmanadac21992023-01-11 23:46:3922#include "base/functional/callback_helpers.h"
Daniel Cheng982f2b22022-08-25 23:46:1623#include "base/functional/function_ref.h"
[email protected]0dd3a0ab2011-02-18 08:17:4424#include "base/gtest_prod_util.h"
Keishi Hattori0e45c022021-11-27 09:25:5225#include "base/memory/raw_ptr.h"
Dave Tapuskad8b0530f2021-10-19 15:12:3126#include "base/memory/safe_ref.h"
[email protected]6eac57a2011-07-12 21:15:0927#include "base/observer_list.h"
Lei Zhang2764bca2021-07-15 02:00:0728#include "base/process/kill.h"
Sigurdur Asgeirsson103e2fb2020-11-10 00:50:1629#include "base/scoped_observation.h"
Daniel Cheng90196c82018-04-25 21:49:1430#include "base/time/time.h"
Ari Chivukula2d8d5e02024-11-04 20:09:5731#include "base/types/pass_key.h"
avib7348942015-12-25 20:57:1032#include "build/build_config.h"
Min Qina904f3302018-02-13 23:33:3433#include "components/download/public/common/download_url_parameters.h"
Kartar Singhb1bfa1a2024-06-24 13:14:5734#include "components/input/render_widget_host_input_event_router.h"
Andrew Verge146fe632025-07-08 14:12:1135#include "content/browser/fenced_frame/fenced_frame_viewport_observer.h"
avayvodcc85bbd2015-08-28 19:11:1536#include "content/browser/media/audio_stream_monitor.h"
Max Morin5bc74f52018-05-09 07:00:2137#include "content/browser/media/forwarding_audio_stream_factory.h"
Taiyo Mizuhashi15ba3bc2025-01-28 04:20:3138#include "content/browser/preloading/prefetch/prefetch_handle_impl.h"
Yoshiki Tanioka49b4cfb2022-10-20 09:25:3139#include "content/browser/preloading/prerender/prerender_final_status.h"
Sreeja Kamishettyc227f7a2022-07-08 22:33:1540#include "content/browser/preloading/prerender/prerender_handle_impl.h"
danakj2adf8322020-09-15 22:06:4941#include "content/browser/renderer_host/frame_tree.h"
42#include "content/browser/renderer_host/frame_tree_node.h"
43#include "content/browser/renderer_host/navigation_controller_delegate.h"
44#include "content/browser/renderer_host/navigation_controller_impl.h"
45#include "content/browser/renderer_host/navigator_delegate.h"
Jeremy Roman2d8dfe132021-07-06 20:51:2646#include "content/browser/renderer_host/page_delegate.h"
Sreeja Kamishetty3dde6312021-06-22 14:05:2947#include "content/browser/renderer_host/page_impl.h"
danakj2adf8322020-09-15 22:06:4948#include "content/browser/renderer_host/render_frame_host_delegate.h"
49#include "content/browser/renderer_host/render_frame_host_manager.h"
[email protected]2e3bf992012-05-24 17:36:2450#include "content/browser/renderer_host/render_view_host_delegate.h"
creisc014b402015-04-23 16:41:4551#include "content/browser/renderer_host/render_view_host_impl.h"
[email protected]4ca76c02012-05-16 16:19:0552#include "content/browser/renderer_host/render_widget_host_delegate.h"
Joe Mason1fc3e2e2021-11-02 05:25:0753#include "content/browser/renderer_host/visible_time_request_trigger.h"
Avi Drissmanbd3e986442020-05-20 21:09:2054#include "content/browser/web_contents/file_chooser_impl.h"
Shintaro Kawamura1042d572024-09-30 13:52:2255#include "content/browser/web_contents/slow_web_preference_cache.h"
[email protected]8d128d62011-09-13 22:11:5756#include "content/common/content_export.h"
Mike Wassermand3609c1f2023-02-28 20:03:1357#include "content/public/browser/fullscreen_types.h"
Lukasz Anforowicz09060bdf72018-08-23 15:53:1758#include "content/public/browser/global_routing_id.h"
Guido Urdaneta73fa6632019-01-14 18:46:2659#include "content/public/browser/media_stream_request.h"
Liviu Tintacf066d52024-07-24 16:00:5560#include "content/public/browser/preloading.h"
[email protected]58f5d562011-12-20 17:13:0361#include "content/public/browser/web_contents.h"
Patrick Monette15442a12025-01-22 20:09:3162#include "content/public/browser/web_contents_capability_type.h"
dalecurtis88c240072015-12-09 02:11:1863#include "content/public/browser/web_contents_observer.h"
Benjamin Keen919ed0f2025-02-25 15:47:2064#include "media/base/picture_in_picture_events_info.h"
Miyoung Shin040d8342021-02-23 15:12:3165#include "mojo/public/cpp/bindings/pending_associated_receiver.h"
Miyoung Shin59f39ff2019-09-17 07:23:2066#include "mojo/public/cpp/bindings/pending_receiver.h"
Julie Jeongeun Kimcaacf9102019-09-12 02:13:0567#include "mojo/public/cpp/bindings/pending_remote.h"
Miyoung Shin298d5ad2019-09-05 01:52:3768#include "mojo/public/cpp/bindings/remote.h"
[email protected]0dd3a0ab2011-02-18 08:17:4469#include "net/base/load_states.h"
Xiao Ma29b2d1e62024-06-13 06:17:0970#include "net/base/network_handle.h"
miktdc1d5a62024-07-29 20:43:0271#include "partition_alloc/buildflags.h"
Ke He31d0bb02018-02-24 07:16:2472#include "services/device/public/mojom/geolocation_context.mojom.h"
Sandor Major878f8352025-02-18 20:16:0273#include "services/network/public/cpp/permissions_policy/permissions_policy_declaration.h"
Kinuko Yasuda433f710a2020-02-14 02:11:5874#include "services/network/public/mojom/fetch_api.mojom-forward.h"
Mario Sanchez Prada0bd8b8c2020-10-21 17:49:2375#include "third_party/blink/public/common/renderer_preferences/renderer_preferences.h"
Gyuyoung Kim1ac4ca782020-09-11 03:32:5176#include "third_party/blink/public/common/web_preferences/web_preferences.h"
Abhijeet Kandalkar849ceff2019-02-28 17:37:2977#include "third_party/blink/public/mojom/choosers/color_chooser.mojom.h"
Lei Zhang2764bca2021-07-15 02:00:0778#include "third_party/blink/public/mojom/choosers/popup_menu.mojom-forward.h"
79#include "third_party/blink/public/mojom/frame/blocked_navigation_types.mojom-shared.h"
Henrique Ferreiroba535472020-04-21 11:38:3680#include "third_party/blink/public/mojom/frame/frame.mojom-forward.h"
Hans Wennborg78b52182021-06-15 13:42:1581#include "third_party/blink/public/mojom/frame/text_autosizer_page_info.mojom.h"
Michellebb18e2d2023-02-22 04:52:2282#include "third_party/blink/public/mojom/input/input_handler.mojom-shared.h"
Lei Zhang2764bca2021-07-15 02:00:0783#include "third_party/blink/public/mojom/loader/resource_load_info.mojom-forward.h"
Lei Zhang3ee2b78a2021-05-18 20:58:4484#include "third_party/blink/public/mojom/media/capture_handle_config.mojom.h"
Lei Zhang2764bca2021-07-15 02:00:0785#include "third_party/blink/public/mojom/page/display_cutout.mojom-shared.h"
Amanda Bakerf48f04b2024-03-26 18:12:3386#include "third_party/blink/public/mojom/page/draggable_region.mojom-forward.h"
Lei Zhang2764bca2021-07-15 02:00:0787#include "third_party/blink/public/mojom/page/page_visibility_state.mojom-shared.h"
Ahmed Elwasefi79a665e2024-10-01 18:24:4788#include "ui/accessibility/ax_location_and_scroll_updates.h"
Dominic Mazzoni90501482018-09-05 22:43:3189#include "ui/accessibility/ax_mode.h"
Nektarios Paisios8e9da982024-02-20 23:14:2290#include "ui/accessibility/ax_node.h"
Alexander Surkov862feee2021-01-29 21:27:4891#include "ui/accessibility/platform/inspect/ax_event_recorder.h"
Xu Li383fced2025-08-12 16:14:0192#include "ui/base/clipboard/clipboard_metadata.h"
Henrique Ferreiro299008ec2020-12-29 14:36:2893#include "ui/base/dragdrop/mojom/drag_drop_types.mojom-forward.h"
David Bokand6e44055b2022-09-21 03:58:0894#include "ui/base/ime/mojom/virtual_keyboard_types.mojom.h"
Md Hasibul Hasan2fe709feb2024-09-12 15:39:5695#include "ui/base/mojom/window_show_state.mojom-forward.h"
Sonja7b2b7762023-09-06 08:33:0896#include "ui/base/ui_base_types.h"
Fabio Muratori8ff26892025-05-06 19:07:2197#include "ui/base/window_open_disposition.h"
Sean Kaud730f5b2023-06-22 16:21:3398#include "ui/color/color_provider_key.h"
tom855c4bf32021-09-30 00:27:2699#include "ui/color/color_provider_source_observer.h"
tfarinaebe974f02015-01-03 04:25:32100#include "ui/gfx/geometry/size.h"
Rune Lillesveen5d8c49982019-04-24 19:07:30101#include "ui/native_theme/native_theme.h"
Alison Maher7f366dc62020-03-03 19:46:00102#include "ui/native_theme/native_theme_observer.h"
[email protected]0dd3a0ab2011-02-18 08:17:44103
Xiaohan Wang24ec9342022-01-15 17:34:22104#if BUILDFLAG(IS_ANDROID)
Bo Liu168c8642017-08-28 18:26:02105#include "content/public/browser/android/child_process_importance.h"
blundellf5316fc2017-05-15 11:49:03106#endif
107
Marijn Kruisselbrink46fa4bd2019-07-11 18:15:47108namespace base {
109class FilePath;
evliu7f736f02019-11-07 17:43:50110} // namespace base
Marijn Kruisselbrink46fa4bd2019-07-11 18:15:47111
Dale Curtisc496a7762021-02-24 01:15:44112namespace device {
113namespace mojom {
114class WakeLock;
115}
116} // namespace device
117
Kartar Singhb1bfa1a2024-06-24 13:14:57118namespace input {
119class RenderWidgetHostInputEventRouter;
120} // namespace input
121
Ming-Ying Chung16d04472025-04-17 22:14:39122namespace network {
123struct ResourceRequest;
124} // namespace network
125
Tsuyoshi Horobcd0b9f62023-06-28 11:35:32126namespace network::mojom {
127class SharedDictionaryAccessDetails;
128} // namespace network::mojom
129
rockot400ea35b2016-10-15 19:15:32130namespace service_manager {
sammcf5f1b0f2016-09-20 23:05:11131class InterfaceProvider;
evliu7f736f02019-11-07 17:43:50132} // namespace service_manager
sammcf5f1b0f2016-09-20 23:05:11133
Jacques Newman517ba1842024-04-16 00:51:07134namespace ui {
Jacques Newmanedb30062024-04-16 22:37:02135struct AXUpdatesAndEvents;
Jacques Newman517ba1842024-04-16 00:51:07136}
137
[email protected]e582fdd2011-12-20 16:48:17138namespace content {
David Bokan1bdb3701f2021-04-30 22:02:35139class JavaScriptDialogDismissNotifier;
Becca Hughes112832e2019-06-11 17:19:02140enum class PictureInPictureResult;
Lei Zhang2764bca2021-07-15 02:00:07141class BeforeUnloadBlockingDelegate; // content_browser_test_utils_internal.h
[email protected]7a846df2012-09-20 19:17:39142class BrowserPluginEmbedder;
143class BrowserPluginGuest;
paulmeyerc0b762b2016-04-13 11:55:17144class FindRequestManager;
Tommy Steimele95348e2024-01-09 21:15:33145class MediaSession;
qinmin58567c82015-01-07 21:00:20146class MediaWebContentsObserver;
Reilly Grantafbe2242020-02-20 21:14:55147class NFCHost;
Ari Chivukula2d8d5e02024-11-04 20:09:57148class PartitionedPopinsController;
Jinsuk Kim895b2c52018-07-03 06:49:16149class RenderFrameHost;
Ian Barkley-Yeungbda77fb2020-12-08 04:26:46150class RenderFrameHostImpl;
[email protected]eaabba22012-03-07 15:02:11151class RenderViewHost;
[email protected]5a3bdf52012-05-24 15:12:57152class RenderViewHostDelegateView;
[email protected]b24b68a2012-09-24 21:57:26153class RenderWidgetHostImpl;
Donn Denmana6d91832023-11-28 21:25:46154class SafeAreaInsetsHost;
[email protected]35869622012-10-26 23:23:55155class SavePackage;
Greg Thompsonf855bf882024-01-30 10:39:45156class ScopedAccessibilityMode;
Mike Wassermanb213b9352020-04-16 00:32:34157class ScreenChangeMonitor;
lunalud4a2cc82016-11-22 00:27:23158class ScreenOrientationProvider;
Sharon Yangefe52632022-03-08 23:06:06159class SiteInstanceGroup;
Lei Zhang2764bca2021-07-15 02:00:07160// For web_contents_impl_browsertest.cc
161class TestWCDelegateForDialogsAndFullscreen;
[email protected]80e776ae2012-03-23 16:17:20162class TestWebContents;
ekaramadadd882292016-06-08 15:22:56163class TextInputManager;
Aman Verma3047aa412024-05-28 09:09:24164class TouchEmulatorImpl;
Lei Zhang2764bca2021-07-15 02:00:07165class WakeLockContextHost;
[email protected]674bc592011-12-20 23:00:42166class WebContentsDelegate;
[email protected]8ff00d72012-10-23 19:12:21167class WebContentsImpl;
[email protected]fc2b46b2014-05-03 16:33:45168class WebContentsView;
dewittj6dc5747a2016-05-17 01:48:47169struct MHTMLGenerationParams;
Sreeja Kamishettyac12140e2022-07-14 22:16:51170class PreloadingAttempt;
[email protected]f66df822012-05-18 16:52:17171
rockot5c478a72016-09-28 23:14:18172namespace mojom {
173class CreateNewWindowParams;
evliu7f736f02019-11-07 17:43:50174} // namespace mojom
rockot5c478a72016-09-28 23:14:18175
Xiaohan Wang24ec9342022-01-15 17:34:22176#if BUILDFLAG(IS_ANDROID)
[email protected]0e813a52014-08-13 10:34:56177class WebContentsAndroid;
danakj30f733132019-09-20 16:14:14178#endif
[email protected]0e813a52014-08-13 10:34:56179
Joel Hockey8c2011b22020-04-30 05:07:19180// CreatedWindow holds the WebContentsImpl and target url between IPC calls to
181// CreateNewWindow and ShowCreatedWindow.
182struct CONTENT_EXPORT CreatedWindow {
183 CreatedWindow();
184 CreatedWindow(std::unique_ptr<WebContentsImpl> contents, GURL target_url);
185 CreatedWindow(CreatedWindow&&);
186 CreatedWindow(const CreatedWindow&) = delete;
187 CreatedWindow& operator=(CreatedWindow&&);
188 CreatedWindow& operator=(const CreatedWindow&) = delete;
189 ~CreatedWindow();
190
191 std::unique_ptr<WebContentsImpl> contents;
192 GURL target_url;
193};
194
Yuzu Saijobe024af02020-05-11 07:35:56195using PageVisibilityState = blink::mojom::PageVisibilityState;
196
Nancy Xiao4f3eae5d62023-04-25 19:38:59197using ClipboardPasteData = content::ClipboardPasteData;
198
Aman Verma3047aa412024-05-28 09:09:24199class CONTENT_EXPORT WebContentsImpl
200 : public WebContents,
201 public FrameTree::Delegate,
202 public RenderFrameHostDelegate,
203 public RenderViewHostDelegate,
204 public RenderWidgetHostDelegate,
205 public RenderFrameHostManager::Delegate,
206 public PageDelegate,
207 public blink::mojom::ColorChooserFactory,
208 public NavigationControllerDelegate,
209 public NavigatorDelegate,
210 public ui::NativeThemeObserver,
211 public ui::ColorProviderSourceObserver,
Shintaro Kawamura1042d572024-09-30 13:52:22212 public SlowWebPreferenceCacheObserver,
Aman Verma37a58592025-05-27 22:18:12213 public input::RenderWidgetHostInputEventRouter::Delegate {
[email protected]0dd3a0ab2011-02-18 08:17:44214 public:
benwells5e7260d2017-03-20 23:36:33215 class FriendWrapper;
nickf9acfbe2014-12-23 19:12:37216
Peter Boström828b9022021-09-21 02:28:43217 WebContentsImpl(const WebContentsImpl&) = delete;
218 WebContentsImpl& operator=(const WebContentsImpl&) = delete;
219
dchengc2282aa2014-10-21 12:07:58220 ~WebContentsImpl() override;
[email protected]0dd3a0ab2011-02-18 08:17:44221
erikchen50735fd2018-05-05 15:08:33222 static std::unique_ptr<WebContentsImpl> CreateWithOpener(
[email protected]54944cde2012-12-09 09:24:59223 const WebContents::CreateParams& params,
Ian Clelland5cbaaf82017-11-27 22:00:03224 RenderFrameHostImpl* opener_rfh);
[email protected]d1198fd2012-08-13 22:50:19225
[email protected]95640212014-07-26 18:14:30226 static std::vector<WebContentsImpl*> GetAllWebContents();
227
paulmeyerfeafc2d2017-04-25 21:46:40228 static WebContentsImpl* FromFrameTreeNode(
229 const FrameTreeNode* frame_tree_node);
Patrick Monette275a6f92b2020-01-09 21:05:04230 static WebContents* FromRenderFrameHostID(
Alexander Timin8690530c2021-06-19 00:34:32231 GlobalRenderFrameHostId render_frame_host_id);
clamy0d32d6d2015-11-24 11:16:26232 static WebContents* FromRenderFrameHostID(int render_process_host_id,
233 int render_frame_host_id);
Avi Drissmane4de1252024-09-05 00:15:45234 static WebContents* FromFrameTreeNodeId(FrameTreeNodeId frame_tree_node_id);
paulmeyerfeafc2d2017-04-25 21:46:40235 static WebContentsImpl* FromOuterFrameTreeNode(
236 const FrameTreeNode* frame_tree_node);
Matt Falkenhagen888db592021-09-07 20:20:25237 static WebContentsImpl* FromRenderWidgetHostImpl(RenderWidgetHostImpl* rwh);
Fergal Daly5b64d472021-10-14 04:31:29238 static WebContentsImpl* FromRenderFrameHostImpl(RenderFrameHostImpl* rfh);
clamya16aa8172015-05-26 13:07:25239
[email protected]d1198fd2012-08-13 22:50:19240 // Complex initialization here. Specifically needed to avoid having
241 // members call back into our virtual functions in the constructor.
Harkiran Bolaria5ce27632022-01-20 15:05:05242 // The primary main frame policy might be passed down as it is inherited from
243 // the opener when WebContents is created with an opener.
244 virtual void Init(const WebContents::CreateParams& params,
245 blink::FramePolicy primary_main_frame_policy);
[email protected]d1198fd2012-08-13 22:50:19246
[email protected]c7dd2f62011-07-18 15:57:59247 // Returns the SavePackage which manages the page saving job. May be NULL.
248 SavePackage* save_package() const { return save_package_.get(); }
249
[email protected]738f57a2013-06-29 21:06:54250 // Sets a BrowserPluginGuest object for this WebContents. If this WebContents
251 // has a BrowserPluginGuest then that implies that it is being hosted by
252 // a BrowserPlugin object in an embedder renderer process.
Albert J. Wongc55cc64d2018-10-12 02:50:04253 void SetBrowserPluginGuest(std::unique_ptr<BrowserPluginGuest> guest);
[email protected]738f57a2013-06-29 21:06:54254
[email protected]7a846df2012-09-20 19:17:39255 // Returns embedder browser plugin object, or NULL if this WebContents is not
256 // an embedder.
[email protected]f8497342013-02-05 22:15:02257 BrowserPluginEmbedder* GetBrowserPluginEmbedder() const;
[email protected]738f57a2013-06-29 21:06:54258
Ehsan Karamadfa983e82018-11-13 01:26:42259 // Returns guest browser plugin object, or nullptr if this WebContents is not
260 // for guest.
261 BrowserPluginGuest* GetBrowserPluginGuest() const;
262
fsamuel60b42282015-03-10 03:29:14263 // Creates a BrowserPluginEmbedder object for this WebContents if one doesn't
264 // already exist.
265 void CreateBrowserPluginEmbedderIfNecessary();
266
creis89a0f782015-05-27 16:13:17267 // Cancels modal dialogs in this WebContents, as well as in any browser
268 // plugins it is hosting.
269 void CancelActiveAndPendingDialogs();
270
[email protected]cf200a562013-05-03 16:24:29271 // Informs the render view host and the BrowserPluginEmbedder, if present, of
272 // a Drag Source End.
Ella Ge80a52dce2017-11-15 18:01:52273 void DragSourceEndedAt(float client_x,
274 float client_y,
275 float screen_x,
276 float screen_y,
Henrique Ferreiro299008ec2020-12-29 14:36:28277 ui::mojom::DragOperation operation,
Paul Meyer0c58c3712016-11-17 22:59:51278 RenderWidgetHost* source_rwh);
[email protected]cf200a562013-05-03 16:24:29279
jam73f892642016-09-11 06:04:06280 // Notification that the RenderViewHost's load state changed.
Dave Tapuskae1a08aaf2021-03-05 18:31:59281 void LoadStateChanged(network::mojom::LoadInfoPtr load_info);
jam73f892642016-09-11 06:04:06282
Collin Baker989e0882019-11-01 01:27:17283 // Updates the visibility and notifies observers. Note that this is
284 // distinct from UpdateWebContentsVisibility which may also update the
285 // visibility of renderer-side objects.
286 void SetVisibilityAndNotifyObservers(Visibility visibility);
Francois Dorayfe4a1772018-02-17 04:17:09287
calamity7fe55ce2015-04-10 03:59:37288 // Notify observers that the web contents has been focused.
Michael Thiessen896405db2017-07-20 17:52:32289 void NotifyWebContentsFocused(RenderWidgetHost* render_widget_host);
calamity7fe55ce2015-04-10 03:59:37290
zijiehe3bee08e22017-05-17 04:14:46291 // Notify observers that the web contents has lost focus.
Michael Thiessen896405db2017-07-20 17:52:32292 void NotifyWebContentsLostFocus(RenderWidgetHost* render_widget_host);
zijiehe3bee08e22017-05-17 04:14:46293
[email protected]fc2b46b2014-05-03 16:33:45294 WebContentsView* GetView() const;
295
Mike Wasserman5a3cc61d2020-08-27 21:12:03296 // Called on screen information changes; |is_multi_screen_changed| is true iff
297 // the plurality of connected screens changed (e.g. 1 screen <-> 2 screens).
298 void OnScreensChange(bool is_multi_screen_changed);
299
leon.han552e9de2017-02-09 14:37:30300 void OnScreenOrientationChange();
301
302 ScreenOrientationProvider* GetScreenOrientationProviderForTesting() const {
303 return screen_orientation_provider_.get();
304 }
leon.hane4db177a2017-02-07 14:19:16305
Aman Vermab3ed74e2024-04-29 13:58:13306 // Return RenderWidgetHostView from RWHIER.
307 std::vector<RenderWidgetHostView*> GetRenderWidgetHostViewsForTests();
308
Aman Vermabb589a32024-05-07 16:38:17309 bool IsDelegatedInkRendererBoundForTest() {
310 return delegated_ink_point_renderer_.is_bound();
311 }
312
wjmaclean64951902016-04-29 20:59:12313 // Sets the zoom level for frames associated with this WebContents.
akabac6bd1212018-06-25 20:10:48314 void UpdateZoom();
wjmaclean64951902016-04-29 20:59:12315
W. James MacLean37af605e2025-01-20 16:59:38316 // Sets the zoom level for frames associated with the subtree for which
317 // `rfh_id` is a local root. Used by guest views and oopif-pdfs.
318 void UpdateZoom(const GlobalRenderFrameHostId& rfh_id);
319
wjmaclean64951902016-04-29 20:59:12320 // Sets the zoom level for frames associated with this WebContents if it
321 // matches |host| and (if non-empty) |scheme|. Matching is done on the
W. James MacLean37af605e2025-01-20 16:59:38322 // last committed entry of the main frame.
wjmaclean64951902016-04-29 20:59:12323 void UpdateZoomIfNecessary(const std::string& scheme,
akabac6bd1212018-06-25 20:10:48324 const std::string& host);
W. James MacLean37af605e2025-01-20 16:59:38325 // Same as above, except uses the last committed entry on `rfh`.
326 void UpdateZoomIfNecessary(const std::string& scheme,
327 const std::string& host,
328 RenderFrameHostImpl* rfh);
akabac6bd1212018-06-25 20:10:48329
paulmeyerfeafc2d2017-04-25 21:46:40330 // Returns the focused WebContents.
331 // If there are multiple inner/outer WebContents (when embedding <webview>,
332 // <guestview>, ...) returns the single one containing the currently focused
333 // frame. Otherwise, returns this WebContents.
334 WebContentsImpl* GetFocusedWebContents();
335
Dave Tapuskad8b0530f2021-10-19 15:12:31336 // Returns the focused FrameTree. For MPArch we may return a different
337 // focused frame tree even though the focused WebContents is the same.
338 FrameTree* GetFocusedFrameTree();
339
Lukasz Anforowicz2cd231bf2020-10-02 19:13:20340 // TODO(lukasza): Maybe this method can be removed altogether (so that the
341 // focus of the location bar is only set in the //chrome layer).
342 void SetFocusToLocationBar();
343
paulmeyerfeafc2d2017-04-25 21:46:40344 // Returns a vector containing this WebContents and all inner WebContents
345 // within it (recursively).
346 std::vector<WebContentsImpl*> GetWebContentsAndAllInner();
347
Carlos Caballero40b0efd2021-01-26 11:55:00348 // Returns the primary FrameTree for this WebContents (as opposed to the
Carlos Caballerob65b6e3a2021-11-15 10:09:00349 // ones held by MPArch features like Prerender or Fenced Frame).
Kevin McNee88bf2242022-11-23 00:27:34350 // See docs/frame_trees.md for more details.
Carlos Caballerob65b6e3a2021-11-15 10:09:00351 FrameTree& GetPrimaryFrameTree() { return primary_frame_tree_; }
Carlos Caballero40b0efd2021-01-26 11:55:00352
Carlos Caballeroede6f8c2021-01-28 11:01:50353 // Whether the initial empty page of this view has been accessed by another
354 // page, making it unsafe to show the pending URL. Always false after the
355 // first commit.
Alison Gale770f3fc2024-04-27 00:39:58356 // TODO(crbug.com/40165695): Rename to HasAccessedInitialMainDocument
Carlos Caballeroede6f8c2021-01-28 11:01:50357 bool HasAccessedInitialDocument();
358
Kuznetsov Alexey1a516bd2021-08-04 23:49:05359 // Returns the human-readable name for title in Media Controls.
360 // If the returned value is an empty string, it means that there is no
361 // human-readable name.
362 std::string GetTitleForMediaControls();
363
Greg Thompsonf855bf882024-01-30 10:39:45364 // Sets the accessibility mode if this WebContents will potentially be
365 // user-visible, and broadcasts it to all of its frames if it differs from the
Greg Thompson023f89b12025-05-13 16:46:03366 // previous mode.
Greg Thompsonf855bf882024-01-30 10:39:45367 void SetAccessibilityMode(ui::AXMode mode);
368
Elad Alonb0a3fc82024-04-03 18:22:34369 // Inform the WebContentsImpl object that a write-access Captured Surface
370 // Control API was invoked (sendWheel, setZoomLevel) for this object.
371 // A notification is then propagated to observers.
372 void DidCapturedSurfaceControl();
373
Joel Hockeycbdcbecd2025-08-08 20:06:38374#if BUILDFLAG(IS_ANDROID)
Jinsuk Kimc8eac442024-07-19 18:33:52375 // Let long press on links select the link text instead of triggering
376 // the context menu.
Jinsuk Kimc8eac442024-07-19 18:33:52377 void SetLongPressLinkSelectText(bool enabled);
Joel Hockeycbdcbecd2025-08-08 20:06:38378
379 // Allow drag-drop of files such as an image to load and replace contents.
380 void SetCanAcceptLoadDrops(bool enabled);
381 bool GetCanAcceptLoadDropsForTesting();
Jinsuk Kimc8eac442024-07-19 18:33:52382#endif
383
[email protected]8ff00d72012-10-23 19:12:21384 // WebContents ------------------------------------------------------
Jeremy Romana0b70c32023-11-09 22:22:53385 WebContentsDelegate* GetDelegate() final;
dchengc2282aa2014-10-21 12:07:58386 void SetDelegate(WebContentsDelegate* delegate) override;
387 NavigationControllerImpl& GetController() override;
Elad Alon32044f532025-03-04 22:16:03388 const NavigationControllerImpl& GetController() const override;
Lucas Furukawa Gadanie1c5dfda2018-11-29 17:57:41389 BrowserContext* GetBrowserContext() override;
Claudio DeSouza2be02d42021-08-12 23:23:40390 base::WeakPtr<WebContents> GetWeakPtr() override;
Lucas Furukawa Gadanie1c5dfda2018-11-29 17:57:41391 const GURL& GetURL() override;
392 const GURL& GetVisibleURL() override;
Elad Alon32044f532025-03-04 22:16:03393 const GURL& GetLastCommittedURL() const override;
Peter Kasting2caacff62023-05-24 16:06:53394 const RenderFrameHostImpl* GetPrimaryMainFrame() const override;
Dave Tapuska1d5e5772022-06-02 17:26:01395 RenderFrameHostImpl* GetPrimaryMainFrame() override;
Sreeja Kamishetty3dde6312021-06-22 14:05:29396 PageImpl& GetPrimaryPage() override;
nick53d5cbf2015-04-23 22:50:14397 RenderFrameHostImpl* GetFocusedFrame() override;
Avi Drissmane4de1252024-09-05 00:15:45398 bool IsPrerenderedFrame(FrameTreeNodeId frame_tree_node_id) override;
creisf71a2632017-05-04 19:03:50399 RenderFrameHostImpl* UnsafeFindFrameByFrameTreeNodeId(
Avi Drissmane4de1252024-09-05 00:15:45400 FrameTreeNodeId frame_tree_node_id) override;
Daniel Cheng982f2b22022-08-25 23:46:16401 void ForEachRenderFrameHostWithAction(
402 base::FunctionRef<FrameIterationAction(RenderFrameHost*)> on_frame)
403 override;
Kevin McNeec9d0fda2021-05-19 15:55:17404 void ForEachRenderFrameHost(
Daniel Cheng982f2b22022-08-25 23:46:16405 base::FunctionRef<void(RenderFrameHost*)> on_frame) override;
Lucas Furukawa Gadanie1c5dfda2018-11-29 17:57:41406 RenderViewHostImpl* GetRenderViewHost() override;
407 RenderWidgetHostView* GetRenderWidgetHostView() override;
lfg265a2672016-04-23 03:11:02408 RenderWidgetHostView* GetTopLevelRenderWidgetHostView() override;
Rodney Ding353fe932025-06-19 18:51:08409 RenderWidgetHost* FindWidgetAtPoint(const gfx::PointF& point) override;
naskoc0fceff2015-04-30 15:53:52410 void ClosePage() override;
Arthur Sonzognic686e8f2024-01-11 08:36:37411 std::optional<SkColor> GetThemeColor() override;
412 std::optional<SkColor> GetBackgroundColor() override;
413 void SetPageBaseBackgroundColor(std::optional<SkColor> color) override;
tom855c4bf32021-09-30 00:27:26414 void SetColorProviderSource(ui::ColorProviderSource* source) override;
Sean Kaud730f5b2023-06-22 16:21:33415 ui::ColorProviderKey::ColorMode GetColorMode() const override;
Lucas Furukawa Gadanie1c5dfda2018-11-29 17:57:41416 WebUI* GetWebUI() override;
Maks Orlovich73f374d2020-04-02 12:46:13417 void SetUserAgentOverride(const blink::UserAgentOverride& ua_override,
Changwan Ryuc1134a82018-03-07 02:10:14418 bool override_in_new_tabs) override;
Maks Orlovich73f374d2020-04-02 12:46:13419 const blink::UserAgentOverride& GetUserAgentOverride() override;
Scott Violet2a6c5bff2020-04-29 23:59:06420 bool ShouldOverrideUserAgentForRendererInitiatedNavigation() override;
Aman Vermaa4b33cf2023-06-13 19:32:33421 void SetAlwaysSendSubresourceNotifications() override;
422 bool GetSendSubresourceNotification() override;
Lucas Furukawa Gadanie1c5dfda2018-11-29 17:57:41423 bool IsWebContentsOnlyAccessibilityModeForTesting() override;
424 bool IsFullAccessibilityModeForTesting() override;
Jan Wilken Dörrieaace0cfef2021-03-11 22:01:58425 const std::u16string& GetTitle() override;
Stanley Honf83c4b8b2025-01-08 00:52:30426 const std::optional<std::u16string>& GetApplicationTitle() override;
afakhry6f0c1ec22016-07-14 13:55:13427 void UpdateTitleForEntry(NavigationEntry* entry,
Jan Wilken Dörrieaace0cfef2021-03-11 22:01:58428 const std::u16string& title) override;
Lucas Furukawa Gadanie1c5dfda2018-11-29 17:57:41429 SiteInstanceImpl* GetSiteInstance() override;
430 bool IsLoading() override;
431 double GetLoadProgress() override;
Nate Chapin9aabf5f2021-11-12 00:31:19432 bool ShouldShowLoadingUI() override;
Sreeja Kamishetty81347582022-01-06 12:46:33433 bool IsDocumentOnLoadCompletedInPrimaryMainFrame() override;
Lucas Furukawa Gadanie1c5dfda2018-11-29 17:57:41434 bool IsWaitingForResponse() override;
Lijin Shen8c0f4362024-03-25 20:05:09435 bool HasUncommittedNavigationInPrimaryMainFrame() override;
Lucas Furukawa Gadanie1c5dfda2018-11-29 17:57:41436 const net::LoadStateWithParam& GetLoadState() override;
Jan Wilken Dörrieaace0cfef2021-03-11 22:01:58437 const std::u16string& GetLoadStateHost() override;
Avi Drissman1e620f32018-03-16 13:57:29438 void RequestAXTreeSnapshot(AXTreeSnapshotCallback callback,
Dominic Mazzoni77d0aba2021-01-14 09:42:16439 ui::AXMode ax_mode,
Dominic Mazzoni77d0aba2021-01-14 09:42:16440 size_t max_nodes,
Vladimir Levinf01905d2024-07-23 13:35:21441 base::TimeDelta timeout,
442 AXTreeSnapshotPolicy policy) override;
Mark Schillacic1e067e82025-04-02 17:36:11443 ui::AXTreeUpdate RequestAXTreeSnapshotWithinBrowserProcess() override;
Lucas Furukawa Gadanie1c5dfda2018-11-29 17:57:41444 uint64_t GetUploadSize() override;
445 uint64_t GetUploadPosition() override;
446 const std::string& GetEncoding() override;
Thomas Lukaszewicze4cdf6e2025-07-31 23:32:27447 void Discard(base::OnceClosure on_discarded_cb) override;
Charles Zhaod72f99d2018-09-17 14:18:27448 bool WasDiscarded() override;
Thomas Lukaszewicz034b34f2024-08-29 22:44:32449 void SetWasDiscarded(bool was_discarded) override;
Daniel Cheng9c9fa1a2022-01-14 03:42:11450 [[nodiscard]] base::ScopedClosureRunner IncrementCapturerCount(
Dale Curtis7030f252021-04-07 14:05:31451 const gfx::Size& capture_size,
452 bool stay_hidden,
Elad Alon0feb6602021-10-14 09:26:36453 bool stay_awake,
Avi Drissman5710b062024-07-02 21:23:29454 bool is_activity) override;
Elad Alonf156eb62021-05-17 22:02:37455 const blink::mojom::CaptureHandleConfig& GetCaptureHandleConfig() override;
Lucas Furukawa Gadanie1c5dfda2018-11-29 17:57:41456 bool IsBeingCaptured() override;
Xianzhu Wangc61434c2020-08-21 19:17:30457 bool IsBeingVisiblyCaptured() override;
Lucas Furukawa Gadanie1c5dfda2018-11-29 17:57:41458 bool IsAudioMuted() override;
dchengc2282aa2014-10-21 12:07:58459 void SetAudioMuted(bool mute) override;
Jan Rucka442c83f2017-08-08 13:27:54460 bool IsCurrentlyAudible() override;
Patrick Monette15442a12025-01-22 20:09:31461 bool IsCapabilityActive(WebContentsCapabilityType capability_type) override;
Austin Sullivanafefb722021-01-14 01:26:39462 bool HasFileSystemAccessHandles() override;
Lucas Furukawa Gadanie1c5dfda2018-11-29 17:57:41463 bool HasPictureInPictureVideo() override;
Klaus Weidnerd8219432022-02-08 21:50:59464 bool HasPictureInPictureDocument() override;
Lucas Furukawa Gadanie1c5dfda2018-11-29 17:57:41465 bool IsCrashed() override;
Lucas Furukawa Gadanie1c5dfda2018-11-29 17:57:41466 base::TerminationStatus GetCrashedStatus() override;
467 int GetCrashedErrorCode() override;
468 bool IsBeingDestroyed() override;
dchengc2282aa2014-10-21 12:07:58469 void NotifyNavigationStateChanged(InvalidateTypes changed_flags) override;
Chris Hamiltondf0d72cd2018-05-29 16:23:53470 void OnAudioStateChanged() override;
Olivier ROBIN4b58dd932024-08-06 13:30:32471 base::TimeTicks GetLastActiveTimeTicks() override;
Olivier ROBINda292fb2024-08-07 14:32:29472 base::Time GetLastActiveTime() override;
dchengc2282aa2014-10-21 12:07:58473 void WasShown() override;
474 void WasHidden() override;
Francois Doray18800972017-08-25 22:38:58475 void WasOccluded() override;
Lucas Furukawa Gadanie1c5dfda2018-11-29 17:57:41476 Visibility GetVisibility() override;
Rakina Zata Amni26e8d8a2020-08-05 06:06:06477 bool NeedToFireBeforeUnloadOrUnloadEvents() override;
Chris Hamilton3b3e315d2018-09-19 13:16:21478 void DispatchBeforeUnload(bool auto_cancel) override;
Dave Tapuska82b54012022-07-15 23:26:10479 void AttachInnerWebContents(
480 std::unique_ptr<WebContents> inner_web_contents,
481 RenderFrameHost* render_frame_host,
Dave Tapuska82b54012022-07-15 23:26:10482 bool is_full_page) override;
Keren Zhu9e378032025-05-26 19:20:39483 void AttachUnownedInnerWebContents(
484 base::PassKey<UnownedInnerWebContentsClient>,
485 WebContents* inner_web_contents,
486 RenderFrameHost* render_frame_host) override;
487 void DetachUnownedInnerWebContents(
488 base::PassKey<UnownedInnerWebContentsClient>,
489 WebContents* inner_web_contents) override;
Kevin McNee2585e732024-10-28 22:11:19490 void AttachGuestPage(std::unique_ptr<GuestPageHolder> guest_page,
491 RenderFrameHost* outer_render_frame_host) override;
W. James MacLean2539adb32019-12-13 00:40:44492 bool IsInnerWebContentsForGuest() override;
Lucas Furukawa Gadani2ec00c82018-12-14 15:53:16493 RenderFrameHostImpl* GetOuterWebContentsFrame() override;
Lucas Furukawa Gadanie1c5dfda2018-11-29 17:57:41494 WebContentsImpl* GetOuterWebContents() override;
W. James MacLean3f9fba232018-08-16 15:20:36495 WebContentsImpl* GetOutermostWebContents() override;
Lucas Furukawa Gadani2ec00c82018-12-14 15:53:16496 std::vector<WebContents*> GetInnerWebContents() override;
Jeremy Roman7e70bf952020-01-07 23:23:58497 WebContentsImpl* GetResponsibleWebContents() override;
dalecurtis6c58ed02016-10-28 23:02:37498 void DidChangeVisibleSecurityState() override;
Bruce Long1e3e1f542019-10-16 17:56:28499 void SyncRendererPrefs() override;
dchengc2282aa2014-10-21 12:07:58500 void Stop() override;
Francois Doray47f759d2018-06-11 18:13:51501 void SetPageFrozen(bool frozen) override;
erikchen6c7df7f7a2018-05-03 18:13:59502 std::unique_ptr<WebContents> Clone() override;
arthursonzogni818c2642019-09-27 12:18:10503 void ReloadFocusedFrame() override;
dchengc2282aa2014-10-21 12:07:58504 void Undo() override;
505 void Redo() override;
506 void Cut() override;
507 void Copy() override;
508 void CopyToFindPboard() override;
Leonard Greyc2bc8002023-03-08 17:53:06509 void CenterSelection() override;
dchengc2282aa2014-10-21 12:07:58510 void Paste() override;
511 void PasteAndMatchStyle() override;
512 void Delete() override;
513 void SelectAll() override;
yabinh351e7ec2017-03-10 02:43:24514 void CollapseSelection() override;
Leonard Greyf378e7d2021-03-25 20:53:50515 void ScrollToTopOfDocument() override;
516 void ScrollToBottomOfDocument() override;
Jan Wilken Dörrieaace0cfef2021-03-11 22:01:58517 void Replace(const std::u16string& word) override;
518 void ReplaceMisspelling(const std::u16string& word) override;
Andrew Paseltiner31c56ab2024-11-20 18:26:19519 void NotifyContextMenuClosed(
520 const GURL& link_followed,
521 const std::optional<blink::Impression>&) override;
Gyuyoung Kim1bc1ba82021-02-08 23:32:44522 void ExecuteCustomContextMenuCommand(int action,
523 const GURL& link_followed) override;
dchengc2282aa2014-10-21 12:07:58524 gfx::NativeView GetNativeView() override;
525 gfx::NativeView GetContentNativeView() override;
526 gfx::NativeWindow GetTopLevelNativeWindow() override;
527 gfx::Rect GetContainerBounds() override;
528 gfx::Rect GetViewBounds() override;
529 DropData* GetDropData() override;
530 void Focus() override;
531 void SetInitialFocus() override;
532 void StoreFocus() override;
533 void RestoreFocus() override;
534 void FocusThroughTabTraversal(bool reverse) override;
dchengc2282aa2014-10-21 12:07:58535 bool IsSavable() override;
536 void OnSavePage() override;
537 bool SavePage(const base::FilePath& main_file,
538 const base::FilePath& dir_path,
539 SavePageType save_type) override;
Yao Xiaoe5007042021-02-26 02:32:09540 void SaveFrame(const GURL& url,
541 const Referrer& referrer,
542 RenderFrameHost* rfh) override;
kundaji6c7f9692015-03-09 18:00:37543 void SaveFrameWithHeaders(const GURL& url,
544 const Referrer& referrer,
Xing Liu10329bf2018-03-20 19:22:14545 const std::string& headers,
Jan Wilken Dörrieaace0cfef2021-03-11 22:01:58546 const std::u16string& suggested_filename,
Jeremy Roman4d408d8a2024-01-10 02:27:21547 RenderFrameHost* rfh,
548 bool is_subresource) override;
dewittj6dc5747a2016-05-17 01:48:47549 void GenerateMHTML(const MHTMLGenerationParams& params,
Avi Drissman149b7832018-03-23 14:31:49550 base::OnceCallback<void(int64_t)> callback) override;
Lucas Furukawa Gadanie1c5dfda2018-11-29 17:57:41551 const std::string& GetContentsMimeType() override;
Mario Sanchez Prada0bd8b8c2020-10-21 17:49:23552 blink::RendererPreferences* GetMutableRendererPrefs() override;
dchengc2282aa2014-10-21 12:07:58553 void Close() override;
dchengc2282aa2014-10-21 12:07:58554 void SetClosedByUserGesture(bool value) override;
Lucas Furukawa Gadanie1c5dfda2018-11-29 17:57:41555 bool GetClosedByUserGesture() override;
556 int GetMinimumZoomPercent() override;
557 int GetMaximumZoomPercent() override;
mcnee432e47d2015-11-09 19:37:46558 void SetPageScale(float page_scale_factor) override;
Lucas Furukawa Gadanie1c5dfda2018-11-29 17:57:41559 gfx::Size GetPreferredSize() override;
Takumi Fujimoto4661871d2024-01-25 02:04:18560 bool GotResponseToPointerLockRequest(
James Hollyerd5c9de462020-03-10 19:02:45561 blink::mojom::PointerLockResult result) override;
Takumi Fujimoto4661871d2024-01-25 02:04:18562 void GotPointerLockPermissionResponse(bool allowed) override;
563 void DropPointerLockForTesting() override;
Joe Downing13dd76b2018-04-09 18:32:15564 bool GotResponseToKeyboardLockRequest(bool allowed) override;
Lucas Furukawa Gadanie1c5dfda2018-11-29 17:57:41565 bool HasOpener() override;
566 RenderFrameHostImpl* GetOpener() override;
Rakina Zata Amni3a48ae42022-05-05 03:39:56567 bool HasLiveOriginalOpenerChain() override;
568 WebContents* GetFirstWebContentsInLiveOriginalOpenerChain() override;
Tom Burginf0e48622024-05-16 15:06:12569#if BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_IOS)
dchengc2282aa2014-10-21 12:07:58570 void DidChooseColorInColorChooser(SkColor color) override;
571 void DidEndColorChooser() override;
Julie Jeongeun Kim88ce9ec2023-07-28 02:25:40572#endif
Jacob Francis0043f242024-07-24 21:46:21573 int DownloadImageFromAxNode(const ui::AXTreeID tree_id,
574 const ui::AXNodeID node_id,
575 const gfx::Size& preferred_size,
576 uint32_t max_bitmap_size,
577 bool bypass_cache,
578 ImageDownloadCallback callback) override;
dchengc2282aa2014-10-21 12:07:58579 int DownloadImage(const GURL& url,
580 bool is_favicon,
Rouslan Solomakhindb19343e2021-09-15 15:34:55581 const gfx::Size& preferred_size,
dchengc2282aa2014-10-21 12:07:58582 uint32_t max_bitmap_size,
pkotwiczfd773552015-03-16 00:29:14583 bool bypass_cache,
Avi Drissmana5a52dd2018-03-27 03:39:02584 ImageDownloadCallback callback) override;
Jacob Francis0043f242024-07-24 21:46:21585
Danyao Wanga78f3dd22020-03-05 05:31:27586 int DownloadImageInFrame(
Alexander Timin8690530c2021-06-19 00:34:32587 const GlobalRenderFrameHostId& initiator_frame_routing_id,
Danyao Wanga78f3dd22020-03-05 05:31:27588 const GURL& url,
589 bool is_favicon,
Rouslan Solomakhindb19343e2021-09-15 15:34:55590 const gfx::Size& preferred_size,
Danyao Wanga78f3dd22020-03-05 05:31:27591 uint32_t max_bitmap_size,
592 bool bypass_cache,
593 WebContents::ImageDownloadCallback callback) override;
dchengc2282aa2014-10-21 12:07:58594 void Find(int request_id,
Jan Wilken Dörrieaace0cfef2021-03-11 22:01:58595 const std::u16string& search_text,
Joey Arharcac45bf2022-01-07 21:59:31596 blink::mojom::FindOptionsPtr options,
Avi Drissman5710b062024-07-02 21:23:29597 bool skip_delay) override;
dchengc2282aa2014-10-21 12:07:58598 void StopFinding(StopFindAction action) override;
Tommy Steimel18360512017-11-01 00:38:19599 bool WasEverAudible() override;
Avi Drissman97aef042020-06-30 21:04:48600 bool IsFullscreen() override;
Malay Keshav87c42c02019-01-15 08:37:47601 bool ShouldShowStaleContentOnEviction() override;
Muyao Xudb226be52023-12-01 04:23:09602 void ExitFullscreen(bool will_cause_resize) override;
Daniel Cheng9c9fa1a2022-01-14 03:42:11603 [[nodiscard]] base::ScopedClosureRunner ForSecurityDropFullscreen(
Avi Drissman5710b062024-07-02 21:23:29604 int64_t display_id) override;
mariakhomenko44bdc4732015-04-29 01:55:38605 void ResumeLoadingCreatedWebContents() override;
qinmin72e8bd02016-10-21 19:35:37606 void SetIsOverlayContent(bool is_overlay_content) override;
ekaramad5c1f9392017-01-25 02:05:23607 bool IsFocusedElementEditable() override;
608 void ClearFocusedElement() override;
Lucas Furukawa Gadanie1c5dfda2018-11-29 17:57:41609 bool IsShowingContextMenu() override;
ekaramadf6750aa2017-06-06 18:29:42610 void SetShowingContextMenu(bool showing) override;
Aidan Wolter52bcc12a2018-11-14 03:27:29611 base::UnguessableToken GetAudioGroupId() override;
Lucas Furukawa Gadanie1c5dfda2018-11-29 17:57:41612 bool CompletedFirstVisuallyNonEmptyPaint() override;
Miyoung Shin5709ab02020-02-19 06:50:41613 void UpdateFaviconURL(
Kevin McNeefb86fcf2021-02-26 23:20:57614 RenderFrameHostImpl* source,
Ian Vollick6d75ac32021-05-05 17:45:09615 const std::vector<blink::mojom::FaviconURLPtr>& candidates) override;
Miyoung Shin5709ab02020-02-19 06:50:41616 const std::vector<blink::mojom::FaviconURLPtr>& GetFaviconURLs() override;
Mugdha Lakhani0a0d7862020-07-29 09:58:45617 void Resize(const gfx::Rect& new_bounds) override;
618 gfx::Size GetSize() override;
Amanda Baker228ec482021-03-24 19:50:08619 void UpdateWindowControlsOverlay(const gfx::Rect& bounding_rect) override;
Xiaohan Wang24ec9342022-01-15 17:34:22620#if BUILDFLAG(IS_ANDROID)
dcheng48d97c52015-02-04 20:03:20621 base::android::ScopedJavaLocalRef<jobject> GetJavaWebContents() override;
Nicolas Ouellet-Payeur177a6c42023-01-25 20:25:07622 base::android::ScopedJavaLocalRef<jthrowable> GetJavaCreatorLocation()
623 override;
Kevin McNee576bb5d82019-05-29 16:47:51624 WebContentsAndroid* GetWebContentsAndroid();
625 void ClearWebContentsAndroid();
paulmeyerc0b762b2016-04-13 11:55:17626 void ActivateNearestFindResult(float x, float y) override;
627 void RequestFindMatchRects(int current_version) override;
rockot400ea35b2016-10-15 19:15:32628 service_manager::InterfaceProvider* GetJavaInterfaces() override;
Shintaro Kawamura30df3e52025-04-10 15:08:21629 ChildProcessImportance GetPrimaryMainFrameImportanceForTesting() override;
Shin Kawamura7c2f4692025-07-30 00:14:33630 ChildProcessImportance GetPrimaryPageSubframeImportanceForTesting() override;
631 void SetPrimaryPageImportance(
632 ChildProcessImportance main_frame_importance,
633 ChildProcessImportance subframe_importance) override;
[email protected]155c7f22013-12-09 17:07:18634#endif
Evan Stade6decc972022-10-24 19:42:18635 bool HasRecentInteraction() override;
Takashi Toyoshimad72a465a2024-03-11 23:37:31636 [[nodiscard]] ScopedIgnoreInputEvents IgnoreInputEvents(
637 std::optional<WebInputEventAuditCallback> audit_callback) override;
Erik Chenfac576802024-11-14 15:26:33638 bool ShouldIgnoreInputEventsForTesting() override;
Sebastien Marchandc38e5ae2021-02-18 20:28:13639 bool HasActiveEffectivelyFullscreenVideo() override;
Alexander Timinbebb2002021-04-20 15:42:24640 void WriteIntoTrace(perfetto::TracedValue context) override;
Lukasz Anforowicz2c1573a2021-09-21 18:58:18641 const base::Location& GetCreatorLocation() override;
Arthur Sonzognic686e8f2024-01-11 08:36:37642 const std::optional<blink::mojom::PictureInPictureWindowOptions>&
Tommy Steimel57eafde2023-01-27 17:33:24643 GetPictureInPictureOptions() const override;
Peilin Wangae08e26e2024-06-10 20:55:30644 void UpdateBrowserControlsState(
645 cc::BrowserControlsState constraints,
646 cc::BrowserControlsState current,
647 bool animate,
Peilin Wang1187e4e82025-02-10 08:53:29648 const std::optional<cc::BrowserControlsOffsetTagModifications>&
649 offset_tag_modifications) override;
Marja Hölttä2019e9d2023-09-07 14:07:35650 void SetV8CompileHints(base::ReadOnlySharedMemoryRegion data) override;
Joe Mason7ae0e2b2021-11-01 12:30:36651 void SetTabSwitchStartTime(base::TimeTicks start_time,
Joe Masonb7004352022-04-06 03:11:08652 bool destination_is_loaded) override;
Takashi Toyoshima8dfc05c2024-01-29 21:03:51653 bool IsInPreviewMode() const override;
654 void WillActivatePreviewPage() override;
Takashi Toyoshima138cf44a2023-11-02 10:33:25655 void ActivatePreviewPage() override;
Fabio Muratori8ff26892025-05-06 19:07:21656 WindowOpenDisposition GetOriginalWindowOpenDisposition() const override;
Min Qin7b7cbbbf2018-06-04 21:49:31657
[email protected]0bfbf882011-12-22 18:19:27658 // Implementation of PageNavigator.
HuanPo Lin0d795c62024-03-28 03:54:05659 WebContents* OpenURL(const OpenURLParams& params,
660 base::OnceCallback<void(content::NavigationHandle&)>
661 navigation_handle_callback) override;
[email protected]151a63d2011-12-20 22:32:52662
Gyuyoung Kim1ac4ca782020-09-11 03:32:51663 const blink::web_pref::WebPreferences& GetOrCreateWebPreferences() override;
Rakina Zata Amni347b70902020-07-22 10:49:04664 void NotifyPreferencesChanged() override;
Gyuyoung Kim1ac4ca782020-09-11 03:32:51665 void SetWebPreferences(const blink::web_pref::WebPreferences& prefs) override;
Rakina Zata Amni4029b6d2020-07-28 02:36:20666 void OnWebPreferencesChanged() override;
Rakina Zata Amni347b70902020-07-22 10:49:04667
Thomas Lukaszewicz034b34f2024-08-29 22:44:32668 void AboutToBeDiscarded(WebContents* new_contents) override;
Thomas Lukaszewicz8ada31b2024-09-01 19:18:16669 void NotifyWasDiscarded() override;
Thomas Lukaszewicz034b34f2024-08-29 22:44:32670
Jan Keitel1d8d51d2023-08-22 05:53:47671 [[nodiscard]] base::ScopedClosureRunner CreateDisallowCustomCursorScope(
672 int max_dimension_dips) override;
Andy Paicu5608bda82023-03-03 15:09:20673
Charles Mengc2cca37e2023-08-15 18:14:30674 void SetOverscrollNavigationEnabled(bool enabled) override;
675
[email protected]92404c62013-12-04 16:40:46676 // RenderFrameHostDelegate ---------------------------------------------------
nicka0ac8382016-12-15 23:59:23677 bool OnMessageReceived(RenderFrameHostImpl* render_frame_host,
dchengc2282aa2014-10-21 12:07:58678 const IPC::Message& message) override;
Abhijeet Kandalkarde7348e2020-01-13 06:06:54679 void OnDidBlockNavigation(
680 const GURL& blocked_url,
681 const GURL& initiator_url,
682 blink::mojom::NavigationBlockedReason reason) override;
Kevin McNeefb86fcf2021-02-26 23:20:57683 void OnDidFinishLoad(RenderFrameHostImpl* render_frame_host,
Gyuyoung Kim525e0c5d2020-03-09 15:04:19684 const GURL& url) override;
Sreeja Kamishettycfb4b862022-03-29 16:59:39685 void OnManifestUrlChanged(PageImpl& page) override;
Kevin McNeefb86fcf2021-02-26 23:20:57686 void RenderFrameCreated(RenderFrameHostImpl* render_frame_host) override;
687 void RenderFrameDeleted(RenderFrameHostImpl* render_frame_host) override;
Gyuyoung Kim1bc1ba82021-02-08 23:32:44688 void ShowContextMenu(
Dave Tapuskacf5a9622024-11-03 19:01:27689 RenderFrameHostImpl& render_frame_host,
Gyuyoung Kim1bc1ba82021-02-08 23:32:44690 mojo::PendingAssociatedRemote<blink::mojom::ContextMenuClient>
691 context_menu_client,
692 const ContextMenuParams& params) override;
Kevin McNeefb86fcf2021-02-26 23:20:57693 void RunJavaScriptDialog(RenderFrameHostImpl* render_frame_host,
Jan Wilken Dörrieaace0cfef2021-03-11 22:01:58694 const std::u16string& message,
695 const std::u16string& default_prompt,
avi777ff452017-02-09 19:04:48696 JavaScriptDialogType dialog_type,
Carlos IL5c669bc2021-05-26 21:16:24697 bool disable_third_party_subframe_suppresion,
Dave Tapuskacdf545cc2020-01-23 18:38:52698 JavaScriptDialogCallback response_callback) override;
Dave Tapuskabe4fbe42025-01-08 16:31:43699 void Close(RenderFrameHostImpl* render_frame_host) override;
Dave Tapuskacdf545cc2020-01-23 18:38:52700 void RunBeforeUnloadConfirm(
Kevin McNeefb86fcf2021-02-26 23:20:57701 RenderFrameHostImpl* render_frame_host,
Dave Tapuskacdf545cc2020-01-23 18:38:52702 bool is_reload,
703 JavaScriptDialogCallback response_callback) override;
Kevin McNeefb86fcf2021-02-26 23:20:57704 void DidChangeName(RenderFrameHostImpl* render_frame_host,
alexmosbe2f4c32015-03-10 02:30:23705 const std::string& name) override;
John Delaneyb625dca92021-04-14 17:00:34706 void DidReceiveUserActivation(
Kevin McNeefb86fcf2021-02-26 23:20:57707 RenderFrameHostImpl* render_frame_host) override;
Jonathan Njeunjeb769687652023-06-15 16:46:30708 void WebAuthnAssertionRequestSucceeded(
709 RenderFrameHostImpl* render_frame_host) override;
Robert Sesekc4eeccbd2021-07-23 21:20:19710 void BindDisplayCutoutHost(
711 RenderFrameHostImpl* render_frame_host,
712 mojo::PendingAssociatedReceiver<blink::mojom::DisplayCutoutHost> receiver)
713 override;
Kevin McNeefb86fcf2021-02-26 23:20:57714 void DidChangeDisplayState(RenderFrameHostImpl* render_frame_host,
John Delaney0146a742019-01-25 19:25:28715 bool is_display_none) override;
Kevin McNeefb86fcf2021-02-26 23:20:57716 void FrameSizeChanged(RenderFrameHostImpl* render_frame_host,
John Delaney0146a742019-01-25 19:25:28717 const gfx::Size& frame_size) override;
Kevin McNeefb86fcf2021-02-26 23:20:57718 void DOMContentLoaded(RenderFrameHostImpl* render_frame_host) override;
719 void DocumentOnLoadCompleted(RenderFrameHostImpl* render_frame_host) override;
720 void UpdateTitle(RenderFrameHostImpl* render_frame_host,
Jan Wilken Dörrieaace0cfef2021-03-11 22:01:58721 const std::u16string& title,
dchengc2282aa2014-10-21 12:07:58722 base::i18n::TextDirection title_direction) override;
Haben Foto533aa352024-01-09 22:01:16723 // The app title is an alternative title. If non-empty, the browser may choose
724 // to use the app title instead of the regular title for a web app displayed
725 // in an app window. See
726 // https://github.com/MicrosoftEdge/MSEdgeExplainers/blob/main/DocumentSubtitle/explainer.md
Stanley Honf83c4b8b2025-01-08 00:52:30727 void UpdateApplicationTitle(RenderFrameHostImpl* render_frame_host,
728 const std::u16string& application_title) override;
Kevin McNeefb86fcf2021-02-26 23:20:57729 void UpdateTargetURL(RenderFrameHostImpl* render_frame_host,
Mario Sanchez Pradadffbe66e2020-09-07 12:01:08730 const GURL& url) override;
danakj77eb7e82020-01-09 19:38:46731 bool IsNeverComposited() override;
Elad Alonf156eb62021-05-17 22:02:37732 void SetCaptureHandleConfig(
733 blink::mojom::CaptureHandleConfigPtr config) override;
Lucas Furukawa Gadanie1c5dfda2018-11-29 17:57:41734 ui::AXMode GetAccessibilityMode() override;
James Wallace-Leeeafc94cb92018-07-23 21:35:09735 // Broadcasts the mode change to all frames.
Greg Thompsonf855bf882024-01-30 10:39:45736 void ResetAccessibility() override;
Mario Sanchez Prada5d7f1ac2020-07-16 17:18:40737 void AXTreeIDForMainFrameHasChanged() override;
David Tseng63bbdea2024-05-30 17:40:34738 void ProcessAccessibilityUpdatesAndEvents(
739 ui::AXUpdatesAndEvents& details) override;
dmazzoni2400c462016-08-23 15:07:13740 void AccessibilityLocationChangesReceived(
Ahmed Elwasefi79a665e2024-10-01 18:24:47741 const ui::AXTreeID& tree_id,
742 ui::AXLocationAndScrollUpdates& details) override;
Nektarios Paisios8e9da982024-02-20 23:14:22743 ui::AXNode* GetAccessibilityRootNode() override;
Alexander Surkov2ab51622020-09-02 12:01:42744 std::string DumpAccessibilityTree(
Abigail Kleinabb428332019-09-13 18:26:21745 bool internal,
Alexander Surkov90482882020-10-12 16:30:38746 std::vector<ui::AXPropertyFilter> property_filters) override;
Jacques Newmane313e142024-03-13 18:47:22747 std::string DumpAccessibilityTree(
748 ui::AXApiType::Type api_type,
749 std::vector<ui::AXPropertyFilter> property_filters) override;
Mark Schillaciac6c9f72025-04-02 17:37:34750 void ApplyAXTreeFixingResult(ui::AXTreeID tree_id,
751 ui::AXNodeID node_id,
752 ax::mojom::Role role) override;
Abigail Kleinbb8304bd2020-05-18 21:44:18753 void RecordAccessibilityEvents(
754 bool start_recording,
Arthur Sonzognic686e8f2024-01-11 08:36:37755 std::optional<ui::AXEventCallback> callback) override;
Jacques Newmane313e142024-03-13 18:47:22756 void RecordAccessibilityEvents(
757 ui::AXApiType::Type api_type,
758 bool start_recording,
759 std::optional<ui::AXEventCallback> callback) override;
Aaron Leventhal6ceb5882024-04-17 15:19:38760 void UnrecoverableAccessibilityError() override;
Ke He7319dbe2017-11-09 05:54:44761 device::mojom::GeolocationContext* GetGeolocationContext() override;
ke.he98b761e2017-05-09 05:59:17762 device::mojom::WakeLockContext* GetWakeLockContext() override;
Gyuyoung Kim9ce9ddda2025-06-19 02:01:14763#if BUILDFLAG(IS_ANDROID) || (BUILDFLAG(IS_IOS) && !BUILDFLAG(IS_IOS_TVOS))
Dave Tapuskab0edabb32025-06-17 17:03:20764 void GetNFC(RenderFrameHostImpl*,
Reilly Grantafbe2242020-02-20 21:14:55765 mojo::PendingReceiver<device::mojom::NFC>) override;
blundellf5316fc2017-05-15 11:49:03766#endif
Mike Wasserman16f130da2024-04-17 23:03:30767 bool CanEnterFullscreenMode(RenderFrameHostImpl* requesting_frame) override;
Dave Tapuskaa4189512019-10-15 20:27:34768 void EnterFullscreenMode(
Kevin McNeefb86fcf2021-02-26 23:20:57769 RenderFrameHostImpl* requesting_frame,
Dave Tapuskaa4189512019-10-15 20:27:34770 const blink::mojom::FullscreenOptions& options) override;
Muyao Xudb226be52023-12-01 04:23:09771 void ExitFullscreenMode(bool will_cause_resize) override;
Batalov Vladislave9a5f3822020-12-02 07:31:11772 void FullscreenStateChanged(
Kevin McNeefb86fcf2021-02-26 23:20:57773 RenderFrameHostImpl* rfh,
Batalov Vladislave9a5f3822020-12-02 07:31:11774 bool is_fullscreen,
775 blink::mojom::FullscreenOptionsPtr options) override;
Jeremy Roman608bcab2023-11-09 22:29:30776 bool CanUseWindowingControls(RenderFrameHostImpl* requesting_frame) override;
Ivan Šandrk5277117562023-07-05 14:07:28777 void Maximize() override;
Ivan Šandrk1b68e6e2023-06-29 11:47:22778 void Minimize() override;
Ivan Šandrkbf6b7302023-07-05 15:16:02779 void Restore() override;
Michael Thiessene5663522022-05-25 21:23:28780#if BUILDFLAG(IS_ANDROID)
781 void UpdateUserGestureCarryoverInfo() override;
782#endif
Avi Drissman36f801f2018-02-01 20:06:04783 void DidCallFocus() override;
ekaramada110f642016-12-21 19:47:28784 void OnFocusedElementChangedInFrame(
785 RenderFrameHostImpl* frame,
Emily Stark023dbacc2020-08-27 22:31:40786 const gfx::Rect& bounds_in_root_view,
787 blink::mojom::FocusType focus_type) override;
Lucas Furukawa Gadaniabbfa342017-08-29 19:37:57788 void OnAdvanceFocus(RenderFrameHostImpl* source_rfh) override;
Alexander Timin9666d502021-06-19 01:34:50789 FrameTree* CreateNewWindow(
Kevin McNeefb86fcf2021-02-26 23:20:57790 RenderFrameHostImpl* opener,
nick5ae4d2d2017-01-06 01:18:35791 const mojom::CreateNewWindowParams& params,
Albert J. Wong65fe64d2019-09-20 02:48:14792 bool is_new_browsing_instance,
Sergey Kuznetsov32257a22019-02-11 20:26:50793 bool has_user_gesture,
nick5ae4d2d2017-01-06 01:18:35794 SessionStorageNamespace* session_storage_namespace) override;
Stefan Zager6f6e57c2025-03-19 22:03:45795 WebContents* ShowCreatedWindow(
796 RenderFrameHostImpl* opener,
797 int main_frame_widget_route_id,
798 WindowOpenDisposition disposition,
799 const blink::mojom::WindowFeatures& window_features,
800 bool user_gesture) override;
Sreeja Kamishetty49783302022-01-28 17:52:25801 void PrimaryMainDocumentElementAvailable() override;
carloskd9d97942017-02-16 08:58:09802 void PassiveInsecureContentFound(const GURL& resource_url) override;
Carlos IL29294a62020-05-15 00:21:16803 bool ShouldAllowRunningInsecureContent(bool allowed_per_prefs,
carloskd9d97942017-02-16 08:58:09804 const url::Origin& origin,
805 const GURL& resource_url) override;
Lukasz Anforowicze1b954d92017-10-30 21:28:06806 void ViewSource(RenderFrameHostImpl* frame) override;
Kevin McNeefb86fcf2021-02-26 23:20:57807 void PrintCrossProcessSubframe(
808 const gfx::Rect& rect,
809 int document_cookie,
810 RenderFrameHostImpl* render_frame_host) override;
ckitagawa8695799b2020-02-05 16:08:49811 void CapturePaintPreviewOfCrossProcessSubframe(
812 const gfx::Rect& rect,
813 const base::UnguessableToken& guid,
Kevin McNeefb86fcf2021-02-26 23:20:57814 RenderFrameHostImpl* render_frame_host) override;
Xiaohan Wang24ec9342022-01-15 17:34:22815#if BUILDFLAG(IS_ANDROID)
rob.buis300b0872017-03-10 20:43:58816 base::android::ScopedJavaLocalRef<jobject> GetJavaRenderFrameHostDelegate()
817 override;
818#endif
Jay Civelli116683f2018-03-27 19:56:23819 void ResourceLoadComplete(
Kevin McNeefb86fcf2021-02-26 23:20:57820 RenderFrameHostImpl* render_frame_host,
Clark DuVall36164bd2018-08-09 22:49:08821 const GlobalRequestID& request_id,
Minggang Wangee5af392020-02-05 02:55:28822 blink::mojom::ResourceLoadInfoPtr resource_load_information) override;
Alexander Timin1cc31f42020-05-12 16:26:01823 void OnCookiesAccessed(RenderFrameHostImpl*,
824 const CookieAccessDetails& details) override;
Steven Valdeza06f680c2023-03-21 19:00:10825 void OnTrustTokensAccessed(RenderFrameHostImpl*,
826 const TrustTokenAccessDetails& details) override;
Tsuyoshi Horobcd0b9f62023-06-28 11:35:32827 void OnSharedDictionaryAccessed(
828 RenderFrameHostImpl*,
829 const network::mojom::SharedDictionaryAccessDetails& details) override;
Daniel Rubery6420d74302024-11-19 01:42:40830 void OnDeviceBoundSessionAccessed(
831 RenderFrameHostImpl* render_frame_host,
Daniel Rubery7cdfa532025-01-24 16:57:50832 const net::device_bound_sessions::SessionAccess& access) override;
Joanne de Abreu7cdb0862024-05-03 21:12:42833 void NotifyStorageAccessed(RenderFrameHostImpl*,
834 blink::mojom::StorageTypeAccessed storage_type,
835 bool blocked) override;
Seung Jae Limc16c5e12024-05-10 23:30:00836 void OnVibrate(RenderFrameHostImpl*) override;
837
Sandor Major878f8352025-02-18 20:16:02838 std::optional<network::ParsedPermissionsPolicy>
Robbie McElrath34dab002024-02-23 20:12:35839 GetPermissionsPolicyForIsolatedWebApp(RenderFrameHostImpl* source) override;
Raymond Toye413650c2018-08-31 00:12:47840
841 // Called when WebAudio starts or stops playing audible audio in an
842 // AudioContext.
Kevin McNeefb86fcf2021-02-26 23:20:57843 void AudioContextPlaybackStarted(RenderFrameHostImpl* host,
Raymond Toye413650c2018-08-31 00:12:47844 int context_id) override;
Kevin McNeefb86fcf2021-02-26 23:20:57845 void AudioContextPlaybackStopped(RenderFrameHostImpl* host,
Raymond Toye413650c2018-08-31 00:12:47846 int context_id) override;
Kevin McNeefb86fcf2021-02-26 23:20:57847 void OnFrameAudioStateChanged(RenderFrameHostImpl* host,
Chris Hamilton16ca64a2020-05-14 23:13:17848 bool is_audible) override;
Patrick Monettebade7342024-09-09 14:07:10849 void OnRemoteSubframeViewportIntersectionStateChanged(
850 RenderFrameHostImpl* host,
851 const blink::mojom::ViewportIntersectionState&
852 viewport_intersection_state) override;
Patrick Monette214fab672023-10-29 03:56:06853 void OnFrameVisibilityChanged(
854 RenderFrameHostImpl* host,
855 blink::mojom::FrameVisibility visibility) override;
Patrick Monette6f1fc912023-11-21 22:10:18856 void OnFrameIsCapturingMediaStreamChanged(
Patrick Monette031229b2023-11-02 17:21:18857 RenderFrameHostImpl* host,
Patrick Monette6f1fc912023-11-21 22:10:18858 bool is_capturing_media_stream) override;
Kevin McNee5f594382021-05-06 23:18:23859 std::vector<FrameTreeNode*> GetUnattachedOwnedNodes(
860 RenderFrameHostImpl* owner) override;
Dave Tapuskaf9fc3122019-10-18 19:42:55861 void RegisterProtocolHandler(RenderFrameHostImpl* source,
862 const std::string& protocol,
863 const GURL& url,
Dave Tapuskaf9fc3122019-10-18 19:42:55864 bool user_gesture) override;
865 void UnregisterProtocolHandler(RenderFrameHostImpl* source,
866 const std::string& protocol,
867 const GURL& url,
868 bool user_gesture) override;
Kristi Saney9632a652025-05-30 19:44:02869 [[nodiscard]] base::ScopedClosureRunner MarkAudible() override;
Carlos Caballeroede6f8c2021-01-28 11:01:50870 bool IsAllowedToGoToEntryAtOffset(int32_t offset) override;
Dominique Fauteux-Chapleau4407a85d2024-01-05 13:18:58871 void IsClipboardPasteAllowedByPolicy(
872 const ClipboardEndpoint& source,
873 const ClipboardEndpoint& destination,
Xu Li383fced2025-08-12 16:14:01874 const ui::ClipboardMetadata& metadata,
Nancy Xiao4f3eae5d62023-04-25 19:38:59875 ClipboardPasteData clipboard_paste_data,
Dominique Fauteux-Chapleau4407a85d2024-01-05 13:18:58876 IsClipboardPasteAllowedCallback callback) override;
siashah1cac9c52024-07-09 23:50:36877 void OnTextCopiedToClipboard(RenderFrameHostImpl* render_frame_host,
878 const std::u16string& copied_text) override;
Dominique Fauteux-Chapleau4407a85d2024-01-05 13:18:58879 void IsClipboardPasteAllowedWrapperCallback(
880 IsClipboardPasteAllowedCallback callback,
Arthur Sonzognic686e8f2024-01-11 08:36:37881 std::optional<ClipboardPasteData> clipboard_paste_data);
Haihan Chen715e6752025-06-18 19:30:25882 std::optional<std::vector<std::u16string>> GetClipboardTypesIfPolicyApplied(
883 const ui::ClipboardSequenceNumberToken& seqno) override;
Kevin McNee3183a7792021-11-09 21:03:36884 void OnPageScaleFactorChanged(PageImpl& source) override;
Robert Sesek5047c412021-08-09 17:36:18885 void BindScreenOrientation(
886 RenderFrameHost* rfh,
887 mojo::PendingAssociatedReceiver<device::mojom::ScreenOrientation>
888 receiver) override;
Mike Wassermanc22b77442024-01-02 19:10:18889 bool IsTransientActivationRequiredForHtmlFullscreen() override;
Dave Tapuskadfff7382021-04-23 19:46:41890 bool IsBackForwardCacheSupported() override;
Dave Tapuska42f9b902020-10-23 21:57:06891 RenderWidgetHostImpl* CreateNewPopupWidget(
Dave Tapuska80fb72522022-03-18 21:34:23892 base::SafeRef<SiteInstanceGroup> site_instance_group,
Dave Tapuska04ccda062020-10-21 21:58:12893 int32_t route_id,
894 mojo::PendingAssociatedReceiver<blink::mojom::PopupWidgetHost>
895 blink_popup_widget_host,
896 mojo::PendingAssociatedReceiver<blink::mojom::WidgetHost>
897 blink_widget_host,
898 mojo::PendingAssociatedRemote<blink::mojom::Widget> blink_widget)
899 override;
Gyuyoung Kim1905f7c2020-05-02 00:00:24900 void DidLoadResourceFromMemoryCache(
901 RenderFrameHostImpl* source,
902 const GURL& url,
903 const std::string& http_request,
904 const std::string& mime_type,
Arthur Sonzogni54013f22021-09-03 14:57:12905 network::mojom::RequestDestination request_destination,
906 bool include_credentials) override;
Ewelina Baraned2df8ad2021-12-22 10:05:37907 void DomOperationResponse(RenderFrameHost* render_frame_host,
908 const std::string& json_string) override;
Gyuyoung Kim4c50517842020-06-04 17:50:44909 void SavableResourceLinksResponse(
910 RenderFrameHostImpl* source,
911 const std::vector<GURL>& resources_list,
912 blink::mojom::ReferrerPtr referrer,
913 const std::vector<blink::mojom::SavableSubframePtr>& subframes) override;
914 void SavableResourceLinksError(RenderFrameHostImpl* source) override;
Sreeja Kamishettybe0ccd6b2020-06-09 11:52:50915 void RenderFrameHostStateChanged(
Sreeja Kamishetty2771b7d2021-04-07 06:34:18916 RenderFrameHost* render_frame_host,
917 RenderFrameHost::LifecycleState old_state,
918 RenderFrameHost::LifecycleState new_state) override;
Dave Tapuska3f201fa2020-10-28 14:17:10919 void SetWindowRect(const gfx::Rect& new_bounds) override;
Kevin McNee5604b1c42025-01-09 22:30:40920 void UpdateWindowPreferredSize(RenderFrameHostImpl* render_frame_host,
921 const gfx::Size& pref_size) override;
Camille Lamy8766bd3e2020-11-26 11:36:32922 std::vector<RenderFrameHostImpl*>
923 GetActiveTopLevelDocumentsInBrowsingContextGroup(
924 RenderFrameHostImpl* render_frame_host) override;
Hiroki Nakagawa1cb14552021-04-23 03:37:34925 PrerenderHostRegistry* GetPrerenderHostRegistry() override;
Dave Tapuska5f966bb72024-11-25 22:39:48926 void DidChangeLoadProgressForMainFrame(
927 RenderFrameHostImpl* render_frame_host) override;
Hyowon Kim5310a2c2022-11-15 03:07:15928 void DidFailLoadWithError(RenderFrameHostImpl* render_frame_host,
929 const GURL& url,
930 int error_code) override;
Amanda Bakerf48f04b2024-03-26 18:12:33931 void DraggableRegionsChanged(
932 const std::vector<blink::mojom::DraggableRegionPtr>& regions) override;
Rakina Zata Amni2620dcb2024-11-13 01:41:58933 void OnFirstContentfulPaintInPrimaryMainFrame() override;
Benjamin Beaudryfed497b2025-02-21 05:45:17934 gfx::NativeWindow GetOwnerNativeWindow() override;
Sreeja Kamishettybe0ccd6b2020-06-09 11:52:50935
Benjamin Keenfdd1a3cb2025-04-07 20:53:58936 media::PictureInPictureEventsInfo::AutoPipInfo GetAutoPipInfo()
Benjamin Keen919ed0f2025-02-25 15:47:20937 const override;
Ming-Ying Chung16d04472025-04-17 22:14:39938 void OnKeepAliveRequestCreated(
939 const network::ResourceRequest& resource_request,
940 RenderFrameHostImpl* initiator_rfh) override;
Benjamin Keen919ed0f2025-02-25 15:47:20941
Ming-Ying Chung16d04472025-04-17 22:14:39942 // RenderViewHostDelegate
943 // ----------------------------------------------------
dchengc2282aa2014-10-21 12:07:58944 RenderViewHostDelegateView* GetDelegateView() override;
dchengc2282aa2014-10-21 12:07:58945 void RenderViewReady(RenderViewHost* render_view_host) override;
946 void RenderViewTerminated(RenderViewHost* render_view_host,
947 base::TerminationStatus status,
948 int error_code) override;
949 void RenderViewDeleted(RenderViewHost* render_view_host) override;
Ian Barkley-Yeung07d8a262020-11-19 22:45:35950 bool DidAddMessageToConsole(
Kevin McNeefb86fcf2021-02-26 23:20:57951 RenderFrameHostImpl* source_frame,
Ian Barkley-Yeung07d8a262020-11-19 22:45:35952 blink::mojom::ConsoleMessageLevel log_level,
Jan Wilken Dörrieaace0cfef2021-03-11 22:01:58953 const std::u16string& message,
Ian Barkley-Yeung07d8a262020-11-19 22:45:35954 int32_t line_no,
Jan Wilken Dörrieaace0cfef2021-03-11 22:01:58955 const std::u16string& source_id,
Arthur Sonzognic686e8f2024-01-11 08:36:37956 const std::optional<std::u16string>& untrusted_stack_trace) override;
Kevin McNee7705fe82024-11-07 18:56:31957 const blink::RendererPreferences& GetRendererPrefs(
958 RenderViewHostImpl* render_view_host) override;
Dave Tapuska183b8d702025-01-07 18:47:18959 const blink::web_pref::WebPreferences& GetOrCreateWebPreferences(
960 RenderViewHostImpl* render_view_host) override;
Daniel Cheng90196c82018-04-25 21:49:14961 void DidReceiveInputEvent(RenderWidgetHostImpl* render_widget_host,
Emily Starkc7bd40c42020-07-21 19:12:55962 const blink::WebInputEvent& event) override;
Takashi Toyoshimad72a465a2024-03-11 23:37:31963 bool ShouldIgnoreWebInputEvents(const blink::WebInputEvent& event) override;
Avi Drissman738ea192018-08-29 20:24:16964 bool ShouldIgnoreInputEvents() override;
dchengc2282aa2014-10-21 12:07:58965 void OnIgnoredUIEvent() override;
dchengc2282aa2014-10-21 12:07:58966 void Activate() override;
alexmosc2a8cec2016-05-23 22:19:53967 void ShowCreatedWidget(int process_id,
Albert J. Wongf6e13ed2018-09-18 15:25:47968 int widget_route_id,
Maksim Sisov113ea342021-08-26 16:19:31969 const gfx::Rect& initial_rect,
970 const gfx::Rect& initial_anchor_rect) override;
Mario Sanchez Pradaf68d98272020-12-09 18:47:52971 void CreateMediaPlayerHostForRenderFrameHost(
Kevin McNeefb86fcf2021-02-26 23:20:57972 RenderFrameHostImpl* frame_host,
Miyoung Shin040d8342021-02-23 15:12:31973 mojo::PendingAssociatedReceiver<media::mojom::MediaPlayerHost> receiver)
974 override;
Dave Tapuskaddcf18f2025-01-13 19:39:36975 void RequestMediaAccessPermission(RenderFrameHostImpl* render_frame_host,
976 const MediaStreamRequest& request,
Mark Pilgrim57499082018-06-12 12:38:30977 MediaResponseCallback callback) override;
Olha Sirikovaa6c4d522024-11-08 18:12:50978
979 void ProcessSelectAudioOutput(const SelectAudioOutputRequest& request,
980 SelectAudioOutputCallback callback) override;
981
Kevin McNeefb86fcf2021-02-26 23:20:57982 bool CheckMediaAccessPermission(RenderFrameHostImpl* render_frame_host,
Raymes Khouryad7c24a12018-03-05 23:22:58983 const url::Origin& security_origin,
Antonio Gomesc8b734b2019-06-05 18:22:16984 blink::mojom::MediaStreamType type) override;
avi85ee8362016-10-08 02:09:08985 bool IsJavaScriptDialogShowing() const override;
avic031d392017-03-03 03:09:42986 bool ShouldIgnoreUnresponsiveRenderer() override;
Charlie Reis3d189602021-04-27 21:24:47987 bool IsGuest() override;
Arthur Sonzognic686e8f2024-01-11 08:36:37988 std::optional<SkColor> GetBaseBackgroundColor() override;
Taiyo Mizuhashi15ba3bc2025-01-28 04:20:31989 std::unique_ptr<PrefetchHandle> StartPrefetch(
990 const GURL& prefetch_url,
991 bool use_prefetch_proxy,
Taiyo Mizuhashi49959d02025-04-22 16:07:54992 const std::string& embedder_histogram_suffix,
Taiyo Mizuhashi15ba3bc2025-01-28 04:20:31993 const blink::mojom::Referrer& referrer,
994 const std::optional<url::Origin>& referring_origin,
kenoss8a1493b2025-03-10 08:16:06995 std::optional<net::HttpNoVarySearchData> no_vary_search_hint,
Taiyo Mizuhashid7c856992025-06-23 08:56:02996 std::optional<PrefetchPriority> priority,
kenossa1af66f12025-03-07 06:10:55997 scoped_refptr<PreloadPipelineInfo> preload_pipeline_info,
Taiyo Mizuhashi15ba3bc2025-01-28 04:20:31998 base::WeakPtr<PreloadingAttempt> attempt,
kenoss6938554c2025-06-10 10:18:17999 std::optional<PreloadingHoldbackStatus> holdback_status_override,
1000 std::optional<base::TimeDelta> ttl) override;
Robert Linc37fb582021-11-11 03:18:471001 std::unique_ptr<PrerenderHandle> StartPrerendering(
Asami Doicf0f1642021-11-25 05:00:261002 const GURL& prerendering_url,
Kouhei Ueno3f37992b2023-11-09 23:29:021003 PreloadingTriggerType trigger_type,
Robert Lin125720c042022-01-21 01:14:581004 const std::string& embedder_histogram_suffix,
Hiroki Nakagawa8348bc42024-12-13 16:24:421005 net::HttpRequestHeaders additional_headers,
Rulong Chen(陈汝龙)bf12169c2024-12-16 05:38:161006 std::optional<net::HttpNoVarySearchData> no_vary_search_hint,
Lingqi Chi21d9feb2022-02-02 09:42:181007 ui::PageTransition page_transition,
Taiyo Mizuhashibc91f802024-06-20 19:37:221008 bool should_warm_up_compositor,
Lingqi Chia2efa8c2024-11-08 10:20:291009 bool should_prepare_paint_tree,
Domenic Denicolabb5d843c2023-07-18 01:47:331010 PreloadingHoldbackStatus holdback_status_override,
kenoss8e8e4112025-03-07 07:33:331011 scoped_refptr<PreloadPipelineInfo> preload_pipeline_info,
Sreeja Kamishettyac12140e2022-07-14 22:16:511012 PreloadingAttempt* preloading_attempt,
Liviu Tintacf066d52024-07-24 16:00:551013 base::RepeatingCallback<bool(const GURL&,
1014 const std::optional<UrlMatchType>&)>,
Jiacheng Guoea20d392025-07-07 01:08:141015 base::RepeatingCallback<void(NavigationHandle&)>,
1016 bool allow_reuse) override;
Hiroki Nakagawa2db55b32024-05-09 08:41:271017 void CancelAllPrerendering() override;
Hiroki Nakagawa68ba6ed92025-01-29 03:39:271018 bool IsAllowedToStartPrerendering() override;
Kevin McNee097680d2023-04-05 22:14:511019 void BackNavigationLikely(PreloadingPredictor predictor,
1020 WindowOpenDisposition disposition) override;
Bo Liud4ced692023-09-18 21:17:141021 void SetOwnerLocationForDebug(
Arthur Sonzognic686e8f2024-01-11 08:36:371022 std::optional<base::Location> owner_location) override;
Sam Davis Omekara (from Dev Box)26b91992023-11-07 20:07:461023 blink::ColorProviderColorMaps GetColorProviderColorMaps() const override;
Rakina Zata Amni347b70902020-07-22 10:49:041024
Joanne de Abreu7cbed872023-10-30 23:25:261025 network::mojom::AttributionSupport GetAttributionSupport() override;
1026 void UpdateAttributionSupportRenderer() override;
1027 static void UpdateAttributionSupportAllRenderers();
William Liu6cf58fe2024-01-19 21:29:321028 BackForwardTransitionAnimationManager*
1029 GetBackForwardTransitionAnimationManager() override;
Xiao Ma29b2d1e62024-06-13 06:17:091030 net::handles::NetworkHandle GetTargetNetwork() override;
Joanne de Abreu7cbed872023-10-30 23:25:261031
Bryant Chandler490c6de2024-01-02 22:08:361032 void GetMediaCaptureRawDeviceIdsOpened(
1033 blink::mojom::MediaStreamType type,
1034 base::OnceCallback<void(std::vector<std::string>)> callback) override;
1035
[email protected]52913802013-12-10 05:52:181036 // NavigatorDelegate ---------------------------------------------------------
1037
clamy0e119882015-07-31 16:12:331038 void DidStartNavigation(NavigationHandle* navigation_handle) override;
1039 void DidRedirectNavigation(NavigationHandle* navigation_handle) override;
clamyefca29e2015-09-17 00:22:111040 void ReadyToCommitNavigation(NavigationHandle* navigation_handle) override;
clamy0e119882015-07-31 16:12:331041 void DidFinishNavigation(NavigationHandle* navigation_handle) override;
William Liuc6cc30ec2024-03-14 16:54:161042 void DidCancelNavigationBeforeStart(
1043 NavigationHandle* navigation_handle) override;
William Liub26568da2024-02-21 20:46:141044 void DidNavigateMainFramePreCommit(NavigationHandle* navigation_handle,
Liviu Tinta235581962021-07-14 20:37:071045 bool navigation_is_within_page) override;
dchengc2282aa2014-10-21 12:07:581046 void DidNavigateMainFramePostCommit(
sky8b00392d2015-01-10 00:30:281047 RenderFrameHostImpl* render_frame_host,
Rakina Zata Amniff10975d2021-10-08 06:04:241048 const LoadCommittedDetails& details) override;
dchengc2282aa2014-10-21 12:07:581049 void DidNavigateAnyFramePostCommit(
[email protected]37567b432014-02-12 01:12:221050 RenderFrameHostImpl* render_frame_host,
Rakina Zata Amniff10975d2021-10-08 06:04:241051 const LoadCommittedDetails& details) override;
Rakina Zata Amni742c2022024-07-02 05:29:171052 void DidUpdateNavigationHandleTiming(
1053 NavigationHandle* navigation_handle) override;
dchengc2282aa2014-10-21 12:07:581054 void NotifyChangedNavigationState(InvalidateTypes changed_flags) override;
Alexander Timina0ef6df2021-06-24 13:34:461055 bool ShouldAllowRendererInitiatedCrossProcessNavigation(
Ian Vollick1c6dd3e2022-04-13 02:06:261056 bool is_outermost_main_frame_navigation) override;
Dave Tapuska94a6978a2024-11-22 14:37:291057 const blink::UserAgentOverride& GetUserAgentOverride(
1058 FrameTree& frame_tree) override;
Takashi Toyoshima2a7f8cc02025-05-07 07:58:461059 void CreateThrottlesForNavigation(
Takashi Toyoshimabe551532025-05-02 18:13:521060 NavigationThrottleRegistry& registry) override;
David Bokan1bdb3701f2021-04-30 22:02:351061 std::vector<std::unique_ptr<CommitDeferringCondition>>
1062 CreateDeferringConditionsForNavigationCommit(
David Bokan51a6df832022-02-17 18:31:191063 NavigationHandle& navigation_handle,
1064 CommitDeferringCondition::NavigationType type) override;
clamy1e5574e92016-09-29 16:48:441065 std::unique_ptr<NavigationUIData> GetNavigationUIData(
1066 NavigationHandle* navigation_handle) override;
Alexander Timin17edc742020-04-23 18:22:181067 void OnServiceWorkerAccessed(NavigationHandle* navigation,
1068 const GURL& scope,
1069 AllowServiceWorkerResult allowed) override;
Alexander Timin1cc31f42020-05-12 16:26:011070 void OnCookiesAccessed(NavigationHandle*,
1071 const CookieAccessDetails& details) override;
Steven Valdeza06f680c2023-03-21 19:00:101072 void OnTrustTokensAccessed(NavigationHandle*,
1073 const TrustTokenAccessDetails& details) override;
Daniel Rubery6420d74302024-11-19 01:42:401074 void OnDeviceBoundSessionAccessed(
1075 NavigationHandle* navigation_handle,
Daniel Rubery7cdfa532025-01-24 16:57:501076 const net::device_bound_sessions::SessionAccess& access) override;
Tsuyoshi Horobcd0b9f62023-06-28 11:35:321077 void OnSharedDictionaryAccessed(
1078 NavigationHandle*,
1079 const network::mojom::SharedDictionaryAccessDetails& details) override;
W. James MacLeanc07dc41b2022-07-25 18:52:161080 void RegisterExistingOriginAsHavingDefaultIsolation(
W. James MacLeanb70fab82020-05-01 18:51:141081 const url::Origin& origin,
1082 NavigationRequest* navigation_request_to_exclude) override;
Lijin Shene4511c12024-03-19 19:31:301083 bool MaybeCopyContentAreaAsBitmap(
1084 base::OnceCallback<void(const SkBitmap&)> callback) override;
Aldo Culquicondorda38be12025-01-13 16:16:231085 bool SupportsForwardTransitionAnimation() override;
[email protected]52913802013-12-10 05:52:181086
Aldo Culquicondor88fe3962025-01-21 16:04:261087#if BUILDFLAG(IS_ANDROID)
1088 void SetSupportsForwardTransitionAnimation(bool supports);
1089#endif
1090
[email protected]4ca76c02012-05-16 16:19:051091 // RenderWidgetHostDelegate --------------------------------------------------
1092
Ahmed Fakhryfaa32d22018-10-05 15:56:161093 void SetTopControlsShownRatio(RenderWidgetHostImpl* render_widget_host,
1094 float ratio) override;
Ahmed Fakhry58e6ef542018-09-04 18:05:381095 void SetTopControlsGestureScrollInProgress(bool in_progress) override;
lazyboy63f5b312015-11-23 20:19:521096 void RenderWidgetCreated(RenderWidgetHostImpl* render_widget_host) override;
dchengc2282aa2014-10-21 12:07:581097 void RenderWidgetDeleted(RenderWidgetHostImpl* render_widget_host) override;
rouslan2f5993f2015-01-29 00:18:311098 void RenderWidgetWasResized(RenderWidgetHostImpl* render_widget_host,
1099 bool width_changed) override;
Fady Samuel97947112018-05-05 16:24:541100 void ResizeDueToAutoResize(RenderWidgetHostImpl* render_widget_host,
1101 const gfx::Size& new_size) override;
David Black9cca3592019-11-06 23:02:221102 void OnVerticalScrollDirectionChanged(
1103 viz::VerticalScrollDirection scroll_direction) override;
David Bokan7ec5ac922022-11-29 03:31:311104 int GetVirtualKeyboardResizeHeight() override;
Anupam Snigdha915824a2024-03-05 17:55:301105 bool ShouldDoLearning() override;
akabac6bd1212018-06-25 20:10:481106
W. James MacLean37af605e2025-01-20 16:59:381107 double GetPendingZoomLevel(RenderWidgetHostImpl* rwh) override;
akabac6bd1212018-06-25 20:10:481108
Emily Shack381369752025-02-19 20:49:191109 bool PreHandleMouseEvent(const blink::WebMouseEvent& event) override;
Kaan Alsand44437c2025-05-08 21:46:261110 void PreHandleDragUpdate(const DropData& drop_data,
1111 const gfx::PointF& client_pt);
Kaan Alsan570addb2025-05-09 18:30:321112 void PreHandleDragExit();
skyf65d9bb2017-03-24 02:26:391113 KeyboardEventProcessingResult PreHandleKeyboardEvent(
Kartar Singh5c8e0b22024-05-30 10:32:141114 const input::NativeWebKeyboardEvent& event) override;
Dave Tapuska344399e2019-09-09 15:18:261115 bool HandleMouseEvent(const blink::WebMouseEvent& event) override;
Kartar Singh5c8e0b22024-05-30 10:32:141116 bool HandleKeyboardEvent(const input::NativeWebKeyboardEvent& event) override;
dchengc2282aa2014-10-21 12:07:581117 bool HandleWheelEvent(const blink::WebMouseWheelEvent& event) override;
1118 bool PreHandleGestureEvent(const blink::WebGestureEvent& event) override;
Jacques Newman6f230d782024-08-26 19:13:341119 ui::BrowserAccessibilityManager* GetRootBrowserAccessibilityManager()
1120 override;
1121 ui::BrowserAccessibilityManager* GetOrCreateRootBrowserAccessibilityManager()
anand.ratn120b0b002014-10-07 15:49:321122 override;
lgarron145aaa82015-07-10 07:39:561123 // The following 4 functions are already listed under WebContents overrides:
mohsen7ab1ec16ec2015-07-02 18:26:231124 // void Cut() override;
1125 // void Copy() override;
1126 // void Paste() override;
lgarron145aaa82015-07-10 07:39:561127 // void SelectAll() override;
Dave Tapuskab336b922017-07-06 19:24:051128 void ExecuteEditCommand(const std::string& command,
Arthur Sonzognic686e8f2024-01-11 08:36:371129 const std::optional<std::u16string>& value) override;
mohsen7ab1ec16ec2015-07-02 18:26:231130 void MoveRangeSelectionExtent(const gfx::Point& extent) override;
1131 void SelectRange(const gfx::Point& base, const gfx::Point& extent) override;
Michellebb18e2d2023-02-22 04:52:221132 void SelectAroundCaret(blink::mojom::SelectionGranularity granularity,
1133 bool should_show_handle,
1134 bool should_show_context_menu) override;
Dave Tapuskab336b922017-07-06 19:24:051135 void MoveCaret(const gfx::Point& extent) override;
Aman Verma7908f9562024-12-13 18:45:481136 base::UnguessableToken GetCompositorFrameSinkGroupingId() const override;
Shimi Zhang37deeb22017-09-28 00:59:011137 void AdjustSelectionByCharacterOffset(int start_adjust,
1138 int end_adjust,
1139 bool show_selection_menu) override;
Kartar Singhb1bfa1a2024-06-24 13:14:571140 input::RenderWidgetHostInputEventRouter* GetInputEventRouter() override;
Aman Vermab3ed74e2024-04-29 13:58:131141 void GetRenderWidgetHostAtPointAsynchronously(
1142 RenderWidgetHostViewBase* root_view,
1143 const gfx::PointF& point,
1144 base::OnceCallback<void(base::WeakPtr<RenderWidgetHostViewBase>,
1145 std::optional<gfx::PointF>)> callback) override;
alexmosc4cbacb2015-11-21 01:29:221146 RenderWidgetHostImpl* GetFocusedRenderWidgetHost(
1147 RenderWidgetHostImpl* receiving_widget) override;
avallee9993fca2016-11-17 06:16:501148 RenderWidgetHostImpl* GetRenderWidgetHostWithPageFocus() override;
1149 void FocusOwningWebContents(
1150 RenderWidgetHostImpl* render_widget_host) override;
Lukasz Anforowicz52b93722018-06-20 16:11:391151 void RendererUnresponsive(
1152 RenderWidgetHostImpl* render_widget_host,
1153 base::RepeatingClosure hang_monitor_restarter) override;
avic3aa8422015-11-09 20:57:221154 void RendererResponsive(RenderWidgetHostImpl* render_widget_host) override;
Takumi Fujimoto4661871d2024-01-25 02:04:181155 void RequestToLockPointer(RenderWidgetHostImpl* render_widget_host,
1156 bool user_gesture,
Dave Tapuska291304d32025-06-27 15:21:091157 bool last_unlocked_by_target) override;
Anantanarayanan G Iyengar21c80ce2024-10-07 16:39:561158 bool IsWaitingForPointerLockPrompt(
1159 RenderWidgetHostImpl* render_widget_host) override;
Joe Downing13dd76b2018-04-09 18:32:151160 bool RequestKeyboardLock(RenderWidgetHostImpl* render_widget_host,
1161 bool esc_key_locked) override;
Joe Downing192998b22018-03-22 15:51:361162 void CancelKeyboardLock(RenderWidgetHostImpl* render_widget_host) override;
1163 RenderWidgetHostImpl* GetKeyboardLockWidget() override;
avi0720b02e2017-06-13 03:22:131164 // The following function is already listed under WebContents overrides:
Avi Drissman97aef042020-06-30 21:04:481165 // bool IsFullscreen() const override;
danakj45d42452020-04-08 17:24:181166 blink::mojom::DisplayMode GetDisplayMode() const override;
Md Hasibul Hasan2fe709feb2024-09-12 15:39:561167 ui::mojom::WindowShowState GetWindowShowState() override;
Alexis Menard634234d2024-05-10 14:27:331168 blink::mojom::DevicePostureProvider* GetDevicePostureProvider() override;
Sonja1e9d6bc12023-09-19 11:19:301169 bool GetResizable() override;
Takumi Fujimoto4661871d2024-01-25 02:04:181170 void LostPointerLock(RenderWidgetHostImpl* render_widget_host) override;
1171 bool HasPointerLock(RenderWidgetHostImpl* render_widget_host) override;
1172 RenderWidgetHostImpl* GetPointerLockWidget() override;
Dave Tapuskae1c62952021-11-02 23:14:061173 bool OnRenderFrameProxyVisibilityChanged(
1174 RenderFrameProxyHost* render_frame_proxy_host,
Dave Tapuskac3344362019-02-20 17:54:281175 blink::mojom::FrameVisibility visibility) override;
lfgbb9c28a2016-03-01 03:19:491176 void SendScreenRects() override;
Dave Tapuska3450d0b2022-04-08 21:27:531177 void SendActiveState(bool active) override;
ekaramadadd882292016-06-08 15:22:561178 TextInputManager* GetTextInputManager() override;
Dave Tapuska1d72e332021-10-13 19:24:381179 bool IsWidgetForPrimaryMainFrame(
1180 RenderWidgetHostImpl* render_widget_host) override;
ekaramadf6750aa2017-06-06 18:29:421181 bool IsShowingContextMenuOnPage() const override;
Klaus Weidnerd32baf42020-02-21 04:10:551182 void DidChangeScreenOrientation() override;
Mike Jacksonf116a2e2021-06-09 16:48:301183 gfx::Rect GetWindowsControlsOverlayRect() const override;
Joe Mason4dc51d42022-12-17 00:00:141184 VisibleTimeRequestTrigger& GetVisibleTimeRequestTrigger() final;
Aman Vermabb589a32024-05-07 16:38:171185 gfx::mojom::DelegatedInkPointRenderer* GetDelegatedInkRenderer(
1186 ui::Compositor* compositor) override;
Baran Erfanide163bd2024-08-26 22:26:271187 void OnInputIgnored(const blink::WebInputEvent& event) override;
Kartar Singh48fb0a72025-03-21 15:52:221188#if BUILDFLAG(IS_ANDROID)
1189 float GetCurrentTouchSequenceYOffset() override;
1190#endif
[email protected]4ca76c02012-05-16 16:19:051191
[email protected]b0936d22013-11-28 06:47:361192 // RenderFrameHostManager::Delegate ------------------------------------------
[email protected]0bfbf882011-12-22 18:19:271193
dchengc2282aa2014-10-21 12:07:581194 bool CreateRenderViewForRenderManager(
[email protected]bffc8302014-01-23 20:52:161195 RenderViewHost* render_view_host,
Arthur Sonzognic686e8f2024-01-11 08:36:371196 const std::optional<blink::FrameToken>& opener_frame_token,
Alex Moshchukd0d759c22025-05-09 18:18:351197 RenderFrameProxyHost* proxy_host,
1198 const std::optional<base::UnguessableToken>& navigation_metrics_token)
1199 override;
Fergal Daly6de62f52020-10-14 01:56:441200 void ReattachOuterDelegateIfNeeded() override;
lfgbede6392015-09-11 21:54:061201 void CreateRenderWidgetHostViewForRenderManager(
1202 RenderViewHost* render_view_host) override;
dchengc2282aa2014-10-21 12:07:581203 void BeforeUnloadFiredFromRenderManager(
1204 bool proceed,
anand.ratn120b0b002014-10-07 15:49:321205 bool* proceed_to_fire_unload) override;
dchengc2282aa2014-10-21 12:07:581206 void CancelModalDialogsForRenderManager() override;
Kevin McNeefb86fcf2021-02-26 23:20:571207 void NotifySwappedFromRenderManager(RenderFrameHostImpl* old_frame,
Dave Tapuskae45d6fd2021-09-29 17:03:591208 RenderFrameHostImpl* new_frame) override;
Jonathan Ross61ec65342021-12-14 23:01:401209 void NotifySwappedFromRenderManagerWithoutFallbackContent(
1210 RenderFrameHostImpl* new_frame) override;
naskof5940b9f2015-03-02 23:04:051211 void NotifyMainFrameSwappedFromRenderManager(
Kevin McNeefb86fcf2021-02-26 23:20:571212 RenderFrameHostImpl* old_frame,
1213 RenderFrameHostImpl* new_frame) override;
dchengc2282aa2014-10-21 12:07:581214 bool FocusLocationBarByDefault() override;
Carlos Caballero6ff6ace2021-02-05 16:53:001215 void OnFrameTreeNodeDestroyed(FrameTreeNode* node) override;
[email protected]0bfbf882011-12-22 18:19:271216
Jeremy Roman2d8dfe132021-07-06 20:51:261217 // PageDelegate -------------------------------------------------------------
1218
1219 void OnFirstVisuallyNonEmptyPaint(PageImpl& page) override;
1220
1221 // These both check that the color has in fact changed before notifying
1222 // observers.
1223 void OnThemeColorChanged(PageImpl& page) override;
1224 void OnBackgroundColorChanged(PageImpl& page) override;
Michael Bai19f17a302021-12-08 04:08:331225 void DidInferColorScheme(PageImpl& page) override;
David Bokand6e44055b2022-09-21 03:58:081226 void OnVirtualKeyboardModeChanged(PageImpl& page) override;
Julie Jeongeun Kimd4597df12022-11-11 02:44:511227 void NotifyPageBecamePrimary(PageImpl& page) override;
Jeremy Roman2d8dfe132021-07-06 20:51:261228
Takashi Toyoshima8dfc05c2024-01-29 21:03:511229 bool IsPageInPreviewMode() const override;
Takashi Toyoshimaa35e5fc2023-10-20 04:00:341230 void CancelPreviewByMojoBinderPolicy(
1231 const std::string& interface_name) override;
Robert Ferens9610d7282025-02-17 09:52:321232 void OnWebApiWindowResizableChanged() override;
Takashi Toyoshima1b73e312023-10-17 04:53:351233
Joel Hockey163835a2017-12-20 11:51:571234 // blink::mojom::ColorChooserFactory ---------------------------------------
Miyoung Shincb6475a2019-11-09 10:49:451235 void OnColorChooserFactoryReceiver(
Julie Jeongeun Kim8e2879e2019-08-06 23:55:201236 mojo::PendingReceiver<blink::mojom::ColorChooserFactory> receiver);
Tom Burginf0e48622024-05-16 15:06:121237#if BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_IOS)
Joel Hockey85b379d2017-12-11 10:42:131238 void OpenColorChooser(
Julie Jeongeun Kim8e2879e2019-08-06 23:55:201239 mojo::PendingReceiver<blink::mojom::ColorChooser> chooser,
1240 mojo::PendingRemote<blink::mojom::ColorChooserClient> client,
Joel Hockey85b379d2017-12-11 10:42:131241 SkColor color,
Joel Hockey163835a2017-12-20 11:51:571242 std::vector<blink::mojom::ColorSuggestionPtr> suggestions) override;
Julie Jeongeun Kim88ce9ec2023-07-28 02:25:401243#endif
Joel Hockey85b379d2017-12-11 10:42:131244
Carlos Caballero03262522021-02-05 14:49:581245 // FrameTree::Delegate -------------------------------------------------------
1246
Nate Chapin470dbc62023-04-25 16:34:381247 void LoadingStateChanged(LoadingState new_state) override;
1248 void DidStartLoading(FrameTreeNode* frame_tree_node) override;
Carlos Caballero03262522021-02-05 14:49:581249 void DidStopLoading() override;
Tsuyoshi Horocd828462021-04-21 04:59:581250 bool IsHidden() override;
Avi Drissmanbd153642024-09-03 18:58:051251 FrameTreeNodeId GetOuterDelegateFrameTreeNodeId() override;
Kevin McNee86e64ee2023-02-17 16:35:501252 RenderFrameHostImpl* GetProspectiveOuterDocument() override;
Sreeja Kamishettyd64b993d2022-02-14 12:04:421253 FrameTree* LoadingTree() override;
Julie Jeongeun Kim2132b37f82022-11-23 08:30:461254 void SetFocusedFrame(FrameTreeNode* node, SiteInstanceGroup* source) override;
Tommy Steimel71f154462024-05-22 19:05:071255 FrameTree* GetOwnedPictureInPictureFrameTree() override;
1256 FrameTree* GetPictureInPictureOpenerFrameTree() override;
Carlos Caballero03262522021-02-05 14:49:581257
[email protected]ec6c05f2013-10-23 18:41:571258 // NavigationControllerDelegate ----------------------------------------------
1259
dchengc2282aa2014-10-21 12:07:581260 void NotifyNavigationEntryCommitted(
anand.ratn120b0b002014-10-07 15:49:321261 const LoadCommittedDetails& load_details) override;
Sam McNally5c087a32017-08-25 01:46:141262 void NotifyNavigationEntryChanged(
1263 const EntryChangedDetails& change_details) override;
1264 void NotifyNavigationListPruned(const PrunedDetails& pruned_details) override;
Christian Dullweber1af31e62018-02-22 11:49:481265 void NotifyNavigationEntriesDeleted() override;
arthursonzogni66f711c2019-10-08 14:40:361266 bool ShouldPreserveAbortedURLs() override;
Abhijeet Kandalkar3dc6e602022-11-09 05:08:371267 void NotifyNavigationStateChangedFromController(
1268 InvalidateTypes changed_flags) override;
[email protected]ec6c05f2013-10-23 18:41:571269
Aman Verma3047aa412024-05-28 09:09:241270 // RenderWidgetHostInputEventRouter::Delegate -------------------------------
Kartar Singhb1bfa1a2024-06-24 13:14:571271 input::TouchEmulator* GetTouchEmulator(bool create_if_necessary) override;
Aman Verma3047aa412024-05-28 09:09:241272
[email protected]ec6c05f2013-10-23 18:41:571273 // Invoked before a form repost warning is shown.
dchengc2282aa2014-10-21 12:07:581274 void NotifyBeforeFormRepostWarningShow() override;
[email protected]ec6c05f2013-10-23 18:41:571275
1276 // Activate this WebContents and show a form repost warning.
dchengc2282aa2014-10-21 12:07:581277 void ActivateAndShowRepostFormWarningDialog() override;
[email protected]ec6c05f2013-10-23 18:41:571278
Mounir Lamouri0f5bdf52019-04-04 16:32:351279 void MediaMutedStatusChanged(const MediaPlayerId& id, bool muted);
Becca Hughes9f6fd4b82017-06-15 10:01:401280
aelias5252baa2016-04-10 01:18:021281 void UpdateOverridingUserAgent() override;
1282
[email protected]34ff1cfc2014-08-20 06:16:051283 // Forces overscroll to be disabled (used by touch emulation).
1284 void SetForceDisableOverscrollContent(bool force_disable);
1285
Jianzhou Fengd8720c72018-01-18 03:06:301286 // Override the render view/widget size of the main frame, return whether the
1287 // size changed.
1288 bool SetDeviceEmulationSize(const gfx::Size& new_size);
1289 void ClearDeviceEmulationSize();
1290
rajendrant4c288462020-10-13 07:35:351291 AudioStreamMonitor* audio_stream_monitor() { return &audio_stream_monitor_; }
dalecurtisbc6572e12014-09-12 19:22:301292
Max Morin5bc74f52018-05-09 07:00:211293 ForwardingAudioStreamFactory* GetAudioStreamFactory();
1294
Dave Tapuska894bfb42024-11-04 22:44:351295 // Creates a new ForwardingAudioStreamFactory. This can only be used by
1296 // GuestPageHolders, if you are looking for the audio stream factory you
1297 // likely want to use GetAudioStreamFactory();
1298 std::unique_ptr<ForwardingAudioStreamFactory> CreateAudioStreamFactory(
1299 base::PassKey<GuestPageHolderImpl> pass_key);
1300
dalecurtis88c240072015-12-09 02:11:181301 // Called by MediaWebContentsObserver when playback starts or stops. See the
1302 // WebContentsObserver function stubs for more details.
billorr21c005d2016-11-17 03:57:041303 void MediaStartedPlaying(
1304 const WebContentsObserver::MediaPlayerInfo& media_info,
Mounir Lamouri0f5bdf52019-04-04 16:32:351305 const MediaPlayerId& id);
billorr21c005d2016-11-17 03:57:041306 void MediaStoppedPlaying(
1307 const WebContentsObserver::MediaPlayerInfo& media_info,
Mounir Lamouri0f5bdf52019-04-04 16:32:351308 const MediaPlayerId& id,
Becca Hughes220bfc102017-11-14 18:24:071309 WebContentsObserver::MediaStoppedReason reason);
Wojciech Dzierżanowski71c3e4c2025-04-29 09:54:081310
1311 // Called when the set of tracks changes.
1312 void MediaMetadataChanged(
1313 const WebContentsObserver::MediaPlayerInfo& media_info,
1314 const MediaPlayerId& id);
1315
peconn257951522017-06-09 18:24:591316 // This will be called before playback is started, check
1317 // GetCurrentlyPlayingVideoCount if you need this when playback starts.
Mounir Lamouri0f5bdf52019-04-04 16:32:351318 void MediaResized(const gfx::Size& size, const MediaPlayerId& id);
Peter E Conneccb34c22017-09-08 09:37:581319 void MediaEffectivelyFullscreenChanged(bool is_fullscreen);
billorr21c005d2016-11-17 03:57:041320
Michael Crousee75c7a42020-07-31 21:11:551321 // Called by MediaWebContentsObserver when a buffer underflow occurs. See the
1322 // WebContentsObserver function stubs for more details.
1323 void MediaBufferUnderflow(const MediaPlayerId& id);
1324
rajendrant4c288462020-10-13 07:35:351325 // Called by MediaWebContentsObserver when player seek event occurs.
1326 void MediaPlayerSeek(const MediaPlayerId& id);
1327
Chris Hamiltonc347e102020-11-18 23:10:211328 // Called by MediaWebContentsObserver when a media player is destroyed.
1329 void MediaDestroyed(const MediaPlayerId& id);
1330
Tommy Steimele95348e2024-01-09 21:15:331331 // Called by MediaSessionImpl when one is created and initialized for this.
1332 void MediaSessionCreated(MediaSession* media_session);
1333
Wojciech Dzierżanowski71c3e4c2025-04-29 09:54:081334 int GetCurrentlyPlayingVideoCount() const override;
Arthur Sonzognic686e8f2024-01-11 08:36:371335 std::optional<gfx::Size> GetFullscreenVideoSize() override;
dalecurtisbc6572e12014-09-12 19:22:301336
qinmin58567c82015-01-07 21:00:201337 MediaWebContentsObserver* media_web_contents_observer() {
1338 return media_web_contents_observer_.get();
1339 }
qinmin58567c82015-01-07 21:00:201340
tapted65ff2ea72016-03-01 23:39:001341 // Update the web contents visibility.
Sreeja Kamishetty1c1ca7a2023-05-12 16:36:401342 void UpdateWebContentsVisibility(Visibility visibility) override;
tapted65ff2ea72016-03-01 23:39:001343
Tsuyoshi Horocd828462021-04-21 04:59:581344 // Returns the PageVisibilityState for the primary page of this web contents,
1345 // taking the capturing state into account.
1346 PageVisibilityState GetPageVisibilityState() const;
1347
paulmeyerc0b762b2016-04-13 11:55:171348 // Called by FindRequestManager when find replies come in from a renderer
1349 // process.
1350 void NotifyFindReply(int request_id,
1351 int number_of_matches,
1352 const gfx::Rect& selection_rect,
1353 int active_match_ordinal,
1354 bool final_update);
1355
ortuno467e5792016-06-10 04:32:391356 // Modify the counter of connected devices for this WebContents.
1357 void IncrementBluetoothConnectedDeviceCount();
1358 void DecrementBluetoothConnectedDeviceCount();
1359
Ovidio Henriquez76696f62020-07-08 03:06:591360 void IncrementBluetoothScanningSessionsCount();
1361 void DecrementBluetoothScanningSessionsCount();
1362
Reilly Grant5e7c79b22019-04-09 17:26:201363 // Modify the counter of frames in this WebContents actively using serial
1364 // ports.
1365 void IncrementSerialActiveFrameCount();
1366 void DecrementSerialActiveFrameCount();
1367
Matt Reynoldse8c6c1f2019-11-02 09:53:531368 // Modify the counter of frames in this WebContents actively using HID
1369 // devices.
1370 void IncrementHidActiveFrameCount();
1371 void DecrementHidActiveFrameCount();
1372
Yifan Luo8e5d3d52024-10-22 19:18:161373 // Modify the counter of frames in this WebContents actively using
1374 // geolocation.
1375 void IncrementGeolocationActiveFrameCount();
1376 void DecrementGeolocationActiveFrameCount();
1377
François Doraye753bf902024-09-17 15:03:081378 // Notifies the delegate and observers when device connection types used by
1379 // the WebContents change.
Patrick Monette15442a12025-01-22 20:09:311380 void OnCapabilityTypesChanged(
1381 WebContentsCapabilityType device_capability_type,
1382 bool used);
Matt Reynoldsed00ca7e72022-08-18 20:56:201383
1384 // Modify the counter of frames in this WebContents actively using USB
1385 // devices.
1386 void IncrementUsbActiveFrameCount();
1387 void DecrementUsbActiveFrameCount();
1388
Austin Sullivanafefb722021-01-14 01:26:391389 // Modify the counter of File System Access handles for this WebContents.
1390 void IncrementFileSystemAccessHandleCount();
1391 void DecrementFileSystemAccessHandleCount();
Marijn Kruisselbrink29051042019-08-06 22:56:551392
mlamouri5cd9ae82017-02-18 11:05:091393 // Called when the WebContents gains or loses a persistent video.
zqzhang8ac49002017-03-16 21:51:351394 void SetHasPersistentVideo(bool has_persistent_video);
mlamouri5cd9ae82017-02-18 11:05:091395
François Beaufortad6c5232018-02-26 11:00:441396 // Whether the WebContents effectively fullscreen active player allows
1397 // Picture-in-Picture.
1398 // |IsFullscreen| must return |true| when this method is called.
1399 bool IsPictureInPictureAllowedForFullscreenVideo() const;
1400
Carlos Caballerob65b6e3a2021-11-15 10:09:001401 // Set this WebContents's `primary_frame_tree_` as the focused frame tree.
1402 // `primary_frame_tree_`'s main frame RenderWidget (and all of its
Dave Tapuska54c76a032021-10-27 22:10:421403 // subframe widgets) will be activated. GetFocusedRenderWidgetHost will search
1404 // this WebContentsImpl for a focused RenderWidgetHost. The previously focused
1405 // WebContentsImpl, if any, will have its RenderWidgetHosts deactivated.
lfg1453e412017-04-11 00:48:501406 void SetAsFocusedWebContentsIfNecessary();
1407
Dave Tapuska54c76a032021-10-27 22:10:421408 // Sets the focused frame tree to be the `frame_tree_to_focus`.
1409 // `frame_tree_to_focus` must be either this WebContents's frame tree or
1410 // contained within it (but not owned by another WebContents).
1411 void SetFocusedFrameTree(FrameTree* frame_tree_to_focus);
1412
Klaus Weidnerd8219432022-02-08 21:50:591413 // Notifies the Picture-in-Picture controller that there is a new video player
1414 // entering video Picture-in-Picture. (This is not used for document
1415 // Picture-in-Picture,
1416 // cf. PictureInPictureWindowManager::EnterDocumentPictureInPicture().)
Becca Hughes112832e2019-06-11 17:19:021417 // Returns the result of the enter request.
François Beaufort1388f2892022-01-29 08:22:471418 PictureInPictureResult EnterPictureInPicture();
Mounir Lamouri11e9ef432018-05-22 03:10:161419
Mounir Lamouri6d759e12018-05-16 20:01:301420 // Updates the Picture-in-Picture controller with a signal that
1421 // Picture-in-Picture mode has ended.
1422 void ExitPictureInPicture();
1423
sawtellea7333a82018-05-31 02:36:361424 // Updates the tracking information for |this| to know if there is
1425 // a video currently in Picture-in-Picture mode.
1426 void SetHasPictureInPictureVideo(bool has_picture_in_picture_video);
1427
Klaus Weidnerd8219432022-02-08 21:50:591428 // Updates the tracking information for |this| to know if there is
1429 // a document currently in Picture-in-Picture mode.
1430 void SetHasPictureInPictureDocument(bool has_picture_in_picture_document);
1431
Ian Vollick5d5c37f2019-06-19 22:50:571432 // Sets the spatial navigation state.
1433 void SetSpatialNavigationDisabled(bool disabled);
1434
Yaroslav Shalivskyyd76a81f42024-10-21 20:08:201435#if BUILDFLAG(IS_ANDROID)
Mahesh Machavolu6cb80182022-07-22 08:09:311436 // Sets the Stylus handwriting feature status. This status is updated to web
1437 // preferences.
1438 void SetStylusHandwritingEnabled(bool enabled);
Yaroslav Shalivskyyd76a81f42024-10-21 20:08:201439#endif // BUILDFLAG(IS_ANDROID)
Mahesh Machavolu6cb80182022-07-22 08:09:311440
Avi Drissmanbd3e986442020-05-20 21:09:201441 // Called when a file selection is to be done.
1442 void RunFileChooser(
Bo Liu3afe2582023-08-11 23:02:561443 base::WeakPtr<FileChooserImpl> file_chooser,
Avi Drissmanbd3e986442020-05-20 21:09:201444 RenderFrameHost* render_frame_host,
Kent Tamura3abb32d2020-07-02 00:23:011445 scoped_refptr<FileChooserImpl::FileSelectListenerImpl> listener,
Avi Drissmanbd3e986442020-05-20 21:09:201446 const blink::mojom::FileChooserParams& params);
1447
1448 // Request to enumerate a directory. This is equivalent to running the file
1449 // chooser in directory-enumeration mode and having the user select the given
1450 // directory.
1451 void EnumerateDirectory(
Bo Liu3afe2582023-08-11 23:02:561452 base::WeakPtr<FileChooserImpl> file_chooser,
Avi Drissmanbd3e986442020-05-20 21:09:201453 RenderFrameHost* render_frame_host,
Kent Tamura3abb32d2020-07-02 00:23:011454 scoped_refptr<FileChooserImpl::FileSelectListenerImpl> listener,
Avi Drissmanbd3e986442020-05-20 21:09:201455 const base::FilePath& directory_path);
1456
Xiaohan Wang24ec9342022-01-15 17:34:221457#if BUILDFLAG(IS_ANDROID)
paulmeyerc0b762b2016-04-13 11:55:171458 // Called by FindRequestManager when all of the find match rects are in.
1459 void NotifyFindMatchRectsReply(int version,
1460 const std::vector<gfx::RectF>& rects,
1461 const gfx::RectF& active_rect);
1462#endif
1463
Xiaohan Wang24ec9342022-01-15 17:34:221464#if BUILDFLAG(IS_ANDROID)
Becca Hughes6daf5662018-06-27 16:50:541465 // Called by WebContentsAndroid to send the Display Cutout safe area to
1466 // DisplayCutoutHostImpl.
1467 void SetDisplayCutoutSafeArea(gfx::Insets insets);
Mason Freed098db032025-05-06 11:52:111468 // Called by WebContentsAndroid to instruct the web contents to "show
1469 // interest" in the referenced element.
1470 void ShowInterestInElement(int nodeID);
Becca Hughes6daf5662018-06-27 16:50:541471#endif
1472
Becca Hughesd11d6502018-07-31 17:01:281473 // Notify observers that the viewport fit value changed. This is called by
Wenyu Fu29b3bb72024-12-27 17:48:041474 // |SafeAreaInsetsHost|.
Becca Hughesd11d6502018-07-31 17:01:281475 void NotifyViewportFitChanged(blink::mojom::ViewportFit value);
Wenyu Fu29b3bb72024-12-27 17:48:041476 // Notify observers that safe area constraint has changed. This is called by
1477 // |SafeAreaInsetsHost|.
1478 void NotifySafeAreaConstraintChanged(bool has_constraint);
Becca Hughesd11d6502018-07-31 17:01:281479
Ehsan Karamad6beb2ea2018-11-25 18:15:131480 // Returns the current FindRequestManager associated with the WebContents;
1481 // this won't create one if none exists.
Lucas Furukawa Gadanie1c5dfda2018-11-29 17:57:411482 FindRequestManager* GetFindRequestManagerForTesting();
Ehsan Karamad6beb2ea2018-11-25 18:15:131483
Kevin McNee8576c402020-09-10 21:58:571484 // Convenience method to notify observers that an inner WebContents was
1485 // created with |this| WebContents as its owner. This does *not* immediately
1486 // guarantee that |inner_web_contents| has been added to the WebContents tree.
1487 void InnerWebContentsCreated(WebContents* inner_web_contents);
1488
Lucas Furukawa Gadani99125822019-01-03 15:41:491489 // Reattaches this inner WebContents to its outer WebContents.
Adithya Srinivasan5bc3b712020-05-21 13:07:571490 virtual void ReattachToOuterWebContentsFrame();
Lucas Furukawa Gadani99125822019-01-03 15:41:491491
Takashi Toyoshima138cf44a2023-11-02 10:33:251492 // Notifies observers that this WebContents completed preview activation
1493 // steps.
1494 // `activation_time` is the time the activation happened, in wall time.
1495 void DidActivatePreviewedPage(base::TimeTicks activation_time);
1496
Alexander Timin17edc742020-04-23 18:22:181497 void OnServiceWorkerAccessed(RenderFrameHost* render_frame_host,
1498 const GURL& scope,
1499 AllowServiceWorkerResult allowed);
1500
David Bokan1bdb3701f2021-04-30 22:02:351501 bool JavaScriptDialogDefersNavigations() {
1502 return javascript_dialog_dismiss_notifier_.get();
Charlie Reis96077362019-07-04 00:34:041503 }
1504
David Bokan1bdb3701f2021-04-30 22:02:351505 void NotifyOnJavaScriptDialogDismiss(base::OnceClosure callback);
1506
John Abd-El-Malek74f0b95c2021-04-05 06:24:021507 bool has_persistent_video() { return has_persistent_video_; }
1508
Dave Tapuskae782bea2019-07-09 16:21:511509 // Returns the focused frame's input handler.
Dave Tapuska58a099e2020-06-08 21:48:401510 blink::mojom::FrameWidgetInputHandler* GetFocusedFrameWidgetInputHandler();
Dave Tapuskae782bea2019-07-09 16:21:511511
Alexander Timinc7bee322020-05-19 17:54:341512 // A render view-originated drag has ended. Informs the render view host and
1513 // WebContentsDelegate.
1514 void SystemDragEnded(RenderWidgetHost* source_rwh);
1515
Kevin McNeec9d0fda2021-05-19 15:55:171516 // These are the content internal equivalents of
Peter Kastingd2876a22024-12-03 01:12:551517 // `WebContents::ForEachRenderFrameHost` whose comment can be referred to
Kevin McNeec9d0fda2021-05-19 15:55:171518 // for details. Content internals can also access speculative
1519 // RenderFrameHostImpls if necessary by using the
Peter Kastingd2876a22024-12-03 01:12:551520 // `ForEachRenderFrameHostImplIncludingSpeculative` variations.
1521 void ForEachRenderFrameHostImplWithAction(
Daniel Cheng982f2b22022-08-25 23:46:161522 base::FunctionRef<FrameIterationAction(RenderFrameHostImpl*)> on_frame);
Peter Kastingd2876a22024-12-03 01:12:551523 void ForEachRenderFrameHostImpl(
Daniel Cheng982f2b22022-08-25 23:46:161524 base::FunctionRef<void(RenderFrameHostImpl*)> on_frame);
Peter Kastingd2876a22024-12-03 01:12:551525 void ForEachRenderFrameHostImplIncludingSpeculativeWithAction(
Daniel Cheng982f2b22022-08-25 23:46:161526 base::FunctionRef<FrameIterationAction(RenderFrameHostImpl*)> on_frame);
Peter Kastingd2876a22024-12-03 01:12:551527 void ForEachRenderFrameHostImplIncludingSpeculative(
Daniel Cheng982f2b22022-08-25 23:46:161528 base::FunctionRef<void(RenderFrameHostImpl*)> on_frame);
Kevin McNeec9d0fda2021-05-19 15:55:171529
Rakina Zata Amni4029b6d2020-07-28 02:36:201530 // Computes and returns the content specific preferences for this WebContents.
1531 // Recomputes only the "fast" preferences (those not requiring slow
1532 // platform/device polling); the remaining "slow" ones are recomputed only if
1533 // the preference cache is empty.
Dave Tapuska183b8d702025-01-07 18:47:181534 const blink::web_pref::WebPreferences ComputeWebPreferences(
1535 RenderFrameHostImpl* main_frame);
Rakina Zata Amni4029b6d2020-07-28 02:36:201536
Alexander Cooper987d046cc2021-04-14 00:07:211537 // Certain WebXr modes integrate with Viz as a compositor directly, and thus
1538 // have their own FrameSinkId that typically renders fullscreen, obscuring
1539 // the WebContents. This allows those WebXr modes to notify us if that
1540 // is occurring. When it has finished, this method may be called again with an
1541 // Invalid FrameSinkId to indicate such. Note that other fullscreen modes,
1542 // e.g. Fullscreen videos, are largely controlled by the renderer process and
1543 // as such are still parented under the existing FrameSinkId.
1544 void OnXrHasRenderTarget(const viz::FrameSinkId& frame_sink_id);
1545
1546 // Because something else may be rendering as the primary contents of this
1547 // WebContents rather than the RenderHostView, targets that wish to capture
Jordan Baylescf8387852023-09-13 21:16:351548 // the contents of this WebContents should query its capture target here.
1549 struct CaptureTarget {
1550 viz::FrameSinkId sink_id;
1551 gfx::NativeView view;
1552 };
1553 CaptureTarget GetCaptureTarget();
Alexander Cooper987d046cc2021-04-14 00:07:211554
Sreeja Kamishetty0be3b1b2021-08-12 17:04:151555 // Sets the value in tests to ensure expected ordering and correctness.
1556 void set_minimum_delay_between_loading_updates_for_testing(
1557 base::TimeDelta duration) {
1558 minimum_delay_between_loading_updates_ms_ = duration;
1559 }
1560
Kevin McNeeab98c4a52022-01-28 16:53:061561 // If the given frame is prerendered, cancels the associated prerender.
1562 // Returns true if a prerender was canceled.
1563 bool CancelPrerendering(FrameTreeNode* frame_tree_node,
Yoshiki Tanioka49b4cfb2022-10-20 09:25:311564 PrerenderFinalStatus final_status);
Kevin McNeeab98c4a52022-01-28 16:53:061565
David Bokane86aa032022-05-08 18:21:241566 void set_suppress_ime_events_for_testing(bool suppress) {
1567 suppress_ime_events_for_testing_ = suppress;
1568 }
1569
Alex Moshchuk83805532022-08-12 15:15:231570 RenderWidgetHost* mouse_lock_widget_for_testing() {
Takumi Fujimoto4661871d2024-01-25 02:04:181571 return pointer_lock_widget_;
Alex Moshchuk83805532022-08-12 15:15:231572 }
1573
David Bokand6e44055b2022-09-21 03:58:081574 ui::mojom::VirtualKeyboardMode GetVirtualKeyboardMode() const;
1575
Arthur Sonzognic686e8f2024-01-11 08:36:371576 const std::optional<base::Location>& ownership_location() const {
Bo Liud4ced692023-09-18 21:17:141577 return ownership_location_;
1578 }
1579
Ari Chivukula41f7bfc92024-07-17 18:16:011580 bool IsPopup() const override;
1581
Ari Chivukula17ba533d2024-09-11 22:47:421582 bool IsPartitionedPopin() const override;
1583
Ari Chivukula2d8d5e02024-11-04 20:09:571584 const struct PartitionedPopinOpenerProperties&
1585 GetPartitionedPopinOpenerProperties() const override;
Ari Chivukula9390bf12024-08-14 18:08:011586
Ari Chivukula2d8d5e02024-11-04 20:09:571587 // Returns the opener of this window if this window is a partitioned popin
1588 // and the opener still exists. This may return null for if the opener was
1589 // already deleted even if this window is a popin.
1590 // See https://explainers-by-googlers.github.io/partitioned-popins/
1591 RenderFrameHostImpl* GetPartitionedPopinOpener(
1592 base::PassKey<PartitionedPopinsController>) const;
1593
1594 // Clears `partitioned_popin_opener_` to test what happens if the opener
1595 // disappears after the popin is opened.
1596 void ClearPartitionedPopinOpenerForTesting();
1597
1598 WebContents* GetOpenedPartitionedPopin() const override;
Ari Chivukulaee503052024-08-30 20:33:531599
Ari Chivukulaf6f09ba2025-03-04 20:01:341600 // Returns the origin of the popin's opener if this is a partitioned popin.
1601 // CHECKS if this is not a partitioned popin, as it should never be called
1602 // in that case. This is used in permissions checks.
1603 // See https://explainers-by-googlers.github.io/partitioned-popins/
1604 GURL GetPartitionedPopinEmbedderOrigin(
1605 base::PassKey<StorageAccessGrantPermissionContext>) const override;
1606
1607 // Same as GetPartitionedPopinEmbedderOrigin but for testing to bypass
1608 // PassKey requirements.
1609 GURL GetPartitionedPopinEmbedderOriginForTesting() const;
1610
lof84501da082016-05-23 21:22:541611 private:
Dave Tapuska894bfb42024-11-04 22:44:351612 using FrameTreeIterationCallback = base::FunctionRef<void(FrameTree&)>;
Dave Tapuska05fcfb62021-10-18 17:09:031613 using RenderViewHostIterationCallback =
1614 base::RepeatingCallback<void(RenderViewHostImpl*)>;
Takashi Toyoshimadc3f7472021-07-21 08:02:321615
[email protected]8ff00d72012-10-23 19:12:211616 friend class WebContentsObserver;
1617 friend class WebContents; // To implement factory methods.
[email protected]0dd3a0ab2011-02-18 08:17:441618
Alex Moshchuk6fcaca752018-07-14 02:13:591619 friend class RenderFrameHostImplBeforeUnloadBrowserTest;
Becca Hughesfd5d8f892018-06-14 18:23:361620 friend class WebContentsImplBrowserTest;
Sarah Murphy3bccae62022-02-15 20:22:451621 friend class TestWebContentsDestructionObserver;
Arthur Hemery2b6bc5a42019-06-20 09:25:121622 friend class BeforeUnloadBlockingDelegate;
Avi Drissman360847d2018-11-02 22:46:511623 friend class TestWCDelegateForDialogsAndFullscreen;
Becca Hughesfd5d8f892018-06-14 18:23:361624
Dale Curtisc496a7762021-02-24 01:15:441625 FRIEND_TEST_ALL_PREFIXES(WebContentsImplTest, CaptureHoldsWakeLock);
[email protected]2db9bd72012-04-13 20:20:561626 FRIEND_TEST_ALL_PREFIXES(WebContentsImplTest, NoJSMessageOnInterstitials);
1627 FRIEND_TEST_ALL_PREFIXES(WebContentsImplTest, UpdateTitle);
[email protected]45a22ad2013-02-21 03:25:001628 FRIEND_TEST_ALL_PREFIXES(WebContentsImplTest, FindOpenerRVHWhenPending);
[email protected]2db9bd72012-04-13 20:20:561629 FRIEND_TEST_ALL_PREFIXES(WebContentsImplTest,
1630 CrossSiteCantPreemptAfterUnload);
nick5ae4d2d2017-01-06 01:18:351631 FRIEND_TEST_ALL_PREFIXES(WebContentsImplTest, PendingContentsDestroyed);
1632 FRIEND_TEST_ALL_PREFIXES(WebContentsImplTest, PendingContentsShown);
[email protected]50904452013-05-09 02:05:121633 FRIEND_TEST_ALL_PREFIXES(WebContentsImplTest, FrameTreeShape);
Elad Alon0feb6602021-10-14 09:26:361634 FRIEND_TEST_ALL_PREFIXES(WebContentsImplTest,
1635 NonActivityCaptureDoesNotCountAsActivity);
Olivier ROBIN4b58dd932024-08-06 13:30:321636 FRIEND_TEST_ALL_PREFIXES(WebContentsImplTest, GetLastActiveTimeTicks);
estarka5635c42015-07-14 00:06:531637 FRIEND_TEST_ALL_PREFIXES(WebContentsImplTest,
1638 LoadResourceFromMemoryCacheWithBadSecurityInfo);
jwwf4684d12015-09-02 06:12:521639 FRIEND_TEST_ALL_PREFIXES(WebContentsImplTest,
jam91dd24e2016-08-12 17:16:421640 LoadResourceWithEmptySecurityInfo);
avid53461d2016-02-25 17:15:041641 FRIEND_TEST_ALL_PREFIXES(WebContentsImplTest,
1642 ResetJavaScriptDialogOnUserNavigate);
Megan Jablonski2f6a4c52017-07-10 23:01:251643 FRIEND_TEST_ALL_PREFIXES(WebContentsImplTest, ParseDownloadHeaders);
Mounir Lamouri7b4a1f232019-12-23 16:32:101644 FRIEND_TEST_ALL_PREFIXES(WebContentsImplTest, FaviconURLsSet);
1645 FRIEND_TEST_ALL_PREFIXES(WebContentsImplTest, FaviconURLsResetWithNavigation);
1646 FRIEND_TEST_ALL_PREFIXES(WebContentsImplTest, FaviconURLsUpdateDelay);
Becca Hughesfd5d8f892018-06-14 18:23:361647 FRIEND_TEST_ALL_PREFIXES(WebContentsImplBrowserTest,
1648 NotifyFullscreenAcquired);
1649 FRIEND_TEST_ALL_PREFIXES(WebContentsImplBrowserTest,
1650 NotifyFullscreenAcquired_Navigate);
1651 FRIEND_TEST_ALL_PREFIXES(WebContentsImplBrowserTest,
1652 NotifyFullscreenAcquired_SameOrigin);
Arthur Sonzogni22e314b02018-08-23 13:55:561653 FRIEND_TEST_ALL_PREFIXES(WebContentsImplBrowserTest,
Batalov Vladislave9a5f3822020-12-02 07:31:111654 PropagateFullscreenOptions);
1655 FRIEND_TEST_ALL_PREFIXES(WebContentsImplBrowserTest,
Nasko Oskov0f3cbb12020-01-07 17:52:141656 FullscreenAfterFrameUnload);
yilkal796e89e2019-10-02 23:58:281657 FRIEND_TEST_ALL_PREFIXES(WebContentsImplBrowserTest,
1658 MaxFrameCountForCrossProcessNavigation);
1659 FRIEND_TEST_ALL_PREFIXES(WebContentsImplBrowserTest,
1660 MaxFrameCountRemovedIframes);
1661 FRIEND_TEST_ALL_PREFIXES(WebContentsImplBrowserTest,
1662 MaxFrameCountInjectedIframes);
Kevin McNee53f0b2d2021-11-02 18:00:451663 FRIEND_TEST_ALL_PREFIXES(WebContentsImplBrowserTest,
1664 ForEachFrameTreeInnerContents);
Andrew Comminosd2256652024-06-21 00:58:371665 FRIEND_TEST_ALL_PREFIXES(WebContentsImplBrowserTest,
1666 UserAgentOverrideDuringDeferredNavigation);
Xiaochen Zhou6443f752022-08-10 16:40:461667 FRIEND_TEST_ALL_PREFIXES(FencedFrameMPArchBrowserTest, FrameIteration);
1668 FRIEND_TEST_ALL_PREFIXES(FencedFrameParameterizedBrowserTest,
1669 ShouldIgnoreJsDialog);
[email protected]0dd3a0ab2011-02-18 08:17:441670 FRIEND_TEST_ALL_PREFIXES(FormStructureBrowserTest, HTMLFiles);
1671 FRIEND_TEST_ALL_PREFIXES(NavigationControllerTest, HistoryNavigate);
[email protected]b0936d22013-11-28 06:47:361672 FRIEND_TEST_ALL_PREFIXES(RenderFrameHostManagerTest, PageDoesBackAndReload);
[email protected]de3c5d82014-05-28 22:12:591673 FRIEND_TEST_ALL_PREFIXES(SitePerProcessBrowserTest, CrossSiteIframe);
alexmosc2a8cec2016-05-23 22:19:531674 FRIEND_TEST_ALL_PREFIXES(SitePerProcessBrowserTest,
1675 TwoSubframesCreatePopupsSimultaneously);
Antonio Gomesda7e03d2020-08-05 15:03:081676 FRIEND_TEST_ALL_PREFIXES(SitePerProcessBrowserTest, TextAutosizerPageInfo);
alexmosc2a8cec2016-05-23 22:19:531677 FRIEND_TEST_ALL_PREFIXES(SitePerProcessBrowserTest,
1678 TwoSubframesCreatePopupMenuWidgetsSimultaneously);
dmazzoni0b5d2482014-09-10 19:45:571679 FRIEND_TEST_ALL_PREFIXES(SitePerProcessAccessibilityBrowserTest,
1680 CrossSiteIframeAccessibility);
avi2d7d2c32017-03-15 21:55:021681 FRIEND_TEST_ALL_PREFIXES(RenderFrameHostImplBrowserTest,
1682 IframeBeforeUnloadParentHang);
avi336125f72017-05-06 22:25:401683 FRIEND_TEST_ALL_PREFIXES(RenderFrameHostImplBrowserTest,
1684 BeforeUnloadDialogRequiresGesture);
Charles Reis15d60b132017-11-03 17:43:471685 FRIEND_TEST_ALL_PREFIXES(RenderFrameHostImplBrowserTest,
1686 CancelBeforeUnloadResetsURL);
Chris Hamilton81997702018-09-12 14:18:061687 FRIEND_TEST_ALL_PREFIXES(RenderFrameHostImplBrowserTest,
1688 BeforeUnloadDialogSuppressedForDiscard);
1689 FRIEND_TEST_ALL_PREFIXES(RenderFrameHostImplBrowserTest,
Dave Tapuska19578e92021-08-09 17:14:021690 BeforeUnloadConfirmOnNonActive);
1691 FRIEND_TEST_ALL_PREFIXES(RenderFrameHostImplBrowserTest,
Chris Hamilton81997702018-09-12 14:18:061692 PendingDialogMakesDiscardUnloadReturnFalse);
Pavel Feldman3c1842b2017-08-02 05:00:161693 FRIEND_TEST_ALL_PREFIXES(DevToolsProtocolTest, JavaScriptDialogNotifications);
1694 FRIEND_TEST_ALL_PREFIXES(DevToolsProtocolTest, JavaScriptDialogInterop);
1695 FRIEND_TEST_ALL_PREFIXES(DevToolsProtocolTest, BeforeUnloadDialog);
Pavel Feldmanfab3cb62017-10-05 01:02:011696 FRIEND_TEST_ALL_PREFIXES(DevToolsProtocolTest, PageDisableWithOpenedDialog);
1697 FRIEND_TEST_ALL_PREFIXES(DevToolsProtocolTest,
1698 PageDisableWithNoDialogManager);
Adithya Srinivasan1964f7e2021-09-21 20:40:021699 FRIEND_TEST_ALL_PREFIXES(
1700 PrerenderWithRenderDocumentBrowserTest,
1701 ModalDialogShouldNotBeDismissedAfterPrerenderSubframeNavigation);
Peter Kastingd2876a22024-12-03 01:12:551702 FRIEND_TEST_ALL_PREFIXES(PrerenderBrowserTest, ForEachRenderFrameHostImpl);
Yuzu Saijoa11069a2020-04-22 10:56:551703 FRIEND_TEST_ALL_PREFIXES(PluginContentOriginAllowlistTest,
Yuzu Saijo97addc32020-04-22 07:51:121704 ClearAllowlistOnNavigate);
Yuzu Saijoa11069a2020-04-22 10:56:551705 FRIEND_TEST_ALL_PREFIXES(PluginContentOriginAllowlistTest,
Yuzu Saijo97addc32020-04-22 07:51:121706 SubframeInheritsAllowlist);
Nick Carterd73635b2018-03-13 18:31:411707 FRIEND_TEST_ALL_PREFIXES(PointerLockBrowserTest,
1708 PointerLockInnerContentsCrashes);
Lucas Gadania0ea0172018-09-20 18:31:371709 FRIEND_TEST_ALL_PREFIXES(PointerLockBrowserTest, PointerLockOopifCrashes);
Wang Hui9f7884a2023-02-20 02:17:591710 FRIEND_TEST_ALL_PREFIXES(WebContentsImplBrowserTest,
1711 PopupWindowBrowserNavResumeLoad);
1712 FRIEND_TEST_ALL_PREFIXES(WebContentsImplBrowserTest,
1713 SuppressedPopupWindowBrowserNavResumeLoad);
Thomas Nguyen583f07e2023-07-19 17:45:371714 FRIEND_TEST_ALL_PREFIXES(RenderWidgetHostSitePerProcessTest,
1715 BrowserClosesPopupIntersectsPermissionPrompt);
[email protected]0dd3a0ab2011-02-18 08:17:441716
paulmeyera41de3b2016-05-05 16:30:181717 // So |find_request_manager_| can be accessed for testing.
1718 friend class FindRequestManagerTest;
1719
[email protected]80e776ae2012-03-23 16:17:201720 // TODO(brettw) TestWebContents shouldn't exist!
[email protected]8ff00d72012-10-23 19:12:211721 friend class TestWebContents;
[email protected]0dd3a0ab2011-02-18 08:17:441722
Avi Drissman783c1232021-02-05 01:27:051723 class RenderWidgetHostDestructionObserver;
1724 class WebContentsDestructionObserver;
[email protected]7fff43e2013-05-21 20:21:101725
lazyboy6ec48b2a2015-06-29 15:18:141726 // Represents a WebContents node in a tree of WebContents structure.
1727 //
1728 // Two WebContents with separate FrameTrees can be connected by
1729 // outer/inner relationship using this class. Note that their FrameTrees
1730 // still remain disjoint.
1731 // The parent is referred to as "outer WebContents" and the descendents are
1732 // referred to as "inner WebContents".
1733 // For each inner WebContents, the outer WebContents will have a
1734 // corresponding FrameTreeNode.
lfga3e2bdc2017-03-07 20:44:011735 class WebContentsTreeNode final : public FrameTreeNode::Observer {
lazyboy6ec48b2a2015-06-29 15:18:141736 public:
lfg601233692017-03-06 22:45:441737 explicit WebContentsTreeNode(WebContentsImpl* current_web_contents);
lfga3e2bdc2017-03-07 20:44:011738 ~WebContentsTreeNode() final;
lazyboy6ec48b2a2015-06-29 15:18:141739
Keren Zhub5adf39c2025-05-19 20:20:301740 // Attaches `inner_web_contents` to the `render_frame_host` within this
1741 // WebContents. If `should_take_ownership` is true, this WebContents will
1742 // take ownership of `inner_web_contents`.
1743 void AttachInnerWebContents(WebContents* inner_web_contents,
1744 RenderFrameHostImpl* render_frame_host,
1745 bool should_take_ownership);
1746
1747 // Detaches `inner_web_contents` from the outer WebContents.
1748 void DetachInnerWebContents(WebContents* inner_web_contents);
1749
1750 // Returns true if `inner_web_contents` is attached but not owned by this
1751 // WebContentsTreeNode. This function will CHECK fail if
1752 // `inner_web_contents` is not attached to this WebContentsTreeNode.
1753 bool IsUnownedInnerWebContents(WebContents* inner_web_contents) const;
lazyboy6ec48b2a2015-06-29 15:18:141754
lfg601233692017-03-06 22:45:441755 WebContentsImpl* outer_web_contents() const { return outer_web_contents_; }
Avi Drissman13d20e92024-09-05 16:56:301756 FrameTreeNodeId outer_contents_frame_tree_node_id() const {
lazyboy6ec48b2a2015-06-29 15:18:141757 return outer_contents_frame_tree_node_id_;
1758 }
lfga3e2bdc2017-03-07 20:44:011759 FrameTreeNode* OuterContentsFrameTreeNode() const;
lazyboy6ec48b2a2015-06-29 15:18:141760
Daniel Cheng3f2c5ff2024-05-30 19:58:181761 FrameTree* focused_frame_tree();
Dave Tapuskad8b0530f2021-10-19 15:12:311762 void SetFocusedFrameTree(FrameTree* frame_tree);
avallee0206f782016-07-28 18:55:331763
paulmeyerfeafc2d2017-04-25 21:46:401764 // Returns the inner WebContents within |frame|, if one exists, or nullptr
1765 // otherwise.
1766 WebContentsImpl* GetInnerWebContentsInFrame(const FrameTreeNode* frame);
1767
Lucas Furukawa Gadani3d38ec152018-10-26 20:55:181768 std::vector<WebContentsImpl*> GetInnerWebContents() const;
paulmeyerfeafc2d2017-04-25 21:46:401769
lazyboy6ec48b2a2015-06-29 15:18:141770 private:
Keren Zhub5adf39c2025-05-19 20:20:301771 void DetachUnownedInnerWebContents(WebContentsImpl* inner_web_contents);
1772 void DestroyOwnedInnerWebContents(WebContentsImpl* inner_web_contents);
paulmeyerfeafc2d2017-04-25 21:46:401773
lfga3e2bdc2017-03-07 20:44:011774 // FrameTreeNode::Observer implementation.
1775 void OnFrameTreeNodeDestroyed(FrameTreeNode* node) final;
lfg601233692017-03-06 22:45:441776
1777 // The WebContents that owns this WebContentsTreeNode.
Ali Hijazi4d4e24092022-10-20 22:59:311778 const raw_ptr<WebContentsImpl, DanglingUntriaged> current_web_contents_;
lfg601233692017-03-06 22:45:441779
1780 // The outer WebContents of |current_web_contents_|, or nullptr if
1781 // |current_web_contents_| is the outermost WebContents.
Ali Hijazi4d4e24092022-10-20 22:59:311782 raw_ptr<WebContentsImpl, DanglingUntriaged> outer_web_contents_;
lfg601233692017-03-06 22:45:441783
1784 // The ID of the FrameTreeNode in the |outer_web_contents_| that hosts
1785 // |current_web_contents_| as an inner WebContents.
Avi Drissman13d20e92024-09-05 16:56:301786 FrameTreeNodeId outer_contents_frame_tree_node_id_;
lfg601233692017-03-06 22:45:441787
Keren Zhub5adf39c2025-05-19 20:20:301788 // List of inner WebContents that we host and own.
1789 std::vector<std::unique_ptr<WebContents>> owned_inner_web_contents_;
1790
1791 // List of inner WebContents that we host but don't own.
1792 std::vector<raw_ptr<WebContents>> unowned_inner_web_contents_;
paulmeyerfeafc2d2017-04-25 21:46:401793
Dave Tapuskad8b0530f2021-10-19 15:12:311794 // Only the root node should have this set. This indicates the FrameTree
1795 // that has the focused frame. The FrameTree tree could be arbitrarily deep.
1796 // An inner WebContents if focused is responsible for setting this back to
1797 // another valid during its destruction. See WebContentsImpl destructor.
Alison Gale81f4f2c72024-04-22 19:33:311798 // TODO(crbug.com/40200744): Support clearing this for inner frame trees.
Daniel Cheng3f2c5ff2024-05-30 19:58:181799 raw_ptr<FrameTree> focused_frame_tree_;
lazyboy6ec48b2a2015-06-29 15:18:141800 };
1801
Alexander Timin90c20c32020-08-12 15:28:321802 // Container for WebContentsObservers, which knows when we are iterating over
1803 // observer set.
1804 class WebContentsObserverList {
1805 public:
1806 WebContentsObserverList();
1807 ~WebContentsObserverList();
1808
1809 void AddObserver(WebContentsObserver* observer);
1810 void RemoveObserver(WebContentsObserver* observer);
1811
Andrew Grievee19cd93e2021-01-22 05:43:061812 // T1 must be a pointer to a WebContentsObserver method.
1813 template <typename T1, typename... P1>
1814 void NotifyObservers(T1 func, P1&&... args) {
Etienne Pierre-doray2f16b82922024-11-08 15:10:251815 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("content.verbose"),
1816 "WebContentsObserverList::NotifyObservers");
Alexander Timin90c20c32020-08-12 15:28:321817 base::AutoReset<bool> scope(&is_notifying_observers_, true);
1818 for (WebContentsObserver& observer : observers_) {
1819 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("content.verbose"),
1820 "Dispatching WebContentsObserver callback");
Andrew Grievee19cd93e2021-01-22 05:43:061821 ((observer).*(func))(std::forward<P1>(args)...);
Alexander Timin90c20c32020-08-12 15:28:321822 }
1823 }
1824
1825 bool is_notifying_observers() { return is_notifying_observers_; }
1826
1827 // Exposed to deal with IPC message handlers which need to stop iteration
1828 // early.
Jordan Baylesa4d7edbe2023-10-07 05:59:341829 const base::ObserverList<WebContentsObserver>& observer_list() {
Alexander Timin90c20c32020-08-12 15:28:321830 return observers_;
1831 }
1832
1833 private:
1834 bool is_notifying_observers_ = false;
Jordan Baylesa4d7edbe2023-10-07 05:59:341835 base::ObserverList<WebContentsObserver> observers_;
Alexander Timin90c20c32020-08-12 15:28:321836 };
1837
[email protected]d1198fd2012-08-13 22:50:191838 // See WebContents::Create for a description of these parameters.
Lukasz Anforowicze9ae3722017-09-29 17:37:381839 explicit WebContentsImpl(BrowserContext* browser_context);
[email protected]d1198fd2012-08-13 22:50:191840
Albert J. Wong65fe64d2019-09-20 02:48:141841 // Covariant return type alternative for WebContents::Create(). Avoids
1842 // need for casting of objects inside the content layer.
1843 static std::unique_ptr<WebContentsImpl> Create(const CreateParams& params);
1844
[email protected]e2225bf2013-11-15 16:09:381845 // Add and remove observers for page navigation notifications. The order in
1846 // which notifications are sent to observers is undefined. Clients must be
1847 // sure to remove the observer before they go away.
[email protected]8ff00d72012-10-23 19:12:211848 void AddObserver(WebContentsObserver* observer);
1849 void RemoveObserver(WebContentsObserver* observer);
[email protected]d1198fd2012-08-13 22:50:191850
danakjcdab6ed52021-02-10 23:44:131851 // Indicates whether this tab should be considered crashed. The setter will
1852 // also notify the delegate when the flag is changed.
Khushalc5eaf222021-06-30 20:15:481853 void SetPrimaryMainFrameProcessStatus(base::TerminationStatus status,
1854 int error_code);
danakjcdab6ed52021-02-10 23:44:131855
alexmose201c7cd2015-06-10 17:14:211856 // Clears a pending contents that has been closed before being shown.
[email protected]7fff43e2013-05-21 20:21:101857 void OnWebContentsDestroyed(WebContentsImpl* web_contents);
1858
Daniel Cheng036c5b92024-05-07 15:19:371859 // Creates and adds to the map a destruction observer watching
1860 // `render_widget_host`. There must be no observer already watching
1861 // `render_widget_host`.
1862 void AddRenderWidgetHostDestructionObserver(
1863 RenderWidgetHost* render_widget_host);
1864
1865 // Deletes and removes from the map a destruction observer
1866 // watching `render_widget_host`. No-op if there is no such observer.
1867 void RemoveRenderWidgetHostDestructionObserver(
1868 RenderWidgetHost* render_widget_host);
1869
Avi Drissman783c1232021-02-05 01:27:051870 // Clears a pending render widget host that has been closed before being
1871 // shown.
1872 void OnRenderWidgetHostDestroyed(RenderWidgetHost* render_widget_host);
1873
1874 // Creates and adds to the map a destruction observer watching `web_contents`.
[email protected]7fff43e2013-05-21 20:21:101875 // No-op if such an observer already exists.
Avi Drissman783c1232021-02-05 01:27:051876 void AddWebContentsDestructionObserver(WebContentsImpl* web_contents);
[email protected]7fff43e2013-05-21 20:21:101877
1878 // Deletes and removes from the map a destruction observer
Avi Drissman783c1232021-02-05 01:27:051879 // watching `web_contents`. No-op if there is no such observer.
1880 void RemoveWebContentsDestructionObserver(WebContentsImpl* web_contents);
1881
Adithya Srinivasane6e7f842019-12-16 18:41:361882 // Traverses all the WebContents in the WebContentsTree and creates a set of
1883 // all the unique RenderWidgetHostViews.
Kevin McNeeef1e9362021-06-08 21:31:521884 std::set<RenderWidgetHostViewBase*>
1885 GetRenderWidgetHostViewsInWebContentsTree();
Adithya Srinivasane6e7f842019-12-16 18:41:361886
pkotwicz75ca8ffd2016-02-16 23:10:191887 // Called with the result of a DownloadImage() request.
Mikel Astiz034ba14e2021-04-30 07:23:491888 void OnDidDownloadImage(base::WeakPtr<RenderFrameHostImpl> rfh,
1889 ImageDownloadCallback callback,
pkotwicz75ca8ffd2016-02-16 23:10:191890 int id,
1891 const GURL& image_url,
leon.hancbc4bc3c2016-02-26 07:08:521892 int32_t http_status_code,
leon.hanc2228532016-08-16 05:59:181893 const std::vector<SkBitmap>& images,
1894 const std::vector<gfx::Size>& original_image_sizes);
pkotwicz75ca8ffd2016-02-16 23:10:191895
Jacob Francis0043f242024-07-24 21:46:211896 int GetNextDownloadId();
1897
Pavel Feldman3c1842b2017-08-02 05:00:161898 // Callback function when showing JavaScript dialogs. Takes in a routing ID
[email protected]6fba26d2014-04-29 09:38:281899 // pair to identify the RenderFrameHost that opened the dialog, because it's
1900 // possible for the RenderFrameHost to be deleted by the time this is called.
1901 void OnDialogClosed(int render_process_id,
1902 int render_frame_id,
Dave Tapuskacdf545cc2020-01-23 18:38:521903 JavaScriptDialogCallback response_callback,
Avi Drissman1a55a9d62020-03-10 18:56:451904 base::ScopedClosureRunner fullscreen_block,
[email protected]87de04b02014-04-08 22:14:491905 bool dialog_was_suppressed,
[email protected]51da7e32012-01-30 19:24:521906 bool success,
Jan Wilken Dörrieaace0cfef2021-03-11 22:01:581907 const std::u16string& user_input);
[email protected]51da7e32012-01-30 19:24:521908
[email protected]d0759f492012-04-19 22:50:501909 // IPC message handlers.
nicka0ac8382016-12-15 23:59:231910 void OnUpdateZoomLimits(RenderViewHostImpl* source,
1911 int minimum_percent,
[email protected]fce823222014-05-30 16:24:301912 int maximum_percent);
nicka0ac8382016-12-15 23:59:231913 void OnShowValidationMessage(RenderViewHostImpl* source,
1914 const gfx::Rect& anchor_in_root_view,
Jan Wilken Dörrieaace0cfef2021-03-11 22:01:581915 const std::u16string& main_text,
1916 const std::u16string& sub_text);
nicka0ac8382016-12-15 23:59:231917 void OnHideValidationMessage(RenderViewHostImpl* source);
1918 void OnMoveValidationMessage(RenderViewHostImpl* source,
1919 const gfx::Rect& anchor_in_root_view);
[email protected]edc3af82013-12-12 21:24:071920
danakj5f22bcc2021-02-12 18:09:011921 // Determines if content is allowed to overscroll. This value comes from the
1922 // WebContentsDelegate, but can also be overridden by the WebContents.
1923 bool CanOverscrollContent() const;
1924
Aman Vermab3ed74e2024-04-29 13:58:131925 // void CastToViewBaseSafely(
1926 // RenderWidgetTargeter::RenderWidgetHostAtPointCallback callback,
1927 // base::WeakPtr<RenderWidgetHostViewInput> view,
1928 // std::optional<gfx::PointF> point) ;
1929
avallee9993fca2016-11-17 06:16:501930 // Inner WebContents Helpers -------------------------------------------------
1931 //
1932 // These functions are helpers in managing a hierarchy of WebContents
1933 // involved in rendering inner WebContents.
1934
K. Moon97def7d2022-02-01 15:56:021935 // The following functions update registrations for all RenderWidgetHostViews
1936 // rooted at this WebContents. They are used when attaching/detaching an inner
1937 // WebContents.
1938 //
1939 // Some properties of RenderWidgetHostViews, such as the FrameSinkId and
1940 // TextInputManager, depend on the outermost WebContents, and must be updated
1941 // during attach/detach.
1942 void RecursivelyRegisterRenderWidgetHostViews();
1943 void RecursivelyUnregisterRenderWidgetHostViews();
W. James MacLean2dc75ed42019-03-06 14:31:091944
avallee9993fca2016-11-17 06:16:501945 // When multiple WebContents are present within a tab or window, a single one
1946 // is focused and will route keyboard events in most cases to a RenderWidget
1947 // contained within it. |GetFocusedWebContents()|'s main frame widget will
1948 // receive page focus and blur events when the containing window changes focus
1949 // state.
1950
avallee9993fca2016-11-17 06:16:501951 // Returns true if |this| is the focused WebContents or an ancestor of the
1952 // focused WebContents.
1953 bool ContainsOrIsFocusedWebContents();
1954
Keren Zhub5adf39c2025-05-19 20:20:301955 // Internal implementation of AttachInnerWebContents() and
1956 // AttachUnownedInnerWebContents().
1957 void AttachInnerWebContentsImpl(WebContents* inner_web_contents,
1958 RenderFrameHost* render_frame_host,
1959 bool is_full_page,
1960 bool should_take_ownership);
1961
Keren Zhu9e378032025-05-26 19:20:391962 // Internal implementation of DetachUnownedInnerWebContents() that does not
1963 // require a pass key. Called by ~WebContentsImpl.
1964 void DetachUnownedInnerWebContents(WebContents* inner_web_contents);
1965
Jeremy Roman03ce13ce2020-05-29 22:16:571966 // Called just after an inner web contents is attached.
1967 void InnerWebContentsAttached(WebContents* inner_web_contents);
1968
1969 // Called just after an inner web contents is detached.
1970 void InnerWebContentsDetached(WebContents* inner_web_contents);
1971
[email protected]0dd3a0ab2011-02-18 08:17:441972 // Navigation helpers --------------------------------------------------------
1973 //
1974 // These functions are helpers for Navigate() and DidNavigate().
1975
1976 // Handles post-navigation tasks in DidNavigate AFTER the entry has been
1977 // committed to the navigation controller. Note that the navigation entry is
1978 // not provided since it may be invalid/changed after being committed. The
1979 // current navigation entry is in the NavigationController at this point.
[email protected]2f7b3c5a2013-06-21 04:59:251980
[email protected]bafe6cd2012-05-23 23:09:501981 // Finds the new RenderWidgetHost and returns it. Note that this can only be
1982 // called once as this call also removes it from the internal map.
alexmosc2a8cec2016-05-23 22:19:531983 RenderWidgetHostView* GetCreatedWidget(int process_id, int route_id);
[email protected]bafe6cd2012-05-23 23:09:501984
Joel Hockey8c2011b22020-04-30 05:07:191985 // Finds the new CreatedWindow by |main_frame_widget_route_id|, initializes
nick5ae4d2d2017-01-06 01:18:351986 // it for renderer-initiated creation, and returns it. Note that this can only
1987 // be called once as this call also removes it from the internal map.
Arthur Sonzognic686e8f2024-01-11 08:36:371988 std::optional<CreatedWindow> GetCreatedWindow(int process_id,
1989 int main_frame_widget_route_id);
[email protected]bafe6cd2012-05-23 23:09:501990
Gyuyoung Kim877e86d2020-07-21 04:01:021991 // Execute a PageBroadcast Mojo method.
1992 void ExecutePageBroadcastMethod(PageBroadcastMethodCallback callback);
1993
Takashi Toyoshimadf3f4e312021-11-19 03:51:481994 // Execute a PageBroadcast Mojo method for all MPArch pages.
1995 void ExecutePageBroadcastMethodForAllPages(
1996 PageBroadcastMethodCallback callback);
1997
lukasza6f8ac622017-06-06 03:10:201998 void SetOpenerForNewContents(FrameTreeNode* opener, bool opener_suppressed);
1999
[email protected]960b0372014-05-19 18:01:002000 // Tracking loading progress -------------------------------------------------
2001
fdegansa696e5112015-04-17 01:57:592002 // Resets the tracking state of the current load progress.
[email protected]960b0372014-05-19 18:01:002003 void ResetLoadProgressState();
2004
fdegansa696e5112015-04-17 01:57:592005 // Notifies the delegate that the load progress was updated.
2006 void SendChangeLoadProgress();
[email protected]960b0372014-05-19 18:01:002007
[email protected]0dd3a0ab2011-02-18 08:17:442008 // Misc non-view stuff -------------------------------------------------------
2009
avi2b177592014-12-10 02:08:022010 // Sets the history for a specified RenderViewHost to |history_length|
Charlie Reis99b2eba22025-01-31 19:18:572011 // entries, with an index of |history_index|.
2012 void SetHistoryIndexAndLengthForView(RenderViewHost* render_view_host,
2013 int history_index,
2014 int history_length);
avi2b177592014-12-10 02:08:022015
[email protected]0dd3a0ab2011-02-18 08:17:442016 // Helper functions for sending notifications.
danakja0bce4c952020-05-12 20:40:282017 void NotifyViewSwapped(RenderViewHost* old_view, RenderViewHost* new_view);
Kevin McNeefb86fcf2021-02-26 23:20:572018 void NotifyFrameSwapped(RenderFrameHostImpl* old_frame,
Dave Tapuskae45d6fd2021-09-29 17:03:592019 RenderFrameHostImpl* new_frame);
[email protected]0dd3a0ab2011-02-18 08:17:442020
[email protected]fa944cb82013-11-15 17:51:212021 // TODO(creis): This should take in a FrameTreeNode to know which node's
2022 // render manager to return. For now, we just return the root's.
Paul Semel3e241042022-10-11 12:57:312023 RenderFrameHostManager* GetRenderManager();
[email protected]fa944cb82013-11-15 17:51:212024
[email protected]7a846df2012-09-20 19:17:392025 // Removes browser plugin embedder if there is one.
2026 void RemoveBrowserPluginEmbedder();
2027
danakja0bce4c952020-05-12 20:40:282028 // Returns the size that the main frame should be sized to.
2029 gfx::Size GetSizeForMainFrame();
[email protected]dc0fd432013-08-27 15:29:212030
[email protected]222f5822014-02-05 23:40:492031 // Helper method that's called whenever |preferred_size_| or
2032 // |preferred_size_for_capture_| changes, to propagate the new value to the
2033 // |delegate_|.
2034 void OnPreferredSizeChanged(const gfx::Size& old_size);
2035
paulmeyerfeafc2d2017-04-25 21:46:402036 // Returns the FindRequestManager, which may be found in an outer WebContents.
Lucas Furukawa Gadanie1c5dfda2018-11-29 17:57:412037 FindRequestManager* GetFindRequestManager();
paulmeyerfeafc2d2017-04-25 21:46:402038
Ehsan Karamad6beb2ea2018-11-25 18:15:132039 // Returns the FindRequestManager, or tries to create one if it doesn't
2040 // already exist. The FindRequestManager may be found in an outer
2041 // WebContents. If this is an inner WebContents which is not yet attached to
2042 // an outer WebContents the method will return nullptr.
paulmeyerc0b762b2016-04-13 11:55:172043 FindRequestManager* GetOrCreateFindRequestManager();
2044
falken52a56e32016-12-08 05:02:402045 // Prints a console warning when visiting a localhost site with a bad
2046 // certificate via --allow-insecure-localhost.
Jeremy Romand597d3372021-07-09 23:36:562047 void ShowInsecureLocalhostWarningIfNeeded(PageImpl& page);
falken52a56e32016-12-08 05:02:402048
Megan Jablonski2f6a4c52017-07-10 23:01:252049 // Format of |headers| is a new line separated list of key value pairs:
2050 // "<key1>: <value1>\r\n<key2>: <value2>".
Min Qina904f3302018-02-13 23:33:342051 static download::DownloadUrlParameters::RequestHeadersType
2052 ParseDownloadHeaders(const std::string& headers);
Megan Jablonski2f6a4c52017-07-10 23:01:252053
EhsanK2075c7e2017-08-21 02:42:392054 // Sets the visibility of immediate child views, i.e. views whose parent view
2055 // is that of the main frame.
2056 void SetVisibilityForChildViews(bool visible);
2057
Lukasz Anforowiczfd707142018-02-07 19:46:132058 // A helper for clearing the link status bubble after navigating away.
2059 // See also UpdateTargetURL.
2060 void ClearTargetURL();
2061
Arthur Sonzogni929d29f2018-09-17 14:19:442062 // Called each time |fullscreen_frames_| is updated. Find the new
Charlie Reis207e93c2023-10-04 23:48:492063 // |current_fullscreen_frame_id_| and notify observers whenever it changes.
Arthur Sonzogni929d29f2018-09-17 14:19:442064 void FullscreenFrameSetUpdated();
2065
Sonja3e1acb12024-01-15 12:06:412066 // Adjusts bounds for minimum window size and available screen area
2067 // constraints. This compliments similar renderer-side adjustments, using the
2068 // resolved display mode for new windows, which renderers may be unable to
2069 // determine.
2070 int64_t AdjustWindowRect(gfx::Rect* bounds, RenderFrameHostImpl* opener);
2071
Alison Maher7f366dc62020-03-03 19:46:002072 // ui::NativeThemeObserver:
2073 void OnNativeThemeUpdated(ui::NativeTheme* observed_theme) override;
Abigail Klein08cfe3f2021-04-01 02:09:312074 void OnCaptionStyleUpdated() override;
Alison Maher7f366dc62020-03-03 19:46:002075
tom855c4bf32021-09-30 00:27:262076 // ui::ColorProviderSourceObserver:
2077 void OnColorProviderChanged() override;
2078
2079 // Returns the ColorProvider instance for this WebContents object. This will
2080 // always return a valid ColorProvider instance.
Tom Lukaszewicz63b3da52022-01-26 01:37:572081 const ui::ColorProvider& GetColorProvider() const override;
tom855c4bf32021-09-30 00:27:262082
Shintaro Kawamura1042d572024-09-30 13:52:222083 // implements SlowWebPreferenceCacheObserver
2084 void OnSlowWebPreferenceChanged() override;
2085
Collin Baker989e0882019-11-01 01:27:172086 // Sets the visibility to |new_visibility| and propagates this to the
2087 // renderer side, taking into account the current capture state. This
Elad Alon0feb6602021-10-14 09:26:362088 // can be called with the current visibility to affect capturing
Collin Baker989e0882019-11-01 01:27:172089 // changes.
Elad Alon0feb6602021-10-14 09:26:362090 // |is_activity| controls whether a change to |visible| affects
Olivier ROBIN4b58dd932024-08-06 13:30:322091 // the value returned by GetLastActiveTimeTicks().
Elad Alon0feb6602021-10-14 09:26:362092 void UpdateVisibilityAndNotifyPageAndView(Visibility new_visibility,
2093 bool is_activity = true);
Collin Baker989e0882019-11-01 01:27:172094
Alexander Timine3ec4192020-04-20 16:39:402095 // Returns UKM source id for the currently displayed page.
2096 // Intentionally kept private, prefer using
2097 // render_frame_host->GetPageUkmSourceId() if you already have a
Dave Tapuska327c06c92022-06-13 20:31:512098 // |render_frame_host| reference or
2099 // GetPrimaryMainFrame()->GetPageUkmSourceId() if you don't.
Alexander Timine3ec4192020-04-20 16:39:402100 ukm::SourceId GetCurrentPageUkmSourceId() override;
2101
Dave Tapuska05fcfb62021-10-18 17:09:032102 // Bit mask to indicate what types of RenderViewHosts to be returned in
2103 // ForEachRenderViewHost.
2104 enum ForEachRenderViewHostTypes {
2105 kPrerenderViews = 1 << 0,
2106 kBackForwardCacheViews = 1 << 1,
2107 kActiveViews = 1 << 2,
2108 kAllViews = kActiveViews | kBackForwardCacheViews | kPrerenderViews,
2109 };
2110
2111 // For each RenderViewHost (including bfcache, prerendering) call the
2112 // callback, this will be filtered by `view_mask`.
2113 void ForEachRenderViewHost(
2114 ForEachRenderViewHostTypes view_mask,
2115 RenderViewHostIterationCallback on_render_view_host);
Yuzu Saijo232076f2020-05-29 07:14:022116
Kevin McNeec9d0fda2021-05-19 15:55:172117 // This is the actual implementation of the various overloads of
2118 // |ForEachRenderFrameHost|.
2119 void ForEachRenderFrameHostImpl(
Daniel Cheng982f2b22022-08-25 23:46:162120 base::FunctionRef<FrameIterationAction(RenderFrameHostImpl*)> on_frame,
Kevin McNeec9d0fda2021-05-19 15:55:172121 bool include_speculative);
2122
Takashi Toyoshimadc3f7472021-07-21 08:02:322123 // Calls |on_frame_tree| for every FrameTree in this WebContents.
Kevin McNee53f0b2d2021-11-02 18:00:452124 // This does not descend into inner WebContents, but does include inner frame
2125 // trees based on MPArch.
Takashi Toyoshimadc3f7472021-07-21 08:02:322126 void ForEachFrameTree(FrameTreeIterationCallback on_frame_tree);
2127
Kevin McNee53f0b2d2021-11-02 18:00:452128 // Returns the primary frame tree, followed by any other outermost frame trees
2129 // in this WebContents. Outermost frame trees include, for example,
Jeremy Romanc0c69be2023-11-21 19:14:522130 // prerendering frame trees, and do not include, for example, fenced frames.
2131 // Also note that bfcached pages do not have a distinct frame tree,
Kevin McNee53f0b2d2021-11-02 18:00:452132 // so the primary frame tree in the result would be the only FrameTree
2133 // representing any bfcached pages.
2134 std::vector<FrameTree*> GetOutermostFrameTrees();
2135
Kevin McNeec9d0fda2021-05-19 15:55:172136 // Returns the primary main frame, followed by the main frames of any other
Kevin McNee53f0b2d2021-11-02 18:00:452137 // outermost frame trees in this WebContents and the main frames of any
2138 // bfcached pages. Note that unlike GetOutermostFrameTrees, bfcached pages
2139 // have a distinct RenderFrameHostImpl in this result.
Kevin McNeec9d0fda2021-05-19 15:55:172140 std::vector<RenderFrameHostImpl*> GetOutermostMainFrames();
2141
Dale Curtis7030f252021-04-07 14:05:312142 // Called when the base::ScopedClosureRunner returned by
2143 // IncrementCapturerCount() is destructed.
Elad Alon0feb6602021-10-14 09:26:362144 void DecrementCapturerCount(bool stay_hidden,
2145 bool stay_awake,
2146 bool is_activity = true);
Dale Curtis7030f252021-04-07 14:05:312147
Tsuyoshi Horocd828462021-04-21 04:59:582148 // Calculates the PageVisibilityState for |visibility|, taking the capturing
2149 // state into account.
2150 PageVisibilityState CalculatePageVisibilityState(Visibility visibility) const;
2151
Khushalc5eaf222021-06-30 20:15:482152 // Called when the process hosting the primary main RenderFrameHost is known
2153 // to be alive.
2154 void NotifyPrimaryMainFrameProcessIsAlive();
2155
Rakina Zata Amni46087a12022-11-11 08:28:382156 // Updates |entry|'s title. |entry| must belong to the WebContents' primary
2157 // NavigationController. Returns true if |entry|'s title was changed, and
2158 // false otherwise.
Adithya Srinivasan9b0c99c2021-08-10 15:19:452159 bool UpdateTitleForEntryImpl(NavigationEntryImpl* entry,
2160 const std::u16string& title);
2161 // Dispatches WebContentsObserver::TitleWasSet and also notifies the delegate
2162 // of a title change if |entry| is the entry whose title is being used as the
2163 // display title.
2164 void NotifyTitleUpdateForEntry(NavigationEntryImpl* entry);
2165 // Returns the navigation entry whose title is used as the display title for
Rakina Zata Amni46087a12022-11-11 08:28:382166 // this WebContents (i.e. for WebContents::GetTitle()).
Adithya Srinivasan9b0c99c2021-08-10 15:19:452167 NavigationEntry* GetNavigationEntryForTitle();
2168
Klaus Weidnerd8219432022-02-08 21:50:592169 // Apply shared logic for SetHasPictureInPictureVideo() and
2170 // SetHasPictureInPictureDocument().
2171 void SetHasPictureInPictureCommon(bool has_picture_in_picture);
2172
Andy Paicu5608bda82023-03-03 15:09:202173 // A scope that disallows custom cursors has expired.
2174 void DisallowCustomCursorScopeExpired();
2175
Jiacheng Guo6dcc29c2024-07-26 00:28:402176 // WarmUp a spare render process for future navigations.
2177 void WarmUpAndroidSpareRenderer();
2178
Ari Chivukulaee503052024-08-30 20:33:532179 // If the new window will be a partitioned popin, we need to validate the
2180 // settings and set the opener.
2181 // See https://explainers-by-googlers.github.io/partitioned-popins/
2182 void SetPartitionedPopinOpenerOnNewWindowIfNeeded(
2183 WebContentsImpl* new_window,
2184 const mojom::CreateNewWindowParams& params,
2185 RenderFrameHostImpl* opener);
2186
Dave Tapuska894bfb42024-11-04 22:44:352187 // Creates a new ForwardingAudioStreamFactory.
2188 std::unique_ptr<ForwardingAudioStreamFactory> CreateAudioStreamFactory();
2189
Dave Tapuska463717e2024-11-21 18:42:472190 // Cancel any pending dialogs created from the delegate's
2191 // JavascriptDialogManager.
2192 void CancelDialogManagerDialogs(bool reset_state);
2193
Ari Chivukulaf6f09ba2025-03-04 20:01:342194 // See GetPartitionedPopinEmbedderOrigin for details.
2195 GURL GetPartitionedPopinEmbedderOriginImpl() const;
2196
Mark Schillacic1e067e82025-04-02 17:36:112197 // Recursively constructs a vector of AXNodeData objects for the children of
2198 // the given |node|.
2199 void RecursivelyConstructAXTree(ui::AXNode* node,
2200 std::vector<ui::AXNodeData>& nodes);
2201
Shin Kawamura7c2f4692025-07-30 00:14:332202#if BUILDFLAG(IS_ANDROID)
2203 // Apply the cached primary subframe importance to the primary frame tree.
2204 void ApplyPrimaryPageSubframeImportance();
2205#endif
2206
[email protected]0dd3a0ab2011-02-18 08:17:442207 // Data for core operation ---------------------------------------------------
2208
2209 // Delegate for notifying our owner about stuff. Not owned by us.
Ali Hijazi4d4e24092022-10-20 22:59:312210 raw_ptr<WebContentsDelegate, DanglingUntriaged> delegate_;
[email protected]0dd3a0ab2011-02-18 08:17:442211
[email protected]0dd3a0ab2011-02-18 08:17:442212 // The corresponding view.
dcheng59716272016-04-09 05:19:082213 std::unique_ptr<WebContentsView> view_;
[email protected]0dd3a0ab2011-02-18 08:17:442214
[email protected]5a3bdf52012-05-24 15:12:572215 // The view of the RVHD. Usually this is our WebContentsView implementation,
2216 // but if an embedder uses a different WebContentsView, they'll need to
2217 // provide this.
Lukasz Anforowicz3eacd9e62023-05-17 21:58:542218 raw_ptr<RenderViewHostDelegateView> render_view_host_delegate_view_;
[email protected]5a3bdf52012-05-24 15:12:572219
Joel Hockey8c2011b22020-04-30 05:07:192220 // Tracks CreatedWindow objects that have not been shown yet. They are
2221 // identified by the process ID and routing ID passed to CreateNewWindow.
2222 std::map<GlobalRoutingID, CreatedWindow> pending_contents_;
[email protected]bafe6cd2012-05-23 23:09:502223
Avi Drissman783c1232021-02-05 01:27:052224 // Watches for the destruction of items in `pending_contents_`.
2225 std::map<WebContentsImpl*, std::unique_ptr<WebContentsDestructionObserver>>
2226 web_contents_destruction_observers_;
2227
alexmosc2a8cec2016-05-23 22:19:532228 // This map holds widgets that were created on behalf of the renderer but
2229 // haven't been shown yet.
Ali Hijazi60a72b0a2024-09-30 17:58:532230 std::map<GlobalRoutingID, raw_ptr<RenderWidgetHost, CtnExperimental>>
2231 pending_widgets_;
[email protected]bafe6cd2012-05-23 23:09:502232
Avi Drissman783c1232021-02-05 01:27:052233 // Watches for the destruction of items in `pending_widgets_`.
2234 std::map<RenderWidgetHost*,
2235 std::unique_ptr<RenderWidgetHostDestructionObserver>>
2236 render_widget_host_destruction_observers_;
[email protected]7fff43e2013-05-21 20:21:102237
[email protected]996042972011-11-08 22:43:592238 // A list of observers notified when page state changes. Weak references.
Carlos Caballerob65b6e3a2021-11-15 10:09:002239 // This MUST be listed above `primary_frame_tree_` since at destruction time
2240 // the latter might cause RenderViewHost's destructor to call us and we might
2241 // use the observer list then.
Alexander Timin90c20c32020-08-12 15:28:322242 WebContentsObserverList observers_;
[email protected]996042972011-11-08 22:43:592243
Greg Thompson9cb192762025-05-12 08:11:572244 // True if the WebContents is never user-visible, thus the renderer need never
2245 // produce pixels for display.
2246 bool is_never_composited_ = false;
2247
Rakina Zata Amnic7ffea882021-08-16 10:04:282248 // True if this tab was opened by another window. This is true even if the tab
2249 // is opened with "noopener", and won't be unset if the opener is closed.
2250 bool opened_by_another_window_;
[email protected]c7c0d822014-04-16 20:19:492251
Daniel Chengbcbc30f2024-05-28 09:02:122252 // Set to true while calling out to notify one-off observers (ie non-
2253 // WebContentsObservers). These observers should not destroy WebContentsImpl
2254 // while it is on the call stack, as that leads to use-after-frees.
2255 bool prevent_destruction_ = false;
2256
2257 bool is_being_destroyed_ = false;
2258
Xiaohan Wang24ec9342022-01-15 17:34:222259#if BUILDFLAG(IS_ANDROID)
Kevin McNee576bb5d82019-05-29 16:47:512260 std::unique_ptr<WebContentsAndroid> web_contents_android_;
Shin Kawamura7c2f4692025-07-30 00:14:332261 // Caches the importance of subframes in the primary frame tree.
2262 // WebContentsImpl::RenderFrameCreated() sets the importance to a new
2263 // RenderWidgetHost for new subframes.
2264 ChildProcessImportance primary_subframe_importance_ =
2265 ChildProcessImportance::NORMAL;
Kevin McNee576bb5d82019-05-29 16:47:512266#endif
2267
Daniel Cheng37d22722024-06-29 00:43:442268 // Manages the embedder state for browser plugins, if this WebContents is an
2269 // embedder; NULL otherwise.
2270 std::unique_ptr<BrowserPluginEmbedder> browser_plugin_embedder_;
2271
2272 // Manages the guest state for browser plugin, if this WebContents is a guest;
2273 // NULL otherwise.
2274 std::unique_ptr<BrowserPluginGuest> browser_plugin_guest_;
2275
[email protected]0dd3a0ab2011-02-18 08:17:442276 // Helper classes ------------------------------------------------------------
2277
Daniel Cheng3f2c5ff2024-05-30 19:58:182278 // Contains information about the WebContents tree structure.
2279 WebContentsTreeNode node_;
2280
Carlos Caballerob65b6e3a2021-11-15 10:09:002281 // Primary FrameTree of this WebContents instance. This WebContents might have
2282 // additional FrameTrees for features like prerendering and fenced frames,
2283 // which either might be standalone (prerendering) to nested within a
2284 // different FrameTree (fenced frame).
2285 FrameTree primary_frame_tree_;
Lucas Furukawa Gadani99125822019-01-03 15:41:492286
[email protected]c7dd2f62011-07-18 15:57:592287 // SavePackage, lazily created.
2288 scoped_refptr<SavePackage> save_package_;
2289
paulmeyerc8cb7cb2016-06-07 01:14:192290 // Manages/coordinates multi-process find-in-page requests. Created lazily.
dcheng18ec0b542016-04-26 19:28:532291 std::unique_ptr<FindRequestManager> find_request_manager_;
paulmeyerc0b762b2016-04-13 11:55:172292
[email protected]0dd3a0ab2011-02-18 08:17:442293 // Data for loading state ----------------------------------------------------
2294
danakjcdab6ed52021-02-10 23:44:132295 // Indicates the process state of the primary main frame's renderer process.
2296 // If the process is not live due to a crash, this will be reflected by
2297 // IsCrashed(), though it's possible to not be live while not indicating a
2298 // crash occurred.
Khushalc5eaf222021-06-30 20:15:482299 base::TerminationStatus primary_main_frame_process_status_;
2300 int primary_main_frame_process_error_code_;
[email protected]0dd3a0ab2011-02-18 08:17:442301
[email protected]0dd3a0ab2011-02-18 08:17:442302 // The current load state and the URL associated with it.
[email protected]9c235f042011-08-10 22:28:212303 net::LoadStateWithParam load_state_;
Jan Wilken Dörrieaace0cfef2021-03-11 22:01:582304 std::u16string load_state_host_;
Dave Tapuskae1a08aaf2021-03-05 18:31:592305 base::TimeTicks load_info_timestamp_;
[email protected]960b0372014-05-19 18:01:002306
[email protected]960b0372014-05-19 18:01:002307 base::TimeTicks loading_last_progress_update_;
2308
Sreeja Kamishetty0be3b1b2021-08-12 17:04:152309 // Default value is set to 100ms between LoadProgressChanged events.
2310 base::TimeDelta minimum_delay_between_loading_updates_ms_ =
Peter Kastinge5a38ed2021-10-02 03:06:352311 base::Milliseconds(100);
Sreeja Kamishetty0be3b1b2021-08-12 17:04:152312
[email protected]0dd3a0ab2011-02-18 08:17:442313 // Upload progress, for displaying in the status bar.
2314 // Set to zero when there is no significant upload happening.
avib7348942015-12-25 20:57:102315 uint64_t upload_size_;
2316 uint64_t upload_position_;
[email protected]0dd3a0ab2011-02-18 08:17:442317
dfalcantarae6b7b46752015-07-10 18:14:162318 // Tracks that this WebContents needs to unblock requests to the renderer.
2319 // See ResumeLoadingCreatedWebContents.
2320 bool is_resume_pending_;
2321
[email protected]0dd3a0ab2011-02-18 08:17:442322 // Data for current page -----------------------------------------------------
2323
yusufod41c5f92015-03-06 00:14:282324 // The last published theme color.
Arthur Sonzognic686e8f2024-01-11 08:36:372325 std::optional<SkColor> last_sent_theme_color_;
yusufod41c5f92015-03-06 00:14:282326
Alan Cutterd73a15d92020-08-21 07:12:452327 // The last published background color.
Arthur Sonzognic686e8f2024-01-11 08:36:372328 std::optional<SkColor> last_sent_background_color_;
Alan Cutterd73a15d92020-08-21 07:12:452329
[email protected]0dd3a0ab2011-02-18 08:17:442330 // Data for misc internal state ----------------------------------------------
2331
Collin Bakerc5259962019-11-14 17:51:582332 // When either > 0, the WebContents is currently being captured (e.g.,
2333 // for screenshots or mirroring); and the underlying RenderWidgetHost
2334 // should not be told it is hidden. If |visible_capturer_count_| > 0,
2335 // the underlying Page is set to fully visible. Otherwise, it is set
2336 // to be hidden but still paint.
Dale Curtis7030f252021-04-07 14:05:312337 int visible_capturer_count_ = 0;
2338 int hidden_capturer_count_ = 0;
2339
2340 // When > 0, |capture_wake_lock_| will be held to prevent display sleep.
2341 int stay_awake_capturer_count_ = 0;
2342
2343 // WakeLock held to ensure screen capture keeps the display on. E.g., for
2344 // presenting through tab capture APIs.
Dale Curtisc496a7762021-02-24 01:15:442345 mojo::Remote<device::mojom::WakeLock> capture_wake_lock_;
[email protected]54597982013-02-06 01:59:552346
Aman Vermabb589a32024-05-07 16:38:172347 // Remote end of the connection for sending delegated ink points to viz to
2348 // support the delegated ink trails feature.
2349 mojo::Remote<gfx::mojom::DelegatedInkPointRenderer>
2350 delegated_ink_point_renderer_;
2351
Francois Doraye6161152018-03-27 22:05:372352 // The visibility of the WebContents. Initialized from
2353 // |CreateParams::initially_hidden|. Updated from
2354 // UpdateWebContentsVisibility(), WasShown(), WasHidden(), WasOccluded().
2355 Visibility visibility_ = Visibility::VISIBLE;
[email protected]0dd3a0ab2011-02-18 08:17:442356
Francois Doraye6161152018-03-27 22:05:372357 // Whether there has been a call to UpdateWebContentsVisibility(VISIBLE).
2358 bool did_first_set_visible_ = false;
tapted65ff2ea72016-03-01 23:39:002359
[email protected]0dd3a0ab2011-02-18 08:17:442360 // Indicates whether we should notify about disconnection of this
[email protected]b172aee2012-04-10 17:05:262361 // WebContentsImpl. This is used to ensure disconnection notifications only
[email protected]0dd3a0ab2011-02-18 08:17:442362 // happen if a connection notification has happened and that they happen only
2363 // once.
2364 bool notify_disconnection_;
2365
Frank Liberatoe837b362023-10-20 23:31:152366 // Counts the number of outstanding requests to ignore input events. They will
2367 // not be sent when this is greater than zero.
2368 int ignore_input_events_count_ = 0;
Takashi Toyoshimad72a465a2024-03-11 23:37:312369 uint64_t next_web_input_event_audit_callback_id_ = 0;
2370 base::flat_map<uint64_t, WebInputEventAuditCallback>
2371 web_input_event_audit_callbacks_;
Avi Drissman738ea192018-08-29 20:24:162372
Dave Tapuska463717e2024-11-21 18:42:472373 // Whether a dialog has been created since the last cancel of dialogs.
2374 bool created_dialog_since_last_cancel_ = false;
[email protected]2e5b90c2011-08-16 21:11:552375
avi85ee8362016-10-08 02:09:082376 // Set to true when there is an active JavaScript dialog showing.
2377 bool is_showing_javascript_dialog_ = false;
2378
[email protected]0dd3a0ab2011-02-18 08:17:442379 // Set to true when there is an active "before unload" dialog. When true,
2380 // we've forced the throbber to start in Navigate, and we need to remember to
2381 // turn it off in OnJavaScriptMessageBoxClosed if the navigation is canceled.
2382 bool is_showing_before_unload_dialog_;
2383
[email protected]0dd3a0ab2011-02-18 08:17:442384 // Settings that get passed to the renderer process.
Mario Sanchez Prada0bd8b8c2020-10-21 17:49:232385 blink::RendererPreferences renderer_preferences_;
[email protected]0dd3a0ab2011-02-18 08:17:442386
Olivier ROBINda292fb2024-08-07 14:32:292387 // The time ticks that this WebContents was last made active. The initial
2388 // value is the WebContents creation time.
2389 base::TimeTicks last_active_time_ticks_;
2390
[email protected]9a890452014-02-13 22:21:022391 // The time that this WebContents was last made active. The initial value is
2392 // the WebContents creation time.
Olivier ROBINda292fb2024-08-07 14:32:292393 base::Time last_active_time_;
[email protected]0dd3a0ab2011-02-18 08:17:442394
Evan Stade6decc972022-10-24 19:42:182395 // The most recent time that this WebContents was interacted with. Currently,
2396 // this counts:
2397 // * 'interactive' input events from the user, like mouse clicks and keyboard
2398 // input but not mouse wheel scrolling
2399 // * editing commands such as `Paste()`, which are invoked programmatically,
2400 // presumably in response to user action
2401 base::TimeTicks last_interaction_time_;
Daniel Cheng90196c82018-04-25 21:49:142402
[email protected]0dd3a0ab2011-02-18 08:17:442403 // See description above setter.
2404 bool closed_by_user_gesture_;
2405
Avi Drissman1a55a9d62020-03-10 18:56:452406 // The number of active fullscreen blockers.
2407 int fullscreen_blocker_count_ = 0;
2408
[email protected]0dd3a0ab2011-02-18 08:17:442409 // Minimum/maximum zoom percent.
danakj30f733132019-09-20 16:14:142410 const int minimum_zoom_percent_;
2411 const int maximum_zoom_percent_;
[email protected]0dd3a0ab2011-02-18 08:17:442412
w.shackleton49bcd392016-01-06 17:38:222413 // Used to correctly handle integer zooming through a smooth scroll device.
2414 float zoom_scroll_remainder_;
2415
[email protected]bcd2815602012-01-14 18:17:232416 // The intrinsic size of the page.
2417 gfx::Size preferred_size_;
2418
[email protected]222f5822014-02-05 23:40:492419 // The preferred size for content screen capture. When |capturer_count_| > 0,
2420 // this overrides |preferred_size_|.
2421 gfx::Size preferred_size_for_capture_;
2422
Jianzhou Fengd8720c72018-01-18 03:06:302423 // When device emulation is enabled, override the size of current and newly
2424 // created render views/widgets.
2425 gfx::Size device_emulation_size_;
2426 gfx::Size view_size_before_emulation_;
2427
Tom Burginf0e48622024-05-16 15:06:122428#if BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_IOS)
[email protected]8ed16472014-04-11 19:02:482429 // Holds information about a current color chooser dialog, if one is visible.
Bo Liu2bceebc2021-06-03 15:06:332430 class ColorChooserHolder;
2431 std::unique_ptr<ColorChooserHolder> color_chooser_holder_;
Julie Jeongeun Kim88ce9ec2023-07-28 02:25:402432#endif
[email protected]da8543762012-03-20 08:52:202433
[email protected]b24b68a2012-09-24 21:57:262434 // All live RenderWidgetHostImpls that are created by this object and may
2435 // outlive it.
Aman Vermaea1fcd02024-11-07 20:04:282436 base::flat_map<viz::FrameSinkId,
2437 raw_ptr<RenderWidgetHostImpl, SetExperimental>>
2438 created_widgets_;
[email protected]b24b68a2012-09-24 21:57:262439
alexmosc9e76ec2016-05-16 22:59:372440 // Process id of the shown fullscreen widget, or kInvalidUniqueID if there is
2441 // no fullscreen widget.
2442 int fullscreen_widget_process_id_;
2443
Tom Sepezcc69c442025-07-17 02:00:302444 // Routing id of the shown fullscreen widget or IPC::mojom::kRoutingIdNone
2445 // otherwise.
[email protected]44470a22013-01-24 01:21:542446 int fullscreen_widget_routing_id_;
2447
[email protected]0b431992014-06-24 00:08:032448 // At the time the fullscreen widget was being shut down, did it have focus?
2449 // This is used to restore focus to the WebContentsView after both: 1) the
2450 // fullscreen widget is destroyed, and 2) the WebContentsDelegate has
2451 // completed making layout changes to effect an exit from fullscreen mode.
2452 bool fullscreen_widget_had_focus_at_shutdown_;
2453
mariakhomenkoa4971c12015-07-21 19:04:372454 // When a new tab is created asynchronously, stores the OpenURLParams needed
2455 // to continue loading the page once the tab is ready.
dcheng59716272016-04-09 05:19:082456 std::unique_ptr<OpenURLParams> delayed_open_url_params_;
mariakhomenkoa4971c12015-07-21 19:04:372457
Nasko Oskov83a8cf92018-10-19 14:58:562458 // When a new tab is created with window.open(), navigation can be deferred
2459 // to execute asynchronously. In such case, the parameters need to be saved
2460 // for the navigation to be started at a later point.
2461 std::unique_ptr<NavigationController::LoadURLParams> delayed_load_url_params_;
HuanPo Lin0d795c62024-03-28 03:54:052462 base::OnceCallback<void(content::NavigationHandle&)>
2463 delayed_navigation_handle_callback_;
Nasko Oskov83a8cf92018-10-19 14:58:562464
[email protected]34ff1cfc2014-08-20 06:16:052465 // Whether overscroll should be unconditionally disabled.
2466 bool force_disable_overscroll_content_;
[email protected]e85165c642014-06-10 14:34:312467
[email protected]87de04b02014-04-08 22:14:492468 // Whether the last JavaScript dialog shown was suppressed. Used for testing.
2469 bool last_dialog_suppressed_;
2470
Miyoung Shin0f4480d2019-09-12 01:15:262471 mojo::Remote<device::mojom::GeolocationContext> geolocation_context_;
blundellc57b93f2014-10-29 13:19:572472
Gyuyoung Kim1bc1ba82021-02-08 23:32:442473 mojo::AssociatedRemote<blink::mojom::ContextMenuClient> context_menu_client_;
2474
blundelle75a8f92017-03-27 08:11:172475 std::unique_ptr<WakeLockContextHost> wake_lock_context_host_;
Thoren Paulsond344c0a2021-10-14 19:20:312476 bool enable_wake_locks_ = true;
alogvinovf50445a2015-10-30 13:00:122477
Rakina Zata Amni347b70902020-07-22 10:49:042478 // The last set/computed value of WebPreferences for this WebContents, either
2479 // set directly through SetWebPreferences, or set after recomputing values
Rakina Zata Amni4029b6d2020-07-28 02:36:202480 // from ComputeWebPreferences.
Gyuyoung Kim1ac4ca782020-09-11 03:32:512481 std::unique_ptr<blink::web_pref::WebPreferences> web_preferences_;
Rakina Zata Amni347b70902020-07-22 10:49:042482
Rakina Zata Amni4029b6d2020-07-28 02:36:202483 bool updating_web_preferences_ = false;
2484
Gyuyoung Kim9ce9ddda2025-06-19 02:01:142485#if BUILDFLAG(IS_ANDROID) || (BUILDFLAG(IS_IOS) && !BUILDFLAG(IS_IOS_TVOS))
Reilly Grantafbe2242020-02-20 21:14:552486 std::unique_ptr<NFCHost> nfc_host_;
2487#endif
2488
Julie Jeongeun Kim8e2879e2019-08-06 23:55:202489 mojo::ReceiverSet<blink::mojom::ColorChooserFactory>
2490 color_chooser_factory_receivers_;
Joel Hockey85b379d2017-12-11 10:42:132491
leon.hane4db177a2017-02-07 14:19:162492 std::unique_ptr<ScreenOrientationProvider> screen_orientation_provider_;
[email protected]01f83f92014-06-17 14:41:542493
[email protected]95640212014-07-26 18:14:302494 // The accessibility mode for all frames. This is queried when each frame
2495 // is created, and broadcast to all frames when it changes.
Doug Turner63f3c7b2017-07-29 05:10:012496 ui::AXMode accessibility_mode_;
[email protected]95640212014-07-26 18:14:302497
Alexander Surkov862feee2021-01-29 21:27:482498 std::unique_ptr<ui::AXEventRecorder> event_recorder_;
Abigail Kleinaa898742019-11-01 02:31:252499
Greg Thompsonf855bf882024-01-30 10:39:452500 // Enables ui::kAXModeBasic for the duration of a recording session.
2501 std::unique_ptr<ScopedAccessibilityMode> recording_mode_;
2502
avayvodcc85bbd2015-08-28 19:11:152503 // Monitors power levels for audio streams associated with this WebContents.
2504 AudioStreamMonitor audio_stream_monitor_;
2505
Max Morin5bc74f52018-05-09 07:00:212506 // Coordinates all the audio streams for this WebContents. Lazily initialized.
Dave Tapuska894bfb42024-11-04 22:44:352507 std::unique_ptr<ForwardingAudioStreamFactory> audio_stream_factory_;
Max Morin5bc74f52018-05-09 07:00:212508
Reilly Grant5e7c79b22019-04-09 17:26:202509 size_t bluetooth_connected_device_count_ = 0;
Ovidio Henriquez76696f62020-07-08 03:06:592510 size_t bluetooth_scanning_sessions_count_ = 0;
Reilly Grant5e7c79b22019-04-09 17:26:202511 size_t serial_active_frame_count_ = 0;
Matt Reynoldse8c6c1f2019-11-02 09:53:532512 size_t hid_active_frame_count_ = 0;
Matt Reynoldsed00ca7e72022-08-18 20:56:202513 size_t usb_active_frame_count_ = 0;
Yifan Luo8e5d3d52024-10-22 19:18:162514 size_t geolocation_active_frame_count_ = 0;
ortuno32e7db3c2016-03-29 16:14:202515
Austin Sullivanafefb722021-01-14 01:26:392516 size_t file_system_access_handle_count_ = 0;
Marijn Kruisselbrinkf1714aa22019-07-02 03:45:332517
sawtellea7333a82018-05-31 02:36:362518 bool has_picture_in_picture_video_ = false;
Klaus Weidnerd8219432022-02-08 21:50:592519 bool has_picture_in_picture_document_ = false;
sawtellea7333a82018-05-31 02:36:362520
dalecurtis88c240072015-12-09 02:11:182521 // Manages media players, CDMs, and power save blockers for media.
dcheng59716272016-04-09 05:19:082522 std::unique_ptr<MediaWebContentsObserver> media_web_contents_observer_;
qinmin58567c82015-01-07 21:00:202523
Aman Vermadf974d4d22024-09-30 18:12:492524 // RenderWidgetHostInputEventRouter is uniquely owned by WebContentsImpl in
2525 // the browser process.
2526 scoped_refptr<input::RenderWidgetHostInputEventRouter>
Kartar Singhb1bfa1a2024-06-24 13:14:572527 rwh_input_event_router_;
kenrb2a565f82015-09-02 20:24:592528
Aman Verma3047aa412024-05-28 09:09:242529 std::unique_ptr<TouchEmulatorImpl> touch_emulator_;
2530
ekaramadadd882292016-06-08 15:22:562531 // TextInputManager tracks the IME-related state for all the
2532 // RenderWidgetHostViews on this WebContents. Only exists on the outermost
2533 // WebContents and is automatically destroyed when a WebContents becomes an
2534 // inner WebContents by attaching to an outer WebContents. Then the
2535 // IME-related state for RenderWidgetHosts on the inner WebContents is tracked
2536 // by the TextInputManager in the outer WebContents.
2537 std::unique_ptr<TextInputManager> text_input_manager_;
2538
David Bokane86aa032022-05-08 18:21:242539 // Tests can set this to true in order to force this web contents to always
2540 // return nullptr for the above `text_input_manager_`, effectively blocking
2541 // IME events from propagating out of the renderer.
2542 bool suppress_ime_events_for_testing_ = false;
2543
lfgbee1e0a2016-06-08 21:24:212544 // Stores the RenderWidgetHost that currently holds a mouse lock or nullptr if
2545 // there's no RenderWidgetHost holding a lock.
Takumi Fujimoto4661871d2024-01-25 02:04:182546 raw_ptr<RenderWidgetHostImpl, DanglingUntriaged> pointer_lock_widget_ =
2547 nullptr;
Joe Downing192998b22018-03-22 15:51:362548
2549 // Stores the RenderWidgetHost that currently holds a keyboard lock or nullptr
2550 // if no RenderWidgetHost has the keyboard locked.
Ali Hijazi4d4e24092022-10-20 22:59:312551 raw_ptr<RenderWidgetHostImpl, DanglingUntriaged> keyboard_lock_widget_ =
2552 nullptr;
lfgbee1e0a2016-06-08 21:24:212553
Joe Downing13dd76b2018-04-09 18:32:152554 // Indicates whether the escape key is one of the requested keys to be locked.
2555 // This information is used to drive the browser UI so the correct exit
2556 // instructions are displayed to the user in fullscreen mode.
2557 bool esc_key_locked_ = false;
2558
Xiaohan Wang24ec9342022-01-15 17:34:222559#if BUILDFLAG(IS_ANDROID)
rockot400ea35b2016-10-15 19:15:322560 std::unique_ptr<service_manager::InterfaceProvider> java_interfaces_;
sammcf5f1b0f2016-09-20 23:05:112561#endif
2562
qinmin72e8bd02016-10-21 19:35:372563 // Whether this WebContents is for content overlay.
2564 bool is_overlay_content_;
2565
ekaramadf6750aa2017-06-06 18:29:422566 bool showing_context_menu_;
2567
Mounir Lamouri0f5bdf52019-04-04 16:32:352568 base::flat_map<MediaPlayerId, gfx::Size> cached_video_sizes_;
billorr21c005d2016-11-17 03:57:042569
mlamouri5cd9ae82017-02-18 11:05:092570 bool has_persistent_video_ = false;
2571
Ian Vollick5d5c37f2019-06-19 22:50:572572 bool is_spatial_navigation_disabled_ = false;
2573
Jinsuk Kimc8eac442024-07-19 18:33:522574#if BUILDFLAG(IS_ANDROID)
Yaroslav Shalivskyyd76a81f42024-10-21 20:08:202575 bool stylus_handwriting_enabled_ = false;
Jinsuk Kimc8eac442024-07-19 18:33:522576 bool long_press_link_select_text_ = false;
2577#endif
2578
Chris Hamiltondf0d72cd2018-05-29 16:23:532579 bool is_currently_audible_ = false;
Tommy Steimel18360512017-11-01 00:38:192580 bool was_ever_audible_ = false;
2581
Lukasz Anforowiczfd707142018-02-07 19:46:132582 // Helper variable for resolving races in UpdateTargetURL / ClearTargetURL.
Ali Hijazi4d4e24092022-10-20 22:59:312583 raw_ptr<RenderFrameHost, DanglingUntriaged> frame_that_set_last_target_url_ =
2584 nullptr;
Lukasz Anforowiczfd707142018-02-07 19:46:132585
Changwan Ryuc1134a82018-03-07 02:10:142586 // Whether we should override user agent in new tabs.
2587 bool should_override_user_agent_in_new_tabs_ = false;
2588
Becca Hughes6fe54e432018-06-09 04:18:562589 // Gets notified about changes in viewport fit events.
Donn Denmana6d91832023-11-28 21:25:462590 std::unique_ptr<SafeAreaInsetsHost> safe_area_insets_host_;
Becca Hughes6fe54e432018-06-09 04:18:562591
Arthur Sonzogni929d29f2018-09-17 14:19:442592 // Stores a set of frames that are fullscreen.
2593 // See https://fullscreen.spec.whatwg.org.
Ali Hijazi133b2d92024-02-09 14:01:522594 std::set<raw_ptr<RenderFrameHostImpl, SetExperimental>> fullscreen_frames_;
Becca Hughesfd5d8f892018-06-14 18:23:362595
Charlie Reis207e93c2023-10-04 23:48:492596 // Store an ID for the frame that is currently fullscreen, or an invalid ID if
2597 // there is none.
2598 GlobalRenderFrameHostId current_fullscreen_frame_id_ =
2599 GlobalRenderFrameHostId();
Becca Hughesfd5d8f892018-06-14 18:23:362600
Xiyuan Xia2a66b112018-12-06 15:52:162601 // Whether location bar should be focused by default. This is computed in
2602 // DidStartNavigation/DidFinishNavigation and only set for an initial
2603 // navigation triggered by the browser going to about:blank.
2604 bool should_focus_location_bar_by_default_ = false;
2605
Mike Jacksonf116a2e2021-06-09 16:48:302606 // Stores the rect of the Windows Control Overlay, which contains system UX
2607 // affordances (e.g. close), for installed desktop Progress Web Apps (PWAs),
2608 // if the app specifies the 'window-controls-overlay' DisplayMode in its
2609 // manifest. This is in frame space coordinates.
2610 gfx::Rect window_controls_overlay_rect_;
2611
Sam Davis Omekaradb307cf2024-03-05 00:15:412612 // Observe native theme for changes to dark mode, forced_colors, preferred
2613 // color scheme, and preferred contrast. Used to notify the renderer of
2614 // preferred color scheme and preferred contrast changes.
Sigurdur Asgeirsson103e2fb2020-11-10 00:50:162615 base::ScopedObservation<ui::NativeTheme, ui::NativeThemeObserver>
2616 native_theme_observation_{this};
Alison Maher7f366dc62020-03-03 19:46:002617
Shintaro Kawamura1042d572024-09-30 13:52:222618 base::ScopedObservation<SlowWebPreferenceCache,
2619 SlowWebPreferenceCacheObserver>
2620 slow_web_preference_cache_observation_{this};
2621
Alison Maher7f366dc62020-03-03 19:46:002622 bool using_dark_colors_ = false;
Sam Davis Omekaradb307cf2024-03-05 00:15:412623 bool in_forced_colors_ = false;
Alison Maher7f366dc62020-03-03 19:46:002624 ui::NativeTheme::PreferredColorScheme preferred_color_scheme_ =
Alison Maher60ddf6f2020-06-12 17:30:282625 ui::NativeTheme::PreferredColorScheme::kLight;
Alison Maher3b11e942020-10-27 17:17:502626 ui::NativeTheme::PreferredContrast preferred_contrast_ =
2627 ui::NativeTheme::PreferredContrast::kNoPreference;
Luke Warlowa9952932023-07-18 01:38:142628 bool prefers_reduced_transparency_ = false;
Luke Warlowa93b1ca2023-08-04 10:08:252629 bool inverted_colors_ = false;
Alison Maher7f366dc62020-03-03 19:46:002630
David Bokan1bdb3701f2021-04-30 22:02:352631 // Tracks clients who want to be notified when a JavaScript dialog is
2632 // dismissed.
2633 std::unique_ptr<JavaScriptDialogDismissNotifier>
2634 javascript_dialog_dismiss_notifier_;
Charlie Reis96077362019-07-04 00:34:042635
yilkal172da772019-11-06 22:49:072636 // The max number of loaded frames that have been seen in this WebContents.
2637 // This number is reset with each main frame navigation.
2638 size_t max_loaded_frame_count_ = 0;
yilkal796e89e2019-10-02 23:58:282639
yilkal172da772019-11-06 22:49:072640 // This boolean value is used to keep track of whether we finished the first
Khushal97d31e82021-06-23 21:07:542641 // successful navigation in this WebContents's primary main frame.
2642 bool first_primary_navigation_completed_ = false;
yilkal796e89e2019-10-02 23:58:282643
Mike Wassermanb213b9352020-04-16 00:32:342644 // Monitors system screen info changes to notify the renderer.
2645 std::unique_ptr<ScreenChangeMonitor> screen_change_monitor_;
2646
Mike Wassermandb8f4f02020-10-06 01:18:372647 // Records the last time we saw a screen orientation change.
Lan Weif81c6e7c2020-02-12 16:46:092648 base::TimeTicks last_screen_orientation_change_time_;
2649
Dominique Fauteux-Chapleau99244382020-07-08 20:37:002650 // Indicates how many sources are currently suppressing the unresponsive
2651 // renderer dialog.
2652 int suppress_unresponsive_renderer_count_ = 0;
2653
Aman Verma2e897242025-01-14 12:08:262654 // Stores the force enable zoom state for Accessibility.
2655 bool force_enable_zoom_ = false;
2656
Hiroki Nakagawa9bc09f22021-04-23 09:48:552657 std::unique_ptr<PrerenderHostRegistry> prerender_host_registry_;
Hiroki Nakagawa1cb14552021-04-23 03:37:342658
Kevin McNee097680d2023-04-05 22:14:512659 // Used to ignore multiple back navigation hints in rapid succession. For
2660 // example, we may get multiple hints due to imprecise mouse movement while
2661 // the user is trying to move the mouse to the back button.
2662 base::TimeTicks last_back_navigation_hint_time_ = base::TimeTicks::Min();
2663
Alexander Cooper987d046cc2021-04-14 00:07:212664 viz::FrameSinkId xr_render_target_;
2665
Elad Alonf156eb62021-05-17 22:02:372666 // Allows the app in the current WebContents to opt-in to exposing
2667 // information to apps that capture it.
2668 blink::mojom::CaptureHandleConfig capture_handle_config_;
2669
Bo Liub5e79d92021-06-12 01:40:412670 // Background color of the page set by the embedder to be passed to all
2671 // renderers attached to this WebContents, for use in the main frame.
2672 // It is used when the page has not loaded enough to know a background
2673 // color or if the page does not set a background color.
Arthur Sonzognic686e8f2024-01-11 08:36:372674 std::optional<SkColor> page_base_background_color_;
Bo Liub5e79d92021-06-12 01:40:412675
Nicolas Ouellet-Payeur177a6c42023-01-25 20:25:072676 // Stores WebContents::CreateParams::creator_location.
Lukasz Anforowicz2c1573a2021-09-21 18:58:182677 base::Location creator_location_;
2678
Nicolas Ouellet-Payeur177a6c42023-01-25 20:25:072679#if BUILDFLAG(IS_ANDROID)
2680 // Stores WebContents::CreateParams::java_creator_location.
2681 base::android::ScopedJavaGlobalRef<jthrowable> java_creator_location_;
2682#endif // BUILDFLAG(IS_ANDROID)
2683
Tommy Steimel57eafde2023-01-27 17:33:242684 // The options used for WebContents associated with a PictureInPicture window.
2685 // This value is the parameter given in
2686 // WebContents::CreateParams::picture_in_picture_options.
Arthur Sonzognic686e8f2024-01-11 08:36:372687 std::optional<blink::mojom::PictureInPictureWindowOptions>
Tommy Steimel57eafde2023-01-27 17:33:242688 picture_in_picture_options_;
Tommy Steimel991916c42022-06-24 20:59:572689
Tommy Steimel71f154462024-05-22 19:05:072690 // Only set if this WebContents represents a document picture-in-picture
2691 // window. This points to the WebContents that originally opened this
2692 // WebContents.
2693 base::WeakPtr<WebContents> picture_in_picture_opener_;
2694
Joe Mason1fc3e2e2021-11-02 05:25:072695 VisibleTimeRequestTrigger visible_time_request_trigger_;
2696
Andy Paicu5608bda82023-03-03 15:09:202697 // Counts the number of open scopes that disallow custom cursors in this web
2698 // contents. Custom cursors are allowed if this is 0.
2699 int disallow_custom_cursor_scope_count_ = 0;
2700
Bo Liu3afe2582023-08-11 23:02:562701 base::WeakPtr<FileChooserImpl> active_file_chooser_;
2702
Arthur Sonzognic686e8f2024-01-11 08:36:372703 std::optional<base::Location> ownership_location_;
Bo Liud4ced692023-09-18 21:17:142704
Aman Vermadf974d4d22024-09-30 18:12:492705 // This id is used by Viz to create RenderWidgetHostInputEventRouter per
2706 // WebContents(concept in browser) to allow grouping CompositorFrameSinks for
2707 // input event routing with InputVizard.
Aman Verma7908f9562024-12-13 18:45:482708 const base::UnguessableToken compositor_frame_sink_grouping_id_;
Aman Vermadf974d4d22024-09-30 18:12:492709
Takashi Toyoshima8dfc05c2024-01-29 21:03:512710 // Indicates if the instance is hosted in a preview window.
2711 // This will be set in Init() and will be reset in WillActivatePreviewPage().
2712 bool is_in_preview_mode_ = false;
2713
David Tsengc3853d0b02024-02-15 16:35:102714 // Indicates accessibility had an unrecoverable error.
Aaron Leventhal6ceb5882024-04-17 15:19:382715 bool unrecoverable_accessibility_error_ = false;
David Tsengc3853d0b02024-02-15 16:35:102716
Xiao Ma29b2d1e62024-06-13 06:17:092717 // The network handle bound to the target network, is used to handle the
2718 // loading requests over a specific network. The network handle is set when
2719 // WebContents is created and will not change during the life cycle of
2720 // WebContents.
Jacob Francis0043f242024-07-24 21:46:212721 net::handles::NetworkHandle target_network_ =
2722 net::handles::kInvalidNetworkHandle;
Xiao Ma29b2d1e62024-06-13 06:17:092723
Ari Chivukula41f7bfc92024-07-17 18:16:012724 // Whether this contents represents a window initially opened as a new popup.
2725 bool is_popup_{false};
2726
Fabio Muratori8ff26892025-05-06 19:07:212727 // The window open disposition that was originally requested
2728 // when this WebContents was created.
2729 WindowOpenDisposition original_window_open_disposition_ =
2730 WindowOpenDisposition::UNKNOWN;
2731
Ari Chivukula2d8d5e02024-11-04 20:09:572732 // If this window was opened as a new partitioned popin this will contain the
2733 // properties needed to setup partitioning which aligns with the opener.
2734 // See https://explainers-by-googlers.github.io/partitioned-popins/
2735 std::optional<PartitionedPopinOpenerProperties>
2736 partitioned_popin_opener_properties_;
2737
Ari Chivukulae22828e2024-08-17 02:44:062738 // If this window was opened as a new partitioned popin this will be the
Giovanni Ortuno Urquidi94e37f692024-10-31 06:25:152739 // frame of the opener. This will only have a value if `is_popup_` is true.
2740 // If the opener frame is deleted the popin should be closed by
Ari Chivukula2d8d5e02024-11-04 20:09:572741 // `PartitionedPopinsController`. This is not a good indicator of whether this
2742 // window is a popin as it may go away before the popin closes.
Ari Chivukulae22828e2024-08-17 02:44:062743 // See https://explainers-by-googlers.github.io/partitioned-popins/
2744 base::WeakPtr<RenderFrameHostImpl> partitioned_popin_opener_;
Ari Chivukula9390bf12024-08-14 18:08:012745
Ari Chivukulaee503052024-08-30 20:33:532746 // Each window can have at most one open partitioned popin, and this will be a
2747 // pointer to it. If this is set `partitioned_popin_opener_` must be null as
2748 // no popin can open a popin.
2749 // See https://explainers-by-googlers.github.io/partitioned-popins/
Ari Chivukulaee503052024-08-30 20:33:532750 base::WeakPtr<WebContents> opened_partitioned_popin_;
2751
Andrew Verge146fe632025-07-08 14:12:112752 // Tracks the number of same-site fenced frames in the viewport per top-level
2753 // page load and stores it in the primary main frame's PageUserData. Metrics
2754 // are logged via UMA every time the PageUserData is destroyed.
2755 std::unique_ptr<FencedFrameViewportObserver> fenced_frame_viewport_observer_;
2756
Aldo Culquicondor88fe3962025-01-21 16:04:262757#if BUILDFLAG(IS_ANDROID)
2758 bool supports_forward_transition_animation_ = true;
2759#endif // !BUILDFLAG(IS_ANDROID)
2760
Jeremy Roman3bca4bf2019-07-11 03:41:252761 base::WeakPtrFactory<WebContentsImpl> loading_weak_factory_{this};
2762 base::WeakPtrFactory<WebContentsImpl> weak_factory_{this};
[email protected]0dd3a0ab2011-02-18 08:17:442763};
2764
nickf9acfbe2014-12-23 19:12:372765// Dangerous methods which should never be made part of the public API, so we
2766// grant their use only to an explicit friend list (c++ attorney/client idiom).
benwells5e7260d2017-03-20 23:36:332767class CONTENT_EXPORT WebContentsImpl::FriendWrapper {
Avi Drissmana9114822018-03-23 18:25:552768 public:
2769 using CreatedCallback = base::RepeatingCallback<void(WebContents*)>;
2770
Peter Boström9b036532021-10-28 23:37:282771 FriendWrapper(const FriendWrapper&) = delete;
2772 FriendWrapper& operator=(const FriendWrapper&) = delete;
2773
nickf9acfbe2014-12-23 19:12:372774 private:
Elly Fong-Jones564de6262022-07-28 21:11:162775 friend base::CallbackListSubscription RegisterWebContentsCreationCallback(
2776 base::RepeatingCallback<void(WebContents*)>);
nickf9acfbe2014-12-23 19:12:372777
benwells5e7260d2017-03-20 23:36:332778 FriendWrapper(); // Not instantiable.
nickf9acfbe2014-12-23 19:12:372779
Elly Fong-Jones564de6262022-07-28 21:11:162780 // Adds a callback called on creation of each new WebContents.
2781 static base::CallbackListSubscription AddCreatedCallbackForTesting(
2782 const CreatedCallback& callback);
nickf9acfbe2014-12-23 19:12:372783};
2784
[email protected]8ff00d72012-10-23 19:12:212785} // namespace content
2786
[email protected]93ddb3c2012-04-11 21:44:292787#endif // CONTENT_BROWSER_WEB_CONTENTS_WEB_CONTENTS_IMPL_H_