blob: 27510ec1c52fa31545c6c045c9fc1af39b502003 [file] [log] [blame]
[email protected]227692c52013-05-31 22:43:041// Copyright 2013 The Chromium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef CONTENT_RENDERER_RENDER_FRAME_IMPL_H_
6#define CONTENT_RENDERER_RENDER_FRAME_IMPL_H_
7
avi1023d012015-12-25 02:39:148#include <stddef.h>
9#include <stdint.h>
10
Charles Reis37c95492016-10-21 20:38:5811#include <map>
dchengcedca5612016-04-09 01:40:1512#include <memory>
thestige62f7382016-11-08 18:31:3913#include <set>
guidou3906a722015-11-12 22:14:4214#include <string>
Mark Lieu6cf3e8fa2019-03-09 02:09:0115#include <unordered_set>
Balazs Engedyba034e72017-10-27 22:26:2816#include <utility>
[email protected]7a4e2532013-12-02 21:30:0217#include <vector>
18
liberatoa8da3b52017-05-02 20:23:5119#include "base/callback.h"
Brett Wilsonf976d3f2017-08-18 17:23:3920#include "base/containers/id_map.h"
[email protected]7a4e2532013-12-02 21:30:0221#include "base/files/file_path.h"
[email protected]a09d53ce2014-01-31 00:46:4222#include "base/gtest_prod_util.h"
avi1023d012015-12-25 02:39:1423#include "base/macros.h"
Sadrul Habib Chowdhury403923e2020-10-01 09:53:1624#include "base/memory/read_only_shared_memory_region.h"
lukaszabb2101b82016-06-17 16:52:2525#include "base/memory/ref_counted.h"
[email protected]abc501e2014-01-27 19:27:2626#include "base/memory/weak_ptr.h"
[email protected]2e2d9632013-12-03 00:55:2627#include "base/observer_list.h"
liberatoa8da3b52017-05-02 20:23:5128#include "base/optional.h"
[email protected]7a4e2532013-12-02 21:30:0229#include "base/process/process_handle.h"
altimin06fe10c2017-01-20 11:28:1530#include "base/single_thread_task_runner.h"
liberatoa8da3b52017-05-02 20:23:5131#include "base/unguessable_token.h"
Avi Drissman4544828f2019-03-11 20:37:3232#include "base/values.h"
avi1023d012015-12-25 02:39:1433#include "build/build_config.h"
Dave Tapuskafc4adbae2020-12-02 22:08:5934#include "cc/input/browser_controls_state.h"
Scott Violetc78fef732018-03-06 17:42:5335#include "content/common/buildflags.h"
Mark Lieuc48b6cc2019-03-13 22:55:5736#include "content/common/download/mhtml_file_writer.mojom.h"
ben76f52b242016-06-18 05:42:4837#include "content/common/frame.mojom.h"
danakjf2342432019-05-15 21:46:0938#include "content/common/frame_delete_intention.h"
Lucas Furukawa Gadania9c45682019-07-31 22:05:1439#include "content/common/navigation_params.mojom.h"
Mario Sanchez Prada60a014b72020-02-20 19:08:0640#include "content/common/render_accessibility.mojom.h"
rockot53be7caf2016-10-04 20:17:0841#include "content/common/renderer.mojom.h"
Miyoung Shin072d4052020-07-13 07:52:4442#include "content/common/web_ui.mojom.h"
Adam Parker6a19ba342018-01-08 23:40:2043#include "content/public/common/fullscreen_video_element.mojom.h"
[email protected]65920f332014-03-04 21:14:1844#include "content/public/common/referrer.h"
paulmeyer5d0a5f02016-01-21 20:15:5245#include "content/public/common/stop_find_action.h"
danakj6a816592018-09-25 18:30:5646#include "content/public/common/widget_type.h"
[email protected]227692c52013-05-31 22:43:0447#include "content/public/renderer/render_frame.h"
Sergey Volk8b09c2c52018-12-12 23:20:4048#include "content/public/renderer/render_frame_media_playback_options.h"
Hiroki Nakagawaea68b642018-04-13 06:24:4249#include "content/public/renderer/websocket_handshake_throttle_provider.h"
Andy Paicucd1e4e02018-05-16 09:59:2050#include "content/renderer/content_security_policy_util.h"
skyostilb4cce1b2016-03-31 17:56:3451#include "content/renderer/frame_blame_context.h"
chcunningham86f025e32017-05-30 20:43:2352#include "content/renderer/media/media_factory.h"
Erik Chen10e9b022019-08-21 23:33:2353#include "content/renderer/render_widget.h"
[email protected]227692c52013-05-31 22:43:0454#include "ipc/ipc_message.h"
lukasza70b79c82015-12-14 20:24:1355#include "ipc/ipc_platform_file.h"
liberatoa8da3b52017-05-02 20:23:5156#include "media/base/routing_token_callback.h"
Evan Liu47f798a2020-06-23 20:27:0957#include "media/base/speech_recognition_client.h"
Shimi Zhangbb738072019-07-09 18:54:4058#include "mojo/public/cpp/bindings/associated_receiver.h"
Mario Sanchez Pradab3b852f2019-10-04 17:53:2459#include "mojo/public/cpp/bindings/associated_remote.h"
Julie Jeongeun Kimed2e5ba72019-09-12 10:14:1760#include "mojo/public/cpp/bindings/pending_associated_receiver.h"
Julie Jeongeun Kim02291d732019-09-07 03:08:5861#include "mojo/public/cpp/bindings/pending_receiver.h"
Miyoung Shin2be9da72019-09-04 09:04:1062#include "mojo/public/cpp/bindings/pending_remote.h"
Henrique Ferreiro3a9751c2019-09-30 13:54:0763#include "mojo/public/cpp/bindings/receiver.h"
Gyuyoung Kim6c9ce9022019-11-26 05:40:0864#include "mojo/public/cpp/bindings/receiver_set.h"
Julie Jeongeun Kim44b804b22019-08-15 06:14:5565#include "mojo/public/cpp/bindings/remote.h"
scottmgefb697302017-04-12 22:37:3066#include "mojo/public/cpp/system/data_pipe.h"
Scott Violet02e38b92018-03-27 23:42:1467#include "ppapi/buildflags/buildflags.h"
Ken Rockot54311e62018-02-10 19:01:5268#include "services/network/public/mojom/url_loader_factory.mojom.h"
Lucas Furukawa Gadania6917ab2019-10-01 17:37:3169#include "services/network/public/mojom/url_response_head.mojom-forward.h"
ben803dba302017-04-27 20:41:4970#include "services/service_manager/public/cpp/binder_registry.h"
Ken Rockot543f5e32018-02-04 02:13:5071#include "services/service_manager/public/mojom/interface_provider.mojom.h"
Ken Rockot26e4e802018-07-31 15:03:3372#include "third_party/blink/public/common/associated_interfaces/associated_interface_provider.h"
73#include "third_party/blink/public/common/associated_interfaces/associated_interface_registry.h"
Oksana Zhuravlovafee097c2019-07-26 17:01:3074#include "third_party/blink/public/common/browser_interface_broker_proxy.h"
arthursonzogni76098e52020-11-25 14:18:4575#include "third_party/blink/public/common/feature_policy/document_policy.h"
Blink Reformata30d4232018-04-07 15:31:0676#include "third_party/blink/public/common/feature_policy/feature_policy.h"
Sergio Villar Senin0c142fa2019-10-16 08:18:5977#include "third_party/blink/public/common/loader/loading_behavior_flag.h"
Hiroki Nakagawa41366152020-07-27 18:31:4078#include "third_party/blink/public/common/loader/previews_state.h"
Sergio Villar Senind7f2ee7f2019-10-17 09:02:4179#include "third_party/blink/public/common/navigation/triggering_event_info.h"
Mario Sanchez Prada0bd8b8c2020-10-21 17:49:2380#include "third_party/blink/public/common/renderer_preferences/renderer_preferences.h"
Miyoung Shin3e6393c2020-09-18 13:37:2081#include "third_party/blink/public/common/unique_name/unique_name_helper.h"
Julie Jeongeun Kimdaa631e2019-02-21 14:17:2582#include "third_party/blink/public/mojom/autoplay/autoplay.mojom.h"
Kent Tamura48c549d02018-09-27 17:19:5483#include "third_party/blink/public/mojom/choosers/file_chooser.mojom.h"
Julie Jeongeun Kim42a90df2019-03-20 23:13:1084#include "third_party/blink/public/mojom/commit_result/commit_result.mojom.h"
Abhijeet Kandalkara5928a0a2019-03-13 05:04:4285#include "third_party/blink/public/mojom/devtools/console_message.mojom.h"
Richard Lie6899952018-11-30 08:42:0086#include "third_party/blink/public/mojom/fetch/fetch_api_request.mojom.h"
Antonio Gomes58d38062020-04-30 01:50:1487#include "third_party/blink/public/mojom/frame/frame_owner_element_type.mojom.h"
Julie Jeongeun Kim70a2e4e2020-02-21 05:09:5488#include "third_party/blink/public/mojom/frame/frame_owner_properties.mojom-forward.h"
Antonio Sartoria1fd1432020-11-25 09:10:2089#include "third_party/blink/public/mojom/frame/policy_container.mojom-shared.h"
Antonio Gomes4b2c5132020-01-16 11:49:4890#include "third_party/blink/public/mojom/frame/user_activation_update_types.mojom.h"
Miyoung Shinff5aff32020-01-25 04:15:2591#include "third_party/blink/public/mojom/input/focus_type.mojom-forward.h"
Minggang Wangd712a912020-07-10 08:12:3592#include "third_party/blink/public/mojom/loader/resource_load_info.mojom.h"
93#include "third_party/blink/public/mojom/loader/resource_load_info_notifier.mojom.h"
Guido Urdaneta3a7cd9e62020-07-21 08:31:2894#include "third_party/blink/public/mojom/media/renderer_audio_input_stream_factory.mojom.h"
Matt Falkenhagen98515e972018-06-20 08:12:4895#include "third_party/blink/public/mojom/service_worker/service_worker_object.mojom.h"
Majid Valipourb9ee0972019-08-22 15:16:2396#include "third_party/blink/public/mojom/use_counter/css_property_id.mojom.h"
Minggang Wang035abc12020-11-05 03:05:1597#include "third_party/blink/public/platform/child_url_loader_factory_bundle.h"
Blink Reformata30d4232018-04-07 15:31:0698#include "third_party/blink/public/platform/web_media_player.h"
Blink Reformata30d4232018-04-07 15:31:0699#include "third_party/blink/public/web/web_ax_object.h"
100#include "third_party/blink/public/web/web_document_loader.h"
Blink Reformata30d4232018-04-07 15:31:06101#include "third_party/blink/public/web/web_frame_load_type.h"
102#include "third_party/blink/public/web/web_frame_serializer_client.h"
103#include "third_party/blink/public/web/web_history_commit_type.h"
Miyoung Shin6acc5d52020-11-22 04:10:38104#include "third_party/blink/public/web/web_local_frame.h"
Mustaq Ahmed55944cb2018-05-25 20:44:27105#include "third_party/blink/public/web/web_local_frame_client.h"
Blink Reformata30d4232018-04-07 15:31:06106#include "third_party/blink/public/web/web_meaningful_layout.h"
107#include "third_party/blink/public/web/web_script_execution_callback.h"
Nektarios Paisios56ee9982020-04-22 07:53:06108#include "ui/accessibility/ax_event.h"
Dominic Mazzoni90501482018-09-05 22:43:31109#include "ui/accessibility/ax_mode.h"
[email protected]4ee64622014-03-21 22:34:15110#include "ui/gfx/range/range.h"
lukaszaede9cc02015-12-30 23:48:32111#include "url/gurl.h"
dominickn6c1f1cf2016-12-20 06:13:33112#include "url/origin.h"
[email protected]227692c52013-05-31 22:43:04113
[email protected]7a4e2532013-12-02 21:30:02114namespace blink {
Minoru Chikamunee9eb7f92020-10-26 04:15:16115namespace scheduler {
116class WebAgentGroupScheduler;
117} // namespace scheduler
118
Minggang Wange0d5db32020-10-07 15:55:31119class WeakWrapperResourceLoadInfoNotifier;
Meredith Lane4947b2d72018-01-24 20:54:28120class WebComputedAXTree;
[email protected]82ce5b92014-03-22 05:15:26121class WebContentDecryptionModule;
Ehsan Karamaded879582018-08-08 02:02:29122class WebElement;
Hiroki Nakagawa8600c372020-07-23 01:53:26123class WebFrameRequestBlocker;
lukasza2f44efa2017-06-06 23:49:51124class WebLocalFrame;
Guido Urdanetadc7090372019-07-29 17:59:54125class WebMediaStreamDeviceObserver;
[email protected]82ce5b92014-03-22 05:15:26126class WebSecurityOrigin;
Ehsan Karamaded879582018-08-08 02:02:29127class WebString;
128class WebURL;
Avi Drissman6ed86dc32018-03-03 00:29:24129struct FramePolicy;
[email protected]a09d53ce2014-01-31 00:46:42130struct WebContextMenuData;
thestig4c8f2a72016-08-13 01:39:11131} // namespace blink
[email protected]7a4e2532013-12-02 21:30:02132
133namespace gfx {
[email protected]a09d53ce2014-01-31 00:46:42134class Point;
[email protected]7a4e2532013-12-02 21:30:02135class Range;
Adithya Srinivasan57f44d0d2019-03-22 15:36:02136} // namespace gfx
[email protected]7a4e2532013-12-02 21:30:02137
jrummell109c3a602014-12-18 01:08:50138namespace media {
xhwang60b430a2015-02-01 05:20:46139class MediaPermission;
chcunningham86f025e32017-05-30 20:43:23140}
jrummell109c3a602014-12-18 01:08:50141
tommycli58e3172c2015-09-15 18:18:26142namespace url {
143class Origin;
144}
145
[email protected]227692c52013-05-31 22:43:04146namespace content {
147
Tal Pressmanb011b2962020-09-28 11:22:55148class AgentSchedulingGroup;
sammc7f964632016-10-14 04:16:21149class BlinkInterfaceRegistryImpl;
kenrba7199832015-01-22 23:44:59150class CompositorDependencies;
Dmitry Gozmanf5b5c5c2019-02-07 00:32:32151class DocumentState;
xhwang5206d4e62016-02-05 02:09:55152class MediaPermissionDispatcher;
Arthur Hemeryd3011f62018-05-30 10:38:44153class NavigationClient;
[email protected]7a4e2532013-12-02 21:30:02154class PepperPluginInstanceImpl;
155class RendererPpapiHost;
Mario Sanchez Prada60a014b72020-02-20 19:08:06156class RenderAccessibilityManager;
[email protected]2e2d9632013-12-03 00:55:26157class RenderFrameObserver;
[email protected]227692c52013-05-31 22:43:04158class RenderViewImpl;
[email protected]7a4e2532013-12-02 21:30:02159class RenderWidget;
[email protected]a09d53ce2014-01-31 00:46:42160struct CustomContextMenuContext;
alexmosbc7eafa2014-12-06 01:38:09161struct FrameReplicationState;
[email protected]227692c52013-05-31 22:43:04162
[email protected]85d85fd2013-06-19 00:57:41163class CONTENT_EXPORT RenderFrameImpl
164 : public RenderFrame,
Minggang Wange0d5db32020-10-07 15:55:31165 public blink::mojom::ResourceLoadInfoNotifier,
Becca Hughes3da69b742018-04-13 19:05:06166 blink::mojom::AutoplayConfigurationClient,
Nico Weber43ddd7a32017-08-15 19:19:27167 mojom::Frame,
Ken Rockot48785452017-10-25 19:33:14168 mojom::FrameNavigationControl,
Adam Parker6a19ba342018-01-08 23:40:20169 mojom::FullscreenVideoElementHandler,
Nico Weber43ddd7a32017-08-15 19:19:27170 mojom::FrameBindingsControl,
Mark Lieu6cf3e8fa2019-03-09 02:09:01171 mojom::MhtmlFileWriter,
Mustaq Ahmed55944cb2018-05-25 20:44:27172 public blink::WebLocalFrameClient,
Nico Weber43ddd7a32017-08-15 19:19:27173 service_manager::mojom::InterfaceProvider {
[email protected]227692c52013-05-31 22:43:04174 public:
dchengc5ef1a52015-08-26 20:58:30175 // Creates a new RenderFrame as the main frame of |render_view|.
dcheng3ce04b62015-10-26 23:30:55176 static RenderFrameImpl* CreateMainFrame(
Tal Pressmanb011b2962020-09-28 11:22:55177 AgentSchedulingGroup& agent_scheduling_group,
dcheng3ce04b62015-10-26 23:30:55178 RenderViewImpl* render_view,
dcheng9e24bd352016-03-01 19:15:51179 CompositorDependencies* compositor_deps,
Daniel Chengd5e56ff2017-06-24 07:44:02180 blink::WebFrame* opener,
Dave Tapuska437e5d92020-10-26 17:59:36181 mojom::CreateViewParamsPtr* params);
[email protected]2f61bdd2013-07-02 18:38:47182
arthursonzogni1efc7b962019-03-14 09:36:33183 // Creates a new RenderFrame with |routing_id|. If |previous_routing_id| is
alexmosa181efc2015-09-03 00:39:04184 // MSG_ROUTING_NONE, it creates the Blink WebLocalFrame and inserts it into
arthursonzogni1efc7b962019-03-14 09:36:33185 // the frame tree after the frame identified by |previous_sibling_routing_id|,
186 // or as the first child if |previous_sibling_routing_id| is MSG_ROUTING_NONE.
187 // Otherwise, the frame is semi-orphaned until it commits, at which point it
188 // replaces the previous object identified by |previous_routing_id|. The
189 // previous object can either be a RenderFrame or a RenderFrameProxy.
Pavel Feldman25234722017-10-11 02:49:06190 // The frame's opener is set to the frame identified by |opener_routing_id|.
191 // The frame is created as a child of the RenderFrame identified by
192 // |parent_routing_id| or as the top-level frame if
193 // the latter is MSG_ROUTING_NONE.
194 // |devtools_frame_token| is passed from the browser and corresponds to the
arthursonzogni1efc7b962019-03-14 09:36:33195 // owner FrameTreeNode. It can only be used for tagging requests and calls
Pavel Feldman25234722017-10-11 02:49:06196 // for context frame attribution. It should never be passed back to the
197 // browser as a frame identifier in the control flows calls.
danakjcbf13042019-09-18 21:01:47198 // The |widget_params| is not null if the frame is to be a local root, which
199 // means it will own a RenderWidget, in which case the |widget_params| hold
200 // the routing id and initialization properties for the RenderWidget.
Pavel Feldman25234722017-10-11 02:49:06201 //
202 // Note: This is called only when RenderFrame is being created in response
203 // to IPC message from the browser process. All other frame creation is driven
204 // through Blink and Create.
Balazs Engedyba034e72017-10-27 22:26:28205 static void CreateFrame(
Tal Pressmanb011b2962020-09-28 11:22:55206 AgentSchedulingGroup& agent_scheduling_group,
Balazs Engedyba034e72017-10-27 22:26:28207 int routing_id,
Oksana Zhuravlovafee097c2019-07-26 17:01:30208 mojo::PendingRemote<blink::mojom::BrowserInterfaceBroker>
209 browser_interface_broker,
arthursonzogni1efc7b962019-03-14 09:36:33210 int previous_routing_id,
Chris Hamilton303ad9b2020-09-17 13:57:22211 const base::Optional<base::UnguessableToken>& opener_frame_token,
Balazs Engedyba034e72017-10-27 22:26:28212 int parent_routing_id,
213 int previous_sibling_routing_id,
Dave Tapuska84449382020-05-01 00:39:04214 const base::UnguessableToken& frame_token,
Balazs Engedyba034e72017-10-27 22:26:28215 const base::UnguessableToken& devtools_frame_token,
216 const FrameReplicationState& replicated_state,
217 CompositorDependencies* compositor_deps,
Dave Tapuska8499eec2020-03-16 17:54:30218 mojom::CreateFrameWidgetParamsPtr widget_params,
Julie Jeongeun Kim70a2e4e2020-02-21 05:09:54219 blink::mojom::FrameOwnerPropertiesPtr frame_owner_properties,
Antonio Sartori7f809cc72020-10-30 07:47:20220 bool has_committed_real_load,
Antonio Sartori9290b6b2020-11-09 10:09:33221 blink::mojom::PolicyContainerPtr policy_container);
[email protected]82307f6b2014-08-07 03:30:12222
[email protected]5a7100d2014-05-19 01:29:04223 // Returns the RenderFrameImpl for the given routing ID.
224 static RenderFrameImpl* FromRoutingID(int routing_id);
225
[email protected]a5ac6dc2014-01-15 07:02:14226 // Just like RenderFrame::FromWebFrame but returns the implementation.
227 static RenderFrameImpl* FromWebFrame(blink::WebFrame* web_frame);
[email protected]b70da4c2014-01-06 19:57:09228
danakj5a7b1932018-07-20 15:44:09229 // Constructor parameters are bundled into a struct.
Balazs Engedyba034e72017-10-27 22:26:28230 struct CONTENT_EXPORT CreateParams {
Tal Pressmanb011b2962020-09-28 11:22:55231 CreateParams(AgentSchedulingGroup& agent_scheduling_group,
232 RenderViewImpl* render_view,
Gyuyoung Kim6c9ce9022019-11-26 05:40:08233 int32_t routing_id,
Gyuyoung Kim6c9ce9022019-11-26 05:40:08234 mojo::PendingRemote<blink::mojom::BrowserInterfaceBroker>
235 browser_interface_broker,
236 const base::UnguessableToken& devtools_frame_token);
Balazs Engedyba034e72017-10-27 22:26:28237 ~CreateParams();
238
239 CreateParams(CreateParams&&);
240 CreateParams& operator=(CreateParams&&);
jochen664198b2015-06-25 14:13:00241
Tal Pressmanb011b2962020-09-28 11:22:55242 AgentSchedulingGroup* agent_scheduling_group;
jochen664198b2015-06-25 14:13:00243 RenderViewImpl* render_view;
avi1023d012015-12-25 02:39:14244 int32_t routing_id;
Oksana Zhuravlovafee097c2019-07-26 17:01:30245 mojo::PendingRemote<blink::mojom::BrowserInterfaceBroker>
246 browser_interface_broker;
Pavel Feldman25234722017-10-11 02:49:06247 base::UnguessableToken devtools_frame_token;
jochen664198b2015-06-25 14:13:00248 };
249
Balazs Engedyba034e72017-10-27 22:26:28250 using CreateRenderFrameImplFunction = RenderFrameImpl* (*)(CreateParams);
danakj6a816592018-09-25 18:30:56251
Albert J. Wong2727e8a82019-02-15 16:56:11252 // Web tests override the creation of RenderFrames in order to inject a
253 // partial testing fake.
254 static void InstallCreateHook(CreateRenderFrameImplFunction create_frame);
[email protected]2f61bdd2013-07-02 18:38:47255
arthursonzogni7fe226e2020-03-09 15:24:37256 // Looks up and returns the WebFrame corresponding to a given frame routing
257 // ID.
258 static blink::WebFrame* ResolveWebFrame(int opener_frame_routing_id);
alexmos95733002015-08-24 16:38:09259
Yao Xiaoaf79ca9b2019-03-12 19:54:18260 // Possibly set the kOpenerCrossOrigin and kSandboxNoGesture policy in
261 // |download_policy|.
Yao Xiao2c1171a2019-04-01 23:44:32262 static void MaybeSetDownloadFramePolicy(
Charlie Harrison8c113a32019-01-07 16:08:29263 bool is_opener_navigation,
264 const blink::WebURLRequest& request,
Yao Xiaoaf79ca9b2019-03-12 19:54:18265 const blink::WebSecurityOrigin& current_origin,
266 bool has_download_sandbox_flag,
Yao Xiao2cc17412019-11-25 09:04:40267 bool blocking_downloads_in_sandbox_enabled,
Yao Xiao2c1171a2019-04-01 23:44:32268 bool from_ad,
Yao Xiaoaf79ca9b2019-03-12 19:54:18269 NavigationDownloadPolicy* download_policy);
Charlie Harrison8c113a32019-01-07 16:08:29270
kdsilvae0135592016-08-09 17:08:11271 // Overwrites the given URL to use an HTML5 embed if possible.
Blink Reformat1c4d759e2017-04-09 16:34:54272 blink::WebURL OverrideFlashEmbedWithHTML(const blink::WebURL& url) override;
kdsilvae0135592016-08-09 17:08:11273
avi5c77d212015-09-25 20:08:25274 ~RenderFrameImpl() override;
[email protected]227692c52013-05-31 22:43:04275
Daniel Cheng999698bd2017-03-22 04:56:37276 // Returns the unique name of the RenderFrame.
277 const std::string& unique_name() const { return unique_name_helper_.value(); }
278
[email protected]7a4e2532013-12-02 21:30:02279 // TODO(jam): this is a temporary getter until all the code is transitioned
280 // to using RenderFrame instead of RenderView.
wjmaclean2a6cab72016-11-03 18:36:40281 RenderViewImpl* render_view() { return render_view_; }
[email protected]7a4e2532013-12-02 21:30:02282
[email protected]7a4e2532013-12-02 21:30:02283 // Returns the RenderWidget associated with this frame.
Albert J. Wong7bbf22d2018-12-20 00:27:27284 RenderWidget* GetLocalRootRenderWidget();
danakjd370dbb2020-05-21 17:54:38285 // Returns the blink::WebFrameWidget attached to the RenderWidget that is
286 // associated with this frame.
287 blink::WebFrameWidget* GetLocalRootWebFrameWidget();
[email protected]7a4e2532013-12-02 21:30:02288
danakjdb106b22020-04-24 15:56:31289 // This method must be called after the WebLocalFrame backing this RenderFrame
290 // has been created and added to the frame tree. It creates all objects that
291 // depend on the frame being at its proper spot.
292 //
293 // Virtual for web tests to inject their own behaviour into the WebLocalFrame.
Keishi Hattorif5ec9b12020-08-26 20:29:43294 virtual void Initialize(blink::WebFrame* parent);
[email protected]0287e762014-04-11 13:07:58295
[email protected]723971b2014-02-12 11:08:25296 // Start/Stop loading notifications.
297 // TODO(nasko): Those are page-level methods at this time and come from
Mustaq Ahmed55944cb2018-05-25 20:44:27298 // WebViewClient. We should move them to be WebLocalFrameClient calls and put
[email protected]723971b2014-02-12 11:08:25299 // logic in the browser side to balance starts/stops.
Camille Lamyefd54b02018-10-04 16:54:14300 void DidStartLoading() override;
Blink Reformat1c4d759e2017-04-09 16:34:54301 void DidStopLoading() override;
[email protected]723971b2014-02-12 11:08:25302
Mario Sanchez Prada60a014b72020-02-20 19:08:06303 // Returns the object implementing the RenderAccessibility mojo interface and
304 // serves as a bridge between RenderFrameImpl and RenderAccessibilityImpl.
305 RenderAccessibilityManager* GetRenderAccessibilityManager() {
306 return render_accessibility_manager_.get();
Sergey Poromov79fbef222020-02-20 14:13:57307 }
Mario Sanchez Prada68d4bec2020-02-20 13:42:05308
Mario Sanchez Prada60a014b72020-02-20 19:08:06309 // Called from RenderAccessibilityManager to let the RenderFrame know when the
310 // accessibility mode has changed, so that it can notify its observers.
311 void NotifyAccessibilityModeChange(ui::AXMode new_mode);
312
Alex Moshchuk43076622017-09-08 21:20:44313 // Whether or not the frame is currently swapped into the frame tree. If
314 // this is false, this is a provisional frame which has not committed yet,
315 // and which will swap with a proxy when it commits.
316 //
317 // TODO(https://crbug.com/578349): Remove this once provisional frames are
318 // gone, and clean up code that depends on it.
319 bool in_frame_tree() { return in_frame_tree_; }
320
brettw4b461082016-11-19 18:55:16321#if BUILDFLAG(ENABLE_PLUGINS)
[email protected]271ff5792013-12-04 22:29:31322 // Notification that a PPAPI plugin has been created.
323 void PepperPluginCreated(RendererPpapiHost* host);
324
[email protected]7a4e2532013-12-02 21:30:02325 // Informs the render view that a PPAPI plugin has changed text input status.
326 void PepperTextInputTypeChanged(PepperPluginInstanceImpl* instance);
327 void PepperCaretPositionChanged(PepperPluginInstanceImpl* instance);
328
329 // Cancels current composition.
330 void PepperCancelComposition(PepperPluginInstanceImpl* instance);
331
332 // Informs the render view that a PPAPI plugin has changed selection.
333 void PepperSelectionChanged(PepperPluginInstanceImpl* instance);
334
[email protected]7a4e2532013-12-02 21:30:02335 // Notification that the given plugin has crashed.
336 void PluginCrashed(const base::FilePath& plugin_path,
337 base::ProcessId plugin_pid);
338
brettw4b461082016-11-19 18:55:16339#endif // BUILDFLAG(ENABLE_PLUGINS)
[email protected]7a4e2532013-12-02 21:30:02340
thestigcb959ce2016-11-17 05:56:32341 void ScriptedPrint(bool user_initiated);
342
[email protected]227692c52013-05-31 22:43:04343 // IPC::Sender
dcheng6d18e402014-10-21 12:32:52344 bool Send(IPC::Message* msg) override;
[email protected]227692c52013-05-31 22:43:04345
346 // IPC::Listener
dcheng6d18e402014-10-21 12:32:52347 bool OnMessageReceived(const IPC::Message& msg) override;
rockotce2138c2016-09-16 00:09:18348 void OnAssociatedInterfaceRequest(
349 const std::string& interface_name,
350 mojo::ScopedInterfaceEndpointHandle handle) override;
[email protected]227692c52013-05-31 22:43:04351
[email protected]271ff5792013-12-04 22:29:31352 // RenderFrame implementation:
dcheng6d18e402014-10-21 12:32:52353 RenderView* GetRenderView() override;
dmazzoni8e6fe4d2016-06-27 06:35:37354 RenderAccessibility* GetRenderAccessibility() override;
Dominic Mazzoni8ea9079682019-12-26 20:08:31355 std::unique_ptr<AXTreeSnapshotter> CreateAXTreeSnapshotter() override;
dcheng6d18e402014-10-21 12:32:52356 int GetRoutingID() override;
357 blink::WebLocalFrame* GetWebFrame() override;
Gyuyoung Kima252d4a2020-09-16 07:20:31358 const blink::web_pref::WebPreferences& GetBlinkPreferences() override;
dcheng6d18e402014-10-21 12:32:52359 int ShowContextMenu(ContextMenuClient* client,
Lukasz Anforowiczc9513682020-03-11 03:13:26360 const UntrustworthyContextMenuParams& params) override;
dcheng6d18e402014-10-21 12:32:52361 void CancelContextMenu(int request_id) override;
Jan Wilken Dörrie225749c92019-10-29 01:22:07362 void ShowVirtualKeyboard() override;
Dave Tapuskaa361ec82020-11-02 18:08:38363 blink::WebPlugin* CreatePlugin(const WebPluginInfo& info,
364 const blink::WebPluginParams& params) override;
dcheng6d18e402014-10-21 12:32:52365 void ExecuteJavaScript(const base::string16& javascript) override;
dglazkov2e140f52015-09-28 16:10:07366 bool IsMainFrame() override;
dcheng6d18e402014-10-21 12:32:52367 bool IsHidden() override;
Ben Goodgerd5ee3cc2017-07-24 23:11:36368 void BindLocalInterface(
369 const std::string& interface_name,
370 mojo::ScopedMessagePipeHandle interface_pipe) override;
Sam McNally52e50282017-11-29 00:54:02371 blink::AssociatedInterfaceRegistry* GetAssociatedInterfaceRegistry() override;
372 blink::AssociatedInterfaceProvider* GetRemoteAssociatedInterfaces() override;
brettw4b461082016-11-19 18:55:16373#if BUILDFLAG(ENABLE_PLUGINS)
nasko2d67b3c2017-01-04 14:48:19374 void PluginDidStartLoading() override;
375 void PluginDidStopLoading() override;
tommyclid481c482014-12-03 01:50:41376#endif
dcheng6d18e402014-10-21 12:32:52377 bool IsFTPDirectoryListing() override;
changwan44664cd2017-05-23 19:14:34378 void SetSelectedText(const base::string16& selection_text,
379 size_t offset,
380 const gfx::Range& range) override;
Abhijeet Kandalkara5928a0a2019-03-13 05:04:42381 void AddMessageToConsole(blink::mojom::ConsoleMessageLevel level,
rdevlin.croninb2cec912015-06-24 20:36:01382 const std::string& message) override;
Hiroki Nakagawa41366152020-07-27 18:31:40383 blink::PreviewsState GetPreviewsState() override;
Lucas Furukawa Gadanid51ff5d62018-12-07 21:26:49384 bool IsPasting() override;
jam485372b12016-10-26 19:46:07385 bool IsBrowserSideNavigationPending() override;
Dmitry Gozmand96e493a82018-11-28 01:13:33386 void LoadHTMLString(const std::string& html,
387 const GURL& base_url,
388 const std::string& text_encoding,
389 const GURL& unreachable_url,
390 bool replace_current_item) override;
Alexander Timin310368112017-09-13 10:01:44391 scoped_refptr<base::SingleThreadTaskRunner> GetTaskRunner(
392 blink::TaskType task_type) override;
Lucas Furukawa Gadanid51ff5d62018-12-07 21:26:49393 int GetEnabledBindings() override;
Dominic Mazzonic6f4bc72017-12-22 22:03:43394 void SetAccessibilityModeForTest(ui::AXMode new_mode) override;
Chong Zhangb7c8d1ce2018-03-13 19:14:11395 scoped_refptr<network::SharedURLLoaderFactory> GetURLLoaderFactory() override;
Sergey Volk8b09c2c52018-12-12 23:20:40396 const RenderFrameMediaPlaybackOptions& GetRenderFrameMediaPlaybackOptions()
397 override;
398 void SetRenderFrameMediaPlaybackOptions(
399 const RenderFrameMediaPlaybackOptions& opts) override;
Dave Tapuskafc457ca832019-08-06 19:52:22400 void SetAllowsCrossBrowsingInstanceFrameLookup() override;
danakj3dcceba2019-10-09 22:16:23401 gfx::RectF ElementBoundsInWindow(const blink::WebElement& element) override;
402 void ConvertViewportToWindow(blink::WebRect* rect) override;
danakj90e9d342019-10-10 19:14:48403 float GetDeviceScaleFactor() override;
[email protected]271ff5792013-12-04 22:29:31404
Becca Hughes3da69b742018-04-13 19:05:06405 // blink::mojom::AutoplayConfigurationClient implementation:
406 void AddAutoplayFlags(const url::Origin& origin,
407 const int32_t flags) override;
Becca Hughes9470c452017-07-27 22:51:05408
Minggang Wangd712a912020-07-10 08:12:35409 // blink::mojom::ResourceLoadInfoNotifier implementation:
Minggang Wang656dfe072020-10-13 15:50:49410#if defined(OS_ANDROID)
411 void NotifyUpdateUserGestureCarryoverInfo() override;
412#endif
Minggang Wangd712a912020-07-10 08:12:35413 void NotifyResourceRedirectReceived(
414 const net::RedirectInfo& redirect_info,
415 network::mojom::URLResponseHeadPtr redirect_response) override;
416 void NotifyResourceResponseReceived(
Minggang Wange0d5db32020-10-07 15:55:31417 int64_t request_id,
418 const GURL& response_url,
Minggang Wangd712a912020-07-10 08:12:35419 network::mojom::URLResponseHeadPtr head,
Minggang Wange0d5db32020-10-07 15:55:31420 network::mojom::RequestDestination request_destination,
Minggang Wangd712a912020-07-10 08:12:35421 int32_t previews_state) override;
Minggang Wange0d5db32020-10-07 15:55:31422 void NotifyResourceTransferSizeUpdated(int64_t request_id,
Minggang Wangd712a912020-07-10 08:12:35423 int32_t transfer_size_diff) override;
424 void NotifyResourceLoadCompleted(
425 blink::mojom::ResourceLoadInfoPtr resource_load_info,
426 const ::network::URLLoaderCompletionStatus& status) override;
Minggang Wange0d5db32020-10-07 15:55:31427 void NotifyResourceLoadCanceled(int64_t request_id) override;
Minggang Wangd712a912020-07-10 08:12:35428 void Clone(mojo::PendingReceiver<blink::mojom::ResourceLoadInfoNotifier>
429 pending_resource_load_info_notifier) override;
430
ben76f52b242016-06-18 05:42:48431 // mojom::Frame implementation:
432 void GetInterfaceProvider(
Gyuyoung Kim6c9ce9022019-11-26 05:40:08433 mojo::PendingReceiver<service_manager::mojom::InterfaceProvider> receiver)
434 override;
Daniel Cheng118f9e282017-11-10 03:28:44435 void GetCanonicalUrlForSharing(
436 GetCanonicalUrlForSharingCallback callback) override;
John Abd-El-Malek9405d80e2018-08-08 16:50:21437 void BlockRequests() override;
438 void ResumeBlockedRequests() override;
Dave Tapuskafc4adbae2020-12-02 22:08:59439 void UpdateBrowserControlsState(cc::BrowserControlsState constraints,
440 cc::BrowserControlsState current,
Scott Violet0de3837c2019-09-06 22:51:54441 bool animate) override;
Mario Sanchez Prada749007a2020-03-13 16:48:29442 void SnapshotAccessibilityTree(
443 uint32_t ax_mode,
444 SnapshotAccessibilityTreeCallback callback) override;
Mario Sanchez Prada13bbad52020-06-01 18:12:29445 void GetSerializedHtmlWithLocalLinks(
446 const base::flat_map<GURL, base::FilePath>& url_map,
447 const base::flat_map<base::UnguessableToken, base::FilePath>&
448 frame_token_map,
449 bool save_with_empty_url,
450 mojo::PendingRemote<mojom::FrameHTMLSerializerHandler> handler_remote)
451 override;
Dave Tapuska1dd57742019-02-07 01:07:37452
Eve Martin-Jones40f552c2018-02-14 22:47:32453#if defined(OS_ANDROID)
Luciano Pacheco8528c16f2017-12-14 07:10:56454 void ExtractSmartClipData(
455 const gfx::Rect& rect,
456 const ExtractSmartClipDataCallback callback) override;
Eve Martin-Jones40f552c2018-02-14 22:47:32457#endif
ben76f52b242016-06-18 05:42:48458
sammc7f6c6a02017-01-30 00:53:51459 // mojom::FrameBindingsControl implementation:
460 void AllowBindings(int32_t enabled_bindings_flags) override;
Nasko Oskov8a73f7d2019-09-27 22:29:32461 void EnableMojoJsBindings() override;
Miyoung Shin072d4052020-07-13 07:52:44462 void BindWebUI(mojo::PendingReceiver<mojom::WebUI> Receiver,
463 mojo::PendingRemote<mojom::WebUIHost> remote) override;
sammc7f6c6a02017-01-30 00:53:51464
Dmitry Gozman9b890002020-05-27 15:24:42465 // These mirror mojom::NavigationClient, called by NavigationClient.
Ken Rockotbe87ab322017-11-02 19:40:23466 void CommitNavigation(
Lucas Furukawa Gadania9c45682019-07-31 22:05:14467 mojom::CommonNavigationParamsPtr common_params,
468 mojom::CommitNavigationParamsPtr commit_params,
Lucas Furukawa Gadani81e294b2019-08-29 16:26:32469 network::mojom::URLResponseHeadPtr response_head,
Minggang Wang47a78222019-06-28 17:05:46470 mojo::ScopedDataPipeConsumerHandle response_body,
John Abd-El-Malekb165dc52018-01-18 17:12:18471 network::mojom::URLLoaderClientEndpointsPtr url_loader_client_endpoints,
Dominic Farolinobc280d22019-12-05 05:49:24472 std::unique_ptr<blink::PendingURLLoaderFactoryBundle>
Arthur Hemery1f46de02019-01-31 16:41:53473 subresource_loader_factories,
Hiroki Nakagawad7ed213e2020-07-21 13:19:28474 base::Optional<std::vector<blink::mojom::TransferrableURLLoaderPtr>>
John Abd-El-Malekecc6f5f2018-03-02 18:47:39475 subresource_overrides,
Hiroki Nakagawacdbc7912018-11-30 11:30:05476 blink::mojom::ControllerServiceWorkerInfoPtr
477 controller_service_worker_info,
Hiroki Nakagawa74cdcf32020-05-15 04:57:21478 blink::mojom::ServiceWorkerContainerInfoForClientPtr container_info,
Kinuko Yasuda8fb556c2019-07-16 05:47:55479 mojo::PendingRemote<network::mojom::URLLoaderFactory>
480 prefetch_loader_factory,
clamy6b92fcf2018-06-01 13:51:37481 const base::UnguessableToken& devtools_navigation_token,
Antonio Sartori9290b6b2020-11-09 10:09:33482 blink::mojom::PolicyContainerPtr policy_container,
Dmitry Gozman9b890002020-05-27 15:24:42483 mojom::NavigationClient::CommitNavigationCallback commit_callback);
Doug Turner84693be2017-12-19 00:18:46484 void CommitFailedNavigation(
Lucas Furukawa Gadanief8290a2019-07-29 20:27:51485 mojom::CommonNavigationParamsPtr common_params,
Lucas Furukawa Gadania9c45682019-07-31 22:05:14486 mojom::CommitNavigationParamsPtr commit_params,
Doug Turner84693be2017-12-19 00:18:46487 bool has_stale_copy_in_cache,
488 int error_code,
dalykd3131c32020-01-06 17:52:57489 net::ResolveErrorInfo resolve_error_info,
Doug Turner84693be2017-12-19 00:18:46490 const base::Optional<std::string>& error_page_content,
Dominic Farolinobc280d22019-12-05 05:49:24491 std::unique_ptr<blink::PendingURLLoaderFactoryBundle>
Arthur Hemery1f46de02019-01-31 16:41:53492 subresource_loader_factories,
Arthur Hemery161d1e62019-02-06 16:46:32493 mojom::NavigationClient::CommitFailedNavigationCallback
494 per_navigation_mojo_interface_callback);
495
Dmitry Gozman9b890002020-05-27 15:24:42496 // mojom::FrameNavigationControl implementation:
clamyaf4bf2d92018-02-06 10:54:36497 void CommitSameDocumentNavigation(
Lucas Furukawa Gadanief8290a2019-07-29 20:27:51498 mojom::CommonNavigationParamsPtr common_params,
Lucas Furukawa Gadania9c45682019-07-31 22:05:14499 mojom::CommitNavigationParamsPtr commit_params,
clamyaf4bf2d92018-02-06 10:54:36500 CommitSameDocumentNavigationCallback callback) override;
clamyb1df7b962018-02-01 17:38:17501 void HandleRendererDebugURL(const GURL& url) override;
Chong Zhang7306b0b2018-01-24 05:59:24502 void UpdateSubresourceLoaderFactories(
Dominic Farolinobc280d22019-12-05 05:49:24503 std::unique_ptr<blink::PendingURLLoaderFactoryBundle>
Arthur Hemery1f46de02019-01-31 16:41:53504 subresource_loader_factories) override;
Dmitry Gozman6adf95b2018-10-10 22:12:19505 void BindDevToolsAgent(
Julie Jeongeun Kim07887792019-08-13 11:05:48506 mojo::PendingAssociatedRemote<blink::mojom::DevToolsAgentHost> host,
Andrey Kosyakov5bb020f2020-03-19 17:28:19507 mojo::PendingAssociatedReceiver<blink::mojom::DevToolsAgent> receiver)
Julie Jeongeun Kim07887792019-08-13 11:05:48508 override;
Maksim Sadymcfb8f8d2020-09-30 20:30:45509 void JavaScriptMethodExecuteRequest(
510 const base::string16& object_name,
511 const base::string16& method_name,
512 base::Value arguments,
513 bool wants_result,
514 JavaScriptMethodExecuteRequestCallback callback) override;
Avi Drissman4544828f2019-03-11 20:37:32515 void JavaScriptExecuteRequest(
516 const base::string16& javascript,
Avi Drissman8e3ebe92019-06-10 20:26:11517 bool wants_result,
Avi Drissman4544828f2019-03-11 20:37:32518 JavaScriptExecuteRequestCallback callback) override;
519 void JavaScriptExecuteRequestForTests(
520 const base::string16& javascript,
Avi Drissman8e3ebe92019-06-10 20:26:11521 bool wants_result,
Avi Drissman4544828f2019-03-11 20:37:32522 bool has_user_gesture,
Hajime Hoshif85e7cf722019-07-19 00:54:49523 int32_t world_id,
Avi Drissman4544828f2019-03-11 20:37:32524 JavaScriptExecuteRequestForTestsCallback callback) override;
525 void JavaScriptExecuteRequestInIsolatedWorld(
526 const base::string16& javascript,
Avi Drissman8e3ebe92019-06-10 20:26:11527 bool wants_result,
Avi Drissman4544828f2019-03-11 20:37:32528 int32_t world_id,
529 JavaScriptExecuteRequestInIsolatedWorldCallback callback) override;
Gyuyoung Kim11aad0b62020-04-29 16:00:26530 void SwapIn() override;
Hajime Hoshi35ad74f2019-03-07 08:38:05531
Adam Parker6a19ba342018-01-08 23:40:20532 // mojom::FullscreenVideoElementHandler implementation:
533 void RequestFullscreenVideoElement() override;
534
Mark Lieu6cf3e8fa2019-03-09 02:09:01535 // mojom::MhtmlFileWriter implementation:
536 void SerializeAsMHTML(const mojom::SerializeAsMHTMLParamsPtr params,
537 SerializeAsMHTMLCallback callback) override;
538
Mustaq Ahmed55944cb2018-05-25 20:44:27539 // blink::WebLocalFrameClient implementation:
Mario Sanchez Pradadde87ee52019-05-29 07:55:01540 void BindToFrame(blink::WebNavigationControl* frame) override;
thestigf7d2fa12017-05-05 19:11:43541 blink::WebPlugin* CreatePlugin(const blink::WebPluginParams& params) override;
Blink Reformat1c4d759e2017-04-09 16:34:54542 blink::WebMediaPlayer* CreateMediaPlayer(
guidou9bfe4e2f2016-04-09 08:31:19543 const blink::WebMediaPlayerSource& source,
srirama.m26f864d02015-07-14 05:21:46544 blink::WebMediaPlayerClient* client,
Ted Meyercda47a0e2019-08-13 20:41:11545 blink::MediaInspectorContext* inspector_context,
srirama.m26f864d02015-07-14 05:21:46546 blink::WebMediaPlayerEncryptedMediaClient* encrypted_client,
guidou9c3cc3e2015-10-27 13:38:15547 blink::WebContentDecryptionModule* initial_cdm,
Dave Tapuska0d3d2c32020-12-02 14:10:02548 const blink::WebString& sink_id,
549 const cc::LayerTreeSettings& settings) override;
Hiroki Nakagawa6bcbd1902017-06-09 07:13:20550 std::unique_ptr<blink::WebContentSettingsClient>
551 CreateWorkerContentSettingsClient() override;
Abigail Klein82807c552020-04-06 19:58:07552#if !defined(OS_ANDROID)
Evan Liu47f798a2020-06-23 20:27:09553 std::unique_ptr<media::SpeechRecognitionClient> CreateSpeechRecognitionClient(
Evan Liuca885402020-06-23 22:02:13554 media::SpeechRecognitionClient::OnReadyCallback callback) override;
Abigail Klein82807c552020-04-06 19:58:07555#endif
Hiroshige Hayashizaki3be04672018-11-09 02:27:39556 scoped_refptr<blink::WebWorkerFetchContext> CreateWorkerFetchContext()
horoe6120582017-04-26 01:48:59557 override;
Hiroki Nakagawa599efcb2019-02-27 12:22:33558 scoped_refptr<blink::WebWorkerFetchContext>
559 CreateWorkerFetchContextForPlzDedicatedWorker(
560 blink::WebDedicatedWorkerHostFactoryClient* factory_client) override;
Kinuko Yasuda027bcfb2019-12-05 12:49:08561 std::unique_ptr<blink::WebPrescientNetworking> CreatePrescientNetworking()
562 override;
Minggang Wange0d5db32020-10-07 15:55:31563 std::unique_ptr<blink::ResourceLoadInfoNotifierWrapper>
564 CreateResourceLoadInfoNotifierWrapper() override;
Blink Reformat1c4d759e2017-04-09 16:34:54565 blink::BlameContext* GetFrameBlameContext() override;
kinukoc3626582017-05-01 07:27:52566 std::unique_ptr<blink::WebServiceWorkerProvider> CreateServiceWorkerProvider()
567 override;
Sam McNally52e50282017-11-29 00:54:02568 blink::AssociatedInterfaceProvider* GetRemoteNavigationAssociatedInterfaces()
569 override;
Blink Reformat1c4d759e2017-04-09 16:34:54570 blink::WebLocalFrame* CreateChildFrame(
alexmose48b1df932015-01-16 01:34:17571 blink::WebLocalFrame* parent,
Antonio Gomes9d5c1ef2020-04-30 20:56:41572 blink::mojom::TreeScopeType scope,
dcheng860817a2015-05-22 03:16:56573 const blink::WebString& name,
Daniel Cheng999698bd2017-03-22 04:56:37574 const blink::WebString& fallback_name,
Ehsan Karamad2b53d152019-04-08 13:11:21575 const blink::FramePolicy& frame_policy,
Ehsan Karamad192a8da2018-10-21 03:48:08576 const blink::WebFrameOwnerProperties& frame_owner_properties,
Antonio Sartoria1fd1432020-11-25 09:10:20577 blink::mojom::FrameOwnerElementType frame_owner_element_type,
578 blink::CrossVariantMojoAssociatedReceiver<
579 blink::mojom::PolicyContainerHostInterfaceBase>
580 policy_container_host_receiver) override;
Adithya Srinivasanea4760c2020-07-30 15:44:57581 std::pair<blink::WebRemoteFrame*, blink::PortalToken> CreatePortal(
Daniel Cheng9a7c6c82020-04-25 04:58:17582 blink::CrossVariantMojoAssociatedReceiver<
583 blink::mojom::PortalInterfaceBase> portal_endpoint,
584 blink::CrossVariantMojoAssociatedRemote<
585 blink::mojom::PortalClientInterfaceBase> client_endpoint,
Jeremy Roman62fee222019-07-09 17:34:14586 const blink::WebElement& portal_element) override;
Lucas Furukawa Gadani56dd5452019-03-22 18:23:12587 blink::WebRemoteFrame* AdoptPortal(
Adithya Srinivasanea4760c2020-07-30 15:44:57588 const blink::PortalToken& portal_token,
Jeremy Roman62fee222019-07-09 17:34:14589 const blink::WebElement& portal_element) override;
Lukasz Anforowiczaf2f33572018-01-17 14:05:08590 blink::WebFrame* FindFrame(const blink::WebString& name) override;
Miyoung Shin00b48252020-07-27 04:03:20591 void WillDetach() override;
592 void FrameDetached() override;
Blink Reformat1c4d759e2017-04-09 16:34:54593 void DidChangeName(const blink::WebString& name) override;
Blink Reformat1c4d759e2017-04-09 16:34:54594 void DidMatchCSS(
[email protected]180ef242013-11-07 06:50:46595 const blink::WebVector<blink::WebString>& newly_matching_selectors,
avi5c77d212015-09-25 20:08:25596 const blink::WebVector<blink::WebString>& stopped_matching_selectors)
597 override;
Blink Reformat1c4d759e2017-04-09 16:34:54598 bool ShouldReportDetailedMessageForSource(
avi5c77d212015-09-25 20:08:25599 const blink::WebString& source) override;
Blink Reformat1c4d759e2017-04-09 16:34:54600 void DidAddMessageToConsole(const blink::WebConsoleMessage& message,
avi5c77d212015-09-25 20:08:25601 const blink::WebString& source_name,
602 unsigned source_line,
603 const blink::WebString& stack_trace) override;
Dmitry Gozman7b10a532018-11-13 17:48:56604 void BeginNavigation(std::unique_ptr<blink::WebNavigationInfo> info) override;
Blink Reformat1c4d759e2017-04-09 16:34:54605 void WillSendSubmitEvent(const blink::WebFormElement& form) override;
Takeshi Yoshino41b671a2017-08-01 12:17:51606 void DidCreateDocumentLoader(
Takeshi Yoshino41b671a2017-08-01 12:17:51607 blink::WebDocumentLoader* document_loader) override;
arthursonzogni76098e52020-11-25 14:18:45608 void DidCommitNavigation(
609 blink::WebHistoryCommitType commit_type,
610 bool should_reset_browser_interface_broker,
611 network::mojom::WebSandboxFlags sandbox_flags,
612 const blink::ParsedFeaturePolicy& feature_policy_header,
613 const blink::DocumentPolicyFeatureState& document_policy_header) override;
Dmitry Gozmanf0c8e0872020-02-11 09:57:28614 void DidCreateInitialEmptyDocument() override;
Nate Chapin950d75e2020-04-20 18:11:23615 void DidCommitDocumentReplacementNavigation(
Dmitry Gozmanf0c8e0872020-02-11 09:57:28616 blink::WebDocumentLoader* document_loader) override;
sashabe40dfa1b2017-04-24 02:12:55617 void DidClearWindowObject() override;
Daniel Cheng7df23c22017-08-03 18:43:58618 void DidCreateDocumentElement() override;
619 void RunScriptsAtDocumentElementAvailable() override;
Julie Jeongeun Kimec6178a2020-02-19 03:28:33620 void DidReceiveTitle(const blink::WebString& title) override;
sashab3730c8a2017-05-03 01:28:54621 void DidFinishDocumentLoad() override;
Rakina Zata Amniba3eecb2020-11-02 10:12:28622 void RunScriptsAtDocumentReady() override;
sashabe68662222017-04-11 03:28:55623 void RunScriptsAtDocumentIdle() override;
Blink Reformat1c4d759e2017-04-09 16:34:54624 void DidHandleOnloadEvents() override;
sashab0bdd956a2017-04-18 09:27:06625 void DidFinishLoad() override;
Miyoung Shin6acc5d52020-11-22 04:10:38626 void DidFinishSameDocumentNavigation(blink::WebHistoryCommitType commit_type,
Eugene But0579ec82018-05-22 17:18:17627 bool content_initiated) override;
Blink Reformat1c4d759e2017-04-09 16:34:54628 void DidUpdateCurrentHistoryItem() override;
Dmitry Gozmanf12caab2018-02-07 03:45:58629 base::UnguessableToken GetDevToolsFrameToken() override;
Blink Reformat1c4d759e2017-04-09 16:34:54630 void AbortClientNavigation() override;
631 void DidChangeSelection(bool is_empty_selection) override;
Gyuyoung Kim49f314f22020-07-04 04:00:28632 void ShowContextMenu(
633 const blink::WebContextMenuData& data,
634 const base::Optional<gfx::Point>& host_context_menu_location) override;
Lucas Furukawa Gadanie5d27a362018-02-13 14:26:02635 void FrameRectsChanged(const blink::WebRect& frame_rect) override;
Miyoung Shinbcd1400702020-03-13 00:35:18636 void FocusedElementChanged(const blink::WebElement& element) override;
Justin Miron95fddee2020-07-10 16:46:37637 void OnMainFrameIntersectionChanged(
Justin Mironc3452f92020-01-24 14:31:09638 const blink::WebRect& intersect_rect) override;
Yutaka Hirano98549882020-08-06 08:43:33639 void WillSendRequest(blink::WebURLRequest& request,
640 ForRedirect for_redirect) override;
Yao Xiao8bf71582020-12-01 00:01:48641 void OnOverlayPopupAdDetected() override;
642 void OnLargeStickyAdDetected() override;
Blink Reformat1c4d759e2017-04-09 16:34:54643 void DidLoadResourceFromMemoryCache(
[email protected]180ef242013-11-07 06:50:46644 const blink::WebURLRequest& request,
avi5c77d212015-09-25 20:08:25645 const blink::WebURLResponse& response) override;
Blink Reformat1c4d759e2017-04-09 16:34:54646 void DidChangePerformanceTiming() override;
Hongbo Song104cef12020-03-26 21:57:07647 void DidObserveInputDelay(base::TimeDelta input_delay) override;
Eric Robinsonfb3cb752019-03-04 13:55:50648 void DidChangeCpuTiming(base::TimeDelta time) override;
Sergio Villar Senin0c142fa2019-10-16 08:18:59649 void DidObserveLoadingBehavior(blink::LoadingBehaviorFlag behavior) override;
Luna Lu7b133f72017-07-27 16:16:47650 void DidObserveNewFeatureUsage(blink::mojom::WebFeature feature) override;
Majid Valipourb9ee0972019-08-22 15:16:23651 void DidObserveNewCssPropertyUsage(blink::mojom::CSSSampleId css_property,
Luna Lu29d922d2018-03-27 18:06:51652 bool is_animated) override;
Steve Kobes7e75d522019-07-11 12:18:42653 void DidObserveLayoutShift(double score, bool after_input_or_scroll) override;
Kent Tamuraabc1e56a2020-05-07 02:03:58654 void DidObserveLayoutNg(uint32_t all_block_count,
655 uint32_t ng_block_count,
656 uint32_t all_call_count,
657 uint32_t ng_call_count) override;
Ryan Sturm4f61ea492019-04-03 23:44:27658 void DidObserveLazyLoadBehavior(
659 blink::WebLocalFrameClient::LazyLoadBehavior lazy_load_behavior) override;
sashab7dbeb112017-05-02 23:13:22660 void DidCreateScriptContext(v8::Local<v8::Context> context,
avi5c77d212015-09-25 20:08:25661 int world_id) override;
sashab9e289b32017-04-26 07:07:10662 void WillReleaseScriptContext(v8::Local<v8::Context> context,
avi5c77d212015-09-25 20:08:25663 int world_id) override;
sashabef13f14a2017-04-26 03:57:26664 void DidChangeScrollOffset() override;
Antonio Gomes32f24faf2019-08-18 16:41:36665 blink::WebMediaStreamDeviceObserver* MediaStreamDeviceObserver() override;
Guido Urdaneta7f9f9df2020-09-29 15:19:17666 bool AllowRTCLegacyTLSProtocols() override;
Blink Reformat1c4d759e2017-04-09 16:34:54667 blink::WebEncryptedMediaClient* EncryptedMediaClient() override;
668 blink::WebString UserAgentOverride() override;
Maks Orlovich73f374d2020-04-02 12:46:13669 base::Optional<blink::UserAgentMetadata> UserAgentMetadataOverride() override;
Blink Reformat1c4d759e2017-04-09 16:34:54670 blink::WebString DoNotTrackValue() override;
Guido Urdaneta3a7cd9e62020-07-21 08:31:28671 blink::mojom::RendererAudioInputStreamFactory* GetAudioInputStreamFactory();
meacerba52f56202017-04-22 00:08:08672 bool AllowContentInitiatedDataUrlNavigations(
673 const blink::WebURL& url) override;
Nektarios Paisios56ee9982020-04-22 07:53:06674 void PostAccessibilityEvent(const ui::AXEvent& event) override;
Dominic Mazzonibb512782018-09-13 16:16:06675 void MarkWebAXObjectDirty(const blink::WebAXObject& obj,
676 bool subtree) override;
Blink Reformat1c4d759e2017-04-09 16:34:54677 void CheckIfAudioSinkExistsAndIsAuthorized(
guidou3906a722015-11-12 22:14:42678 const blink::WebString& sink_id,
Antonio Gomese7813f32019-04-02 06:11:03679 blink::WebSetSinkIdCompleteCallback callback) override;
Kinuko Yasuda017b79e62017-10-24 17:46:10680 std::unique_ptr<blink::WebURLLoaderFactory> CreateURLLoaderFactory() override;
Mario Sanchez Prada70fb3b32020-04-30 20:27:39681 void OnStopLoading() override;
Tsuyoshi Horod7d7da832020-09-14 11:26:26682 void MaybeProxyURLLoaderFactory(
683 blink::CrossVariantMojoReceiver<
684 network::mojom::URLLoaderFactoryInterfaceBase>* factory_receiver)
685 override;
lukasza060c739be2017-06-13 23:09:27686 void DraggableRegionsChanged() override;
Olga Sharonovae03b90692019-09-05 09:06:58687 blink::BrowserInterfaceBrokerProxy* GetBrowserInterfaceBroker() override;
Dave Tapuska23748d42020-06-26 16:01:20688 // Dispatches the current state of selection on the webpage to the browser if
689 // it has changed.
690 // TODO(varunjain): delete this method once we figure out how to keep
691 // selection handles in sync with the webpage.
692 void SyncSelectionIfRequired() override;
Antonio Gomes98bfb182020-09-03 13:36:49693 void CreateAudioInputStream(
694 blink::CrossVariantMojoRemote<
695 blink::mojom::RendererAudioInputStreamFactoryClientInterfaceBase>
696 client,
697 const base::UnguessableToken& session_id,
698 const media::AudioParameters& params,
699 bool automatic_gain_control,
700 uint32_t shared_memory_count) override;
701 void AssociateInputAndOutputForAec(
702 const base::UnguessableToken& input_stream_id,
703 const std::string& output_device_id) override;
Dave Tapuska064cb5e2020-09-15 17:43:27704 void DidMeaningfulLayout(blink::WebMeaningfulLayout layout_type) override;
Dave Tapuska15385522020-09-15 20:03:15705 void DidCommitAndDrawCompositorFrame() override;
Miyoung Shinf264e2a2020-09-17 08:21:43706 void WasHidden() override;
707 void WasShown() override;
Hiroki Kumazaki2560dd82020-10-29 09:25:59708 void DidChangeMobileFriendliness(const blink::MobileFriendliness&) override;
709
Sadrul Habib Chowdhury403923e2020-10-01 09:53:16710 void SetUpSharedMemoryForSmoothness(
Dave Tapuska32e57d42020-10-27 20:07:31711 base::ReadOnlySharedMemoryRegion shared_memory) override;
Dave Tapuska39305ff2020-10-28 22:54:13712 blink::WebURL LastCommittedUrlForUKM() override;
Sadrul Habib Chowdhury403923e2020-10-01 09:53:16713
Adam Parker6a19ba342018-01-08 23:40:20714 // Binds to the fullscreen service in the browser.
715 void BindFullscreen(
Mario Sanchez Pradab3b852f2019-10-04 17:53:24716 mojo::PendingAssociatedReceiver<mojom::FullscreenVideoElementHandler>
717 receiver);
Adam Parker6a19ba342018-01-08 23:40:20718
Mark Lieu6cf3e8fa2019-03-09 02:09:01719 // Binds to the MHTML file generation service in the browser.
Mario Sanchez Pradab3b852f2019-10-04 17:53:24720 void BindMhtmlFileWriter(
721 mojo::PendingAssociatedReceiver<mojom::MhtmlFileWriter> receiver);
Mark Lieu6cf3e8fa2019-03-09 02:09:01722
Becca Hughes3da69b742018-04-13 19:05:06723 // Binds to the autoplay configuration service in the browser.
724 void BindAutoplayConfiguration(
Mario Sanchez Pradab3b852f2019-10-04 17:53:24725 mojo::PendingAssociatedReceiver<blink::mojom::AutoplayConfigurationClient>
726 receiver);
Becca Hughes9470c452017-07-27 22:51:05727
ben76f52b242016-06-18 05:42:48728 // Binds to the FrameHost in the browser.
Ken Rockot13051c932019-11-14 20:11:51729 void BindFrame(mojo::PendingReceiver<mojom::Frame> receiver);
csharrison95f01e922017-04-24 18:52:35730
Balazs Engedya40712f2017-09-15 15:01:11731 // Virtual so that a TestRenderFrame can mock out the interface.
732 virtual mojom::FrameHost* GetFrameHost();
rockotf8fdd9b2015-12-16 22:22:35733
sammc7f6c6a02017-01-30 00:53:51734 void BindFrameBindingsControl(
Henrique Ferreiro3a9751c2019-09-30 13:54:07735 mojo::PendingAssociatedReceiver<mojom::FrameBindingsControl> receiver);
Ken Rockot48785452017-10-25 19:33:14736 void BindFrameNavigationControl(
Shimi Zhangbb738072019-07-09 18:54:40737 mojo::PendingAssociatedReceiver<mojom::FrameNavigationControl> receiver);
Arthur Hemeryd3011f62018-05-30 10:38:44738 // Only used when PerNavigationMojoInterface is enabled.
Julie Jeongeun Kimed2e5ba72019-09-12 10:14:17739 void BindNavigationClient(
740 mojo::PendingAssociatedReceiver<mojom::NavigationClient> receiver);
sammc7f6c6a02017-01-30 00:53:51741
xhwang5206d4e62016-02-05 02:09:55742 media::MediaPermission* GetMediaPermission();
guoweisf4282b02015-09-24 23:05:22743
creis69b184a472015-11-26 05:29:51744 // Sends the current frame's navigation state to the browser.
745 void SendUpdateState();
746
sammce2f99982016-03-14 22:38:12747 // Creates a MojoBindingsController if Mojo bindings have been enabled for
748 // this frame. For WebUI, this allows the page to communicate with the browser
749 // process; for layout tests, this allows the test to mock out services at
750 // the Mojo IPC layer.
751 void MaybeEnableMojoBindings();
Kent Tamura647f1a502018-08-01 10:24:08752
Dmitry Gozman3682f762019-09-16 23:19:59753 void NotifyObserversOfFailedProvisionalLoad();
Lucas Garrona15d3fc2017-11-02 02:48:18754
lfge0c2792ec2016-05-11 18:52:08755 // Plugin-related functions --------------------------------------------------
756
brettw4b461082016-11-19 18:55:16757#if BUILDFLAG(ENABLE_PLUGINS)
lfge0c2792ec2016-05-11 18:52:08758 PepperPluginInstanceImpl* focused_pepper_plugin() {
759 return focused_pepper_plugin_;
760 }
lfge0c2792ec2016-05-11 18:52:08761 // Indicates that the given instance has been created.
762 void PepperInstanceCreated(PepperPluginInstanceImpl* instance);
763
764 // Indicates that the given instance is being destroyed. This is called from
765 // the destructor, so it's important that the instance is not dereferenced
766 // from this call.
767 void PepperInstanceDeleted(PepperPluginInstanceImpl* instance);
768
769 // Notification that the given plugin is focused or unfocused.
770 void PepperFocusChanged(PepperPluginInstanceImpl* instance, bool focused);
zqzhangc885f6b2016-06-23 19:44:46771
772 void PepperStartsPlayback(PepperPluginInstanceImpl* instance);
773 void PepperStopsPlayback(PepperPluginInstanceImpl* instance);
774 void OnSetPepperVolume(int32_t pp_instance, double volume);
lfge0c2792ec2016-05-11 18:52:08775#endif // ENABLE_PLUGINS
776
Mario Sanchez Prada0bd8b8c2020-10-21 17:49:23777 const blink::RendererPreferences& GetRendererPreferences() const;
chcunningham86f025e32017-05-30 20:43:23778
Arthur Hemeryd3011f62018-05-30 10:38:44779 // Called when an ongoing renderer-initiated navigation was dropped by the
780 // browser.
781 void OnDroppedNavigation();
782
Lukasz Anforowiczd334bba2020-02-10 23:32:55783 void DidStartResponse(const GURL& response_url,
rajendrant811e3572018-11-05 23:18:55784 int request_id,
Lucas Furukawa Gadania6917ab2019-10-01 17:37:31785 network::mojom::URLResponseHeadPtr response_head,
Kinuko Yasuda433f710a2020-02-14 02:11:58786 network::mojom::RequestDestination request_destination,
Hiroki Nakagawa41366152020-07-27 18:31:40787 blink::PreviewsState previews_state);
rajendrant2e83a102018-06-19 05:58:02788 void DidCompleteResponse(int request_id,
789 const network::URLLoaderCompletionStatus& status);
790 void DidCancelResponse(int request_id);
791 void DidReceiveTransferSizeUpdate(int request_id, int received_data_length);
792
Julie Jeongeun Kimf43639292020-05-05 05:33:01793 bool GetCaretBoundsFromFocusedPlugin(gfx::Rect& rect) override;
794
Vladimir Levinb41bfe42019-07-16 21:13:44795 // Used in tests to install a fake WebURLLoaderFactory via
796 // RenderViewTest::CreateFakeWebURLLoaderFactory().
797 void SetWebURLLoaderFactoryOverrideForTest(
Vladimir Levincfca8522019-07-30 19:01:21798 std::unique_ptr<blink::WebURLLoaderFactoryForTest> factory);
Vladimir Levinb41bfe42019-07-16 21:13:44799
Minoru Chikamunee9eb7f92020-10-26 04:15:16800 blink::scheduler::WebAgentGroupScheduler& GetAgentGroupScheduler() override;
801
[email protected]2f61bdd2013-07-02 18:38:47802 protected:
Balazs Engedyba034e72017-10-27 22:26:28803 explicit RenderFrameImpl(CreateParams params);
[email protected]2f61bdd2013-07-02 18:38:47804
danakjc9acb1132019-03-28 19:10:05805 bool IsLocalRoot() const;
806 const RenderFrameImpl* GetLocalRoot() const;
807
danakj654897c2020-05-29 22:36:17808 // Gets the unique_name() of the frame being replaced by this frame, when
809 // it is a provisional frame. Invalid to call on frames that are already
810 // attached to the frame tree.
Anders Hartvoll Ruud4bb45c62020-07-10 17:10:55811 std::string GetPreviousFrameUniqueName();
danakj654897c2020-05-29 22:36:17812
[email protected]227692c52013-05-31 22:43:04813 private:
kenrbf98a4d22015-04-01 21:59:35814 friend class RenderFrameImplTest;
[email protected]2e2d9632013-12-03 00:55:26815 friend class RenderFrameObserver;
clamy98a9dee02015-06-24 16:09:10816 friend class TestRenderFrame;
Kinuko Yasudaf6e87a42018-12-21 08:15:27817
dmazzoni8e6fe4d2016-06-27 06:35:37818 FRIEND_TEST_ALL_PREFIXES(RenderAccessibilityImplTest,
[email protected]66bbadaf2014-03-28 16:25:54819 AccessibilityMessagesQueueWhileSwappedOut);
Ken Buchananc398e282017-11-29 19:28:57820 FRIEND_TEST_ALL_PREFIXES(RenderFrameImplTest, LocalChildFrameWasShown);
scottmg276753cf2016-10-27 18:25:22821 FRIEND_TEST_ALL_PREFIXES(RenderFrameImplTest, ZoomLimit);
liberatoa8da3b52017-05-02 20:23:51822 FRIEND_TEST_ALL_PREFIXES(RenderFrameImplTest,
823 TestOverlayRoutingTokenSendsLater);
824 FRIEND_TEST_ALL_PREFIXES(RenderFrameImplTest,
825 TestOverlayRoutingTokenSendsNow);
[email protected]2e2d9632013-12-03 00:55:26826
twellington376424ad2015-05-04 18:57:25827 // A wrapper class used as the callback for JavaScript executed
828 // in an isolated world.
829 class JavaScriptIsolatedWorldRequest
830 : public blink::WebScriptExecutionCallback {
831 public:
832 JavaScriptIsolatedWorldRequest(
Avi Drissman4544828f2019-03-11 20:37:32833 base::WeakPtr<RenderFrameImpl> render_frame_impl,
Avi Drissman8e3ebe92019-06-10 20:26:11834 bool wants_result,
Avi Drissman4544828f2019-03-11 20:37:32835 JavaScriptExecuteRequestInIsolatedWorldCallback callback);
Blink Reformat1c4d759e2017-04-09 16:34:54836 void Completed(
twellington376424ad2015-05-04 18:57:25837 const blink::WebVector<v8::Local<v8::Value>>& result) override;
838
839 private:
avi5c77d212015-09-25 20:08:25840 ~JavaScriptIsolatedWorldRequest() override;
twellington376424ad2015-05-04 18:57:25841
twellington376424ad2015-05-04 18:57:25842 base::WeakPtr<RenderFrameImpl> render_frame_impl_;
Avi Drissman8e3ebe92019-06-10 20:26:11843 bool wants_result_;
Avi Drissman4544828f2019-03-11 20:37:32844 JavaScriptExecuteRequestInIsolatedWorldCallback callback_;
twellington376424ad2015-05-04 18:57:25845
846 DISALLOW_COPY_AND_ASSIGN(JavaScriptIsolatedWorldRequest);
847 };
848
Daniel Cheng46894b72017-07-19 13:01:25849 // Similar to base::AutoReset, but skips restoration of the original value if
850 // |this| is already destroyed.
851 template <typename T>
852 class AutoResetMember {
853 public:
854 AutoResetMember(RenderFrameImpl* frame,
855 T RenderFrameImpl::*member,
856 T new_value)
857 : weak_frame_(frame->weak_factory_.GetWeakPtr()),
858 scoped_variable_(&(frame->*member)),
859 original_value_(*scoped_variable_) {
860 *scoped_variable_ = new_value;
861 }
862
863 ~AutoResetMember() {
864 if (weak_frame_)
865 *scoped_variable_ = original_value_;
866 }
867
868 private:
869 base::WeakPtr<RenderFrameImpl> weak_frame_;
870 T* scoped_variable_;
871 T original_value_;
872 };
873
Kinuko Yasuda017b79e62017-10-24 17:46:10874 class FrameURLLoaderFactory;
875
dchengc5ef1a52015-08-26 20:58:30876 // Creates a new RenderFrame. |render_view| is the RenderView object that this
Ken Rockot228182e2020-12-01 18:43:59877 // frame belongs to, and |browser_interface_broker| is the RenderFrameHost's
Oksana Zhuravlova977b4b72019-11-07 19:21:55878 // BrowserInterfaceBroker through which services are exposed to the
Oksana Zhuravlova8b88e572019-01-07 21:54:00879 // RenderFrame.
Pavel Feldman25234722017-10-11 02:49:06880 static RenderFrameImpl* Create(
Tal Pressmanb011b2962020-09-28 11:22:55881 AgentSchedulingGroup& agent_scheduling_group,
Pavel Feldman25234722017-10-11 02:49:06882 RenderViewImpl* render_view,
883 int32_t routing_id,
Oksana Zhuravlovafee097c2019-07-26 17:01:30884 mojo::PendingRemote<blink::mojom::BrowserInterfaceBroker>
885 browser_interface_broker,
Pavel Feldman25234722017-10-11 02:49:06886 const base::UnguessableToken& devtools_frame_token);
dchengc5ef1a52015-08-26 20:58:30887
[email protected]2e2d9632013-12-03 00:55:26888 // Functions to add and remove observers for this object.
889 void AddObserver(RenderFrameObserver* observer);
890 void RemoveObserver(RenderFrameObserver* observer);
[email protected]1c2052f2013-08-28 08:24:34891
alexmosf65a795a2017-01-12 22:04:00892 // Swaps the current frame into the frame tree, replacing the
Gyuyoung Kim11aad0b62020-04-29 16:00:26893 // RenderFrameProxy it is associated with. Return value indicates whether
894 // the swap operation succeeded. This should only be used for provisional
895 // frames associated with a proxy, while the proxy is still in the frame tree.
896 // If the associated proxy has been detached before this is called, this
897 // returns false and aborts the swap.
898 bool SwapInInternal();
alexmosf65a795a2017-01-12 22:04:00899
Albert J. Wong7bbf22d2018-12-20 00:27:27900 // Returns the RenderWidget associated with the main frame.
901 // TODO(ajwong): This method should go away when cross-frame property setting
902 // events moves into RenderWidget.
903 RenderWidget* GetMainFrameRenderWidget();
904
Mario Sanchez Prada60a014b72020-02-20 19:08:06905 // Checks whether accessibility support for this frame is currently enabled.
906 bool IsAccessibilityEnabled() const;
907
[email protected]b70da4c2014-01-06 19:57:09908 // IPC message handlers ------------------------------------------------------
909 //
910 // The documentation for these functions should be in
911 // content/common/*_messages.h for the message that the function is handling.
Nasko Oskov0f3cbb12020-01-07 17:52:14912 void OnUnload(int proxy_routing_id,
913 bool is_loading,
Dave Tapuska84449382020-05-01 00:39:04914 const FrameReplicationState& replicated_frame_state,
915 const base::UnguessableToken& frame_token);
danakjf2342432019-05-15 21:46:09916 void OnDeleteFrame(FrameDeleteIntention intent);
[email protected]a09d53ce2014-01-31 00:46:42917 void OnShowContextMenu(const gfx::Point& location);
918 void OnContextMenuClosed(const CustomContextMenuContext& custom_context);
919 void OnCustomContextMenuAction(const CustomContextMenuContext& custom_context,
920 unsigned action);
Dave Tapuskab336b922017-07-06 19:24:05921 void OnMoveCaret(const gfx::Point& point);
922 void OnScrollFocusedEditableNodeIntoRect(const gfx::Rect& rect);
christiankaeed9862014-11-05 10:49:14923 void OnSelectRange(const gfx::Point& base, const gfx::Point& extent);
avi6b8dbb32016-04-08 18:59:35924 void OnSuppressFurtherDialogs();
haibinluc643d33c2016-06-03 02:22:34925
Mark Lieu6cf3e8fa2019-03-09 02:09:01926 // Callback scheduled from SerializeAsMHTML for when writing serialized
Mark Lieuc625be62019-04-04 22:42:49927 // MHTML to the handle has been completed in the file thread.
928 void OnWriteMHTMLComplete(
Mark Lieu6cf3e8fa2019-03-09 02:09:01929 SerializeAsMHTMLCallback callback,
930 std::unordered_set<std::string> serialized_resources_uri_digests,
carlosk27fa0652016-10-05 23:10:36931 base::TimeDelta main_thread_use_time,
Mark Lieuc48b6cc2019-03-13 22:55:57932 mojom::MhtmlSaveStatus save_status);
carlosk27fa0652016-10-05 23:10:36933
Arthur Hemerybee4a752019-05-29 10:50:55934 // Requests that the browser process navigates to |url|.
935 void OpenURL(std::unique_ptr<blink::WebNavigationInfo> info);
[email protected]a09d53ce2014-01-31 00:46:42936
Minggang Wang035abc12020-11-05 03:05:15937 // Returns a blink::ChildURLLoaderFactoryBundle which can be used to request
Yuzhu Shen0c1715f2018-01-27 03:48:50938 // subresources for this frame.
939 // For frames with committed navigations, this bundle is created with the
940 // factories provided by the browser at navigation time. For any other frames
941 // (i.e. frames on the initial about:blank Document), the bundle returned here
942 // is lazily cloned from the parent or opener's own bundle.
Minggang Wang035abc12020-11-05 03:05:15943 blink::ChildURLLoaderFactoryBundle* GetLoaderFactoryBundle();
Yuzhu Shen0c1715f2018-01-27 03:48:50944
Lukasz Anforowiczcf7f598e2019-08-08 19:05:45945 // Clones and returns the creator's (parent's or opener's)
Minggang Wang035abc12020-11-05 03:05:15946 // blink::ChildURLLoaderFactoryBundle.
947 scoped_refptr<blink::ChildURLLoaderFactoryBundle>
Lukasz Anforowiczcf7f598e2019-08-08 19:05:45948 GetLoaderFactoryBundleFromCreator();
949
Lukasz Anforowicz18160d1a82020-08-04 16:09:22950 // Returns a mostly empty bundle, with a fallback that uses a process-wide,
951 // direct-network factory.
952 //
Lukasz Anforowiczb5eba582020-08-13 02:28:42953 // TODO(lukasza): https://crbug.com/1114822: Remove once the fallback is no
Lukasz Anforowicz18160d1a82020-08-04 16:09:22954 // longer needed.
Minggang Wang035abc12020-11-05 03:05:15955 scoped_refptr<blink::ChildURLLoaderFactoryBundle>
956 GetLoaderFactoryBundleFallback();
Lukasz Anforowicz18160d1a82020-08-04 16:09:22957
Minggang Wang035abc12020-11-05 03:05:15958 scoped_refptr<blink::ChildURLLoaderFactoryBundle> CreateLoaderFactoryBundle(
Dominic Farolinobc280d22019-12-05 05:49:24959 std::unique_ptr<blink::PendingURLLoaderFactoryBundle> info,
Hiroki Nakagawad7ed213e2020-07-21 13:19:28960 base::Optional<std::vector<blink::mojom::TransferrableURLLoaderPtr>>
Tsuyoshi Horo2cf21db2018-10-04 08:01:11961 subresource_overrides,
Kinuko Yasuda8fb556c2019-07-16 05:47:55962 mojo::PendingRemote<network::mojom::URLLoaderFactory>
963 prefetch_loader_factory);
clamyd6983032015-04-29 14:48:12964
[email protected]ef3adfc2014-05-11 00:04:54965 // Update current main frame's encoding and send it to browser window.
966 // Since we want to let users see the right encoding info from menu
967 // before finishing loading, we call the UpdateEncoding in
968 // a) function:DidCommitLoadForFrame. When this function is called,
969 // that means we have got first data. In here we try to get encoding
970 // of page if it has been specified in http header.
971 // b) function:DidReceiveTitle. When this function is called,
972 // that means we have got specified title. Because in most of webpages,
973 // title tags will follow meta tags. In here we try to get encoding of
974 // page if it has been specified in meta tag.
975 // c) function:DidFinishDocumentLoadForFrame. When this function is
976 // called, that means we have got whole html page. In here we should
977 // finally get right encoding of page.
Adithya Srinivasan57f44d0d2019-03-22 15:36:02978 void UpdateEncoding(blink::WebFrame* frame, const std::string& encoding_name);
[email protected]ef3adfc2014-05-11 00:04:54979
Avi Drissman4544828f2019-03-11 20:37:32980 base::Value GetJavaScriptExecutionResult(v8::Local<v8::Value> result);
zeeshanq3454e9c2014-09-04 21:30:28981
Antonio Gomes32f24faf2019-08-18 16:41:36982 void InitializeMediaStreamDeviceObserver();
[email protected]96307312014-05-04 01:00:19983
avi5cad4912015-06-19 05:25:44984 // Does preparation for the navigation to |url|.
985 void PrepareRenderViewForNavigation(
clamyda97e8322014-10-07 21:57:25986 const GURL& url,
Lucas Furukawa Gadania9c45682019-07-31 22:05:14987 const mojom::CommitNavigationParams& commit_params);
clamyda97e8322014-10-07 21:57:25988
arthursonzogni69824eb2016-07-13 16:22:03989 // Sends a FrameHostMsg_BeginNavigation to the browser
Arthur Hemerybee4a752019-05-29 10:50:55990 void BeginNavigationInternal(std::unique_ptr<blink::WebNavigationInfo> info,
Katie Dilloneb6c69812020-07-10 23:29:20991 bool is_history_navigation_in_new_child_frame,
992 base::TimeTicks renderer_before_unload_start,
993 base::TimeTicks renderer_before_unload_end);
clamyece38882014-11-19 15:00:20994
arthursonzognibe9935c2019-07-10 16:28:53995 // Used to load the initial empty document. This one is special, since it
996 // isn't the result of a navigation.
arthursonzogni915ce492020-11-24 16:48:33997 //
998 // TODO(arthursonzogni): Consider removing this function. Blink already have a
999 // concept of an initial empty document. It has already committed, as part of
1000 // constructing the blink::LocalFrame.
1001 // This function in reality commits an empty document a second time! Moreover
1002 // it isn't considered by blink to be an initial empty document
1003 // (CommitReason::kRegular, not CommitReason::kInitialization).
1004 // The purpose of this function is to trigger DidCommitNavigation, even if it
1005 // isn't associated with a real NavigationRequest.
1006 // See also:
1007 // - https://crbug.com/778318
1008 // - https://chromium-review.googlesource.com/c/chromium/src/+/804797
1009 // - https://github.com/whatwg/html/issues/3267
1010 void CommitInitialEmptyDocument(
1011 std::unique_ptr<blink::WebNavigationInfo> info);
Nate Chapina10f3d552018-12-17 20:05:261012
Dmitry Gozmanf5b5c5c2019-02-07 00:32:321013 // Commit navigation with |navigation_params| prepared.
1014 void CommitNavigationWithParams(
Lucas Furukawa Gadanief8290a2019-07-29 20:27:511015 mojom::CommonNavigationParamsPtr common_params,
Lucas Furukawa Gadania9c45682019-07-31 22:05:141016 mojom::CommitNavigationParamsPtr commit_params,
Dominic Farolinobc280d22019-12-05 05:49:241017 std::unique_ptr<blink::PendingURLLoaderFactoryBundle>
Dmitry Gozmanf5b5c5c2019-02-07 00:32:321018 subresource_loader_factories,
Hiroki Nakagawad7ed213e2020-07-21 13:19:281019 base::Optional<std::vector<blink::mojom::TransferrableURLLoaderPtr>>
Dmitry Gozmanf5b5c5c2019-02-07 00:32:321020 subresource_overrides,
1021 blink::mojom::ControllerServiceWorkerInfoPtr
1022 controller_service_worker_info,
Hiroki Nakagawa74cdcf32020-05-15 04:57:211023 blink::mojom::ServiceWorkerContainerInfoForClientPtr container_info,
Kinuko Yasuda8fb556c2019-07-16 05:47:551024 mojo::PendingRemote<network::mojom::URLLoaderFactory>
1025 prefetch_loader_factory,
Dmitry Gozmanf5b5c5c2019-02-07 00:32:321026 std::unique_ptr<DocumentState> document_state,
1027 std::unique_ptr<blink::WebNavigationParams> navigation_params);
1028
Dmitry Gozman7038dae2018-12-05 23:23:331029 // Decodes a data url for navigation commit.
Lucas Furukawa Gadanief8290a2019-07-29 20:27:511030 void DecodeDataURL(const mojom::CommonNavigationParams& common_params,
Lucas Furukawa Gadania9c45682019-07-31 22:05:141031 const mojom::CommitNavigationParams& commit_params,
Dmitry Gozman7038dae2018-12-05 23:23:331032 std::string* mime_type,
1033 std::string* charset,
1034 std::string* data,
1035 GURL* base_url);
clamy4cc9b8202015-03-02 13:51:361036
Dmitry Gozman710d69b2019-10-10 23:18:221037 // |transition_type| corresponds to the document which triggered this request.
Dmitry Gozman7335cab2019-03-20 03:31:401038 void WillSendRequestInternal(blink::WebURLRequest& request,
Kinuko Yasuda881484e72020-02-08 00:37:051039 bool for_main_frame,
Yutaka Hirano98549882020-08-06 08:43:331040 ui::PageTransition transition_type,
1041 ForRedirect for_redirect);
Dmitry Gozman4604d6e52019-03-14 03:00:461042
[email protected]f3a95312014-06-12 16:46:581043 // Returns the URL being loaded by the |frame_|'s request.
1044 GURL GetLoadingUrl() const;
1045
ben155ecf82016-06-21 22:43:261046 void RegisterMojoInterfaces();
halton.huoca2eabd2015-07-06 08:17:401047
skyostilb4cce1b2016-03-31 17:56:341048 void InitializeBlameContext(RenderFrameImpl* parent_frame);
1049
benb932d5a2017-04-26 19:40:131050 // service_manager::mojom::InterfaceProvider:
1051 void GetInterface(const std::string& interface_name,
1052 mojo::ScopedMessagePipeHandle interface_pipe) override;
1053
Gyuyoung Kim88708332020-07-01 03:21:021054 // Send |callback| our AndroidOverlay routing token.
liberato2ff93ad2017-05-17 07:28:241055 void RequestOverlayRoutingToken(media::RoutingTokenCallback callback);
liberatoa8da3b52017-05-02 20:23:511056
Miyoung Shin072d4052020-07-13 07:52:441057 void BindWebUIReceiver(mojo::PendingReceiver<mojom::WebUI> receiver);
1058
Lukasz Anforowiczc9513682020-03-11 03:13:261059 void ShowDeferredContextMenu(const UntrustworthyContextMenuParams& params);
Pedro Amaral741b117e02017-08-29 01:21:361060
arthursonzogni73fe3212020-11-17 13:24:071061 // Build DidCommitProvisionalLoadParams based on the frame internal state.
1062 mojom::DidCommitProvisionalLoadParamsPtr MakeDidCommitProvisionalLoadParams(
ckitagawac2e43402020-01-17 00:09:251063 blink::WebHistoryCommitType commit_type,
1064 ui::PageTransition transition,
arthursonzogni76098e52020-11-25 14:18:451065 network::mojom::WebSandboxFlags sandbox_flags,
1066 const blink::ParsedFeaturePolicy& feature_policy_header,
1067 const blink::DocumentPolicyFeatureState& document_policy_header,
ckitagawac2e43402020-01-17 00:09:251068 const base::Optional<base::UnguessableToken>& embedding_token);
Arthur Hemery268be322018-01-08 17:25:291069
Arthur Hemery2c613fa42018-01-08 09:36:321070 // Updates the navigation history depending on the passed parameters.
1071 // This could result either in the creation of a new entry or a modification
1072 // of the current entry or nothing. If a new entry was created,
1073 // returns true, false otherwise.
Miyoung Shin6acc5d52020-11-22 04:10:381074 void UpdateNavigationHistory(blink::WebHistoryCommitType commit_type);
Arthur Hemery2c613fa42018-01-08 09:36:321075
Arthur Hemeryb94d3db2018-01-08 12:42:421076 // Notify render_view_ observers that a commit happened.
Dmitry Gozman02dd8272020-06-09 20:01:231077 void NotifyObserversOfNavigationCommit(ui::PageTransition transition);
Arthur Hemeryb94d3db2018-01-08 12:42:421078
Arthur Hemeryc23999c2018-01-11 19:29:101079 // Updates the internal state following a navigation commit. This should be
1080 // called before notifying the FrameHost of the commit.
Miyoung Shin6acc5d52020-11-22 04:10:381081 void UpdateStateForCommit(blink::WebHistoryCommitType commit_type,
Dmitry Gozman730b21c2018-09-19 19:44:251082 ui::PageTransition transition);
Arthur Hemeryc23999c2018-01-11 19:29:101083
Arthur Hemery7b0ae492018-02-05 16:04:451084 // Internal function used by same document navigation as well as cross
1085 // document navigation that updates the state of the RenderFrameImpl and sends
1086 // a commit message to the browser process.
1087 void DidCommitNavigationInternal(
Arthur Hemery7b0ae492018-02-05 16:04:451088 blink::WebHistoryCommitType commit_type,
1089 bool was_within_same_document,
Dmitry Gozman730b21c2018-09-19 19:44:251090 ui::PageTransition transition,
arthursonzogni76098e52020-11-25 14:18:451091 network::mojom::WebSandboxFlags sandbox_flags,
1092 const blink::ParsedFeaturePolicy& feature_policy_header,
1093 const blink::DocumentPolicyFeatureState& document_policy_header,
ckitagawac2e43402020-01-17 00:09:251094 mojom::DidCommitProvisionalLoadInterfaceParamsPtr interface_params,
1095 const base::Optional<base::UnguessableToken>& embedding_token);
Arthur Hemery7b0ae492018-02-05 16:04:451096
Meredith Lane4947b2d72018-01-24 20:54:281097 blink::WebComputedAXTree* GetOrCreateWebComputedAXTree() override;
1098
Hiroki Nakagawaea68b642018-04-13 06:24:421099 std::unique_ptr<blink::WebSocketHandshakeThrottle>
1100 CreateWebSocketHandshakeThrottle() override;
Ehsan Karamad466529d2019-05-24 03:24:431101 bool IsPluginHandledExternally(
Ehsan Karamaded879582018-08-08 02:02:291102 const blink::WebElement& plugin_element,
1103 const blink::WebURL& url,
1104 const blink::WebString& suggested_mime_type) override;
Ehsan Karamade70a0352019-02-26 15:39:421105 v8::Local<v8::Object> GetScriptableObject(
1106 const blink::WebElement& plugin_element,
1107 v8::Isolate* isolate) override;
Hiroki Nakagawaea68b642018-04-13 06:24:421108
Julie Jeongeun Kimf445fc22019-05-29 12:46:021109 void UpdateSubresourceFactory(
Dominic Farolinobc280d22019-12-05 05:49:241110 std::unique_ptr<blink::PendingURLLoaderFactoryBundle> info) override;
Julie Jeongeun Kimf445fc22019-05-29 12:46:021111
clamyaf4bf2d92018-02-06 10:54:361112 // Updates the state of this frame when asked to commit a navigation.
Lucas Furukawa Gadania9c45682019-07-31 22:05:141113 void PrepareFrameForCommit(
1114 const GURL& url,
1115 const mojom::CommitNavigationParams& commit_params);
clamyaf4bf2d92018-02-06 10:54:361116
Maks Orlovich73f374d2020-04-02 12:46:131117 // Returns true if UA (and UA client hints) overrides in renderer preferences
1118 // should be used.
1119 bool ShouldUseUserAgentOverride() const;
1120
Rakina Zata Amni60858132020-08-19 10:33:481121 // Sets the PageLifecycleState and runs pagehide and visibilitychange handlers
1122 // of the old page before committing this RenderFrame. Should only be called
1123 // for main-frame same-site navigations where we did a proactive
1124 // BrowsingInstance swap and we're reusing the old page's process. This is
1125 // needed to ensure consistency with other same-site main frame navigations.
1126 // Note that we will set the page's visibility to hidden, but not run the
1127 // unload handlers of the old page, nor actually unload/freeze the page here.
1128 // That needs a more complicated support on the browser side which will be
1129 // implemented later.
1130 // TODO(crbug.com/1110744): Support unload-in-commit.
1131 void SetOldPageLifecycleStateFromNewPageCommitIfNeeded(
1132 const mojom::OldPageInfo* old_page_info);
1133
clamyaf4bf2d92018-02-06 10:54:361134 // Updates the state when asked to commit a history navigation. Sets
1135 // |item_for_history_navigation| and |load_type| to the appropriate values for
1136 // commit.
1137 //
1138 // The function will also return whether to proceed with the commit of a
1139 // history navigation or not. This can return false when the state of the
1140 // history in the browser process goes out of sync with the renderer process.
1141 // This can happen in the following scenario:
1142 // * this RenderFrame has a document with URL foo, which does a push state
1143 // to foo#bar.
1144 // * the user starts a navigation to foo/bar.
1145 // * the browser process asks this renderer process to commit the navigation
1146 // to foo/bar.
1147 // * the browser process starts a navigation back to foo, which it
1148 // considers same-document since the navigation to foo/bar hasn't
1149 // committed yet. It asks the RenderFrame to commit the same-document
1150 // navigation to foo#bar.
1151 // * by the time the RenderFrame receives the call to commit the
1152 // same-document back navigation, the navigation to foo/bar has committed.
1153 // A back navigation to foo is no longer same-document with the current
1154 // document of the RenderFrame (foo/bar). Therefore, the navigation cannot
1155 // be committed as a same-document navigation.
1156 // When this happens, the navigation will be sent back to the browser process
1157 // so that it can be performed in cross-document fashion.
1158 blink::mojom::CommitResult PrepareForHistoryNavigationCommit(
Lucas Furukawa Gadanief8290a2019-07-29 20:27:511159 const mojom::CommonNavigationParams& common_params,
Lucas Furukawa Gadania9c45682019-07-31 22:05:141160 const mojom::CommitNavigationParams& commit_params,
clamyaf4bf2d92018-02-06 10:54:361161 blink::WebHistoryItem* item_for_history_navigation,
1162 blink::WebFrameLoadType* load_type);
1163
Arthur Hemeryb8ead262019-03-18 12:13:461164 // Ignores the navigation commit and stop its processing in the RenderFrame.
1165 // This will drop the NavigationRequest in the RenderFrameHost.
1166 // Note: This is only meant to be used before building the DocumentState.
1167 // Commit abort and navigation end is handled by it afterwards.
Dmitry Gozman9b890002020-05-27 15:24:421168 void AbortCommitNavigation();
Arthur Hemeryb8ead262019-03-18 12:13:461169
Lily Chenee280942019-06-14 22:31:111170 // Implements AddMessageToConsole().
1171 void AddMessageToConsoleImpl(blink::mojom::ConsoleMessageLevel level,
1172 const std::string& message,
1173 bool discard_duplicates);
1174
creiscfaa4462015-03-16 19:27:181175 // Stores the WebLocalFrame we are associated with. This is null from the
Daniel Chengbd3794202017-06-21 09:30:101176 // constructor until BindToFrame() is called, and it is null after
1177 // FrameDetached() is called until destruction (which is asynchronous in the
creiscfaa4462015-03-16 19:27:181178 // case of the main frame, but not subframes).
Dmitry Gozmand96e493a82018-11-28 01:13:331179 blink::WebNavigationControl* frame_ = nullptr;
[email protected]b70da4c2014-01-06 19:57:091180
Tal Pressmanb011b2962020-09-28 11:22:551181 // The `AgentSchedulingGroup` this frame is associated with.
1182 AgentSchedulingGroup& agent_scheduling_group_;
1183
dglazkov2e140f52015-09-28 16:10:071184 // Boolean value indicating whether this RenderFrameImpl object is for the
1185 // main frame or not. It remains accurate during destruction, even when
1186 // |frame_| has been invalidated.
1187 bool is_main_frame_;
nasko8b9d9bd2015-05-06 19:23:191188
Miyoung Shin3e6393c2020-09-18 13:37:201189 class UniqueNameFrameAdapter : public blink::UniqueNameHelper::FrameAdapter {
dcheng61b2c9222017-05-25 23:10:111190 public:
1191 explicit UniqueNameFrameAdapter(RenderFrameImpl* render_frame);
1192 ~UniqueNameFrameAdapter() override;
1193
1194 // FrameAdapter overrides:
1195 bool IsMainFrame() const override;
Daniel Cheng6ca7f1c92017-08-09 21:45:411196 bool IsCandidateUnique(base::StringPiece name) const override;
dcheng61b2c9222017-05-25 23:10:111197 int GetSiblingCount() const override;
1198 int GetChildCount() const override;
Anders Hartvoll Ruud4bb45c62020-07-10 17:10:551199 std::vector<std::string> CollectAncestorNames(
dcheng61b2c9222017-05-25 23:10:111200 BeginPoint begin_point,
1201 bool (*should_stop)(base::StringPiece)) const override;
1202 std::vector<int> GetFramePosition(BeginPoint begin_point) const override;
1203
1204 private:
1205 blink::WebLocalFrame* GetWebFrame() const;
1206
1207 RenderFrameImpl* render_frame_;
1208 };
1209 UniqueNameFrameAdapter unique_name_frame_adapter_;
Miyoung Shin3e6393c2020-09-18 13:37:201210 blink::UniqueNameHelper unique_name_helper_;
Daniel Cheng999698bd2017-03-22 04:56:371211
naskoeab5c5582015-12-15 05:20:001212 // Indicates whether the frame has been inserted into the frame tree yet or
1213 // not.
1214 //
1215 // When a frame is created by the browser process, it is for a pending
1216 // navigation. In this case, it is not immediately attached to the frame tree
1217 // if there is a RenderFrameProxy for the same frame. It is inserted into the
1218 // frame tree at the time the pending navigation commits.
1219 // Frames added by the parent document are created from the renderer process
1220 // and are immediately inserted in the frame tree.
1221 // TODO(dcheng): Remove this once we have FrameTreeHandle and can use the
1222 // Blink Web* layer to check for provisional frames.
1223 bool in_frame_tree_;
1224
wjmaclean2a6cab72016-11-03 18:36:401225 RenderViewImpl* render_view_;
Fergal Dalyc93b7352020-04-07 19:47:431226 const int routing_id_;
nasko8b9d9bd2015-05-06 19:23:191227
arthursonzogni1efc7b962019-03-14 09:36:331228 // If this RenderFrame was created to replace a previous object, this will
1229 // store its routing id. The previous object can be:
1230 // - A RenderFrame. This requires RenderDocument to be enabled.
1231 // - A RenderFrameProxy.
1232 // At commit time, the two objects will be swapped and the old one cleared.
1233 int previous_routing_id_;
japhete6adf142014-10-31 00:01:491234
dcheng3d886b732015-11-05 19:16:011235 // Non-null when the RenderFrame is a local root for compositing, input,
1236 // layout, etc. A local frame is also a local root iff it does not have a
1237 // parent that is a local frame.
Erik Chen3433ee02019-08-05 20:14:261238 RenderWidget* render_widget_ = nullptr;
1239
1240 // If this is a main frame, the RenderView owns the RenderWidget and this
1241 // member is null. If this is a child frame, then this object owns the
1242 // RenderWidget and this member is not null.
1243 std::unique_ptr<RenderWidget> owned_render_widget_;
kenrba7199832015-01-22 23:44:591244
creisc8ca51e2016-09-29 23:10:281245 // Keeps track of which future subframes the browser process has history items
Charles Reis37c95492016-10-21 20:38:581246 // for during a history navigation, as well as whether those items are for
1247 // about:blank. The renderer process should ask the browser for history items
1248 // when subframes with these names are created (as long as they are not
1249 // staying at about:blank), and directly load the initial URLs for any other
1250 // subframes.
1251 //
1252 // This state is incrementally cleared as it is used and then reset in
1253 // didStopLoading, since it is not needed after the first load completes and
1254 // is never used after the initial navigation.
creisc8ca51e2016-09-29 23:10:281255 // TODO(creis): Expand this to include any corresponding same-process
1256 // PageStates for the whole subtree in https://crbug.com/639842.
Lucas Furukawa Gadania9c45682019-07-31 22:05:141257 base::flat_map<std::string, bool> history_subframe_unique_names_;
creis45b3bba2016-09-22 22:47:131258
[email protected]2e2d9632013-12-03 00:55:261259 // All the registered observers.
Trent Apteda250ec3ab2018-08-19 08:52:191260 base::ObserverList<RenderFrameObserver>::Unchecked observers_;
[email protected]2e2d9632013-12-03 00:55:261261
[email protected]a09d53ce2014-01-31 00:46:421262 // External context menu requests we're waiting for. "Internal"
1263 // (WebKit-originated) context menu events will have an ID of 0 and will not
1264 // be in this map.
1265 //
1266 // We don't want to add internal ones since some of the "special" page
1267 // handlers in the browser process just ignore the context menu requests so
1268 // avoid showing context menus, and so this will cause right clicks to leak
1269 // entries in this map. Most users of the custom context menu (e.g. Pepper
1270 // plugins) are normally only on "regular" pages and the regular pages will
1271 // always respond properly to the request, so we don't have to worry so
1272 // much about leaks.
Brett Wilsonf976d3f2017-08-18 17:23:391273 base::IDMap<ContextMenuClient*> pending_context_menus_;
[email protected]a09d53ce2014-01-31 00:46:421274
[email protected]4ee64622014-03-21 22:34:151275 // The text selection the last time DidChangeSelection got called. May contain
1276 // additional characters before and after the selected text, for IMEs. The
1277 // portion of this string that is the actual selected text starts at index
1278 // |selection_range_.GetMin() - selection_text_offset_| and has length
1279 // |selection_range_.length()|.
1280 base::string16 selection_text_;
1281 // The offset corresponding to the start of |selection_text_| in the document.
1282 size_t selection_text_offset_;
1283 // Range over the document corresponding to the actual selected text (which
1284 // could correspond to a substring of |selection_text_|; see above).
1285 gfx::Range selection_range_;
[email protected]4ee64622014-03-21 22:34:151286
Guido Urdanetad8c24a5212019-08-03 08:35:461287 // Implements getUserMedia() and related functionality.
Antonio Gomes32f24faf2019-08-18 16:41:361288 std::unique_ptr<blink::WebMediaStreamDeviceObserver>
1289 web_media_stream_device_observer_;
[email protected]96307312014-05-04 01:00:191290
Guido Urdaneta3a7cd9e62020-07-21 08:31:281291 mojo::Remote<blink::mojom::RendererAudioInputStreamFactory>
Mario Sanchez Prada22694e5a2019-09-13 07:16:571292 audio_input_stream_factory_;
Max Morin3d464a42018-01-15 11:17:001293
xhwang6bca21e2016-02-06 00:21:451294 // The media permission dispatcher attached to this frame.
dchengcedca5612016-04-09 01:40:151295 std::unique_ptr<MediaPermissionDispatcher> media_permission_dispatcher_;
xhwang36b1f3b2015-01-27 17:54:011296
Ben Goodgerd5ee3cc2017-07-24 23:11:361297 service_manager::BinderRegistry registry_;
sammc7f964632016-10-14 04:16:211298 std::unique_ptr<BlinkInterfaceRegistryImpl> blink_interface_registry_;
[email protected]c52a1412014-06-25 06:09:251299
Oksana Zhuravlovafee097c2019-07-26 17:01:301300 blink::BrowserInterfaceBrokerProxy browser_interface_broker_proxy_;
Oksana Zhuravlova8b88e572019-01-07 21:54:001301
Mario Sanchez Prada60a014b72020-02-20 19:08:061302 // Valid during the entire life time of the RenderFrame.
1303 std::unique_ptr<RenderAccessibilityManager> render_accessibility_manager_;
[email protected]95640212014-07-26 18:14:301304
xiaochengh01c3b102016-06-13 23:56:081305 std::unique_ptr<FrameBlameContext> blame_context_;
skyostilb4cce1b2016-03-31 17:56:341306
Minggang Wange0d5db32020-10-07 15:55:311307 std::unique_ptr<blink::WeakWrapperResourceLoadInfoNotifier>
1308 weak_wrapper_resource_load_info_notifier_;
1309
lfge0c2792ec2016-05-11 18:52:081310 // Plugins -------------------------------------------------------------------
brettw4b461082016-11-19 18:55:161311#if BUILDFLAG(ENABLE_PLUGINS)
lfge0c2792ec2016-05-11 18:52:081312 typedef std::set<PepperPluginInstanceImpl*> PepperPluginSet;
1313 PepperPluginSet active_pepper_instances_;
1314
1315 // Whether or not the focus is on a PPAPI plugin
1316 PepperPluginInstanceImpl* focused_pepper_plugin_;
lfge0c2792ec2016-05-11 18:52:081317#endif
1318
Becca Hughes3da69b742018-04-13 19:05:061319 using AutoplayOriginAndFlags = std::pair<url::Origin, int32_t>;
1320 AutoplayOriginAndFlags autoplay_flags_;
scottmg276753cf2016-10-27 18:25:221321
Mario Sanchez Pradab3b852f2019-10-04 17:53:241322 mojo::AssociatedReceiver<blink::mojom::AutoplayConfigurationClient>
1323 autoplay_configuration_receiver_{this};
Henrique Ferreiro3a9751c2019-09-30 13:54:071324 mojo::Receiver<mojom::Frame> frame_receiver_{this};
1325 mojo::AssociatedReceiver<mojom::FrameBindingsControl>
1326 frame_bindings_control_receiver_{this};
Shimi Zhangbb738072019-07-09 18:54:401327 mojo::AssociatedReceiver<mojom::FrameNavigationControl>
Mario Sanchez Pradab3b852f2019-10-04 17:53:241328 frame_navigation_control_receiver_{this};
1329 mojo::AssociatedReceiver<mojom::FullscreenVideoElementHandler>
1330 fullscreen_receiver_{this};
1331 mojo::AssociatedReceiver<mojom::MhtmlFileWriter> mhtml_file_writer_receiver_{
1332 this};
ben76f52b242016-06-18 05:42:481333
Daniel Cheng039670a42020-11-21 00:00:581334 // There are two different kinds of NavigationClients, the request
1335 // NavigationClient and the commit NavigationClient.
1336 //
1337 // ## Request NavigationClient ##
1338 // Set if and only if the frame that initiated the navigation and the frame
1339 // being navigated are both RenderFrameImpls in the same frame tree (i.e. the
1340 // navigation does not ever go through a RenderFrameProxy). This has
1341 // interesting implications for behavior differences between the two example
1342 // frame trees below:
1343 //
1344 // a.com a.com
1345 // ↓ ↓
1346 // b.com example.a.com
1347 //
1348 // Assuming the standard site-per-process allocation policy, though (a.com) is
1349 // cross-origin to both (b.com) and (example.a.com):
1350 //
1351 // - (a.com) performing a navigation in (b.com) *will not* create a request
1352 // NavigationClient but
1353 // - (a.com) performing a navigation in (example.a.com) *will* create a
1354 // request
1355 //
1356 // Finally, note that the initiating RenderFrameImpl does *not* own the
1357 // request NavigationClient. Rather, the RanderFrameImpl that the navigation
1358 // *targets* is the RenderFrameImpl that owns the request NavigationClient.
1359 //
1360 // ## Commit NavigationClient ##
1361 // Always set in the RenderFrameImpl that has been selected to commit a
1362 // navigation. This selection happens when the NavigationRequest in the
1363 // browser process reaches READY_TO_COMMIT.
1364 //
1365 // If a navigation will commit in the same RenderFrameImpl that owns the
1366 // request NavigationClient, the request NavigationClient will be reused as
1367 // the commit NavigationClient.
1368 //
1369 // ## Navigation Cancellation ##
1370 // Cancellation is signalled by resetting the NavigationClient. This will
1371 // eventually trigger a connection error in the browser process, which
1372 // normally invokes NavigationRequest::OnRendererAbortedNavigation().
1373 //
1374 // However, once the NavigationRequest reaches READY_TO_COMMIT in the browser
1375 // process, *only* the commit NavigationClient may cancel the navigation. This
1376 // has several implications:
1377 //
1378 // - Web APIs like window.stop() and document() use AbortClientNavigation().
1379 // However, once the NavigationRequest reaches READY_TO_COMMIT, cancellation
1380 // is only respected if the navigation reuses the same RenderFrameImpl;
1381 // otherwise, it is ignored.
1382 //
1383 // Note that using RenderDocument means that all cross-document navigations
1384 // will use a provisional RenderFrameImpl: as such, all cross-document
1385 // navigations with RenderDocument will ignore cancellation after
1386 // READY_TO_COMMIT. This will be a compatibility issue for shipping
1387 // RenderDocument: see https://crbug.com/763106 for historical context.
1388 //
1389 // - If the frame is owned by an <object> element, CommitFailedNavigation()
1390 // will first trigger the fallback path (for remote frames, this
1391 // unconditionally sends the RenderFallbackContentInParentProcess() IPC; for
1392 // local frames, things are a bit more complicated...) before then
1393 // unconditionally calling AbortCommitNavigation() to ignore the commit.
1394 //
1395 // TODO(dcheng): The browser side knows the owner type of the navigating
1396 // frame. Don't bother sending a commit at all in that case.
Arthur Hemeryd3011f62018-05-30 10:38:441397 std::unique_ptr<NavigationClient> navigation_client_impl_;
1398
chcunningham86f025e32017-05-30 20:43:231399 // Creates various media clients.
1400 MediaFactory media_factory_;
1401
Ken Rockot26e4e802018-07-31 15:03:331402 blink::AssociatedInterfaceRegistry associated_interfaces_;
1403 std::unique_ptr<blink::AssociatedInterfaceProvider>
rockotf62002a2016-09-15 00:08:591404 remote_associated_interfaces_;
1405
Dmitry Gozman6b7727d2019-05-06 18:30:241406 // This flag is true while browser process is processing a pending navigation,
1407 // as a result of mojom::FrameHost::BeginNavigation call. It is reset when the
1408 // navigation is either committed or cancelled.
jam485372b12016-10-26 19:46:071409 bool browser_side_navigation_pending_ = false;
jam485372b12016-10-26 19:46:071410
sammc7f6c6a02017-01-30 00:53:511411 // A bitwise OR of bindings types that have been enabled for this RenderFrame.
1412 // See BindingsPolicy for details.
1413 int enabled_bindings_ = 0;
1414
Nasko Oskov8a73f7d2019-09-27 22:29:321415 // This boolean indicates whether JS bindings for Mojo should be enabled at
1416 // the time the next script context is created.
1417 bool enable_mojo_js_bindings_ = false;
1418
Mario Sanchez Pradab3b852f2019-10-04 17:53:241419 mojo::AssociatedRemote<mojom::FrameHost> frame_host_remote_;
Gyuyoung Kim6c9ce9022019-11-26 05:40:081420 mojo::ReceiverSet<service_manager::mojom::InterfaceProvider>
1421 interface_provider_receivers_;
benb932d5a2017-04-26 19:40:131422
Minggang Wangd712a912020-07-10 08:12:351423 mojo::ReceiverSet<blink::mojom::ResourceLoadInfoNotifier>
1424 resource_load_info_notifier_receivers_;
1425
Yuzhu Shen0c1715f2018-01-27 03:48:501426 // URLLoaderFactory instances used for subresource loading.
Chong Zhang4513fab2018-02-28 18:50:181427 // Depending on how the frame was created, |loader_factories_| could be:
1428 // * |HostChildURLLoaderFactoryBundle| for standalone frames, or
1429 // * |TrackedChildURLLoaderFactoryBundle| for frames opened by other frames.
Lukasz Anforowiczcf7f598e2019-08-08 19:05:451430 //
1431 // This must be updated only via SetLoaderFactoryBundle, which is called at a
1432 // certain timing - right before the new document is committed during
1433 // FrameLoader::CommitNavigation.
Minggang Wang035abc12020-11-05 03:05:151434 scoped_refptr<blink::ChildURLLoaderFactoryBundle> loader_factories_;
Ken Rockotbe87ab322017-11-02 19:40:231435
Dmitry Gozman5e95b592020-03-04 23:01:511436 // Loader factory bundle is stored here temporary between CommitNavigation
1437 // and DidCommitNavigation calls. These happen synchronously one after
1438 // another.
Minggang Wang035abc12020-11-05 03:05:151439 scoped_refptr<blink::ChildURLLoaderFactoryBundle> pending_loader_factories_;
Dmitry Gozman5e95b592020-03-04 23:01:511440
Hiroki Nakagawa8600c372020-07-23 01:53:261441 scoped_refptr<blink::WebFrameRequestBlocker> frame_request_blocker_;
John Abd-El-Malek9405d80e2018-08-08 16:50:211442
liberatoa8da3b52017-05-02 20:23:511443 // AndroidOverlay routing token from the browser, if we have one yet.
1444 base::Optional<base::UnguessableToken> overlay_routing_token_;
1445
Pavel Feldman25234722017-10-11 02:49:061446 // Used for devtools instrumentation and trace-ability. This token is
1447 // used to tag calls and requests in order to attribute them to the context
1448 // frame.
1449 // |devtools_frame_token_| is only defined by the browser and is never
1450 // sent back from the renderer in the control calls.
Dmitry Gozmanf12caab2018-02-07 03:45:581451 base::UnguessableToken devtools_frame_token_;
Pavel Feldman25234722017-10-11 02:49:061452
Meredith Lane4947b2d72018-01-24 20:54:281453 // Contains a representation of the accessibility tree stored in content for
1454 // use inside of Blink.
1455 std::unique_ptr<blink::WebComputedAXTree> computed_ax_tree_;
1456
Lucas Gadani471160f92018-03-01 03:13:211457 // Used for tracking the frame's size and replicating it to the browser
1458 // process when it changes.
1459 base::Optional<gfx::Size> frame_size_;
1460
Justin Mironc3452f92020-01-24 14:31:091461 // Used for tracking a frame's main frame document intersection and
1462 // and replicating it to the browser when it changes.
Justin Miron95fddee2020-07-10 16:46:371463 base::Optional<blink::WebRect> mainframe_intersection_rect_;
Justin Mironc3452f92020-01-24 14:31:091464
Hiroki Nakagawaea68b642018-04-13 06:24:421465 std::unique_ptr<WebSocketHandshakeThrottleProvider>
1466 websocket_handshake_throttle_provider_;
1467
Sergey Volk8b09c2c52018-12-12 23:20:401468 RenderFrameMediaPlaybackOptions renderer_media_playback_options_;
1469
Dmitry Gozmanf5b5c5c2019-02-07 00:32:321470 class MHTMLBodyLoaderClient;
1471 std::unique_ptr<MHTMLBodyLoaderClient> mhtml_body_loader_client_;
1472
Vladimir Levincfca8522019-07-30 19:01:211473 std::unique_ptr<blink::WebURLLoaderFactoryForTest>
Vladimir Levinb41bfe42019-07-16 21:13:441474 web_url_loader_factory_override_for_test_;
1475
Daniel Cheng8a8a9202020-08-10 19:46:571476 // When the browser asks the renderer to commit a navigation, it should always
1477 // result in a committed navigation reported via DidCommitProvisionalLoad().
1478 // This is important because DidCommitProvisionalLoad() is responsible for
1479 // swapping in the provisional local frame during a cross-process navigation.
1480 // Since this involves updating state in both the browser process and the
1481 // renderer process, this assert ensures that the state remains synchronized
1482 // between the two processes.
1483 //
1484 // Note: there is one exception that can result in no commit happening.
1485 // Committing a navigation runs unload handlers, which can detach |this|. In
1486 // that case, it doesn't matter that the navigation never commits, since the
1487 // logical node for |this| has been removed from the DOM.
1488 enum class NavigationCommitState {
1489 // Represents the initial empty document. This is represented separately
1490 // from |kNone| because Blink does not report the commit of the initial
1491 // empty document in a newly created frame. However, note that there are
1492 // some surprising quirks:
1493 //
1494 // <iframe></iframe>
1495 //
1496 // will *not* be in the |kInitialEmptyDocument| state: while it initially
1497 // starts at the initial empty document, the initial empty document is then
1498 // synchronously replaced with a navigation to about:blank. In contrast:
1499 //
1500 // <iframe src="https://slow.example.com"></iframe>
1501 //
1502 // will be in |kInitialEmptyDocument| until the navigation to
1503 // https://slow.example.com commits.
1504 kInitialEmptyDocument,
1505 // No commit in progress. This state also implies that the frame is not
1506 // displaying the initial empty document.
1507 kNone,
1508 // Marks that an active commit attempt is on the stack.
1509 kWillCommit,
1510 // Marks an active commit attempt as successful.
1511 kDidCommit,
1512 };
1513
1514 enum MayReplaceInitialEmptyDocumentTag {
1515 kMayReplaceInitialEmptyDocument,
1516 };
1517
1518 class CONTENT_EXPORT AssertNavigationCommits {
1519 public:
1520 // Construct a new scoper to verify that a navigation commit attempt
1521 // succeeds. Asserts that:
1522 // - no navigation is in progress
1523 // - the frame is not displaying the initial empty document.
1524 explicit AssertNavigationCommits(RenderFrameImpl* frame);
1525
1526 // Similar to the previous constructor but allows transitions from the
1527 // initial empty document.
1528 explicit AssertNavigationCommits(RenderFrameImpl* frame,
1529 MayReplaceInitialEmptyDocumentTag);
1530
1531 ~AssertNavigationCommits();
1532
1533 private:
1534 explicit AssertNavigationCommits(
1535 RenderFrameImpl* frame,
1536 bool allow_transition_from_initial_empty_document);
1537
1538 const base::WeakPtr<RenderFrameImpl> frame_;
1539 };
1540
1541 NavigationCommitState navigation_commit_state_ =
1542 NavigationCommitState::kInitialEmptyDocument;
1543
Jeremy Roman3bca4bf2019-07-11 03:41:251544 base::WeakPtrFactory<RenderFrameImpl> weak_factory_{this};
[email protected]96307312014-05-04 01:00:191545
[email protected]227692c52013-05-31 22:43:041546 DISALLOW_COPY_AND_ASSIGN(RenderFrameImpl);
1547};
1548
1549} // namespace content
1550
[email protected]85d85fd2013-06-19 00:57:411551#endif // CONTENT_RENDERER_RENDER_FRAME_IMPL_H_