nasko@chromium.org | 227692c5 | 2013-05-31 22:43:04 | [diff] [blame] | 1 | // 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.org | 67048bd | 2014-03-18 07:32:35 | [diff] [blame] | 8 | #include <string> |
Lukasz Anforowicz | e1b954d9 | 2017-10-30 21:28:06 | [diff] [blame] | 9 | #include <vector> |
avi@chromium.org | 67048bd | 2014-03-18 07:32:35 | [diff] [blame] | 10 | |
avi@chromium.org | f13ab89 | 2014-03-12 06:48:52 | [diff] [blame] | 11 | #include "base/callback_forward.h" |
Lukasz Anforowicz | 4b630b4 | 2018-11-08 05:23:35 | [diff] [blame] | 12 | #include "base/containers/flat_set.h" |
Paul Meyer | 8846a41 | 2018-10-31 21:59:40 | [diff] [blame] | 13 | #include "base/feature_list.h" |
John Delaney | 0146a74 | 2019-01-25 19:25:28 | [diff] [blame] | 14 | #include "base/optional.h" |
avi | 652869c | 2015-12-25 01:48:45 | [diff] [blame] | 15 | #include "build/build_config.h" |
Dave Tapuska | fc4adbae | 2020-12-02 22:08:59 | [diff] [blame^] | 16 | #include "cc/input/browser_controls_state.h" |
nasko@chromium.org | 227692c5 | 2013-05-31 22:43:04 | [diff] [blame] | 17 | #include "content/common/content_export.h" |
Patrick Monette | 275a6f92b | 2020-01-09 21:05:04 | [diff] [blame] | 18 | #include "content/public/browser/global_routing_id.h" |
Hajime Hoshi | f85e7cf72 | 2019-07-19 00:54:49 | [diff] [blame] | 19 | #include "content/public/common/isolated_world_ids.h" |
Collin Baker | 98457b5 | 2019-11-06 21:34:29 | [diff] [blame] | 20 | #include "content/public/common/page_visibility_state.h" |
nasko@chromium.org | 227692c5 | 2013-05-31 22:43:04 | [diff] [blame] | 21 | #include "ipc/ipc_listener.h" |
| 22 | #include "ipc/ipc_sender.h" |
Julie Jeongeun Kim | b405097b | 2019-10-10 15:34:07 | [diff] [blame] | 23 | #include "mojo/public/cpp/bindings/pending_receiver.h" |
Miyoung Shin | 298d5ad | 2019-09-05 01:52:37 | [diff] [blame] | 24 | #include "mojo/public/cpp/bindings/remote.h" |
Alexander Timin | e3ec419 | 2020-04-20 16:39:40 | [diff] [blame] | 25 | #include "services/metrics/public/cpp/ukm_source_id.h" |
Takuto Ikuta | aa3b796c | 2019-02-06 02:54:56 | [diff] [blame] | 26 | #include "services/network/public/mojom/url_loader_factory.mojom-forward.h" |
Charlie Hu | 5ecaae0 | 2020-02-20 15:12:18 | [diff] [blame] | 27 | #include "third_party/blink/public/common/feature_policy/document_policy.h" |
Luna Lu | 0c2cd5a | 2019-02-12 16:24:59 | [diff] [blame] | 28 | #include "third_party/blink/public/common/feature_policy/feature_policy.h" |
Alexander Timin | 5afc73e | 2019-06-24 01:03:10 | [diff] [blame] | 29 | #include "third_party/blink/public/common/scheduler/web_scheduler_tracked_feature.h" |
Yao Xiao | 24ec9aa | 2020-01-28 16:36:00 | [diff] [blame] | 30 | #include "third_party/blink/public/mojom/ad_tagging/ad_frame.mojom-forward.h" |
Abhijeet Kandalkar | a5928a0a | 2019-03-13 05:04:42 | [diff] [blame] | 31 | #include "third_party/blink/public/mojom/devtools/console_message.mojom.h" |
John Delaney | 9880057 | 2019-10-14 23:02:08 | [diff] [blame] | 32 | #include "third_party/blink/public/mojom/frame/frame.mojom.h" |
Antonio Gomes | 58d3806 | 2020-04-30 01:50:14 | [diff] [blame] | 33 | #include "third_party/blink/public/mojom/frame/frame_owner_element_type.mojom.h" |
Dave Tapuska | 97d22ab | 2019-12-03 17:56:36 | [diff] [blame] | 34 | #include "third_party/blink/public/mojom/frame/sudden_termination_disabler_type.mojom.h" |
Mike Wasserman | a11c45f | 2020-09-30 23:52:49 | [diff] [blame] | 35 | #include "third_party/blink/public/mojom/frame/user_activation_notification_type.mojom.h" |
Takuto Ikuta | aa3b796c | 2019-02-06 02:54:56 | [diff] [blame] | 36 | #include "third_party/blink/public/mojom/loader/pause_subresource_loading_handle.mojom-forward.h" |
Ken Buchanan | 3889e2b | 2020-02-11 04:26:53 | [diff] [blame] | 37 | #include "third_party/blink/public/mojom/webauthn/authenticator.mojom.h" |
Dominic Mazzoni | 336bc006 | 2018-09-23 16:46:43 | [diff] [blame] | 38 | #include "ui/accessibility/ax_tree_id.h" |
tfarina | 3b0452d | 2014-12-31 15:20:09 | [diff] [blame] | 39 | #include "ui/gfx/geometry/rect.h" |
jam@chromium.org | 6dd625e | 2013-12-20 17:03:07 | [diff] [blame] | 40 | #include "ui/gfx/native_widget_types.h" |
kaznacheev@chromium.org | 2114da5 | 2014-02-28 15:17:57 | [diff] [blame] | 41 | #include "url/gurl.h" |
nick | 1466c84 | 2015-11-25 20:08:06 | [diff] [blame] | 42 | #include "url/origin.h" |
nasko@chromium.org | 227692c5 | 2013-05-31 22:43:04 | [diff] [blame] | 43 | |
iclelland | 08debb3 | 2017-04-13 21:24:14 | [diff] [blame] | 44 | namespace blink { |
Sam McNally | 52e5028 | 2017-11-29 00:54:02 | [diff] [blame] | 45 | class AssociatedInterfaceProvider; |
Luna Lu | 730f283f | 2018-02-08 16:38:03 | [diff] [blame] | 46 | namespace mojom { |
Luna Lu | bd7ae2f | 2017-11-07 15:18:03 | [diff] [blame] | 47 | enum class FeaturePolicyFeature; |
Luna Lu | 730f283f | 2018-02-08 16:38:03 | [diff] [blame] | 48 | } // namespace mojom |
| 49 | } // namespace blink |
iclelland | 08debb3 | 2017-04-13 21:24:14 | [diff] [blame] | 50 | |
avi@chromium.org | f13ab89 | 2014-03-12 06:48:52 | [diff] [blame] | 51 | namespace base { |
Alexander Timin | f8c2fe64 | 2020-08-07 22:18:33 | [diff] [blame] | 52 | namespace trace_event { |
| 53 | class TracedValue; |
| 54 | } // namespace trace_event |
| 55 | |
Pavel Feldman | 2523472 | 2017-10-11 02:49:06 | [diff] [blame] | 56 | class UnguessableToken; |
avi@chromium.org | f13ab89 | 2014-03-12 06:48:52 | [diff] [blame] | 57 | class Value; |
ckitagawa | 2504257 | 2020-05-28 14:43:19 | [diff] [blame] | 58 | } // namespace base |
avi@chromium.org | f13ab89 | 2014-03-12 06:48:52 | [diff] [blame] | 59 | |
Paul Meyer | 8846a41 | 2018-10-31 21:59:40 | [diff] [blame] | 60 | namespace features { |
| 61 | CONTENT_EXPORT extern const base::Feature kCrashReporting; |
| 62 | } // namespace features |
| 63 | |
Matt Menke | 2a33dee | 2019-12-02 17:01:54 | [diff] [blame] | 64 | namespace net { |
Matt Menke | e396871 | 2020-04-07 23:07:24 | [diff] [blame] | 65 | class IsolationInfo; |
Matt Menke | 2a33dee | 2019-12-02 17:01:54 | [diff] [blame] | 66 | class NetworkIsolationKey; |
| 67 | } |
| 68 | |
rockot | 400ea35b | 2016-10-15 19:15:32 | [diff] [blame] | 69 | namespace service_manager { |
ben | 155ecf8 | 2016-06-21 22:43:26 | [diff] [blame] | 70 | class InterfaceProvider; |
| 71 | } |
| 72 | |
dmazzoni | e6f29fc | 2016-10-19 16:34:29 | [diff] [blame] | 73 | namespace ui { |
| 74 | struct AXActionData; |
| 75 | } |
| 76 | |
nasko@chromium.org | 227692c5 | 2013-05-31 22:43:04 | [diff] [blame] | 77 | namespace content { |
Dave Tapuska | b336b92 | 2017-07-06 19:24:05 | [diff] [blame] | 78 | |
jam@chromium.org | a86c0e96 | 2013-12-17 17:10:39 | [diff] [blame] | 79 | class RenderProcessHost; |
jam@chromium.org | 1a4e975 | 2013-12-31 20:10:58 | [diff] [blame] | 80 | class RenderViewHost; |
kenrb | 015b5b5 | 2016-01-26 15:57:52 | [diff] [blame] | 81 | class RenderWidgetHostView; |
jam@chromium.org | 6dd625e | 2013-12-20 17:03:07 | [diff] [blame] | 82 | class SiteInstance; |
Alexander Timin | 16a5395 | 2020-04-28 18:27:39 | [diff] [blame] | 83 | class BrowserContext; |
| 84 | class StoragePartition; |
Nasko Oskov | 310c66a | 2020-05-18 21:58:57 | [diff] [blame] | 85 | class WebUI; |
nasko@chromium.org | 227692c5 | 2013-05-31 22:43:04 | [diff] [blame] | 86 | |
| 87 | // The interface provides a communication conduit with a frame in the renderer. |
Rouslan Solomakhin | af1dda91 | 2020-10-05 11:29:05 | [diff] [blame] | 88 | // 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.org | 227692c5 | 2013-05-31 22:43:04 | [diff] [blame] | 91 | class CONTENT_EXPORT RenderFrameHost : public IPC::Listener, |
| 92 | public IPC::Sender { |
ajwong@chromium.org | 1c2052f | 2013-08-28 08:24:34 | [diff] [blame] | 93 | public: |
lpz | e83861a | 2017-05-25 14:14:19 | [diff] [blame] | 94 | // Constant used to denote that a lookup of a FrameTreeNode ID has failed. |
| 95 | static const int kNoFrameTreeNodeId = -1; |
| 96 | |
jam@chromium.org | a86c0e96 | 2013-12-17 17:10:39 | [diff] [blame] | 97 | // Returns the RenderFrameHost given its ID and the ID of its render process. |
mlamouri | 8c61ffc | 2015-01-13 16:17:59 | [diff] [blame] | 98 | // Returns nullptr if the IDs do not correspond to a live RenderFrameHost. |
Patrick Monette | 275a6f92b | 2020-01-09 21:05:04 | [diff] [blame] | 99 | static RenderFrameHost* FromID(GlobalFrameRoutingId id); |
jam@chromium.org | a86c0e96 | 2013-12-17 17:10:39 | [diff] [blame] | 100 | static RenderFrameHost* FromID(int render_process_id, int render_frame_id); |
| 101 | |
Jochen Eisinger | 14ea977 | 2015-07-24 12:04:37 | [diff] [blame] | 102 | // Globally allows for injecting JavaScript into the main world. This feature |
Clark DuVall | 1a196bf | 2019-11-05 20:05:15 | [diff] [blame] | 103 | // 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 Marshall | b269640 | 2018-11-02 02:53:18 | [diff] [blame] | 105 | static void AllowInjectingJavaScript(); |
Jochen Eisinger | 14ea977 | 2015-07-24 12:04:37 | [diff] [blame] | 106 | |
dmazzoni | 1efe879 | 2015-08-07 01:02:15 | [diff] [blame] | 107 | // Returns a RenderFrameHost given its accessibility tree ID. |
Dominic Mazzoni | 336bc006 | 2018-09-23 16:46:43 | [diff] [blame] | 108 | static RenderFrameHost* FromAXTreeID(ui::AXTreeID ax_tree_id); |
dmazzoni | 1efe879 | 2015-08-07 01:02:15 | [diff] [blame] | 109 | |
lpz | e83861a | 2017-05-25 14:14:19 | [diff] [blame] | 110 | // 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 Kim | 5f7f4c7 | 2020-07-14 13:09:03 | [diff] [blame] | 115 | // 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 Li | 5bb6597 | 2018-02-14 03:07:58 | [diff] [blame] | 123 | |
Danyao Wang | c7bdca4 | 2020-03-12 15:52:52 | [diff] [blame] | 124 | #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 | |
dcheng | e933b3e | 2014-10-21 11:44:09 | [diff] [blame] | 130 | ~RenderFrameHost() override {} |
ajwong@chromium.org | 1c2052f | 2013-08-28 08:24:34 | [diff] [blame] | 131 | |
creis@chromium.org | 27dd82fd | 2014-03-03 22:11:43 | [diff] [blame] | 132 | // Returns the route id for this frame. |
| 133 | virtual int GetRoutingID() = 0; |
| 134 | |
Antonio Gomes | 256e8a40 | 2020-05-26 03:20:07 | [diff] [blame] | 135 | // Returns the frame token for this frame. |
| 136 | virtual const base::UnguessableToken& GetFrameToken() = 0; |
| 137 | |
dmazzoni | 1efe879 | 2015-08-07 01:02:15 | [diff] [blame] | 138 | // Returns the accessibility tree ID for this RenderFrameHost. |
Dominic Mazzoni | 336bc006 | 2018-09-23 16:46:43 | [diff] [blame] | 139 | virtual ui::AXTreeID GetAXTreeID() = 0; |
dmazzoni | 1efe879 | 2015-08-07 01:02:15 | [diff] [blame] | 140 | |
creis@chromium.org | 27dd82fd | 2014-03-03 22:11:43 | [diff] [blame] | 141 | // Returns the SiteInstance grouping all RenderFrameHosts that have script |
| 142 | // access to this RenderFrameHost, and must therefore live in the same |
| 143 | // process. |
Alexander Timin | 16a5395 | 2020-04-28 18:27:39 | [diff] [blame] | 144 | // Associated SiteInstance never changes. |
jam@chromium.org | 6dd625e | 2013-12-20 17:03:07 | [diff] [blame] | 145 | virtual SiteInstance* GetSiteInstance() = 0; |
| 146 | |
jam@chromium.org | a86c0e96 | 2013-12-17 17:10:39 | [diff] [blame] | 147 | // Returns the process for this frame. |
Alexander Timin | 16a5395 | 2020-04-28 18:27:39 | [diff] [blame] | 148 | // Associated RenderProcessHost never changes. |
jam@chromium.org | a86c0e96 | 2013-12-17 17:10:39 | [diff] [blame] | 149 | virtual RenderProcessHost* GetProcess() = 0; |
| 150 | |
Jochen Eisinger | 37c74c52 | 2020-10-05 17:46:00 | [diff] [blame] | 151 | // Returns the GlobalFrameRoutingId for this frame. Embedders should store |
| 152 | // this instead of a raw RenderFrameHost pointer. |
| 153 | virtual GlobalFrameRoutingId GetGlobalFrameRoutingId() = 0; |
| 154 | |
Alexander Timin | 16a5395 | 2020-04-28 18:27:39 | [diff] [blame] | 155 | // 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 | |
kenrb | 015b5b5 | 2016-01-26 15:57:52 | [diff] [blame] | 163 | // Returns the RenderWidgetHostView that can be used to control focus and |
| 164 | // visibility for this frame. |
| 165 | virtual RenderWidgetHostView* GetView() = 0; |
| 166 | |
Alexander Timin | fe6cc8d | 2020-03-15 17:38:13 | [diff] [blame] | 167 | // 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 |
mlamouri | 8c61ffc | 2015-01-13 16:17:59 | [diff] [blame] | 170 | // current RenderFrameHost. |
kaznacheev@chromium.org | 2114da5 | 2014-02-28 15:17:57 | [diff] [blame] | 171 | virtual RenderFrameHost* GetParent() = 0; |
| 172 | |
Alexander Timin | fe6cc8d | 2020-03-15 17:38:13 | [diff] [blame] | 173 | // 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 Delaney | 9880057 | 2019-10-14 23:02:08 | [diff] [blame] | 183 | // 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 Sonzogni | 969a794e | 2018-10-11 08:56:09 | [diff] [blame] | 190 | // 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 | |
rob | 3e2a073 | 2016-01-06 21:22:09 | [diff] [blame] | 197 | // 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 Feldman | 2523472 | 2017-10-11 02:49:06 | [diff] [blame] | 208 | // 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 | |
ckitagawa | 223004a | 2020-06-23 16:10:17 | [diff] [blame] | 216 | // 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. |
ckitagawa | 60c7d82b | 2020-01-23 16:07:00 | [diff] [blame] | 226 | virtual base::Optional<base::UnguessableToken> GetEmbeddingToken() = 0; |
| 227 | |
avi@chromium.org | 52322d42 | 2014-03-21 18:59:56 | [diff] [blame] | 228 | // 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.org | 67048bd | 2014-03-18 07:32:35 | [diff] [blame] | 230 | // 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 Delaney | 0146a74 | 2019-01-25 19:25:28 | [diff] [blame] | 234 | // 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 Delaney | a0de115 | 2019-05-17 20:05:52 | [diff] [blame] | 241 | // Returns the distance from this frame to the root frame. |
| 242 | virtual size_t GetFrameDepth() = 0; |
| 243 | |
kaznacheev@chromium.org | 2114da5 | 2014-02-28 15:17:57 | [diff] [blame] | 244 | // Returns true if the frame is out of process. |
| 245 | virtual bool IsCrossProcessSubframe() = 0; |
| 246 | |
| 247 | // Returns the last committed URL of the frame. |
creis | 9f1ab5a | 2016-02-26 01:30:31 | [diff] [blame] | 248 | virtual const GURL& GetLastCommittedURL() = 0; |
kaznacheev@chromium.org | 2114da5 | 2014-02-28 15:17:57 | [diff] [blame] | 249 | |
nick | 1466c84 | 2015-11-25 20:08:06 | [diff] [blame] | 250 | // Returns the last committed origin of the frame. |
alexmos | e47445d | 2016-12-09 21:24:33 | [diff] [blame] | 251 | virtual const url::Origin& GetLastCommittedOrigin() = 0; |
nick | 1466c84 | 2015-11-25 20:08:06 | [diff] [blame] | 252 | |
Matt Menke | 2a33dee | 2019-12-02 17:01:54 | [diff] [blame] | 253 | // 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 Menke | e396871 | 2020-04-07 23:07:24 | [diff] [blame] | 256 | // |
| 257 | // TODO(mmenke): Remove this in favor of GetIsolationInfoForSubresoruces(). |
Matt Menke | 2a33dee | 2019-12-02 17:01:54 | [diff] [blame] | 258 | virtual const net::NetworkIsolationKey& GetNetworkIsolationKey() = 0; |
| 259 | |
Matt Menke | e396871 | 2020-04-07 23:07:24 | [diff] [blame] | 260 | // 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.org | 6dd625e | 2013-12-20 17:03:07 | [diff] [blame] | 265 | // Returns the associated widget's native view. |
| 266 | virtual gfx::NativeView GetNativeView() = 0; |
| 267 | |
peter | 4eb24200 | 2015-06-02 12:45:13 | [diff] [blame] | 268 | // Adds |message| to the DevTools console. |
Abhijeet Kandalkar | a5928a0a | 2019-03-13 05:04:42 | [diff] [blame] | 269 | virtual void AddMessageToConsole(blink::mojom::ConsoleMessageLevel level, |
peter | 4eb24200 | 2015-06-02 12:45:13 | [diff] [blame] | 270 | const std::string& message) = 0; |
| 271 | |
Avi Drissman | 4544828f | 2019-03-11 20:37:32 | [diff] [blame] | 272 | // 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 Drissman | 8e888000 | 2019-03-12 00:33:27 | [diff] [blame] | 276 | using JavaScriptResultCallback = base::OnceCallback<void(base::Value)>; |
Avi Drissman | 4544828f | 2019-03-11 20:37:32 | [diff] [blame] | 277 | |
Maksim Sadym | cfb8f8d | 2020-09-30 20:30:45 | [diff] [blame] | 278 | // 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 Drissman | 4544828f | 2019-03-11 20:37:32 | [diff] [blame] | 295 | // This is the default API to run JavaScript in this frame. This API can only |
James Lissiak | 28b21a6 | 2019-05-15 15:32:04 | [diff] [blame] | 296 | // be called on chrome:// or devtools:// URLs. |
avi@chromium.org | f13ab89 | 2014-03-12 06:48:52 | [diff] [blame] | 297 | virtual void ExecuteJavaScript(const base::string16& javascript, |
Avi Drissman | 8e888000 | 2019-03-12 00:33:27 | [diff] [blame] | 298 | JavaScriptResultCallback callback) = 0; |
Jochen Eisinger | 14ea977 | 2015-07-24 12:04:37 | [diff] [blame] | 299 | |
Avi Drissman | 4544828f | 2019-03-11 20:37:32 | [diff] [blame] | 300 | // This runs the JavaScript in an isolated world of the top of this frame's |
| 301 | // context. |
twellington | 376424ad | 2015-05-04 18:57:25 | [diff] [blame] | 302 | virtual void ExecuteJavaScriptInIsolatedWorld( |
| 303 | const base::string16& javascript, |
Avi Drissman | 8e888000 | 2019-03-12 00:33:27 | [diff] [blame] | 304 | JavaScriptResultCallback callback, |
Hajime Hoshi | 3dd37bc | 2019-07-31 08:44:59 | [diff] [blame] | 305 | int32_t world_id) = 0; |
avi@chromium.org | f13ab89 | 2014-03-12 06:48:52 | [diff] [blame] | 306 | |
Avi Drissman | 4544828f | 2019-03-11 20:37:32 | [diff] [blame] | 307 | // This runs the JavaScript, but without restrictions. THIS IS ONLY FOR TESTS. |
Hajime Hoshi | f85e7cf72 | 2019-07-19 00:54:49 | [diff] [blame] | 308 | virtual void ExecuteJavaScriptForTests( |
| 309 | const base::string16& javascript, |
| 310 | JavaScriptResultCallback callback, |
Hajime Hoshi | 3dd37bc | 2019-07-31 08:44:59 | [diff] [blame] | 311 | int32_t world_id = ISOLATED_WORLD_ID_GLOBAL) = 0; |
Avi Drissman | 4544828f | 2019-03-11 20:37:32 | [diff] [blame] | 312 | |
| 313 | // This runs the JavaScript, but without restrictions. THIS IS ONLY FOR TESTS. |
Mustaq Ahmed | 02cd883 | 2019-12-05 15:46:56 | [diff] [blame] | 314 | // Unlike the method above, this one triggers a fake user activation |
| 315 | // notification to test functionalities that are gated by user |
| 316 | // activation. |
jochen | 2e7d95b | 2015-05-04 15:28:50 | [diff] [blame] | 317 | virtual void ExecuteJavaScriptWithUserGestureForTests( |
Hajime Hoshi | f85e7cf72 | 2019-07-19 00:54:49 | [diff] [blame] | 318 | const base::string16& javascript, |
Hajime Hoshi | 3dd37bc | 2019-07-31 08:44:59 | [diff] [blame] | 319 | int32_t world_id = ISOLATED_WORLD_ID_GLOBAL) = 0; |
zeeshanq | 3454e9c | 2014-09-04 21:30:28 | [diff] [blame] | 320 | |
dmazzoni | e6f29fc | 2016-10-19 16:34:29 | [diff] [blame] | 321 | // 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.org | 9564021 | 2014-07-26 18:14:30 | [diff] [blame] | 324 | |
dmazzoni | 1a69e2b3 | 2014-11-06 20:34:28 | [diff] [blame] | 325 | // 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 Newcomer | 104c214 | 2020-11-19 02:06:38 | [diff] [blame] | 332 | // See RenderWidgetHost::InsertVisualStateCallback(). |
Wez | b04806e | 2018-07-06 22:53:03 | [diff] [blame] | 333 | using VisualStateCallback = base::OnceCallback<void(bool)>; |
| 334 | virtual void InsertVisualStateCallback(VisualStateCallback callback) = 0; |
igsolla | 37c8d8b | 2015-02-05 16:54:45 | [diff] [blame] | 335 | |
brettw | 8f508f4 | 2016-06-20 21:34:21 | [diff] [blame] | 336 | // 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 Anforowicz | 6244271 | 2019-10-07 17:16:52 | [diff] [blame] | 342 | // 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). |
brettw | 8f508f4 | 2016-06-20 21:34:21 | [diff] [blame] | 346 | virtual void SaveImageAt(int x, int y) = 0; |
| 347 | |
brettw | 760f744 | 2016-05-23 21:19:22 | [diff] [blame] | 348 | // RenderViewHost for this frame. |
jam@chromium.org | 1a4e975 | 2013-12-31 20:10:58 | [diff] [blame] | 349 | virtual RenderViewHost* GetRenderViewHost() = 0; |
| 350 | |
ben | 155ecf8 | 2016-06-21 22:43:26 | [diff] [blame] | 351 | // Returns the InterfaceProvider that this process can use to bind |
| 352 | // interfaces exposed to it by the application running in this frame. |
rockot | 400ea35b | 2016-10-15 19:15:32 | [diff] [blame] | 353 | virtual service_manager::InterfaceProvider* GetRemoteInterfaces() = 0; |
sammc@chromium.org | c52a141 | 2014-06-25 06:09:25 | [diff] [blame] | 354 | |
rockot | f62002a | 2016-09-15 00:08:59 | [diff] [blame] | 355 | // Returns the AssociatedInterfaceProvider that this process can use to access |
| 356 | // remote frame-specific Channel-associated interfaces for this frame. |
Sam McNally | 52e5028 | 2017-11-29 00:54:02 | [diff] [blame] | 357 | virtual blink::AssociatedInterfaceProvider* |
| 358 | GetRemoteAssociatedInterfaces() = 0; |
rockot | f62002a | 2016-09-15 00:08:59 | [diff] [blame] | 359 | |
mlamouri | f8c23a200 | 2015-01-27 13:10:10 | [diff] [blame] | 360 | // Returns the visibility state of the frame. The different visibility states |
| 361 | // of a frame are defined in Blink. |
danakj | 0018a29a | 2018-12-01 01:03:43 | [diff] [blame] | 362 | virtual PageVisibilityState GetVisibilityState() = 0; |
mlamouri | f8c23a200 | 2015-01-27 13:10:10 | [diff] [blame] | 363 | |
Sigurdur Asgeirsson | 2d00b9a | 2019-04-15 18:54:57 | [diff] [blame] | 364 | // 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.cronin | 6f42c252 | 2015-06-19 18:58:51 | [diff] [blame] | 369 | // 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.org | ced590ab29 | 2020-03-12 00:37:21 | [diff] [blame] | 373 | // 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. |
lukasza | f2c4f1f | 2017-05-17 04:35:50 | [diff] [blame] | 377 | // |
sreejakshetty@chromium.org | ced590ab29 | 2020-03-12 00:37:21 | [diff] [blame] | 378 | // 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 Solomakhin | ebf6103 | 2020-10-19 23:45:34 | [diff] [blame] | 388 | // |
| 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. |
lukasza | f2c4f1f | 2017-05-17 04:35:50 | [diff] [blame] | 394 | virtual bool IsCurrent() = 0; |
| 395 | |
Sreeja Kamishetty | 113235c | 2020-07-16 12:47:20 | [diff] [blame] | 396 | // 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 | |
nick | de8b027 | 2016-02-11 04:29:25 | [diff] [blame] | 417 | // Get the number of proxies to this frame, in all processes. Exposed for |
| 418 | // use by resource metrics. |
Raul Tambre | 13078e3 | 2019-01-29 23:29:22 | [diff] [blame] | 419 | virtual size_t GetProxyCount() = 0; |
nick | de8b027 | 2016-02-11 04:29:25 | [diff] [blame] | 420 | |
thestig | cb959ce | 2016-11-17 05:56:32 | [diff] [blame] | 421 | // Returns true if the frame has a selection. |
| 422 | virtual bool HasSelection() = 0; |
| 423 | |
ajith.v | deb8484 | 2016-07-21 10:23:49 | [diff] [blame] | 424 | // Text surrounding selection. |
ajith.v | deb8484 | 2016-07-21 10:23:49 | [diff] [blame] | 425 | virtual void RequestTextSurroundingSelection( |
Dave Tapuska | 629ccb7 | 2019-10-18 18:02:13 | [diff] [blame] | 426 | blink::mojom::LocalFrame::GetTextSurroundingSelectionCallback callback, |
ajith.v | deb8484 | 2016-07-21 10:23:49 | [diff] [blame] | 427 | int max_length) = 0; |
| 428 | |
John Delaney | 9880057 | 2019-10-14 23:02:08 | [diff] [blame] | 429 | // Generates an intervention report in this frame. |
| 430 | virtual void SendInterventionReport(const std::string& id, |
| 431 | const std::string& message) = 0; |
| 432 | |
Nasko Oskov | 310c66a | 2020-05-18 21:58:57 | [diff] [blame] | 433 | // Returns the WebUI object associated wit this RenderFrameHost or nullptr |
| 434 | // otherwise. |
| 435 | virtual WebUI* GetWebUI() = 0; |
| 436 | |
sammc | 7f6c6a0 | 2017-01-30 00:53:51 | [diff] [blame] | 437 | // 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 Gadani | 0d5e714 | 2019-04-18 23:00:50 | [diff] [blame] | 443 | virtual int GetEnabledBindings() = 0; |
sammc | 7f6c6a0 | 2017-01-30 00:53:51 | [diff] [blame] | 444 | |
Nasko Oskov | dce1a62 | 2019-11-06 23:58:33 | [diff] [blame] | 445 | // 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.buis | 6e62a57 | 2017-03-16 17:12:05 | [diff] [blame] | 450 | #if defined(OS_ANDROID) |
Manas Verma | 6f50f14 | 2020-04-30 18:06:44 | [diff] [blame] | 451 | // Returns the Java object of this instance. |
| 452 | virtual base::android::ScopedJavaLocalRef<jobject> |
| 453 | GetJavaRenderFrameHost() = 0; |
| 454 | |
rob.buis | 6e62a57 | 2017-03-16 17:12:05 | [diff] [blame] | 455 | // 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 | |
avi | 64b8b65b | 2017-03-29 18:50:34 | [diff] [blame] | 462 | // 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; |
avi | 3c70a0d | 2017-04-06 00:31:42 | [diff] [blame] | 466 | virtual bool IsBeforeUnloadHangMonitorDisabledForTesting() = 0; |
avi | 64b8b65b | 2017-03-29 18:50:34 | [diff] [blame] | 467 | |
Fadi Meawad | d9680cb | 2017-07-19 00:15:38 | [diff] [blame] | 468 | // Check whether the specific Blink feature is currently preventing fast |
| 469 | // shutdown of the frame. |
| 470 | virtual bool GetSuddenTerminationDisablerState( |
Dave Tapuska | 97d22ab | 2019-12-03 17:56:36 | [diff] [blame] | 471 | blink::mojom::SuddenTerminationDisablerType disabler_type) = 0; |
Fadi Meawad | d9680cb | 2017-07-19 00:15:38 | [diff] [blame] | 472 | |
Charlie Hu | 5ecaae0 | 2020-02-20 15:12:18 | [diff] [blame] | 473 | // Returns true if the queried FeaturePolicyFeature is allowed by |
| 474 | // feature policy. |
| 475 | virtual bool IsFeatureEnabled(blink::mojom::FeaturePolicyFeature feature) = 0; |
| 476 | |
Lukasz Anforowicz | e1b954d9 | 2017-10-30 21:28:06 | [diff] [blame] | 477 | // Opens view-source tab for the document last committed in this |
| 478 | // RenderFrameHost. |
| 479 | virtual void ViewSource() = 0; |
| 480 | |
Mounir Lamouri | fdff8bf | 2018-06-27 21:49:53 | [diff] [blame] | 481 | // Run the given action on the media player location at the given point. |
| 482 | virtual void ExecuteMediaPlayerActionAtLocation( |
| 483 | const gfx::Point& location, |
Abhijeet Kandalkar | ad9e6dfd | 2020-01-23 18:35:31 | [diff] [blame] | 484 | const blink::mojom::MediaPlayerAction& action) = 0; |
Mounir Lamouri | fdff8bf | 2018-06-27 21:49:53 | [diff] [blame] | 485 | |
John Abd-El-Malek | f752a67 | 2018-07-16 23:01:09 | [diff] [blame] | 486 | // Creates a Network Service-backed factory from appropriate |NetworkContext|. |
Clark DuVall | b2680c2 | 2018-08-10 15:27:27 | [diff] [blame] | 487 | // If this returns true, any redirect safety checks should be bypassed in |
| 488 | // downstream loaders. |
| 489 | virtual bool CreateNetworkServiceDefaultFactory( |
Julie Jeongeun Kim | b405097b | 2019-10-10 15:34:07 | [diff] [blame] | 490 | mojo::PendingReceiver<network::mojom::URLLoaderFactory> |
| 491 | default_factory_receiver) = 0; |
John Abd-El-Malek | f752a67 | 2018-07-16 23:01:09 | [diff] [blame] | 492 | |
Lukasz Anforowicz | 2f81016 | 2018-10-03 21:38:07 | [diff] [blame] | 493 | // Requests that future URLLoaderFactoryBundle(s) sent to the renderer should |
Lukasz Anforowicz | 401587c | 2019-10-10 02:53:13 | [diff] [blame] | 494 | // use a separate URLLoaderFactory for requests initiated by isolated worlds |
| 495 | // listed in |isolated_world_origins|. The URLLoaderFactory(s) for each |
Lukasz Anforowicz | 2f81016 | 2018-10-03 21:38:07 | [diff] [blame] | 496 | // origin will be created via |
| 497 | // ContentBrowserClient::CreateURLLoaderFactoryForNetworkRequests method. |
Lukasz Anforowicz | 401587c | 2019-10-10 02:53:13 | [diff] [blame] | 498 | virtual void MarkIsolatedWorldsAsRequiringSeparateURLLoaderFactory( |
| 499 | base::flat_set<url::Origin> isolated_world_origins, |
Lukasz Anforowicz | 2f81016 | 2018-10-03 21:38:07 | [diff] [blame] | 500 | bool push_to_renderer_now) = 0; |
| 501 | |
Yao Xiao | bec0db34 | 2018-11-02 17:28:25 | [diff] [blame] | 502 | // 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. |
arthursonzogni | b93a447 | 2020-04-10 07:38:00 | [diff] [blame] | 506 | virtual bool IsSandboxed(network::mojom::WebSandboxFlags flags) = 0; |
Yao Xiao | bec0db34 | 2018-11-02 17:28:25 | [diff] [blame] | 507 | |
Lukasz Anforowicz | 4b630b4 | 2018-11-08 05:23:35 | [diff] [blame] | 508 | // 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 Karamad | 44fc7211 | 2019-02-26 18:15:47 | [diff] [blame] | 513 | 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 Karamad | dd9a414 | 2018-12-04 20:38:20 | [diff] [blame] | 539 | |
Takashi Toyoshima | 20c20cf | 2019-02-27 07:39:23 | [diff] [blame] | 540 | // 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 Karamad | e0d96b8 | 2019-05-02 05:29:48 | [diff] [blame] | 545 | // Returns the type of frame owner element for the FrameTreeNode associated |
| 546 | // with this RenderFrameHost (e.g., <iframe>, <object>, etc). Note that it |
Antonio Gomes | 58d3806 | 2020-04-30 01:50:14 | [diff] [blame] | 547 | // returns blink::mojom::FrameOwnerElementType::kNone if the RenderFrameHost |
| 548 | // is a main frame. |
| 549 | virtual blink::mojom::FrameOwnerElementType GetFrameOwnerElementType() = 0; |
Ehsan Karamad | e0d96b8 | 2019-05-02 05:29:48 | [diff] [blame] | 550 | |
Marijn Kruisselbrink | 798f4f0 | 2019-07-12 23:34:08 | [diff] [blame] | 551 | // 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 Wasserman | a11c45f | 2020-09-30 23:52:49 | [diff] [blame] | 555 | // 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 Violet | 0de3837c | 2019-09-06 22:51:54 | [diff] [blame] | 560 | // 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 Tapuska | fc4adbae | 2020-12-02 22:08:59 | [diff] [blame^] | 563 | virtual void UpdateBrowserControlsState(cc::BrowserControlsState constraints, |
| 564 | cc::BrowserControlsState current, |
Scott Violet | 0de3837c | 2019-09-06 22:51:54 | [diff] [blame] | 565 | bool animate) = 0; |
| 566 | |
Tsuyoshi Horo | 52fd08e | 2020-07-07 07:03:45 | [diff] [blame] | 567 | // 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; |
yilkal | 921048bd | 2019-10-09 23:51:04 | [diff] [blame] | 571 | |
Carlos Caballero | 87bf949 | 2019-12-04 01:53:26 | [diff] [blame] | 572 | // Returns true if this frame has fired DOMContentLoaded. |
| 573 | virtual bool IsDOMContentLoaded() = 0; |
| 574 | |
Yao Xiao | 24ec9aa | 2020-01-28 16:36:00 | [diff] [blame] | 575 | // 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 Buchanan | 3889e2b | 2020-02-11 04:26:53 | [diff] [blame] | 587 | // 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 Verma | 6f50f14 | 2020-04-30 18:06:44 | [diff] [blame] | 590 | // 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 Buchanan | 3889e2b | 2020-02-11 04:26:53 | [diff] [blame] | 593 | virtual blink::mojom::AuthenticatorStatus |
| 594 | PerformGetAssertionWebAuthSecurityChecks( |
Manas Verma | 6f50f14 | 2020-04-30 18:06:44 | [diff] [blame] | 595 | const std::string& relying_party_id, |
| 596 | const url::Origin& effective_origin) = 0; |
Ken Buchanan | 3889e2b | 2020-02-11 04:26:53 | [diff] [blame] | 597 | virtual blink::mojom::AuthenticatorStatus |
| 598 | PerformMakeCredentialWebAuthSecurityChecks( |
Manas Verma | 6f50f14 | 2020-04-30 18:06:44 | [diff] [blame] | 599 | const std::string& relying_party_id, |
| 600 | const url::Origin& effective_origin) = 0; |
Ken Buchanan | 3889e2b | 2020-02-11 04:26:53 | [diff] [blame] | 601 | |
Klaus Weidner | 3a05759a | 2020-02-21 04:09:35 | [diff] [blame] | 602 | // 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 Hoshi | bbc509c | 2020-04-06 08:55:08 | [diff] [blame] | 607 | // 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 Sun | 12880493 | 2020-09-30 22:19:17 | [diff] [blame] | 615 | // Returns the UKM source id for the page load (last committed cross-document |
Alexander Timin | e3ec419 | 2020-04-20 16:39:40 | [diff] [blame] | 616 | // 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 Robinson | beccae9 | 2020-06-22 21:05:40 | [diff] [blame] | 622 | // 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 Valipour | ae11335e | 2020-10-14 04:09:24 | [diff] [blame] | 630 | // Returns whether a document uses WebOTP. Returns true if a WebOTPService is |
Yi Gu | 745a8a7 | 2020-08-15 04:04:37 | [diff] [blame] | 631 | // created on the document. |
| 632 | virtual bool DocumentUsedWebOTP() = 0; |
| 633 | |
Alexander Timin | f8c2fe64 | 2020-08-07 22:18:33 | [diff] [blame] | 634 | // 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.org | 227692c5 | 2013-05-31 22:43:04 | [diff] [blame] | 640 | 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_ |