[go: nahoru, domu]

blob: f170559073b6086ad5fc09e840fa09b2e0e2d4fa [file] [log] [blame]
nasko@chromium.org227692c52013-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_PUBLIC_BROWSER_RENDER_FRAME_HOST_H_
6#define CONTENT_PUBLIC_BROWSER_RENDER_FRAME_HOST_H_
7
avi@chromium.org67048bd2014-03-18 07:32:358#include <string>
Lukasz Anforowicze1b954d92017-10-30 21:28:069#include <vector>
avi@chromium.org67048bd2014-03-18 07:32:3510
avi@chromium.orgf13ab892014-03-12 06:48:5211#include "base/callback_forward.h"
Lukasz Anforowicz4b630b42018-11-08 05:23:3512#include "base/containers/flat_set.h"
Paul Meyer8846a412018-10-31 21:59:4013#include "base/feature_list.h"
John Delaney0146a742019-01-25 19:25:2814#include "base/optional.h"
avi652869c2015-12-25 01:48:4515#include "build/build_config.h"
Dave Tapuskafc4adbae2020-12-02 22:08:5916#include "cc/input/browser_controls_state.h"
nasko@chromium.org227692c52013-05-31 22:43:0417#include "content/common/content_export.h"
Patrick Monette275a6f92b2020-01-09 21:05:0418#include "content/public/browser/global_routing_id.h"
Hajime Hoshif85e7cf722019-07-19 00:54:4919#include "content/public/common/isolated_world_ids.h"
Collin Baker98457b52019-11-06 21:34:2920#include "content/public/common/page_visibility_state.h"
nasko@chromium.org227692c52013-05-31 22:43:0421#include "ipc/ipc_listener.h"
22#include "ipc/ipc_sender.h"
Julie Jeongeun Kimb405097b2019-10-10 15:34:0723#include "mojo/public/cpp/bindings/pending_receiver.h"
Miyoung Shin298d5ad2019-09-05 01:52:3724#include "mojo/public/cpp/bindings/remote.h"
Alexander Timine3ec4192020-04-20 16:39:4025#include "services/metrics/public/cpp/ukm_source_id.h"
Takuto Ikutaaa3b796c2019-02-06 02:54:5626#include "services/network/public/mojom/url_loader_factory.mojom-forward.h"
Charlie Hu5ecaae02020-02-20 15:12:1827#include "third_party/blink/public/common/feature_policy/document_policy.h"
Luna Lu0c2cd5a2019-02-12 16:24:5928#include "third_party/blink/public/common/feature_policy/feature_policy.h"
Alexander Timin5afc73e2019-06-24 01:03:1029#include "third_party/blink/public/common/scheduler/web_scheduler_tracked_feature.h"
Yao Xiao24ec9aa2020-01-28 16:36:0030#include "third_party/blink/public/mojom/ad_tagging/ad_frame.mojom-forward.h"
Abhijeet Kandalkara5928a0a2019-03-13 05:04:4231#include "third_party/blink/public/mojom/devtools/console_message.mojom.h"
John Delaney98800572019-10-14 23:02:0832#include "third_party/blink/public/mojom/frame/frame.mojom.h"
Antonio Gomes58d38062020-04-30 01:50:1433#include "third_party/blink/public/mojom/frame/frame_owner_element_type.mojom.h"
Dave Tapuska97d22ab2019-12-03 17:56:3634#include "third_party/blink/public/mojom/frame/sudden_termination_disabler_type.mojom.h"
Mike Wassermana11c45f2020-09-30 23:52:4935#include "third_party/blink/public/mojom/frame/user_activation_notification_type.mojom.h"
Takuto Ikutaaa3b796c2019-02-06 02:54:5636#include "third_party/blink/public/mojom/loader/pause_subresource_loading_handle.mojom-forward.h"
Ken Buchanan3889e2b2020-02-11 04:26:5337#include "third_party/blink/public/mojom/webauthn/authenticator.mojom.h"
Dominic Mazzoni336bc0062018-09-23 16:46:4338#include "ui/accessibility/ax_tree_id.h"
tfarina3b0452d2014-12-31 15:20:0939#include "ui/gfx/geometry/rect.h"
jam@chromium.org6dd625e2013-12-20 17:03:0740#include "ui/gfx/native_widget_types.h"
kaznacheev@chromium.org2114da52014-02-28 15:17:5741#include "url/gurl.h"
nick1466c842015-11-25 20:08:0642#include "url/origin.h"
nasko@chromium.org227692c52013-05-31 22:43:0443
iclelland08debb32017-04-13 21:24:1444namespace blink {
Sam McNally52e50282017-11-29 00:54:0245class AssociatedInterfaceProvider;
Luna Lu730f283f2018-02-08 16:38:0346namespace mojom {
Luna Lubd7ae2f2017-11-07 15:18:0347enum class FeaturePolicyFeature;
Luna Lu730f283f2018-02-08 16:38:0348} // namespace mojom
49} // namespace blink
iclelland08debb32017-04-13 21:24:1450
avi@chromium.orgf13ab892014-03-12 06:48:5251namespace base {
Alexander Timinf8c2fe642020-08-07 22:18:3352namespace trace_event {
53class TracedValue;
54} // namespace trace_event
55
Pavel Feldman25234722017-10-11 02:49:0656class UnguessableToken;
avi@chromium.orgf13ab892014-03-12 06:48:5257class Value;
ckitagawa25042572020-05-28 14:43:1958} // namespace base
avi@chromium.orgf13ab892014-03-12 06:48:5259
Paul Meyer8846a412018-10-31 21:59:4060namespace features {
61CONTENT_EXPORT extern const base::Feature kCrashReporting;
62} // namespace features
63
Matt Menke2a33dee2019-12-02 17:01:5464namespace net {
Matt Menkee3968712020-04-07 23:07:2465class IsolationInfo;
Matt Menke2a33dee2019-12-02 17:01:5466class NetworkIsolationKey;
67}
68
rockot400ea35b2016-10-15 19:15:3269namespace service_manager {
ben155ecf82016-06-21 22:43:2670class InterfaceProvider;
71}
72
dmazzonie6f29fc2016-10-19 16:34:2973namespace ui {
74struct AXActionData;
75}
76
nasko@chromium.org227692c52013-05-31 22:43:0477namespace content {
Dave Tapuskab336b922017-07-06 19:24:0578
jam@chromium.orga86c0e962013-12-17 17:10:3979class RenderProcessHost;
jam@chromium.org1a4e9752013-12-31 20:10:5880class RenderViewHost;
kenrb015b5b52016-01-26 15:57:5281class RenderWidgetHostView;
jam@chromium.org6dd625e2013-12-20 17:03:0782class SiteInstance;
Alexander Timin16a53952020-04-28 18:27:3983class BrowserContext;
84class StoragePartition;
Nasko Oskov310c66a2020-05-18 21:58:5785class WebUI;
nasko@chromium.org227692c52013-05-31 22:43:0486
87// The interface provides a communication conduit with a frame in the renderer.
Rouslan Solomakhinaf1dda912020-10-05 11:29:0588// The preferred way to keep a reference to a RenderFrameHost is storing a
89// GlobalFrameRoutingId and using RenderFrameHost::FromID() when you need to
90// access it.
nasko@chromium.org227692c52013-05-31 22:43:0491class CONTENT_EXPORT RenderFrameHost : public IPC::Listener,
92 public IPC::Sender {
ajwong@chromium.org1c2052f2013-08-28 08:24:3493 public:
lpze83861a2017-05-25 14:14:1994 // Constant used to denote that a lookup of a FrameTreeNode ID has failed.
95 static const int kNoFrameTreeNodeId = -1;
96
jam@chromium.orga86c0e962013-12-17 17:10:3997 // Returns the RenderFrameHost given its ID and the ID of its render process.
mlamouri8c61ffc2015-01-13 16:17:5998 // Returns nullptr if the IDs do not correspond to a live RenderFrameHost.
Patrick Monette275a6f92b2020-01-09 21:05:0499 static RenderFrameHost* FromID(GlobalFrameRoutingId id);
jam@chromium.orga86c0e962013-12-17 17:10:39100 static RenderFrameHost* FromID(int render_process_id, int render_frame_id);
101
Jochen Eisinger14ea9772015-07-24 12:04:37102 // Globally allows for injecting JavaScript into the main world. This feature
Clark DuVall1a196bf2019-11-05 20:05:15103 // is present only to support Android WebView, WebLayer, Fuchsia web.Contexts,
104 // and CastOS content shell. It must not be used in other configurations.
Kevin Marshallb2696402018-11-02 02:53:18105 static void AllowInjectingJavaScript();
Jochen Eisinger14ea9772015-07-24 12:04:37106
dmazzoni1efe8792015-08-07 01:02:15107 // Returns a RenderFrameHost given its accessibility tree ID.
Dominic Mazzoni336bc0062018-09-23 16:46:43108 static RenderFrameHost* FromAXTreeID(ui::AXTreeID ax_tree_id);
dmazzoni1efe8792015-08-07 01:02:15109
lpze83861a2017-05-25 14:14:19110 // Returns the FrameTreeNode ID corresponding to the specified |process_id|
111 // and |routing_id|. This routing ID pair may represent a placeholder for
112 // frame that is currently rendered in a different process than |process_id|.
113 static int GetFrameTreeNodeIdForRoutingId(int process_id, int routing_id);
114
Gyuyoung Kim5f7f4c72020-07-14 13:09:03115 // Returns the RenderFrameHost corresponding to the
116 // |placeholder_frame_token| in the given |render_process_id|. The returned
117 // RenderFrameHost will always be in a different process. It may be null if
118 // the placeholder is not found in the given process, which may happen if the
119 // frame was recently deleted or swapped to |render_process_id| itself.
120 static RenderFrameHost* FromPlaceholderToken(
121 int render_process_id,
122 const base::UnguessableToken& placeholder_frame_token);
Wei Li5bb65972018-02-14 03:07:58123
Danyao Wangc7bdca42020-03-12 15:52:52124#if defined(OS_ANDROID)
125 // Returns the RenderFrameHost object associated with a Java native pointer.
126 static RenderFrameHost* FromJavaRenderFrameHost(
127 const base::android::JavaRef<jobject>& jrender_frame_host_android);
128#endif
129
dchenge933b3e2014-10-21 11:44:09130 ~RenderFrameHost() override {}
ajwong@chromium.org1c2052f2013-08-28 08:24:34131
creis@chromium.org27dd82fd2014-03-03 22:11:43132 // Returns the route id for this frame.
133 virtual int GetRoutingID() = 0;
134
Antonio Gomes256e8a402020-05-26 03:20:07135 // Returns the frame token for this frame.
136 virtual const base::UnguessableToken& GetFrameToken() = 0;
137
dmazzoni1efe8792015-08-07 01:02:15138 // Returns the accessibility tree ID for this RenderFrameHost.
Dominic Mazzoni336bc0062018-09-23 16:46:43139 virtual ui::AXTreeID GetAXTreeID() = 0;
dmazzoni1efe8792015-08-07 01:02:15140
creis@chromium.org27dd82fd2014-03-03 22:11:43141 // Returns the SiteInstance grouping all RenderFrameHosts that have script
142 // access to this RenderFrameHost, and must therefore live in the same
143 // process.
Alexander Timin16a53952020-04-28 18:27:39144 // Associated SiteInstance never changes.
jam@chromium.org6dd625e2013-12-20 17:03:07145 virtual SiteInstance* GetSiteInstance() = 0;
146
jam@chromium.orga86c0e962013-12-17 17:10:39147 // Returns the process for this frame.
Alexander Timin16a53952020-04-28 18:27:39148 // Associated RenderProcessHost never changes.
jam@chromium.orga86c0e962013-12-17 17:10:39149 virtual RenderProcessHost* GetProcess() = 0;
150
Jochen Eisinger37c74c522020-10-05 17:46:00151 // Returns the GlobalFrameRoutingId for this frame. Embedders should store
152 // this instead of a raw RenderFrameHost pointer.
153 virtual GlobalFrameRoutingId GetGlobalFrameRoutingId() = 0;
154
Alexander Timin16a53952020-04-28 18:27:39155 // Returns a StoragePartition associated with this RenderFrameHost.
156 // Associated StoragePartition never changes.
157 virtual StoragePartition* GetStoragePartition() = 0;
158
159 // Returns the user browser context associated with this RenderFrameHost.
160 // Associated BrowserContext never changes.
161 virtual BrowserContext* GetBrowserContext() = 0;
162
kenrb015b5b52016-01-26 15:57:52163 // Returns the RenderWidgetHostView that can be used to control focus and
164 // visibility for this frame.
165 virtual RenderWidgetHostView* GetView() = 0;
166
Alexander Timinfe6cc8d2020-03-15 17:38:13167 // Returns the parent of this RenderFrameHost, or nullptr if this
168 // RenderFrameHost is the main one and there is no parent.
169 // The result may be in a different process than the
mlamouri8c61ffc2015-01-13 16:17:59170 // current RenderFrameHost.
kaznacheev@chromium.org2114da52014-02-28 15:17:57171 virtual RenderFrameHost* GetParent() = 0;
172
Alexander Timinfe6cc8d2020-03-15 17:38:13173 // Returns the eldest parent of this RenderFrameHost.
174 // Always non-null, but might be equal to |this|.
175 // The result may be in a different process that the current RenderFrameHost.
176 //
177 // NOTE: The result might be different from
178 // WebContents::FromRenderFrameHost(this)->GetMainFrame().
179 // This function (RenderFrameHost::GetMainFrame) is the preferred API in
180 // almost all of the cases. See RenderFrameHost::IsCurrent for the details.
181 virtual RenderFrameHost* GetMainFrame() = 0;
182
John Delaney98800572019-10-14 23:02:08183 // Returns a vector of all RenderFrameHosts in the subtree rooted at |this|.
184 // The results may be in different processes.
185 // TODO(https://crbug.com/1013740): Consider exposing a way for the browser
186 // process to run a function across a subtree in all renderers rather than
187 // exposing the RenderFrameHosts of the frames here.
188 virtual std::vector<RenderFrameHost*> GetFramesInSubtree() = 0;
189
Arthur Sonzogni969a794e2018-10-11 08:56:09190 // Returns whether or not this RenderFrameHost is a descendant of |ancestor|.
191 // This is equivalent to check that |ancestor| is reached by iterating on
192 // GetParent().
193 // This is a strict relationship, a RenderFrameHost is never an ancestor of
194 // itself.
195 virtual bool IsDescendantOf(RenderFrameHost* ancestor) = 0;
196
rob3e2a0732016-01-06 21:22:09197 // Returns the FrameTreeNode ID for this frame. This ID is browser-global and
198 // uniquely identifies a frame that hosts content. The identifier is fixed at
199 // the creation of the frame and stays constant for the lifetime of the frame.
200 // When the frame is removed, the ID is not used again.
201 //
202 // A RenderFrameHost is tied to a process. Due to cross-process navigations,
203 // the RenderFrameHost may have a shorter lifetime than a frame. Consequently,
204 // the same FrameTreeNode ID may refer to a different RenderFrameHost after a
205 // navigation.
206 virtual int GetFrameTreeNodeId() = 0;
207
Pavel Feldman25234722017-10-11 02:49:06208 // Used for devtools instrumentation and trace-ability. The token is
209 // propagated to Blink's LocalFrame and both Blink and content/
210 // can tag calls and requests with this token in order to attribute them
211 // to the context frame. The token is only defined by the browser process and
212 // is never sent back from the renderer in the control calls. It should be
213 // never used to look up the FrameTreeNode instance.
214 virtual base::UnguessableToken GetDevToolsFrameToken() = 0;
215
ckitagawa223004a2020-06-23 16:10:17216 // This token is present on all frames. For frames with parents, it allows
217 // identification of embedding relationships between parent and child. For
218 // main frames, it also allows generalization of the embedding relationship
219 // when the WebContents itself is embedded in another context such as the rest
220 // of the browser UI. This will be nullopt prior to the RenderFrameHost
221 // committing a navigation. After the first navigation commits this
222 // will return the token for the last committed document.
223 //
224 // TODO(crbug/1098283): Remove the nullopt scenario by creating the token in
225 // CreateChildFrame() or similar.
ckitagawa60c7d82b2020-01-23 16:07:00226 virtual base::Optional<base::UnguessableToken> GetEmbeddingToken() = 0;
227
avi@chromium.org52322d422014-03-21 18:59:56228 // Returns the assigned name of the frame, the name of the iframe tag
229 // declaring it. For example, <iframe name="framename">[...]</iframe>. It is
avi@chromium.org67048bd2014-03-18 07:32:35230 // quite possible for a frame to have no name, in which case GetFrameName will
231 // return an empty string.
232 virtual const std::string& GetFrameName() = 0;
233
John Delaney0146a742019-01-25 19:25:28234 // Returns true if the frame is display: none.
235 virtual bool IsFrameDisplayNone() = 0;
236
237 // Returns the size of the frame in the viewport. The frame may not be aware
238 // of its size.
239 virtual const base::Optional<gfx::Size>& GetFrameSize() = 0;
240
John Delaneya0de1152019-05-17 20:05:52241 // Returns the distance from this frame to the root frame.
242 virtual size_t GetFrameDepth() = 0;
243
kaznacheev@chromium.org2114da52014-02-28 15:17:57244 // Returns true if the frame is out of process.
245 virtual bool IsCrossProcessSubframe() = 0;
246
247 // Returns the last committed URL of the frame.
creis9f1ab5a2016-02-26 01:30:31248 virtual const GURL& GetLastCommittedURL() = 0;
kaznacheev@chromium.org2114da52014-02-28 15:17:57249
nick1466c842015-11-25 20:08:06250 // Returns the last committed origin of the frame.
alexmose47445d2016-12-09 21:24:33251 virtual const url::Origin& GetLastCommittedOrigin() = 0;
nick1466c842015-11-25 20:08:06252
Matt Menke2a33dee2019-12-02 17:01:54253 // Returns the network isolation key used for subresources from the currently
254 // committed navigation. It's set on commit and does not change until the next
255 // navigation is committed.
Matt Menkee3968712020-04-07 23:07:24256 //
257 // TODO(mmenke): Remove this in favor of GetIsolationInfoForSubresoruces().
Matt Menke2a33dee2019-12-02 17:01:54258 virtual const net::NetworkIsolationKey& GetNetworkIsolationKey() = 0;
259
Matt Menkee3968712020-04-07 23:07:24260 // Returns the IsolationInfo used for subresources from the currently
261 // committed navigation. It's set on commit and does not change until the next
262 // navigation is committed.
263 virtual const net::IsolationInfo& GetIsolationInfoForSubresources() = 0;
264
jam@chromium.org6dd625e2013-12-20 17:03:07265 // Returns the associated widget's native view.
266 virtual gfx::NativeView GetNativeView() = 0;
267
peter4eb242002015-06-02 12:45:13268 // Adds |message| to the DevTools console.
Abhijeet Kandalkara5928a0a2019-03-13 05:04:42269 virtual void AddMessageToConsole(blink::mojom::ConsoleMessageLevel level,
peter4eb242002015-06-02 12:45:13270 const std::string& message) = 0;
271
Avi Drissman4544828f2019-03-11 20:37:32272 // Functions to run JavaScript in this frame's context. Pass in a callback to
273 // receive a result when it is available. If there is no need to receive the
274 // result, pass in a default-constructed callback. If provided, the callback
275 // will be invoked on the UI thread.
Avi Drissman8e8880002019-03-12 00:33:27276 using JavaScriptResultCallback = base::OnceCallback<void(base::Value)>;
Avi Drissman4544828f2019-03-11 20:37:32277
Maksim Sadymcfb8f8d2020-09-30 20:30:45278 // This API allows to execute JavaScript methods in this frame, without
279 // having to serialize the arguments into a single string, and is a lot
280 // cheaper than ExecuteJavaScript below since it avoids the need to compile
281 // and evaluate new scripts all the time.
282 //
283 // Calling
284 //
285 // ExecuteJavaScriptMethod("obj", "foo", [1, true], callback)
286 //
287 // is semantically equivalent to
288 //
289 // ExecuteJavaScript("obj.foo(1, true)", callback)
290 virtual void ExecuteJavaScriptMethod(const base::string16& object_name,
291 const base::string16& method_name,
292 base::Value arguments,
293 JavaScriptResultCallback callback) = 0;
294
Avi Drissman4544828f2019-03-11 20:37:32295 // This is the default API to run JavaScript in this frame. This API can only
James Lissiak28b21a62019-05-15 15:32:04296 // be called on chrome:// or devtools:// URLs.
avi@chromium.orgf13ab892014-03-12 06:48:52297 virtual void ExecuteJavaScript(const base::string16& javascript,
Avi Drissman8e8880002019-03-12 00:33:27298 JavaScriptResultCallback callback) = 0;
Jochen Eisinger14ea9772015-07-24 12:04:37299
Avi Drissman4544828f2019-03-11 20:37:32300 // This runs the JavaScript in an isolated world of the top of this frame's
301 // context.
twellington376424ad2015-05-04 18:57:25302 virtual void ExecuteJavaScriptInIsolatedWorld(
303 const base::string16& javascript,
Avi Drissman8e8880002019-03-12 00:33:27304 JavaScriptResultCallback callback,
Hajime Hoshi3dd37bc2019-07-31 08:44:59305 int32_t world_id) = 0;
avi@chromium.orgf13ab892014-03-12 06:48:52306
Avi Drissman4544828f2019-03-11 20:37:32307 // This runs the JavaScript, but without restrictions. THIS IS ONLY FOR TESTS.
Hajime Hoshif85e7cf722019-07-19 00:54:49308 virtual void ExecuteJavaScriptForTests(
309 const base::string16& javascript,
310 JavaScriptResultCallback callback,
Hajime Hoshi3dd37bc2019-07-31 08:44:59311 int32_t world_id = ISOLATED_WORLD_ID_GLOBAL) = 0;
Avi Drissman4544828f2019-03-11 20:37:32312
313 // This runs the JavaScript, but without restrictions. THIS IS ONLY FOR TESTS.
Mustaq Ahmed02cd8832019-12-05 15:46:56314 // Unlike the method above, this one triggers a fake user activation
315 // notification to test functionalities that are gated by user
316 // activation.
jochen2e7d95b2015-05-04 15:28:50317 virtual void ExecuteJavaScriptWithUserGestureForTests(
Hajime Hoshif85e7cf722019-07-19 00:54:49318 const base::string16& javascript,
Hajime Hoshi3dd37bc2019-07-31 08:44:59319 int32_t world_id = ISOLATED_WORLD_ID_GLOBAL) = 0;
zeeshanq3454e9c2014-09-04 21:30:28320
dmazzonie6f29fc2016-10-19 16:34:29321 // Send a message to the RenderFrame to trigger an action on an
322 // accessibility object.
323 virtual void AccessibilityPerformAction(const ui::AXActionData& data) = 0;
dmazzoni@chromium.org95640212014-07-26 18:14:30324
dmazzoni1a69e2b32014-11-06 20:34:28325 // This is called when the user has committed to the given find in page
326 // request (e.g. by pressing enter or by clicking on the next / previous
327 // result buttons). It triggers sending a native accessibility event on
328 // the result object on the page, navigating assistive technology to that
329 // result.
330 virtual void ActivateFindInPageResultForAccessibility(int request_id) = 0;
331
Alex Newcomer104c2142020-11-19 02:06:38332 // See RenderWidgetHost::InsertVisualStateCallback().
Wezb04806e2018-07-06 22:53:03333 using VisualStateCallback = base::OnceCallback<void(bool)>;
334 virtual void InsertVisualStateCallback(VisualStateCallback callback) = 0;
igsolla37c8d8b2015-02-05 16:54:45335
brettw8f508f42016-06-20 21:34:21336 // Copies the image at the location in viewport coordinates (not frame
337 // coordinates) to the clipboard. If there is no image at that location, does
338 // nothing.
339 virtual void CopyImageAt(int x, int y) = 0;
340
341 // Requests to save the image at the location in viewport coordinates (not
Lukasz Anforowicz62442712019-10-07 17:16:52342 // frame coordinates). If there is a data-URL-based image at the location, the
343 // renderer will post back the appropriate download message to trigger the
344 // save UI. Nothing gets done if there is no image at that location (or if
345 // the image has a non-data URL).
brettw8f508f42016-06-20 21:34:21346 virtual void SaveImageAt(int x, int y) = 0;
347
brettw760f7442016-05-23 21:19:22348 // RenderViewHost for this frame.
jam@chromium.org1a4e9752013-12-31 20:10:58349 virtual RenderViewHost* GetRenderViewHost() = 0;
350
ben155ecf82016-06-21 22:43:26351 // Returns the InterfaceProvider that this process can use to bind
352 // interfaces exposed to it by the application running in this frame.
rockot400ea35b2016-10-15 19:15:32353 virtual service_manager::InterfaceProvider* GetRemoteInterfaces() = 0;
sammc@chromium.orgc52a1412014-06-25 06:09:25354
rockotf62002a2016-09-15 00:08:59355 // Returns the AssociatedInterfaceProvider that this process can use to access
356 // remote frame-specific Channel-associated interfaces for this frame.
Sam McNally52e50282017-11-29 00:54:02357 virtual blink::AssociatedInterfaceProvider*
358 GetRemoteAssociatedInterfaces() = 0;
rockotf62002a2016-09-15 00:08:59359
mlamourif8c23a2002015-01-27 13:10:10360 // Returns the visibility state of the frame. The different visibility states
361 // of a frame are defined in Blink.
danakj0018a29a2018-12-01 01:03:43362 virtual PageVisibilityState GetVisibilityState() = 0;
mlamourif8c23a2002015-01-27 13:10:10363
Sigurdur Asgeirsson2d00b9a2019-04-15 18:54:57364 // Returns true if WebContentsObserver::RenderFrameCreate notification has
365 // been dispatched for this frame, and so a RenderFrameDeleted notification
366 // will later be dispatched for this frame.
367 virtual bool IsRenderFrameCreated() = 0;
368
rdevlin.cronin6f42c2522015-06-19 18:58:51369 // Returns whether the RenderFrame in the renderer process has been created
370 // and still has a connection. This is valid for all frames.
371 virtual bool IsRenderFrameLive() = 0;
372
sreejakshetty@chromium.orgced590ab292020-03-12 00:37:21373 // Returns true if this RenderFrameHost is currently in the frame tree for its
374 // page. Specifically, this is when the RenderFrameHost and all of its
375 // ancestors are the current RenderFrameHost in their respective
376 // FrameTreeNodes.
lukaszaf2c4f1f2017-05-17 04:35:50377 //
sreejakshetty@chromium.orgced590ab292020-03-12 00:37:21378 // For instance, during a navigation, if a new RenderFrameHost replaces this
379 // RenderFrameHost, IsCurrent() becomes false for this frame and its
380 // children even if the children haven't been replaced.
381 //
382 // After a RenderFrameHost has been replaced in its frame, it will either:
383 // 1) Enter the BackForwardCache.
384 // 2) Start running unload handlers and will be deleted after this ("pending
385 // deletion").
386 // In both cases, IsCurrent() becomes false for this frame and all its
387 // children.
Rouslan Solomakhinebf61032020-10-19 23:45:34388 //
389 // This method should be called before trying to display some UI to the user
390 // on behalf of the given RenderFrameHost (or when crossing document / tab
391 // boundary in general, e.g. when using WebContents::FromRenderFrameHost) to
392 // check if the given RenderFrameHost is currently being displayed in a given
393 // tab.
lukaszaf2c4f1f2017-05-17 04:35:50394 virtual bool IsCurrent() = 0;
395
Sreeja Kamishetty113235c2020-07-16 12:47:20396 // Returns true iff the RenderFrameHost is inactive i.e., when the
397 // RenderFrameHost is either in BackForwardCache or pending deletion. This
398 // function should be used when we are unsure if inactive RenderFrameHosts can
399 // be properly handled and their processing shouldn't be deferred until the
400 // RenderFrameHost becomes active again. Callers that only want to check
401 // whether a RenderFrameHost is current or not should use IsCurrent() instead.
402 //
403 // This method additionally has a side effect for back-forward cache: it
404 // disallows reactivating by evicting the document from the cache and
405 // triggering deletion. This avoids reactivating the frame as restoring would
406 // be unsafe after dropping an event, which means that the frame will never be
407 // shown to the user again and the event can be safely ignored.
408 //
409 // Note that if |IsInactiveAndDisallowReactivation()| returns false, then
410 // IsCurrent() returns false as well.
411 // This should not be called for speculative RenderFrameHosts as disallowing
412 // reactivation before the document became active for the first time is not
413 // supported. In that case |IsInactiveAndDisallowReactivation()|
414 // returns false along with terminating the renderer process.
415 virtual bool IsInactiveAndDisallowReactivation() = 0;
416
nickde8b0272016-02-11 04:29:25417 // Get the number of proxies to this frame, in all processes. Exposed for
418 // use by resource metrics.
Raul Tambre13078e32019-01-29 23:29:22419 virtual size_t GetProxyCount() = 0;
nickde8b0272016-02-11 04:29:25420
thestigcb959ce2016-11-17 05:56:32421 // Returns true if the frame has a selection.
422 virtual bool HasSelection() = 0;
423
ajith.vdeb84842016-07-21 10:23:49424 // Text surrounding selection.
ajith.vdeb84842016-07-21 10:23:49425 virtual void RequestTextSurroundingSelection(
Dave Tapuska629ccb72019-10-18 18:02:13426 blink::mojom::LocalFrame::GetTextSurroundingSelectionCallback callback,
ajith.vdeb84842016-07-21 10:23:49427 int max_length) = 0;
428
John Delaney98800572019-10-14 23:02:08429 // Generates an intervention report in this frame.
430 virtual void SendInterventionReport(const std::string& id,
431 const std::string& message) = 0;
432
Nasko Oskov310c66a2020-05-18 21:58:57433 // Returns the WebUI object associated wit this RenderFrameHost or nullptr
434 // otherwise.
435 virtual WebUI* GetWebUI() = 0;
436
sammc7f6c6a02017-01-30 00:53:51437 // Tell the render frame to enable a set of javascript bindings. The argument
438 // should be a combination of values from BindingsPolicy.
439 virtual void AllowBindings(int binding_flags) = 0;
440
441 // Returns a bitwise OR of bindings types that have been enabled for this
442 // RenderFrame. See BindingsPolicy for details.
Lucas Furukawa Gadani0d5e7142019-04-18 23:00:50443 virtual int GetEnabledBindings() = 0;
sammc7f6c6a02017-01-30 00:53:51444
Nasko Oskovdce1a622019-11-06 23:58:33445 // Sets a property with the given name and value on the WebUI object
446 // associated with this RenderFrameHost, if one exists.
447 virtual void SetWebUIProperty(const std::string& name,
448 const std::string& value) = 0;
449
rob.buis6e62a572017-03-16 17:12:05450#if defined(OS_ANDROID)
Manas Verma6f50f142020-04-30 18:06:44451 // Returns the Java object of this instance.
452 virtual base::android::ScopedJavaLocalRef<jobject>
453 GetJavaRenderFrameHost() = 0;
454
rob.buis6e62a572017-03-16 17:12:05455 // Returns an InterfaceProvider for Java-implemented interfaces that are
456 // scoped to this RenderFrameHost. This provides access to interfaces
457 // implemented in Java in the browser process to C++ code in the browser
458 // process.
459 virtual service_manager::InterfaceProvider* GetJavaInterfaces() = 0;
460#endif // OS_ANDROID
461
avi64b8b65b2017-03-29 18:50:34462 // Stops and disables the hang monitor for beforeunload. This avoids flakiness
463 // in tests that need to observe beforeunload dialogs, which could fail if the
464 // timeout skips the dialog.
465 virtual void DisableBeforeUnloadHangMonitorForTesting() = 0;
avi3c70a0d2017-04-06 00:31:42466 virtual bool IsBeforeUnloadHangMonitorDisabledForTesting() = 0;
avi64b8b65b2017-03-29 18:50:34467
Fadi Meawadd9680cb2017-07-19 00:15:38468 // Check whether the specific Blink feature is currently preventing fast
469 // shutdown of the frame.
470 virtual bool GetSuddenTerminationDisablerState(
Dave Tapuska97d22ab2019-12-03 17:56:36471 blink::mojom::SuddenTerminationDisablerType disabler_type) = 0;
Fadi Meawadd9680cb2017-07-19 00:15:38472
Charlie Hu5ecaae02020-02-20 15:12:18473 // Returns true if the queried FeaturePolicyFeature is allowed by
474 // feature policy.
475 virtual bool IsFeatureEnabled(blink::mojom::FeaturePolicyFeature feature) = 0;
476
Lukasz Anforowicze1b954d92017-10-30 21:28:06477 // Opens view-source tab for the document last committed in this
478 // RenderFrameHost.
479 virtual void ViewSource() = 0;
480
Mounir Lamourifdff8bf2018-06-27 21:49:53481 // Run the given action on the media player location at the given point.
482 virtual void ExecuteMediaPlayerActionAtLocation(
483 const gfx::Point& location,
Abhijeet Kandalkarad9e6dfd2020-01-23 18:35:31484 const blink::mojom::MediaPlayerAction& action) = 0;
Mounir Lamourifdff8bf2018-06-27 21:49:53485
John Abd-El-Malekf752a672018-07-16 23:01:09486 // Creates a Network Service-backed factory from appropriate |NetworkContext|.
Clark DuVallb2680c22018-08-10 15:27:27487 // If this returns true, any redirect safety checks should be bypassed in
488 // downstream loaders.
489 virtual bool CreateNetworkServiceDefaultFactory(
Julie Jeongeun Kimb405097b2019-10-10 15:34:07490 mojo::PendingReceiver<network::mojom::URLLoaderFactory>
491 default_factory_receiver) = 0;
John Abd-El-Malekf752a672018-07-16 23:01:09492
Lukasz Anforowicz2f810162018-10-03 21:38:07493 // Requests that future URLLoaderFactoryBundle(s) sent to the renderer should
Lukasz Anforowicz401587c2019-10-10 02:53:13494 // use a separate URLLoaderFactory for requests initiated by isolated worlds
495 // listed in |isolated_world_origins|. The URLLoaderFactory(s) for each
Lukasz Anforowicz2f810162018-10-03 21:38:07496 // origin will be created via
497 // ContentBrowserClient::CreateURLLoaderFactoryForNetworkRequests method.
Lukasz Anforowicz401587c2019-10-10 02:53:13498 virtual void MarkIsolatedWorldsAsRequiringSeparateURLLoaderFactory(
499 base::flat_set<url::Origin> isolated_world_origins,
Lukasz Anforowicz2f810162018-10-03 21:38:07500 bool push_to_renderer_now) = 0;
501
Yao Xiaobec0db342018-11-02 17:28:25502 // Returns true if the given sandbox flag |flags| is in effect on this frame.
503 // The effective flags include those which have been set by a
504 // Content-Security-Policy header, in addition to those which are set by the
505 // embedding frame.
arthursonzognib93a4472020-04-10 07:38:00506 virtual bool IsSandboxed(network::mojom::WebSandboxFlags flags) = 0;
Yao Xiaobec0db342018-11-02 17:28:25507
Lukasz Anforowicz4b630b42018-11-08 05:23:35508 // Calls |FlushForTesting()| on Network Service and FrameNavigationControl
509 // related interfaces to make sure all in-flight mojo messages have been
510 // received by the other end. For test use only.
511 virtual void FlushNetworkAndNavigationInterfacesForTesting() = 0;
512
Ehsan Karamad44fc72112019-02-26 18:15:47513 using PrepareForInnerWebContentsAttachCallback =
514 base::OnceCallback<void(RenderFrameHost*)>;
515 // This API is used to provide the caller with a RenderFrameHost which is safe
516 // for usage in WebContents::AttachToOuterWebContentsFrame API. The final
517 // frame returned with |callback| will share the same FrameTreeNodeId with
518 // this RenderFrameHost but might not necessarily be the same RenderFrameHost.
519 // IMPORTANT: This method can only be called on a child frame. It does not
520 // make sense to attach an inner WebContents to the outer WebContents main
521 // frame.
522 // Essentially, this method will:
523 // 1- Cancel any ongoing navigation and navigation requests for this frame.
524 // 2- Dispatch beforeunload event on this frame and all of the frame's
525 // subframes, and wait for all beforeunload events to complete.
526 // 3- Will create and return a new RenderFrameHost (destroying this one) if
527 // this RenderFrameHost is a cross-process subframe.
528 // After steps 1-3 are completed, the callback is invoked asynchronously with
529 // the RenderFrameHost which can be safely used for attaching. This
530 // RenderFrameHost could be different than |this| which is the case if this
531 // RenderFrameHost is for a cross-process frame. The callback could also be
532 // invoked with nullptr. This happens if:
533 // 1- This frame has beforeunload handlers under it and the user decides to
534 // remain on the page in response to beforeunload prompt.
535 // 2- Preparations happened successfully but the frame was somehow removed (
536 // e.g. parent frame detached).
537 virtual void PrepareForInnerWebContentsAttach(
538 PrepareForInnerWebContentsAttachCallback callback) = 0;
Ehsan Karamaddd9a4142018-12-04 20:38:20539
Takashi Toyoshima20c20cf2019-02-27 07:39:23540 // Re-creates loader factories and pushes them to |RenderFrame|.
541 // Used in case we need to add or remove intercepting proxies to the
542 // running renderer, or in case of Network Service connection errors.
543 virtual void UpdateSubresourceLoaderFactories() = 0;
544
Ehsan Karamade0d96b82019-05-02 05:29:48545 // Returns the type of frame owner element for the FrameTreeNode associated
546 // with this RenderFrameHost (e.g., <iframe>, <object>, etc). Note that it
Antonio Gomes58d38062020-04-30 01:50:14547 // returns blink::mojom::FrameOwnerElementType::kNone if the RenderFrameHost
548 // is a main frame.
549 virtual blink::mojom::FrameOwnerElementType GetFrameOwnerElementType() = 0;
Ehsan Karamade0d96b82019-05-02 05:29:48550
Marijn Kruisselbrink798f4f02019-07-12 23:34:08551 // Returns the transient bit of the User Activation v2 state of the
552 // FrameTreeNode associated with this RenderFrameHost.
553 virtual bool HasTransientUserActivation() = 0;
554
Mike Wassermana11c45f2020-09-30 23:52:49555 // Notifies the renderer of a user activation event for the associated frame.
556 // The |notification_type| parameter is used for histograms only.
557 virtual void NotifyUserActivation(
558 blink::mojom::UserActivationNotificationType notification_type) = 0;
559
Scott Violet0de3837c2019-09-06 22:51:54560 // Notifies the renderer whether hiding/showing the browser controls is
561 // enabled, what the current state should be, and whether or not to animate to
562 // the proper state.
Dave Tapuskafc4adbae2020-12-02 22:08:59563 virtual void UpdateBrowserControlsState(cc::BrowserControlsState constraints,
564 cc::BrowserControlsState current,
Scott Violet0de3837c2019-09-06 22:51:54565 bool animate) = 0;
566
Tsuyoshi Horo52fd08e2020-07-07 07:03:45567 // Reloads the frame. It initiates a reload but doesn't wait for it to finish.
568 // In some rare cases, there is no history related to the frame, nothing
569 // happens and this returns false.
570 virtual bool Reload() = 0;
yilkal921048bd2019-10-09 23:51:04571
Carlos Caballero87bf9492019-12-04 01:53:26572 // Returns true if this frame has fired DOMContentLoaded.
573 virtual bool IsDOMContentLoaded() = 0;
574
Yao Xiao24ec9aa2020-01-28 16:36:00575 // Update the ad frame state. The parameter |ad_frame_type| cannot be kNonAd,
576 // and once this has been called, it cannot be called again with a different
577 // |ad_frame_type|, since once a frame is determined to be an ad, it will stay
578 // tagged as an ad of the same type for its entire lifetime.
579 //
580 // Note: The ad frame type is currently maintained and updated *outside*
581 // content. This is used to ensure the render frame proxies are in sync (since
582 // they aren't exposed in the public API). Eventually, we might be able to
583 // simplify this somewhat (maybe //content would be responsible for
584 // maintaining the state, with some content client method used to update it).
585 virtual void UpdateAdFrameType(blink::mojom::AdFrameType ad_frame_type) = 0;
586
Ken Buchanan3889e2b2020-02-11 04:26:53587 // Perform security checks on Web Authentication requests. These can be
588 // called by other |Authenticator| mojo interface implementations in the
589 // browser process so that they don't have to duplicate security policies.
Manas Verma6f50f142020-04-30 18:06:44590 // For requests originating from the render process, |effective_origin| will
591 // be the same as the last committed origin. However, for request originating
592 // from the browser process, this may be different.
Ken Buchanan3889e2b2020-02-11 04:26:53593 virtual blink::mojom::AuthenticatorStatus
594 PerformGetAssertionWebAuthSecurityChecks(
Manas Verma6f50f142020-04-30 18:06:44595 const std::string& relying_party_id,
596 const url::Origin& effective_origin) = 0;
Ken Buchanan3889e2b2020-02-11 04:26:53597 virtual blink::mojom::AuthenticatorStatus
598 PerformMakeCredentialWebAuthSecurityChecks(
Manas Verma6f50f142020-04-30 18:06:44599 const std::string& relying_party_id,
600 const url::Origin& effective_origin) = 0;
Ken Buchanan3889e2b2020-02-11 04:26:53601
Klaus Weidner3a05759a2020-02-21 04:09:35602 // Tells the host that this is part of setting up a WebXR DOM Overlay. This
603 // starts a short timer that permits entering fullscreen mode, similar to a
604 // recent orientation change.
605 virtual void SetIsXrOverlaySetup() = 0;
606
Hajime Hoshibbc509c2020-04-06 08:55:08607 // Returns true if this RenderFrameHost is currently stored in the
608 // back-forward cache.
609 //
610 // TODO(hajimehoshi): Introduce an enum value for lifecycle states and replace
611 // IsInBackForwardCache with the enum values and a new function like
612 // DidChangeLifecycleState.
613 virtual bool IsInBackForwardCache() = 0;
614
Yue Ru Sun128804932020-09-30 22:19:17615 // Returns the UKM source id for the page load (last committed cross-document
Alexander Timine3ec4192020-04-20 16:39:40616 // non-bfcache navigation in the main frame).
617 // This id typically has an associated PageLoad UKM event.
618 // Note: this can be called on any frame, but this id for all subframes is the
619 // same as the id for the main frame.
620 virtual ukm::SourceId GetPageUkmSourceId() = 0;
621
Eric Robinsonbeccae92020-06-22 21:05:40622 // Report an inspector issue to devtools due the frame using an excessive
623 // amount of resources (cpu or network). Invoked only for ad frames.
624 // TODO(crbug.com/1091720): This reporting should be done directly in the
625 // chrome layer in the future.
626 virtual void ReportHeavyAdIssue(
627 blink::mojom::HeavyAdResolutionStatus resolution,
628 blink::mojom::HeavyAdReason reason) = 0;
629
Majid Valipourae11335e2020-10-14 04:09:24630 // Returns whether a document uses WebOTP. Returns true if a WebOTPService is
Yi Gu745a8a72020-08-15 04:04:37631 // created on the document.
632 virtual bool DocumentUsedWebOTP() = 0;
633
Alexander Timinf8c2fe642020-08-07 22:18:33634 // Write a description of this RenderFrameHost into provided |traced_value|.
635 // The caller is responsible for ensuring that key-value pairs can be written
636 // into |traced_value| — either by creating a new TracedValue or calling
637 // BeginDictionary() before calling this method.
638 virtual void AsValueInto(base::trace_event::TracedValue* traced_value) = 0;
639
nasko@chromium.org227692c52013-05-31 22:43:04640 private:
641 // This interface should only be implemented inside content.
642 friend class RenderFrameHostImpl;
643 RenderFrameHost() {}
644};
645
646} // namespace content
647
648#endif // CONTENT_PUBLIC_BROWSER_RENDER_FRAME_HOST_H_