blob: e17c4439e58df950f98c95abc990d2134b244e20 [file] [log] [blame]
Avi Drissman4e1b7bc32022-09-15 14:03:501// Copyright 2013 The Chromium Authors
danakjc492bf82020-09-09 20:02:442// 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_BROWSER_RENDERER_HOST_FRAME_TREE_NODE_H_
6#define CONTENT_BROWSER_RENDERER_HOST_FRAME_TREE_NODE_H_
7
8#include <stddef.h>
9
10#include <memory>
11#include <string>
David Sanders2c1194d92022-04-19 23:32:3212#include <utility>
danakjc492bf82020-09-09 20:02:4413
14#include "base/gtest_prod_util.h"
Keishi Hattori0e45c022021-11-27 09:25:5215#include "base/memory/raw_ptr.h"
David Sanders2c1194d92022-04-19 23:32:3216#include "base/memory/scoped_refptr.h"
David Sandersd4bf5eb2022-03-17 07:12:0517#include "base/observer_list.h"
Daniel Cheng390e2a72022-09-28 06:07:5318#include "content/browser/renderer_host/navigation_discard_reason.h"
danakjc492bf82020-09-09 20:02:4419#include "content/browser/renderer_host/navigator.h"
20#include "content/browser/renderer_host/render_frame_host_impl.h"
21#include "content/browser/renderer_host/render_frame_host_manager.h"
Miyoung Shin7cf88b42022-11-07 13:22:3022#include "content/browser/renderer_host/render_frame_host_owner.h"
danakjc492bf82020-09-09 20:02:4423#include "content/common/content_export.h"
Julie Jeongeun Kimf38c1eca2021-12-14 07:46:5524#include "content/public/browser/frame_type.h"
danakjc492bf82020-09-09 20:02:4425#include "services/network/public/mojom/content_security_policy.mojom-forward.h"
Julie Jeongeun Kim0e242242022-11-30 10:45:0926#include "services/network/public/mojom/referrer_policy.mojom-forward.h"
Lei Zhang698df03c2021-05-21 04:23:3427#include "third_party/abseil-cpp/absl/types/optional.h"
Kevin McNee43fe8292021-10-04 22:59:4128#include "third_party/blink/public/common/frame/frame_owner_element_type.h"
danakjc492bf82020-09-09 20:02:4429#include "third_party/blink/public/common/frame/frame_policy.h"
danakjc492bf82020-09-09 20:02:4430#include "third_party/blink/public/mojom/frame/frame_owner_properties.mojom.h"
Gyuyoung Kimc16e52e92021-03-19 02:45:3731#include "third_party/blink/public/mojom/frame/frame_replication_state.mojom-forward.h"
Daniel Cheng6ac128172021-05-25 18:49:0132#include "third_party/blink/public/mojom/frame/tree_scope_type.mojom.h"
David Sanders2c1194d92022-04-19 23:32:3233#include "third_party/blink/public/mojom/frame/user_activation_update_types.mojom-forward.h"
danakjc492bf82020-09-09 20:02:4434
Gabriel Charetted87f10f2022-03-31 00:44:2235#include "base/time/time.h"
danakjc492bf82020-09-09 20:02:4436#include "url/gurl.h"
37#include "url/origin.h"
38
39namespace content {
40
41class NavigationRequest;
42class RenderFrameHostImpl;
43class NavigationEntryImpl;
Paul Semel3e241042022-10-11 12:57:3144class FrameTree;
danakjc492bf82020-09-09 20:02:4445
46// When a page contains iframes, its renderer process maintains a tree structure
47// of those frames. We are mirroring this tree in the browser process. This
48// class represents a node in this tree and is a wrapper for all objects that
49// are frame-specific (as opposed to page-specific).
50//
51// Each FrameTreeNode has a current RenderFrameHost, which can change over
52// time as the frame is navigated. Any immediate subframes of the current
53// document are tracked using FrameTreeNodes owned by the current
54// RenderFrameHost, rather than as children of FrameTreeNode itself. This
55// allows subframe FrameTreeNodes to stay alive while a RenderFrameHost is
56// still alive - for example while pending deletion, after a new current
57// RenderFrameHost has replaced it.
Miyoung Shin7cf88b42022-11-07 13:22:3058class CONTENT_EXPORT FrameTreeNode : public RenderFrameHostOwner {
danakjc492bf82020-09-09 20:02:4459 public:
60 class Observer {
61 public:
62 // Invoked when a FrameTreeNode is being destroyed.
63 virtual void OnFrameTreeNodeDestroyed(FrameTreeNode* node) {}
64
65 // Invoked when a FrameTreeNode becomes focused.
66 virtual void OnFrameTreeNodeFocused(FrameTreeNode* node) {}
67
Arthur Hemerye4659282022-03-28 08:36:1568 // Invoked when a FrameTreeNode moves to a different BrowsingInstance and
69 // the popups it opened should be disowned.
70 virtual void OnFrameTreeNodeDisownedOpenee(FrameTreeNode* node) {}
71
Fergal Dalya1d569972021-03-16 03:24:5372 virtual ~Observer() = default;
danakjc492bf82020-09-09 20:02:4473 };
74
75 static const int kFrameTreeNodeInvalidId;
76
77 // Returns the FrameTreeNode with the given global |frame_tree_node_id|,
78 // regardless of which FrameTree it is in.
79 static FrameTreeNode* GloballyFindByID(int frame_tree_node_id);
80
81 // Returns the FrameTreeNode for the given |rfh|. Same as
82 // rfh->frame_tree_node(), but also supports nullptrs.
83 static FrameTreeNode* From(RenderFrameHost* rfh);
84
85 // Callers are are expected to initialize sandbox flags separately after
86 // calling the constructor.
87 FrameTreeNode(
Arthur Sonzognif6785ec2022-12-05 10:11:5088 FrameTree& frame_tree,
danakjc492bf82020-09-09 20:02:4489 RenderFrameHostImpl* parent,
Daniel Cheng6ac128172021-05-25 18:49:0190 blink::mojom::TreeScopeType tree_scope_type,
danakjc492bf82020-09-09 20:02:4491 bool is_created_by_script,
danakjc492bf82020-09-09 20:02:4492 const blink::mojom::FrameOwnerProperties& frame_owner_properties,
Kevin McNee43fe8292021-10-04 22:59:4193 blink::FrameOwnerElementType owner_type,
Dominic Farolino08662c82021-06-11 07:36:3494 const blink::FramePolicy& frame_owner);
danakjc492bf82020-09-09 20:02:4495
Peter Boström828b9022021-09-21 02:28:4396 FrameTreeNode(const FrameTreeNode&) = delete;
97 FrameTreeNode& operator=(const FrameTreeNode&) = delete;
98
Miyoung Shin7cf88b42022-11-07 13:22:3099 ~FrameTreeNode() override;
danakjc492bf82020-09-09 20:02:44100
101 void AddObserver(Observer* observer);
102 void RemoveObserver(Observer* observer);
103
Ian Vollick25a9d032022-04-12 23:20:17104 // Frame trees may be nested so it can be the case that IsMainFrame() is true,
105 // but is not the outermost main frame. In particular, !IsMainFrame() cannot
106 // be used to check if the frame is an embedded frame -- use
107 // !IsOutermostMainFrame() instead. NB: this does not escape guest views;
108 // IsOutermostMainFrame will be true for the outermost main frame in an inner
109 // guest view.
danakjc492bf82020-09-09 20:02:44110 bool IsMainFrame() const;
Ian Vollick25a9d032022-04-12 23:20:17111 bool IsOutermostMainFrame();
danakjc492bf82020-09-09 20:02:44112
arthursonzogni76098e52020-11-25 14:18:45113 // Clears any state in this node which was set by the document itself (CSP &
114 // UserActivationState) and notifies proxies as appropriate. Invoked after
115 // committing navigation to a new document (since the new document comes with
116 // a fresh set of CSP).
117 // TODO(arthursonzogni): Remove this function. The frame/document must not be
118 // left temporarily with lax state.
Hiroki Nakagawaab309622021-05-19 16:38:13119 void ResetForNavigation();
danakjc492bf82020-09-09 20:02:44120
Arthur Sonzognif6785ec2022-12-05 10:11:50121 FrameTree& frame_tree() const { return frame_tree_.get(); }
Paul Semel3e241042022-10-11 12:57:31122 Navigator& navigator();
danakjc492bf82020-09-09 20:02:44123
124 RenderFrameHostManager* render_manager() { return &render_manager_; }
Alexander Timin33e2e2c12022-03-03 04:21:33125 const RenderFrameHostManager* render_manager() const {
126 return &render_manager_;
127 }
danakjc492bf82020-09-09 20:02:44128 int frame_tree_node_id() const { return frame_tree_node_id_; }
Yuzu Saijo03dbf9b2022-07-22 04:29:45129 // This reflects window.name, which is initially set to the the "name"
130 // attribute. But this won't reflect changes of 'name' attribute and instead
131 // reflect changes to the Window object's name property.
132 // This is different from IframeAttributes' name in that this will not get
133 // updated when 'name' attribute gets updated.
Harkiran Bolaria4eacb3a2021-12-13 20:03:47134 const std::string& frame_name() const {
135 return render_manager_.current_replication_state().name;
136 }
danakjc492bf82020-09-09 20:02:44137
138 const std::string& unique_name() const {
Harkiran Bolaria4eacb3a2021-12-13 20:03:47139 return render_manager_.current_replication_state().unique_name;
danakjc492bf82020-09-09 20:02:44140 }
141
danakjc492bf82020-09-09 20:02:44142 size_t child_count() const { return current_frame_host()->child_count(); }
143
danakjc492bf82020-09-09 20:02:44144 RenderFrameHostImpl* parent() const { return parent_; }
145
Dave Tapuskac8de3b02021-12-03 21:51:01146 // See `RenderFrameHost::GetParentOrOuterDocument()` for
147 // documentation.
148 RenderFrameHostImpl* GetParentOrOuterDocument();
149
150 // See `RenderFrameHostImpl::GetParentOrOuterDocumentOrEmbedder()` for
151 // documentation.
152 RenderFrameHostImpl* GetParentOrOuterDocumentOrEmbedder();
153
danakjc492bf82020-09-09 20:02:44154 FrameTreeNode* opener() const { return opener_; }
155
Rakina Zata Amni3a48ae42022-05-05 03:39:56156 FrameTreeNode* first_live_main_frame_in_original_opener_chain() const {
157 return first_live_main_frame_in_original_opener_chain_;
158 }
danakjc492bf82020-09-09 20:02:44159
Anton Bikineevf62d1bf2021-05-15 17:56:07160 const absl::optional<base::UnguessableToken>& opener_devtools_frame_token() {
Wolfgang Beyerd8809db2020-09-30 15:29:39161 return opener_devtools_frame_token_;
162 }
163
Julie Jeongeun Kimf38c1eca2021-12-14 07:46:55164 // Returns the type of the frame. Refer to frame_type.h for the details.
165 FrameType GetFrameType() const;
166
danakjc492bf82020-09-09 20:02:44167 // Assigns a new opener for this node and, if |opener| is non-null, registers
168 // an observer that will clear this node's opener if |opener| is ever
169 // destroyed.
170 void SetOpener(FrameTreeNode* opener);
171
172 // Assigns the initial opener for this node, and if |opener| is non-null,
173 // registers an observer that will clear this node's opener if |opener| is
174 // ever destroyed. The value set here is the root of the tree.
175 //
176 // It is not possible to change the opener once it was set.
177 void SetOriginalOpener(FrameTreeNode* opener);
178
Wolfgang Beyerd8809db2020-09-30 15:29:39179 // Assigns an opener frame id for this node. This string id is only set once
180 // and cannot be changed. It persists, even if the |opener| is destroyed. It
181 // is used for attribution in the DevTools frontend.
182 void SetOpenerDevtoolsFrameToken(
183 base::UnguessableToken opener_devtools_frame_token);
184
danakjc492bf82020-09-09 20:02:44185 FrameTreeNode* child_at(size_t index) const {
186 return current_frame_host()->child_at(index);
187 }
188
189 // Returns the URL of the last committed page in the current frame.
190 const GURL& current_url() const {
191 return current_frame_host()->GetLastCommittedURL();
192 }
193
Abhijeet Kandalkarb86993b2022-11-22 05:17:40194 // Note that the current RenderFrameHost might not exist yet when calling this
195 // during FrameTreeNode initialization. In this case the FrameTreeNode must be
196 // on the initial empty document. Refer RFHI::is_initial_empty_document for a
197 // more details.
Rakina Zata Amni86c88fa2021-11-01 01:27:30198 bool is_on_initial_empty_document() const {
Abhijeet Kandalkarb86993b2022-11-22 05:17:40199 return current_frame_host()
200 ? current_frame_host()->is_initial_empty_document()
201 : true;
Rakina Zata Amnifc4cc3d42021-06-10 09:03:56202 }
203
danakjc492bf82020-09-09 20:02:44204 // Returns whether the frame's owner element in the parent document is
205 // collapsed, that is, removed from the layout as if it did not exist, as per
206 // request by the embedder (of the content/ layer).
207 bool is_collapsed() const { return is_collapsed_; }
208
209 // Sets whether to collapse the frame's owner element in the parent document,
210 // that is, to remove it from the layout as if it did not exist, as per
211 // request by the embedder (of the content/ layer). Cannot be called for main
212 // frames.
213 //
214 // This only has an effect for <iframe> owner elements, and is a no-op when
215 // called on sub-frames hosted in <frame>, <object>, and <embed> elements.
216 void SetCollapsed(bool collapsed);
217
218 // Returns the origin of the last committed page in this frame.
219 // WARNING: To get the last committed origin for a particular
220 // RenderFrameHost, use RenderFrameHost::GetLastCommittedOrigin() instead,
221 // which will behave correctly even when the RenderFrameHost is not the
222 // current one for this frame (such as when it's pending deletion).
223 const url::Origin& current_origin() const {
Harkiran Bolaria4eacb3a2021-12-13 20:03:47224 return render_manager_.current_replication_state().origin;
danakjc492bf82020-09-09 20:02:44225 }
226
danakjc492bf82020-09-09 20:02:44227 // Returns the latest frame policy (sandbox flags and container policy) for
228 // this frame. This includes flags inherited from parent frames and the latest
229 // flags from the <iframe> element hosting this frame. The returned policies
230 // may not yet have taken effect, since "sandbox" and "allow" attribute
Liam Brady25a14162022-12-02 15:25:57231 // updates in an <iframe> element take effect on next navigation. For
232 // <fencedframe> elements, not everything in the frame policy might actually
233 // take effect after the navigation. To retrieve the currently active policy
234 // for this frame, use effective_frame_policy().
danakjc492bf82020-09-09 20:02:44235 const blink::FramePolicy& pending_frame_policy() const {
236 return pending_frame_policy_;
237 }
238
239 // Update this frame's sandbox flags and container policy. This is called
240 // when a parent frame updates the "sandbox" attribute in the <iframe> element
241 // for this frame, or any of the attributes which affect the container policy
242 // ("allowfullscreen", "allowpaymentrequest", "allow", and "src".)
243 // These policies won't take effect until next navigation. If this frame's
244 // parent is itself sandboxed, the parent's sandbox flags are combined with
245 // those in |frame_policy|.
246 // Attempting to change the container policy on the main frame will have no
247 // effect.
248 void SetPendingFramePolicy(blink::FramePolicy frame_policy);
249
250 // Returns the currently active frame policy for this frame, including the
251 // sandbox flags which were present at the time the document was loaded, and
Charlie Hu5130d25e2021-03-05 21:53:39252 // the permissions policy container policy, which is set by the iframe's
danakjc492bf82020-09-09 20:02:44253 // allowfullscreen, allowpaymentrequest, and allow attributes, along with the
254 // origin of the iframe's src attribute (which may be different from the URL
255 // of the document currently loaded into the frame). This does not include
256 // policy changes that have been made by updating the containing iframe
257 // element attributes since the frame was last navigated; use
258 // pending_frame_policy() for those.
259 const blink::FramePolicy& effective_frame_policy() const {
Harkiran Bolaria4eacb3a2021-12-13 20:03:47260 return render_manager_.current_replication_state().frame_policy;
danakjc492bf82020-09-09 20:02:44261 }
262
danakjc492bf82020-09-09 20:02:44263 const blink::mojom::FrameOwnerProperties& frame_owner_properties() {
264 return frame_owner_properties_;
265 }
266
267 void set_frame_owner_properties(
268 const blink::mojom::FrameOwnerProperties& frame_owner_properties) {
269 frame_owner_properties_ = frame_owner_properties;
270 }
271
Yuzu Saijo03dbf9b2022-07-22 04:29:45272 // Reflects the attributes of the corresponding iframe html element, such
Arthur Sonzogni64457592022-11-22 11:08:59273 // as 'credentialless', 'id', 'name' and 'src'. These values should not be
Yuzu Saijo03dbf9b2022-07-22 04:29:45274 // exposed to cross-origin renderers.
275 const network::mojom::ContentSecurityPolicy* csp_attribute() const {
276 return attributes_->parsed_csp_attribute.get();
danakjc492bf82020-09-09 20:02:44277 }
Arthur Sonzogni64457592022-11-22 11:08:59278 bool credentialless() const { return attributes_->credentialless; }
Yuzu Saijo03dbf9b2022-07-22 04:29:45279 const std::string& html_id() const { return attributes_->id; }
280 // This tracks iframe's 'name' attribute instead of window.name, which is
281 // tracked in FrameReplicationState. See the comment for frame_name() for
282 // more details.
283 const std::string& html_name() const { return attributes_->name; }
284 const std::string& html_src() const { return attributes_->src; }
danakjc492bf82020-09-09 20:02:44285
Yuzu Saijo03dbf9b2022-07-22 04:29:45286 void SetAttributes(blink::mojom::IframeAttributesPtr attributes);
Antonio Sartori5abc8de2021-07-13 08:42:47287
danakjc492bf82020-09-09 20:02:44288 bool HasSameOrigin(const FrameTreeNode& node) const {
Harkiran Bolaria4eacb3a2021-12-13 20:03:47289 return render_manager_.current_replication_state().origin.IsSameOriginWith(
290 node.current_replication_state().origin);
danakjc492bf82020-09-09 20:02:44291 }
292
Gyuyoung Kimc16e52e92021-03-19 02:45:37293 const blink::mojom::FrameReplicationState& current_replication_state() const {
Harkiran Bolaria4eacb3a2021-12-13 20:03:47294 return render_manager_.current_replication_state();
danakjc492bf82020-09-09 20:02:44295 }
296
297 RenderFrameHostImpl* current_frame_host() const {
298 return render_manager_.current_frame_host();
299 }
300
danakjc492bf82020-09-09 20:02:44301 // Returns true if this node is in a loading state.
302 bool IsLoading() const;
303
Alex Moshchuk9b0fd822020-10-26 23:08:15304 // Returns true if this node has a cross-document navigation in progress.
305 bool HasPendingCrossDocumentNavigation() const;
306
danakjc492bf82020-09-09 20:02:44307 NavigationRequest* navigation_request() { return navigation_request_.get(); }
308
309 // Transfers the ownership of the NavigationRequest to |render_frame_host|.
310 // From ReadyToCommit to DidCommit, the NavigationRequest is owned by the
311 // RenderFrameHost that is committing the navigation.
312 void TransferNavigationRequestOwnership(
313 RenderFrameHostImpl* render_frame_host);
314
315 // Takes ownership of |navigation_request| and makes it the current
316 // NavigationRequest of this frame. This corresponds to the start of a new
317 // navigation. If there was an ongoing navigation request before calling this
318 // function, it is canceled. |navigation_request| should not be null.
319 void CreatedNavigationRequest(
320 std::unique_ptr<NavigationRequest> navigation_request);
321
Rakina Zata Amnif8f2bb62022-11-23 05:54:32322 // Resets the navigation request owned by `this` (which shouldn't have reached
323 // the "pending commit" stage yet) and any state created by it, including the
Rakina Zata Amni33175cb92022-11-24 02:46:03324 // speculative RenderFrameHost (if there are no other navigations associated
325 // with it). Note that this does not affect navigations that have reached the
326 // "pending commit" stage, which are owned by their corresponding
327 // RenderFrameHosts instead.
Daniel Cheng390e2a72022-09-28 06:07:53328 void ResetNavigationRequest(NavigationDiscardReason reason);
329
Rakina Zata Amnif8f2bb62022-11-23 05:54:32330 // Similar to `ResetNavigationRequest()`, but keeps the state created by the
Daniel Cheng390e2a72022-09-28 06:07:53331 // NavigationRequest (e.g. speculative RenderFrameHost, loading state).
332 void ResetNavigationRequestButKeepState();
danakjc492bf82020-09-09 20:02:44333
danakjc492bf82020-09-09 20:02:44334 // The load progress for a RenderFrameHost in this node was updated to
335 // |load_progress|. This will notify the FrameTree which will in turn notify
336 // the WebContents.
337 void DidChangeLoadProgress(double load_progress);
338
339 // Called when the user directed the page to stop loading. Stops all loads
340 // happening in the FrameTreeNode. This method should be used with
341 // FrameTree::ForEach to stop all loads in the entire FrameTree.
342 bool StopLoading();
343
344 // Returns the time this frame was last focused.
345 base::TimeTicks last_focus_time() const { return last_focus_time_; }
346
347 // Called when this node becomes focused. Updates the node's last focused
348 // time and notifies observers.
349 void DidFocus();
350
351 // Called when the user closed the modal dialogue for BeforeUnload and
352 // cancelled the navigation. This should stop any load happening in the
353 // FrameTreeNode.
354 void BeforeUnloadCanceled();
355
danakjc492bf82020-09-09 20:02:44356 // Returns the sandbox flags currently in effect for this frame. This includes
357 // flags inherited from parent frames, the currently active flags from the
358 // <iframe> element hosting this frame, as well as any flags set from a
359 // Content-Security-Policy HTTP header. This does not include flags that have
360 // have been updated in an <iframe> element but have not taken effect yet; use
361 // pending_frame_policy() for those. To see the flags which will take effect
362 // on navigation (which does not include the CSP-set flags), use
363 // effective_frame_policy().
364 network::mojom::WebSandboxFlags active_sandbox_flags() const {
Harkiran Bolaria4eacb3a2021-12-13 20:03:47365 return render_manager_.current_replication_state().active_sandbox_flags;
danakjc492bf82020-09-09 20:02:44366 }
367
danakjc492bf82020-09-09 20:02:44368 // Returns whether the frame received a user gesture on a previous navigation
369 // on the same eTLD+1.
370 bool has_received_user_gesture_before_nav() const {
Harkiran Bolaria4eacb3a2021-12-13 20:03:47371 return render_manager_.current_replication_state()
372 .has_received_user_gesture_before_nav;
danakjc492bf82020-09-09 20:02:44373 }
374
375 // When a tab is discarded, WebContents sets was_discarded on its
376 // root FrameTreeNode.
377 // In addition, when a child frame is created, this bit is passed on from
378 // parent to child.
379 // When a navigation request is created, was_discarded is passed on to the
380 // request and reset to false in FrameTreeNode.
381 void set_was_discarded() { was_discarded_ = true; }
382 bool was_discarded() const { return was_discarded_; }
383
Miyoung Shin8a66ec022022-11-28 23:50:09384 // Deprecated. Use directly HasStickyUserActivation in RFHI.
danakjc492bf82020-09-09 20:02:44385 // Returns the sticky bit of the User Activation v2 state of the
386 // |FrameTreeNode|.
387 bool HasStickyUserActivation() const {
Miyoung Shin8a66ec022022-11-28 23:50:09388 return current_frame_host()->HasStickyUserActivation();
danakjc492bf82020-09-09 20:02:44389 }
390
Miyoung Shin8a66ec022022-11-28 23:50:09391 // Deprecated. Use directly HasStickyUserActivation in RFHI.
danakjc492bf82020-09-09 20:02:44392 // Returns the transient bit of the User Activation v2 state of the
393 // |FrameTreeNode|.
394 bool HasTransientUserActivation() {
Miyoung Shin8a66ec022022-11-28 23:50:09395 return current_frame_host()->HasTransientUserActivation();
danakjc492bf82020-09-09 20:02:44396 }
397
398 // Remove history entries for all frames created by script in this frame's
399 // subtree. If a frame created by a script is removed, then its history entry
400 // will never be reused - this saves memory.
401 void PruneChildFrameNavigationEntries(NavigationEntryImpl* entry);
402
Abhijeet Kandalkarb43affa72022-09-27 16:48:01403 using FencedFrameStatus = RenderFrameHostImpl::FencedFrameStatus;
Abhijeet Kandalkar3f29bc42022-09-23 12:39:58404 FencedFrameStatus fenced_frame_status() const { return fenced_frame_status_; }
405
Kevin McNee43fe8292021-10-04 22:59:41406 blink::FrameOwnerElementType frame_owner_element_type() const {
Daniel Cheng9bd90f92021-04-23 20:49:45407 return frame_owner_element_type_;
danakjc492bf82020-09-09 20:02:44408 }
danakjc492bf82020-09-09 20:02:44409
Daniel Cheng6ac128172021-05-25 18:49:01410 blink::mojom::TreeScopeType tree_scope_type() const {
411 return tree_scope_type_;
412 }
413
arthursonzogni034bb9c2020-10-01 08:29:56414 // The initial popup URL for new window opened using:
415 // `window.open(initial_popup_url)`.
416 // An empty GURL otherwise.
417 //
418 // [WARNING] There is no guarantee the FrameTreeNode will ever host a
419 // document served from this URL. The FrameTreeNode always starts hosting the
420 // initial empty document and attempts a navigation toward this URL. However
421 // the navigation might be delayed, redirected and even cancelled.
422 void SetInitialPopupURL(const GURL& initial_popup_url);
423 const GURL& initial_popup_url() const { return initial_popup_url_; }
424
425 // The origin of the document that used window.open() to create this frame.
426 // Otherwise, an opaque Origin with a nonce different from all previously
427 // existing Origins.
428 void SetPopupCreatorOrigin(const url::Origin& popup_creator_origin);
429 const url::Origin& popup_creator_origin() const {
430 return popup_creator_origin_;
431 }
432
Harkiran Bolaria59290d62021-03-17 01:53:01433 // Sets the associated FrameTree for this node. The node can change FrameTrees
434 // when blink::features::Prerender2 is enabled, which allows a page loaded in
435 // the prerendered FrameTree to be used for a navigation in the primary frame
436 // tree.
437 void SetFrameTree(FrameTree& frame_tree);
438
Alexander Timin074cd182022-03-23 18:11:22439 using TraceProto = perfetto::protos::pbzero::FrameTreeNodeInfo;
Alexander Timinf785f342021-03-18 00:00:56440 // Write a representation of this object into a trace.
Alexander Timin074cd182022-03-23 18:11:22441 void WriteIntoTrace(perfetto::TracedProto<TraceProto> proto) const;
Alexander Timinf785f342021-03-18 00:00:56442
Carlos Caballero76711352021-03-24 17:38:21443 // Returns true the node is navigating, i.e. it has an associated
444 // NavigationRequest.
445 bool HasNavigation();
446
shivanigithubf3ddff52021-07-03 22:06:30447 // Fenced frames (meta-bug crbug.com/1111084):
shivanigithub4cd016a2021-09-20 21:10:30448 // Note that these two functions cannot be invoked from a FrameTree's or
449 // its root node's constructor since they require the frame tree and the
450 // root node to be completely constructed.
451 //
shivanigithubf3ddff52021-07-03 22:06:30452 // Returns false if fenced frames are disabled. Returns true if the feature is
453 // enabled and if |this| is a fenced frame. Returns false for
454 // iframes embedded in a fenced frame. To clarify: for the MPArch
455 // implementation this only returns true if |this| is the actual
456 // root node of the inner FrameTree and not the proxy FrameTreeNode in the
457 // outer FrameTree.
Dominic Farolino4bc10ee2021-08-31 00:37:36458 bool IsFencedFrameRoot() const;
shivanigithubf3ddff52021-07-03 22:06:30459
460 // Returns false if fenced frames are disabled. Returns true if the
461 // feature is enabled and if |this| or any of its ancestor nodes is a
462 // fenced frame.
463 bool IsInFencedFrameTree() const;
464
shivanigithub4cd016a2021-09-20 21:10:30465 // Returns a valid nonce if `IsInFencedFrameTree()` returns true for `this`.
Garrett Tanzer34cb92fe2022-09-28 17:50:54466 // Returns nullopt otherwise.
467 //
468 // Nonce used in the net::IsolationInfo and blink::StorageKey for a fenced
469 // frame and any iframes nested within it. Not set if this frame is not in a
470 // fenced frame's FrameTree. Note that this could be a field in FrameTree for
471 // the MPArch version but for the shadow DOM version we need to keep it here
472 // since the fenced frame root is not a main frame for the latter. The value
473 // of the nonce will be the same for all of the the iframes inside a fenced
474 // frame tree. If there is a nested fenced frame it will have a different
475 // nonce than its parent fenced frame. The nonce will stay the same across
476 // navigations initiated from the fenced frame tree because it is always used
477 // in conjunction with other fields of the keys and would be good to access
478 // the same storage across same-origin navigations. If the navigation is
479 // same-origin/site then the same network stack partition/storage will be
480 // reused and if it's cross-origin/site then other parts of the key will
481 // change and so, even with the same nonce, another partition will be used.
482 // But if the navigation is initiated from the embedder, the nonce will be
483 // reinitialized irrespective of same or cross origin such that there is no
484 // privacy leak via storage shared between two embedder initiated navigations.
485 // Note that this reinitialization is implemented for all embedder-initiated
486 // navigations in MPArch, but only urn:uuid navigations in ShadowDOM.
487 absl::optional<base::UnguessableToken> GetFencedFrameNonce();
shivanigithub4cd016a2021-09-20 21:10:30488
Garrett Tanzer34cb92fe2022-09-28 17:50:54489 // If applicable, initialize the default fenced frame properties. Right now,
490 // this means setting a new fenced frame nonce. See comment on
shivanigithub4cd016a2021-09-20 21:10:30491 // fenced_frame_nonce() for when it is set to a non-null value. Invoked
492 // by FrameTree::Init() or FrameTree::AddFrame().
Garrett Tanzer34cb92fe2022-09-28 17:50:54493 void SetFencedFramePropertiesIfNeeded();
shivanigithub4cd016a2021-09-20 21:10:30494
Garrett Tanzera42fdef2022-06-13 16:09:14495 // Returns the mode attribute set on the fenced frame root if this frame is
496 // in a fenced frame tree, otherwise returns `absl::nullopt`.
Nan Line376738a2022-03-25 22:05:41497 absl::optional<blink::mojom::FencedFrameMode> GetFencedFrameMode();
Nan Lin171fe9a2022-02-17 16:42:16498
Dave Tapuskac8de3b02021-12-03 21:51:01499 // Helper for GetParentOrOuterDocument/GetParentOrOuterDocumentOrEmbedder.
500 // Do not use directly.
501 RenderFrameHostImpl* GetParentOrOuterDocumentHelper(bool escape_guest_view);
502
Harkiran Bolariab4437fd2021-08-11 17:51:22503 // Sets the unique_name and name fields on replication_state_. To be used in
504 // prerender activation to make sure the FrameTreeNode replication state is
505 // correct after the RenderFrameHost is moved between FrameTreeNodes. The
506 // renderers should already have the correct value, so unlike
507 // FrameTreeNode::SetFrameName, we do not notify them here.
Harkiran Bolaria4eacb3a2021-12-13 20:03:47508 // TODO(https://crbug.com/1237091): Remove this once the BrowsingContextState
509 // is implemented to utilize the new path.
Harkiran Bolariab4437fd2021-08-11 17:51:22510 void set_frame_name_for_activation(const std::string& unique_name,
511 const std::string& name) {
Harkiran Bolaria0b3bdef02022-03-10 13:04:40512 current_frame_host()->browsing_context_state()->set_frame_name(unique_name,
513 name);
Harkiran Bolariab4437fd2021-08-11 17:51:22514 }
515
Nan Linaaf84f72021-12-02 22:31:56516 // Returns true if error page isolation is enabled.
517 bool IsErrorPageIsolationEnabled() const;
518
W. James MacLean81b8d01f2022-01-25 20:50:59519 // Functions to store and retrieve a frame's srcdoc value on this
520 // FrameTreeNode.
521 void SetSrcdocValue(const std::string& srcdoc_value);
522 const std::string& srcdoc_value() const { return srcdoc_value_; }
523
Garrett Tanzerc69f4642022-08-15 22:15:14524 void set_fenced_frame_properties(
525 absl::optional<FencedFrameURLMapping::FencedFrameProperties>&
526 fenced_frame_properties) {
Garrett Tanzer2975eeac2022-08-22 16:34:01527 // TODO(crbug.com/1262022): Reenable this DCHECK once ShadowDOM and
528 // loading urns in iframes (for FLEDGE OT) are gone.
529 // DCHECK_EQ(fenced_frame_status_,
530 // RenderFrameHostImpl::FencedFrameStatus::kFencedFrameRoot);
Garrett Tanzerc69f4642022-08-15 22:15:14531 fenced_frame_properties_ = fenced_frame_properties;
532 }
533
Garrett Tanzer34cb92fe2022-09-28 17:50:54534 // Return the fenced frame properties for this fenced frame tree (if any).
535 // That is to say, this function returns the `fenced_frame_properties_`
536 // variable attached to the fenced frame root FrameTreeNode, which may be
537 // either this node or an ancestor of it.
Garrett Tanzerc69f4642022-08-15 22:15:14538 const absl::optional<FencedFrameURLMapping::FencedFrameProperties>&
Garrett Tanzer34cb92fe2022-09-28 17:50:54539 GetFencedFrameProperties();
Garrett Tanzerc69f4642022-08-15 22:15:14540
Yao Xiaoa2337ad2022-10-12 20:59:29541 // Return the number of fenced frame boundaries above this frame. The
542 // outermost main frame's frame tree has fenced frame depth 0, a topmost
543 // fenced frame tree embedded in the outermost main frame has fenced frame
544 // depth 1, etc.
545 size_t GetFencedFrameDepth();
546
547 // Traverse up from this node. Return all valid
548 // `node->fenced_frame_properties_->shared_storage_budget_metadata` (i.e. this
549 // node is subjected to the shared storage budgeting associated with those
550 // metadata). Every node that originates from sharedStorage.selectURL() will
551 // have an associated metadata. This indicates that the metadata can only
552 // possibly be associated with a fenced frame root, unless when
553 // `kAllowURNsInIframes` is enabled in which case they could be be associated
554 // with any node.
555 std::vector<const FencedFrameURLMapping::SharedStorageBudgetMetadata*>
Yao Xiao1ac702d2022-06-08 17:20:49556 FindSharedStorageBudgetMetadata();
557
Harkiran Bolariaebbe7702022-02-22 19:19:03558 // Accessor to BrowsingContextState for subframes only. Only main frame
559 // navigations can change BrowsingInstances and BrowsingContextStates,
560 // therefore for subframes associated BrowsingContextState never changes. This
561 // helper method makes this more explicit and guards against calling this on
562 // main frames (there an appropriate BrowsingContextState should be obtained
563 // from RenderFrameHost or from RenderFrameProxyHost as e.g. during
564 // cross-BrowsingInstance navigations multiple BrowsingContextStates exist in
565 // the same frame).
566 const scoped_refptr<BrowsingContextState>&
567 GetBrowsingContextStateForSubframe() const;
568
Arthur Hemerye4659282022-03-28 08:36:15569 // Clears the opener property of popups referencing this FrameTreeNode as
570 // their opener.
571 void ClearOpenerReferences();
572
Liam Bradyd2a41e152022-07-19 13:58:48573 // Calculates whether one of the ancestor frames or this frame has a CSPEE
574 // in place. This is eventually sent over to LocalFrame in the renderer where
575 // it will be used by HTMLFencedFrameElement::canLoadOpaqueURL for information
576 // it can't get on its own.
577 bool AncestorOrSelfHasCSPEE() const;
578
Miyoung Shin7cf88b42022-11-07 13:22:30579 // RenderFrameHostOwner implementation:
Julie Jeongeun Kim07c077bd2022-12-05 08:40:31580 void DidStartLoading(bool should_show_loading_ui,
581 bool was_previously_loading) override;
582 void DidStopLoading() override;
Miyoung Shin7cf88b42022-11-07 13:22:30583 void RestartNavigationAsCrossDocument(
584 std::unique_ptr<NavigationRequest> navigation_request) override;
Julie Jeongeun Kimc1b07c32022-11-11 10:26:32585 Navigator& GetCurrentNavigator() override;
Miyoung Shine16cd2262022-11-30 05:52:16586 RenderFrameHostManager& GetRenderFrameHostManager() override;
Julie Jeongeun Kim2132b37f82022-11-23 08:30:46587 void SetFocusedFrame(SiteInstanceGroup* source) override;
Julie Jeongeun Kim0e242242022-11-30 10:45:09588 void DidChangeReferrerPolicy(
589 network::mojom::ReferrerPolicy referrer_policy) override;
Miyoung Shin7cf88b42022-11-07 13:22:30590
Miyoung Shin8a66ec022022-11-28 23:50:09591 // Updates the user activation state in the browser frame tree and in the
592 // frame trees in all renderer processes except the renderer for this node
593 // (which initiated the update). Returns |false| if the update tries to
594 // consume an already consumed/expired transient state, |true| otherwise. See
595 // the comment on `user_activation_state_` in RenderFrameHostImpl.
596 //
597 // The |notification_type| parameter is used for histograms, only for the case
598 // |update_state == kNotifyActivation|.
599 bool UpdateUserActivationState(
600 blink::mojom::UserActivationUpdateType update_type,
601 blink::mojom::UserActivationNotificationType notification_type) override;
602
Miyoung Shinff13ed22022-11-30 09:21:47603 std::unique_ptr<NavigationRequest>
604 CreateNavigationRequestForSynchronousRendererCommit(
605 RenderFrameHostImpl* render_frame_host,
606 bool is_same_document,
607 const GURL& url,
608 const url::Origin& origin,
609 const net::IsolationInfo& isolation_info_for_subresources,
610 blink::mojom::ReferrerPtr referrer,
611 const ui::PageTransition& transition,
612 bool should_replace_current_entry,
613 const std::string& method,
614 bool has_transient_activation,
615 bool is_overriding_user_agent,
616 const std::vector<GURL>& redirects,
617 const GURL& original_url,
618 std::unique_ptr<CrossOriginEmbedderPolicyReporter> coep_reporter,
619 std::unique_ptr<WebBundleNavigationInfo> web_bundle_navigation_info,
620 std::unique_ptr<SubresourceWebBundleNavigationInfo>
621 subresource_web_bundle_navigation_info,
622 int http_response_code) override;
Miyoung Shinb5561802022-12-01 08:21:35623 void CancelNavigation() override;
Miyoung Shinff13ed22022-11-30 09:21:47624
danakjc492bf82020-09-09 20:02:44625 private:
Yuzu Saijo03dbf9b2022-07-22 04:29:45626 friend class CSPEmbeddedEnforcementUnitTest;
Charlie Hubb5943d2021-03-09 19:46:12627 FRIEND_TEST_ALL_PREFIXES(SitePerProcessPermissionsPolicyBrowserTest,
danakjc492bf82020-09-09 20:02:44628 ContainerPolicyDynamic);
Charlie Hubb5943d2021-03-09 19:46:12629 FRIEND_TEST_ALL_PREFIXES(SitePerProcessPermissionsPolicyBrowserTest,
danakjc492bf82020-09-09 20:02:44630 ContainerPolicySandboxDynamic);
Yuzu Saijo03dbf9b2022-07-22 04:29:45631 FRIEND_TEST_ALL_PREFIXES(NavigationRequestTest, StorageKeyToCommit);
Arthur Sonzogni64457592022-11-22 11:08:59632 FRIEND_TEST_ALL_PREFIXES(
633 NavigationRequestTest,
634 NavigationToCredentiallessDocumentNetworkIsolationInfo);
Yuzu Saijo03dbf9b2022-07-22 04:29:45635 FRIEND_TEST_ALL_PREFIXES(RenderFrameHostImplTest,
Arthur Sonzogni64457592022-11-22 11:08:59636 ChildOfCredentiallessIsCredentialless);
Yifan Luo86a79f42022-08-16 18:38:27637 FRIEND_TEST_ALL_PREFIXES(ContentPasswordManagerDriverTest,
Arthur Sonzogni64457592022-11-22 11:08:59638 PasswordAutofillDisabledOnCredentiallessIframe);
danakjc492bf82020-09-09 20:02:44639
Dominic Farolino8a2187b2021-12-24 20:44:21640 // Called by the destructor. When `this` is an outer dummy FrameTreeNode
641 // representing an inner FrameTree, this method destroys said inner FrameTree.
642 void DestroyInnerFrameTreeIfExists();
643
danakjc492bf82020-09-09 20:02:44644 class OpenerDestroyedObserver;
645
danakjc492bf82020-09-09 20:02:44646 // The |notification_type| parameter is used for histograms only.
647 bool NotifyUserActivation(
648 blink::mojom::UserActivationNotificationType notification_type);
649
650 bool ConsumeTransientUserActivation();
651
652 bool ClearUserActivation();
653
654 // Verify that the renderer process is allowed to set user activation on this
655 // frame by checking whether this frame's RenderWidgetHost had previously seen
656 // an input event that might lead to user activation. If user activation
657 // should be allowed, this returns true and also clears corresponding pending
658 // user activation state in the widget. Otherwise, this returns false.
659 bool VerifyUserActivation();
660
661 // The next available browser-global FrameTreeNode ID.
662 static int next_frame_tree_node_id_;
663
Arthur Sonzognif6785ec2022-12-05 10:11:50664 // The FrameTree owning |this|. It can change with Prerender2 during
665 // activation.
666 raw_ref<FrameTree> frame_tree_;
danakjc492bf82020-09-09 20:02:44667
danakjc492bf82020-09-09 20:02:44668 // A browser-global identifier for the frame in the page, which stays stable
669 // even if the frame does a cross-process navigation.
670 const int frame_tree_node_id_;
671
672 // The RenderFrameHost owning this FrameTreeNode, which cannot change for the
673 // life of this FrameTreeNode. |nullptr| if this node is the root.
Keishi Hattori0e45c022021-11-27 09:25:52674 const raw_ptr<RenderFrameHostImpl> parent_;
danakjc492bf82020-09-09 20:02:44675
danakjc492bf82020-09-09 20:02:44676 // The frame that opened this frame, if any. Will be set to null if the
677 // opener is closed, or if this frame disowns its opener by setting its
678 // window.opener to null.
Keishi Hattori0e45c022021-11-27 09:25:52679 raw_ptr<FrameTreeNode> opener_ = nullptr;
danakjc492bf82020-09-09 20:02:44680
681 // An observer that clears this node's |opener_| if the opener is destroyed.
682 // This observer is added to the |opener_|'s observer list when the |opener_|
683 // is set to a non-null node, and it is removed from that list when |opener_|
684 // changes or when this node is destroyed. It is also cleared if |opener_|
685 // is disowned.
686 std::unique_ptr<OpenerDestroyedObserver> opener_observer_;
687
Rakina Zata Amni3a48ae42022-05-05 03:39:56688 // Unlike `opener_`, the "original opener chain" doesn't reflect
689 // window.opener, which can be suppressed or updated. The "original opener"
690 // is the main frame of the actual opener of this frame. This traces the all
691 // the way back, so if the original opener was closed (deleted or severed due
692 // to COOP), but _it_ had an original opener, this will return the original
693 // opener's original opener, etc. So this value will always be set as long as
694 // there is at least one live frame in the chain whose connection is not
695 // severed due to COOP.
696 raw_ptr<FrameTreeNode> first_live_main_frame_in_original_opener_chain_ =
697 nullptr;
danakjc492bf82020-09-09 20:02:44698
Wolfgang Beyerd8809db2020-09-30 15:29:39699 // The devtools frame token of the frame which opened this frame. This is
700 // not cleared even if the opener is destroyed or disowns the frame.
Anton Bikineevf62d1bf2021-05-15 17:56:07701 absl::optional<base::UnguessableToken> opener_devtools_frame_token_;
Wolfgang Beyerd8809db2020-09-30 15:29:39702
Rakina Zata Amni3a48ae42022-05-05 03:39:56703 // An observer that updates this node's
704 // |first_live_main_frame_in_original_opener_chain_| to the next original
705 // opener in the chain if the original opener is destroyed.
danakjc492bf82020-09-09 20:02:44706 std::unique_ptr<OpenerDestroyedObserver> original_opener_observer_;
707
arthursonzogni034bb9c2020-10-01 08:29:56708 // When created by an opener, the URL specified in window.open(url)
709 // Please refer to {Get,Set}InitialPopupURL() documentation.
710 GURL initial_popup_url_;
711
712 // When created using window.open, the origin of the creator.
713 // Please refer to {Get,Set}PopupCreatorOrigin() documentation.
714 url::Origin popup_creator_origin_;
715
W. James MacLean81b8d01f2022-01-25 20:50:59716 // If the url from the the last BeginNavigation is about:srcdoc, this value
717 // stores the srcdoc_attribute's value for re-use in history navigations.
718 std::string srcdoc_value_;
719
danakjc492bf82020-09-09 20:02:44720 // Whether the frame's owner element in the parent document is collapsed.
arthursonzogni9816b9192021-03-29 16:09:19721 bool is_collapsed_ = false;
danakjc492bf82020-09-09 20:02:44722
Daniel Cheng6ac128172021-05-25 18:49:01723 // The type of frame owner for this frame. This is only relevant for non-main
724 // frames.
Kevin McNee43fe8292021-10-04 22:59:41725 const blink::FrameOwnerElementType frame_owner_element_type_ =
726 blink::FrameOwnerElementType::kNone;
Daniel Cheng9bd90f92021-04-23 20:49:45727
Daniel Cheng6ac128172021-05-25 18:49:01728 // The tree scope type of frame owner element, i.e. whether the element is in
729 // the document tree (https://dom.spec.whatwg.org/#document-trees) or the
730 // shadow tree (https://dom.spec.whatwg.org/#shadow-trees). This is only
731 // relevant for non-main frames.
732 const blink::mojom::TreeScopeType tree_scope_type_ =
733 blink::mojom::TreeScopeType::kDocument;
734
danakjc492bf82020-09-09 20:02:44735 // Track the pending sandbox flags and container policy for this frame. When a
736 // parent frame dynamically updates 'sandbox', 'allow', 'allowfullscreen',
737 // 'allowpaymentrequest' or 'src' attributes, the updated policy for the frame
Harkiran Bolaria4eacb3a2021-12-13 20:03:47738 // is stored here, and transferred into
739 // render_manager_.current_replication_state().frame_policy when they take
740 // effect on the next frame navigation.
danakjc492bf82020-09-09 20:02:44741 blink::FramePolicy pending_frame_policy_;
742
743 // Whether the frame was created by javascript. This is useful to prune
744 // history entries when the frame is removed (because frames created by
745 // scripts are never recreated with the same unique name - see
746 // https://crbug.com/500260).
arthursonzogni9816b9192021-03-29 16:09:19747 const bool is_created_by_script_;
danakjc492bf82020-09-09 20:02:44748
danakjc492bf82020-09-09 20:02:44749 // Tracks the scrolling and margin properties for this frame. These
750 // properties affect the child renderer but are stored on its parent's
751 // frame element. When this frame's parent dynamically updates these
752 // properties, we update them here too.
753 //
754 // Note that dynamic updates only take effect on the next frame navigation.
755 blink::mojom::FrameOwnerProperties frame_owner_properties_;
756
Yuzu Saijo03dbf9b2022-07-22 04:29:45757 // Contains the tracked HTML attributes of the corresponding iframe element,
758 // such as 'id' and 'src'.
759 blink::mojom::IframeAttributesPtr attributes_;
Antonio Sartori5abc8de2021-07-13 08:42:47760
danakjc492bf82020-09-09 20:02:44761 // Owns an ongoing NavigationRequest until it is ready to commit. It will then
762 // be reset and a RenderFrameHost will be responsible for the navigation.
763 std::unique_ptr<NavigationRequest> navigation_request_;
764
765 // List of objects observing this FrameTreeNode.
766 base::ObserverList<Observer>::Unchecked observers_;
767
768 base::TimeTicks last_focus_time_;
769
arthursonzogni9816b9192021-03-29 16:09:19770 bool was_discarded_ = false;
danakjc492bf82020-09-09 20:02:44771
Abhijeet Kandalkar3f29bc42022-09-23 12:39:58772 const FencedFrameStatus fenced_frame_status_ =
773 FencedFrameStatus::kNotNestedInFencedFrame;
Harkiran Bolaria16f2c48d2022-04-22 12:39:57774
Garrett Tanzerc69f4642022-08-15 22:15:14775 // If this is a fenced frame resulting from a urn:uuid navigation, this
776 // contains all the metadata specifying the resulting context.
Garrett Tanzer34cb92fe2022-09-28 17:50:54777 // TODO(crbug.com/1262022): Move this into the FrameTree once ShadowDOM
778 // and urn iframes are gone.
Garrett Tanzerc69f4642022-08-15 22:15:14779 absl::optional<FencedFrameURLMapping::FencedFrameProperties>
780 fenced_frame_properties_;
781
Lukasz Anforowicz147141962020-12-16 18:03:24782 // Manages creation and swapping of RenderFrameHosts for this frame.
783 //
784 // This field needs to be declared last, because destruction of
785 // RenderFrameHostManager may call arbitrary callbacks (e.g. via
786 // WebContentsObserver::DidFinishNavigation fired after RenderFrameHostManager
787 // destructs a RenderFrameHostImpl and its NavigationRequest). Such callbacks
788 // may try to use FrameTreeNode's fields above - this would be an undefined
789 // behavior if the fields (even trivially-destructible ones) were destructed
790 // before the RenderFrameHostManager's destructor runs. See also
791 // https://crbug.com/1157988.
792 RenderFrameHostManager render_manager_;
danakjc492bf82020-09-09 20:02:44793};
794
795} // namespace content
796
797#endif // CONTENT_BROWSER_RENDERER_HOST_FRAME_TREE_NODE_H_