blob: 9d7c7c8354f107c61d8cc8669caedeca93a3556b [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 }
Yuzu Saijo03dbf9b2022-07-22 04:29:45278 const std::string& html_id() const { return attributes_->id; }
279 // This tracks iframe's 'name' attribute instead of window.name, which is
280 // tracked in FrameReplicationState. See the comment for frame_name() for
281 // more details.
282 const std::string& html_name() const { return attributes_->name; }
283 const std::string& html_src() const { return attributes_->src; }
danakjc492bf82020-09-09 20:02:44284
Yuzu Saijo03dbf9b2022-07-22 04:29:45285 void SetAttributes(blink::mojom::IframeAttributesPtr attributes);
Antonio Sartori5abc8de2021-07-13 08:42:47286
danakjc492bf82020-09-09 20:02:44287 bool HasSameOrigin(const FrameTreeNode& node) const {
Harkiran Bolaria4eacb3a2021-12-13 20:03:47288 return render_manager_.current_replication_state().origin.IsSameOriginWith(
289 node.current_replication_state().origin);
danakjc492bf82020-09-09 20:02:44290 }
291
Gyuyoung Kimc16e52e92021-03-19 02:45:37292 const blink::mojom::FrameReplicationState& current_replication_state() const {
Harkiran Bolaria4eacb3a2021-12-13 20:03:47293 return render_manager_.current_replication_state();
danakjc492bf82020-09-09 20:02:44294 }
295
296 RenderFrameHostImpl* current_frame_host() const {
297 return render_manager_.current_frame_host();
298 }
299
danakjc492bf82020-09-09 20:02:44300 // Returns true if this node is in a loading state.
301 bool IsLoading() const;
302
Alex Moshchuk9b0fd822020-10-26 23:08:15303 // Returns true if this node has a cross-document navigation in progress.
304 bool HasPendingCrossDocumentNavigation() const;
305
danakjc492bf82020-09-09 20:02:44306 NavigationRequest* navigation_request() { return navigation_request_.get(); }
307
308 // Transfers the ownership of the NavigationRequest to |render_frame_host|.
309 // From ReadyToCommit to DidCommit, the NavigationRequest is owned by the
310 // RenderFrameHost that is committing the navigation.
311 void TransferNavigationRequestOwnership(
312 RenderFrameHostImpl* render_frame_host);
313
314 // Takes ownership of |navigation_request| and makes it the current
315 // NavigationRequest of this frame. This corresponds to the start of a new
316 // navigation. If there was an ongoing navigation request before calling this
317 // function, it is canceled. |navigation_request| should not be null.
Charlie Reis09952ee2022-12-08 16:35:07318 void TakeNavigationRequest(
danakjc492bf82020-09-09 20:02:44319 std::unique_ptr<NavigationRequest> navigation_request);
320
Rakina Zata Amnif8f2bb62022-11-23 05:54:32321 // Resets the navigation request owned by `this` (which shouldn't have reached
322 // the "pending commit" stage yet) and any state created by it, including the
Rakina Zata Amni33175cb92022-11-24 02:46:03323 // speculative RenderFrameHost (if there are no other navigations associated
324 // with it). Note that this does not affect navigations that have reached the
325 // "pending commit" stage, which are owned by their corresponding
326 // RenderFrameHosts instead.
Daniel Cheng390e2a72022-09-28 06:07:53327 void ResetNavigationRequest(NavigationDiscardReason reason);
328
Rakina Zata Amnif8f2bb62022-11-23 05:54:32329 // Similar to `ResetNavigationRequest()`, but keeps the state created by the
Daniel Cheng390e2a72022-09-28 06:07:53330 // NavigationRequest (e.g. speculative RenderFrameHost, loading state).
331 void ResetNavigationRequestButKeepState();
danakjc492bf82020-09-09 20:02:44332
danakjc492bf82020-09-09 20:02:44333 // The load progress for a RenderFrameHost in this node was updated to
334 // |load_progress|. This will notify the FrameTree which will in turn notify
335 // the WebContents.
336 void DidChangeLoadProgress(double load_progress);
337
338 // Called when the user directed the page to stop loading. Stops all loads
339 // happening in the FrameTreeNode. This method should be used with
340 // FrameTree::ForEach to stop all loads in the entire FrameTree.
341 bool StopLoading();
342
343 // Returns the time this frame was last focused.
344 base::TimeTicks last_focus_time() const { return last_focus_time_; }
345
346 // Called when this node becomes focused. Updates the node's last focused
347 // time and notifies observers.
348 void DidFocus();
349
350 // Called when the user closed the modal dialogue for BeforeUnload and
351 // cancelled the navigation. This should stop any load happening in the
352 // FrameTreeNode.
353 void BeforeUnloadCanceled();
354
danakjc492bf82020-09-09 20:02:44355 // Returns the sandbox flags currently in effect for this frame. This includes
356 // flags inherited from parent frames, the currently active flags from the
357 // <iframe> element hosting this frame, as well as any flags set from a
358 // Content-Security-Policy HTTP header. This does not include flags that have
359 // have been updated in an <iframe> element but have not taken effect yet; use
360 // pending_frame_policy() for those. To see the flags which will take effect
361 // on navigation (which does not include the CSP-set flags), use
362 // effective_frame_policy().
363 network::mojom::WebSandboxFlags active_sandbox_flags() const {
Harkiran Bolaria4eacb3a2021-12-13 20:03:47364 return render_manager_.current_replication_state().active_sandbox_flags;
danakjc492bf82020-09-09 20:02:44365 }
366
danakjc492bf82020-09-09 20:02:44367 // Returns whether the frame received a user gesture on a previous navigation
368 // on the same eTLD+1.
369 bool has_received_user_gesture_before_nav() const {
Harkiran Bolaria4eacb3a2021-12-13 20:03:47370 return render_manager_.current_replication_state()
371 .has_received_user_gesture_before_nav;
danakjc492bf82020-09-09 20:02:44372 }
373
374 // When a tab is discarded, WebContents sets was_discarded on its
375 // root FrameTreeNode.
376 // In addition, when a child frame is created, this bit is passed on from
377 // parent to child.
378 // When a navigation request is created, was_discarded is passed on to the
379 // request and reset to false in FrameTreeNode.
380 void set_was_discarded() { was_discarded_ = true; }
381 bool was_discarded() const { return was_discarded_; }
382
Miyoung Shin8a66ec022022-11-28 23:50:09383 // Deprecated. Use directly HasStickyUserActivation in RFHI.
danakjc492bf82020-09-09 20:02:44384 // Returns the sticky bit of the User Activation v2 state of the
385 // |FrameTreeNode|.
386 bool HasStickyUserActivation() const {
Miyoung Shin8a66ec022022-11-28 23:50:09387 return current_frame_host()->HasStickyUserActivation();
danakjc492bf82020-09-09 20:02:44388 }
389
Miyoung Shin8a66ec022022-11-28 23:50:09390 // Deprecated. Use directly HasStickyUserActivation in RFHI.
danakjc492bf82020-09-09 20:02:44391 // Returns the transient bit of the User Activation v2 state of the
392 // |FrameTreeNode|.
393 bool HasTransientUserActivation() {
Miyoung Shin8a66ec022022-11-28 23:50:09394 return current_frame_host()->HasTransientUserActivation();
danakjc492bf82020-09-09 20:02:44395 }
396
397 // Remove history entries for all frames created by script in this frame's
398 // subtree. If a frame created by a script is removed, then its history entry
399 // will never be reused - this saves memory.
400 void PruneChildFrameNavigationEntries(NavigationEntryImpl* entry);
401
Abhijeet Kandalkarb43affa72022-09-27 16:48:01402 using FencedFrameStatus = RenderFrameHostImpl::FencedFrameStatus;
Abhijeet Kandalkar3f29bc42022-09-23 12:39:58403 FencedFrameStatus fenced_frame_status() const { return fenced_frame_status_; }
404
Kevin McNee43fe8292021-10-04 22:59:41405 blink::FrameOwnerElementType frame_owner_element_type() const {
Daniel Cheng9bd90f92021-04-23 20:49:45406 return frame_owner_element_type_;
danakjc492bf82020-09-09 20:02:44407 }
danakjc492bf82020-09-09 20:02:44408
Daniel Cheng6ac128172021-05-25 18:49:01409 blink::mojom::TreeScopeType tree_scope_type() const {
410 return tree_scope_type_;
411 }
412
arthursonzogni034bb9c2020-10-01 08:29:56413 // The initial popup URL for new window opened using:
414 // `window.open(initial_popup_url)`.
415 // An empty GURL otherwise.
416 //
417 // [WARNING] There is no guarantee the FrameTreeNode will ever host a
418 // document served from this URL. The FrameTreeNode always starts hosting the
419 // initial empty document and attempts a navigation toward this URL. However
420 // the navigation might be delayed, redirected and even cancelled.
421 void SetInitialPopupURL(const GURL& initial_popup_url);
422 const GURL& initial_popup_url() const { return initial_popup_url_; }
423
424 // The origin of the document that used window.open() to create this frame.
425 // Otherwise, an opaque Origin with a nonce different from all previously
426 // existing Origins.
427 void SetPopupCreatorOrigin(const url::Origin& popup_creator_origin);
428 const url::Origin& popup_creator_origin() const {
429 return popup_creator_origin_;
430 }
431
Harkiran Bolaria59290d62021-03-17 01:53:01432 // Sets the associated FrameTree for this node. The node can change FrameTrees
433 // when blink::features::Prerender2 is enabled, which allows a page loaded in
434 // the prerendered FrameTree to be used for a navigation in the primary frame
435 // tree.
436 void SetFrameTree(FrameTree& frame_tree);
437
Alexander Timin074cd182022-03-23 18:11:22438 using TraceProto = perfetto::protos::pbzero::FrameTreeNodeInfo;
Alexander Timinf785f342021-03-18 00:00:56439 // Write a representation of this object into a trace.
Alexander Timin074cd182022-03-23 18:11:22440 void WriteIntoTrace(perfetto::TracedProto<TraceProto> proto) const;
Alexander Timinf785f342021-03-18 00:00:56441
Carlos Caballero76711352021-03-24 17:38:21442 // Returns true the node is navigating, i.e. it has an associated
443 // NavigationRequest.
444 bool HasNavigation();
445
shivanigithubf3ddff52021-07-03 22:06:30446 // Fenced frames (meta-bug crbug.com/1111084):
shivanigithub4cd016a2021-09-20 21:10:30447 // Note that these two functions cannot be invoked from a FrameTree's or
448 // its root node's constructor since they require the frame tree and the
449 // root node to be completely constructed.
450 //
shivanigithubf3ddff52021-07-03 22:06:30451 // Returns false if fenced frames are disabled. Returns true if the feature is
452 // enabled and if |this| is a fenced frame. Returns false for
453 // iframes embedded in a fenced frame. To clarify: for the MPArch
454 // implementation this only returns true if |this| is the actual
455 // root node of the inner FrameTree and not the proxy FrameTreeNode in the
456 // outer FrameTree.
Dominic Farolino4bc10ee2021-08-31 00:37:36457 bool IsFencedFrameRoot() const;
shivanigithubf3ddff52021-07-03 22:06:30458
459 // Returns false if fenced frames are disabled. Returns true if the
460 // feature is enabled and if |this| or any of its ancestor nodes is a
461 // fenced frame.
462 bool IsInFencedFrameTree() const;
463
shivanigithub4cd016a2021-09-20 21:10:30464 // Returns a valid nonce if `IsInFencedFrameTree()` returns true for `this`.
Garrett Tanzer34cb92fe2022-09-28 17:50:54465 // Returns nullopt otherwise.
466 //
467 // Nonce used in the net::IsolationInfo and blink::StorageKey for a fenced
468 // frame and any iframes nested within it. Not set if this frame is not in a
469 // fenced frame's FrameTree. Note that this could be a field in FrameTree for
470 // the MPArch version but for the shadow DOM version we need to keep it here
471 // since the fenced frame root is not a main frame for the latter. The value
472 // of the nonce will be the same for all of the the iframes inside a fenced
473 // frame tree. If there is a nested fenced frame it will have a different
474 // nonce than its parent fenced frame. The nonce will stay the same across
475 // navigations initiated from the fenced frame tree because it is always used
476 // in conjunction with other fields of the keys and would be good to access
477 // the same storage across same-origin navigations. If the navigation is
478 // same-origin/site then the same network stack partition/storage will be
479 // reused and if it's cross-origin/site then other parts of the key will
480 // change and so, even with the same nonce, another partition will be used.
481 // But if the navigation is initiated from the embedder, the nonce will be
482 // reinitialized irrespective of same or cross origin such that there is no
483 // privacy leak via storage shared between two embedder initiated navigations.
484 // Note that this reinitialization is implemented for all embedder-initiated
485 // navigations in MPArch, but only urn:uuid navigations in ShadowDOM.
486 absl::optional<base::UnguessableToken> GetFencedFrameNonce();
shivanigithub4cd016a2021-09-20 21:10:30487
Garrett Tanzer34cb92fe2022-09-28 17:50:54488 // If applicable, initialize the default fenced frame properties. Right now,
489 // this means setting a new fenced frame nonce. See comment on
shivanigithub4cd016a2021-09-20 21:10:30490 // fenced_frame_nonce() for when it is set to a non-null value. Invoked
491 // by FrameTree::Init() or FrameTree::AddFrame().
Garrett Tanzer34cb92fe2022-09-28 17:50:54492 void SetFencedFramePropertiesIfNeeded();
shivanigithub4cd016a2021-09-20 21:10:30493
Garrett Tanzera42fdef2022-06-13 16:09:14494 // Returns the mode attribute set on the fenced frame root if this frame is
495 // in a fenced frame tree, otherwise returns `absl::nullopt`.
Nan Line376738a2022-03-25 22:05:41496 absl::optional<blink::mojom::FencedFrameMode> GetFencedFrameMode();
Nan Lin171fe9a2022-02-17 16:42:16497
Dave Tapuskac8de3b02021-12-03 21:51:01498 // Helper for GetParentOrOuterDocument/GetParentOrOuterDocumentOrEmbedder.
499 // Do not use directly.
500 RenderFrameHostImpl* GetParentOrOuterDocumentHelper(bool escape_guest_view);
501
Harkiran Bolariab4437fd2021-08-11 17:51:22502 // Sets the unique_name and name fields on replication_state_. To be used in
503 // prerender activation to make sure the FrameTreeNode replication state is
504 // correct after the RenderFrameHost is moved between FrameTreeNodes. The
505 // renderers should already have the correct value, so unlike
506 // FrameTreeNode::SetFrameName, we do not notify them here.
Harkiran Bolaria4eacb3a2021-12-13 20:03:47507 // TODO(https://crbug.com/1237091): Remove this once the BrowsingContextState
508 // is implemented to utilize the new path.
Harkiran Bolariab4437fd2021-08-11 17:51:22509 void set_frame_name_for_activation(const std::string& unique_name,
510 const std::string& name) {
Harkiran Bolaria0b3bdef02022-03-10 13:04:40511 current_frame_host()->browsing_context_state()->set_frame_name(unique_name,
512 name);
Harkiran Bolariab4437fd2021-08-11 17:51:22513 }
514
Nan Linaaf84f72021-12-02 22:31:56515 // Returns true if error page isolation is enabled.
516 bool IsErrorPageIsolationEnabled() const;
517
W. James MacLean81b8d01f2022-01-25 20:50:59518 // Functions to store and retrieve a frame's srcdoc value on this
519 // FrameTreeNode.
520 void SetSrcdocValue(const std::string& srcdoc_value);
521 const std::string& srcdoc_value() const { return srcdoc_value_; }
522
Garrett Tanzerc69f4642022-08-15 22:15:14523 void set_fenced_frame_properties(
Garrett Tanzer29de7112022-12-06 21:26:32524 const absl::optional<FencedFrameProperties>& fenced_frame_properties) {
Garrett Tanzer2975eeac2022-08-22 16:34:01525 // TODO(crbug.com/1262022): Reenable this DCHECK once ShadowDOM and
526 // loading urns in iframes (for FLEDGE OT) are gone.
527 // DCHECK_EQ(fenced_frame_status_,
528 // RenderFrameHostImpl::FencedFrameStatus::kFencedFrameRoot);
Garrett Tanzerc69f4642022-08-15 22:15:14529 fenced_frame_properties_ = fenced_frame_properties;
530 }
531
Garrett Tanzer34cb92fe2022-09-28 17:50:54532 // Return the fenced frame properties for this fenced frame tree (if any).
533 // That is to say, this function returns the `fenced_frame_properties_`
534 // variable attached to the fenced frame root FrameTreeNode, which may be
535 // either this node or an ancestor of it.
Garrett Tanzer29de7112022-12-06 21:26:32536 const absl::optional<FencedFrameProperties>& GetFencedFrameProperties();
Garrett Tanzerc69f4642022-08-15 22:15:14537
Yao Xiaoa2337ad2022-10-12 20:59:29538 // Return the number of fenced frame boundaries above this frame. The
539 // outermost main frame's frame tree has fenced frame depth 0, a topmost
540 // fenced frame tree embedded in the outermost main frame has fenced frame
541 // depth 1, etc.
542 size_t GetFencedFrameDepth();
543
544 // Traverse up from this node. Return all valid
545 // `node->fenced_frame_properties_->shared_storage_budget_metadata` (i.e. this
546 // node is subjected to the shared storage budgeting associated with those
547 // metadata). Every node that originates from sharedStorage.selectURL() will
548 // have an associated metadata. This indicates that the metadata can only
549 // possibly be associated with a fenced frame root, unless when
550 // `kAllowURNsInIframes` is enabled in which case they could be be associated
551 // with any node.
Garrett Tanzer29de7112022-12-06 21:26:32552 std::vector<const SharedStorageBudgetMetadata*>
Yao Xiao1ac702d2022-06-08 17:20:49553 FindSharedStorageBudgetMetadata();
554
Harkiran Bolariaebbe7702022-02-22 19:19:03555 // Accessor to BrowsingContextState for subframes only. Only main frame
556 // navigations can change BrowsingInstances and BrowsingContextStates,
557 // therefore for subframes associated BrowsingContextState never changes. This
558 // helper method makes this more explicit and guards against calling this on
559 // main frames (there an appropriate BrowsingContextState should be obtained
560 // from RenderFrameHost or from RenderFrameProxyHost as e.g. during
561 // cross-BrowsingInstance navigations multiple BrowsingContextStates exist in
562 // the same frame).
563 const scoped_refptr<BrowsingContextState>&
564 GetBrowsingContextStateForSubframe() const;
565
Arthur Hemerye4659282022-03-28 08:36:15566 // Clears the opener property of popups referencing this FrameTreeNode as
567 // their opener.
568 void ClearOpenerReferences();
569
Liam Bradyd2a41e152022-07-19 13:58:48570 // Calculates whether one of the ancestor frames or this frame has a CSPEE
571 // in place. This is eventually sent over to LocalFrame in the renderer where
572 // it will be used by HTMLFencedFrameElement::canLoadOpaqueURL for information
573 // it can't get on its own.
574 bool AncestorOrSelfHasCSPEE() const;
575
Arthur Sonzogni8e8eb1f2023-01-10 14:51:01576 // Reset every navigation in this frame, and its descendants. This is called
577 // after the <iframe> element has been removed, or after the document owning
578 // this frame has been navigated away.
579 //
580 // This takes into account:
581 // - Non-pending commit NavigationRequest owned by the FrameTreeNode
582 // - Pending commit NavigationRequest owned by the current RenderFrameHost
583 // - Speculative RenderFrameHost and its pending commit NavigationRequests.
584 void ResetAllNavigationsForFrameDetach();
585
Miyoung Shin7cf88b42022-11-07 13:22:30586 // RenderFrameHostOwner implementation:
Julie Jeongeun Kim07c077bd2022-12-05 08:40:31587 void DidStartLoading(bool should_show_loading_ui,
588 bool was_previously_loading) override;
589 void DidStopLoading() override;
Miyoung Shin7cf88b42022-11-07 13:22:30590 void RestartNavigationAsCrossDocument(
591 std::unique_ptr<NavigationRequest> navigation_request) override;
Miyoung Shin1504eb712022-12-07 10:32:18592 bool Reload() override;
Julie Jeongeun Kimc1b07c32022-11-11 10:26:32593 Navigator& GetCurrentNavigator() override;
Miyoung Shine16cd2262022-11-30 05:52:16594 RenderFrameHostManager& GetRenderFrameHostManager() override;
Miyoung Shin64fd1bea2023-01-04 04:22:08595 FrameTreeNode* GetOpener() const override;
Julie Jeongeun Kim2132b37f82022-11-23 08:30:46596 void SetFocusedFrame(SiteInstanceGroup* source) override;
Julie Jeongeun Kim0e242242022-11-30 10:45:09597 void DidChangeReferrerPolicy(
598 network::mojom::ReferrerPolicy referrer_policy) override;
Miyoung Shin7cf88b42022-11-07 13:22:30599
Miyoung Shin8a66ec022022-11-28 23:50:09600 // Updates the user activation state in the browser frame tree and in the
601 // frame trees in all renderer processes except the renderer for this node
602 // (which initiated the update). Returns |false| if the update tries to
603 // consume an already consumed/expired transient state, |true| otherwise. See
604 // the comment on `user_activation_state_` in RenderFrameHostImpl.
605 //
606 // The |notification_type| parameter is used for histograms, only for the case
607 // |update_state == kNotifyActivation|.
608 bool UpdateUserActivationState(
609 blink::mojom::UserActivationUpdateType update_type,
610 blink::mojom::UserActivationNotificationType notification_type) override;
611
Miyoung Shinff13ed22022-11-30 09:21:47612 std::unique_ptr<NavigationRequest>
613 CreateNavigationRequestForSynchronousRendererCommit(
614 RenderFrameHostImpl* render_frame_host,
615 bool is_same_document,
616 const GURL& url,
617 const url::Origin& origin,
W. James MacLean23e90a12022-12-21 04:38:21618 const absl::optional<GURL>& initiator_base_url,
Miyoung Shinff13ed22022-11-30 09:21:47619 const net::IsolationInfo& isolation_info_for_subresources,
620 blink::mojom::ReferrerPtr referrer,
621 const ui::PageTransition& transition,
622 bool should_replace_current_entry,
623 const std::string& method,
624 bool has_transient_activation,
625 bool is_overriding_user_agent,
626 const std::vector<GURL>& redirects,
627 const GURL& original_url,
628 std::unique_ptr<CrossOriginEmbedderPolicyReporter> coep_reporter,
629 std::unique_ptr<WebBundleNavigationInfo> web_bundle_navigation_info,
630 std::unique_ptr<SubresourceWebBundleNavigationInfo>
631 subresource_web_bundle_navigation_info,
632 int http_response_code) override;
Miyoung Shinb5561802022-12-01 08:21:35633 void CancelNavigation() override;
Miyoung Shinc9ff4812023-01-05 08:58:05634 bool Credentialless() const override;
Miyoung Shinff13ed22022-11-30 09:21:47635
danakjc492bf82020-09-09 20:02:44636 private:
Yuzu Saijo03dbf9b2022-07-22 04:29:45637 friend class CSPEmbeddedEnforcementUnitTest;
Charlie Hubb5943d2021-03-09 19:46:12638 FRIEND_TEST_ALL_PREFIXES(SitePerProcessPermissionsPolicyBrowserTest,
danakjc492bf82020-09-09 20:02:44639 ContainerPolicyDynamic);
Charlie Hubb5943d2021-03-09 19:46:12640 FRIEND_TEST_ALL_PREFIXES(SitePerProcessPermissionsPolicyBrowserTest,
danakjc492bf82020-09-09 20:02:44641 ContainerPolicySandboxDynamic);
Yuzu Saijo03dbf9b2022-07-22 04:29:45642 FRIEND_TEST_ALL_PREFIXES(NavigationRequestTest, StorageKeyToCommit);
Arthur Sonzogni64457592022-11-22 11:08:59643 FRIEND_TEST_ALL_PREFIXES(
644 NavigationRequestTest,
645 NavigationToCredentiallessDocumentNetworkIsolationInfo);
Yuzu Saijo03dbf9b2022-07-22 04:29:45646 FRIEND_TEST_ALL_PREFIXES(RenderFrameHostImplTest,
Arthur Sonzogni64457592022-11-22 11:08:59647 ChildOfCredentiallessIsCredentialless);
Yifan Luo86a79f42022-08-16 18:38:27648 FRIEND_TEST_ALL_PREFIXES(ContentPasswordManagerDriverTest,
Arthur Sonzogni64457592022-11-22 11:08:59649 PasswordAutofillDisabledOnCredentiallessIframe);
danakjc492bf82020-09-09 20:02:44650
Dominic Farolino8a2187b2021-12-24 20:44:21651 // Called by the destructor. When `this` is an outer dummy FrameTreeNode
652 // representing an inner FrameTree, this method destroys said inner FrameTree.
653 void DestroyInnerFrameTreeIfExists();
654
danakjc492bf82020-09-09 20:02:44655 class OpenerDestroyedObserver;
656
danakjc492bf82020-09-09 20:02:44657 // The |notification_type| parameter is used for histograms only.
658 bool NotifyUserActivation(
659 blink::mojom::UserActivationNotificationType notification_type);
660
661 bool ConsumeTransientUserActivation();
662
663 bool ClearUserActivation();
664
665 // Verify that the renderer process is allowed to set user activation on this
666 // frame by checking whether this frame's RenderWidgetHost had previously seen
667 // an input event that might lead to user activation. If user activation
668 // should be allowed, this returns true and also clears corresponding pending
669 // user activation state in the widget. Otherwise, this returns false.
670 bool VerifyUserActivation();
671
672 // The next available browser-global FrameTreeNode ID.
673 static int next_frame_tree_node_id_;
674
Arthur Sonzognif6785ec2022-12-05 10:11:50675 // The FrameTree owning |this|. It can change with Prerender2 during
676 // activation.
677 raw_ref<FrameTree> frame_tree_;
danakjc492bf82020-09-09 20:02:44678
danakjc492bf82020-09-09 20:02:44679 // A browser-global identifier for the frame in the page, which stays stable
680 // even if the frame does a cross-process navigation.
681 const int frame_tree_node_id_;
682
683 // The RenderFrameHost owning this FrameTreeNode, which cannot change for the
684 // life of this FrameTreeNode. |nullptr| if this node is the root.
Keishi Hattori0e45c022021-11-27 09:25:52685 const raw_ptr<RenderFrameHostImpl> parent_;
danakjc492bf82020-09-09 20:02:44686
danakjc492bf82020-09-09 20:02:44687 // The frame that opened this frame, if any. Will be set to null if the
688 // opener is closed, or if this frame disowns its opener by setting its
689 // window.opener to null.
Keishi Hattori0e45c022021-11-27 09:25:52690 raw_ptr<FrameTreeNode> opener_ = nullptr;
danakjc492bf82020-09-09 20:02:44691
692 // An observer that clears this node's |opener_| if the opener is destroyed.
693 // This observer is added to the |opener_|'s observer list when the |opener_|
694 // is set to a non-null node, and it is removed from that list when |opener_|
695 // changes or when this node is destroyed. It is also cleared if |opener_|
696 // is disowned.
697 std::unique_ptr<OpenerDestroyedObserver> opener_observer_;
698
Rakina Zata Amni3a48ae42022-05-05 03:39:56699 // Unlike `opener_`, the "original opener chain" doesn't reflect
700 // window.opener, which can be suppressed or updated. The "original opener"
701 // is the main frame of the actual opener of this frame. This traces the all
702 // the way back, so if the original opener was closed (deleted or severed due
703 // to COOP), but _it_ had an original opener, this will return the original
704 // opener's original opener, etc. So this value will always be set as long as
705 // there is at least one live frame in the chain whose connection is not
706 // severed due to COOP.
707 raw_ptr<FrameTreeNode> first_live_main_frame_in_original_opener_chain_ =
708 nullptr;
danakjc492bf82020-09-09 20:02:44709
Wolfgang Beyerd8809db2020-09-30 15:29:39710 // The devtools frame token of the frame which opened this frame. This is
711 // not cleared even if the opener is destroyed or disowns the frame.
Anton Bikineevf62d1bf2021-05-15 17:56:07712 absl::optional<base::UnguessableToken> opener_devtools_frame_token_;
Wolfgang Beyerd8809db2020-09-30 15:29:39713
Rakina Zata Amni3a48ae42022-05-05 03:39:56714 // An observer that updates this node's
715 // |first_live_main_frame_in_original_opener_chain_| to the next original
716 // opener in the chain if the original opener is destroyed.
danakjc492bf82020-09-09 20:02:44717 std::unique_ptr<OpenerDestroyedObserver> original_opener_observer_;
718
arthursonzogni034bb9c2020-10-01 08:29:56719 // When created by an opener, the URL specified in window.open(url)
720 // Please refer to {Get,Set}InitialPopupURL() documentation.
721 GURL initial_popup_url_;
722
723 // When created using window.open, the origin of the creator.
724 // Please refer to {Get,Set}PopupCreatorOrigin() documentation.
725 url::Origin popup_creator_origin_;
726
W. James MacLean81b8d01f2022-01-25 20:50:59727 // If the url from the the last BeginNavigation is about:srcdoc, this value
728 // stores the srcdoc_attribute's value for re-use in history navigations.
729 std::string srcdoc_value_;
730
danakjc492bf82020-09-09 20:02:44731 // Whether the frame's owner element in the parent document is collapsed.
arthursonzogni9816b9192021-03-29 16:09:19732 bool is_collapsed_ = false;
danakjc492bf82020-09-09 20:02:44733
Daniel Cheng6ac128172021-05-25 18:49:01734 // The type of frame owner for this frame. This is only relevant for non-main
735 // frames.
Kevin McNee43fe8292021-10-04 22:59:41736 const blink::FrameOwnerElementType frame_owner_element_type_ =
737 blink::FrameOwnerElementType::kNone;
Daniel Cheng9bd90f92021-04-23 20:49:45738
Daniel Cheng6ac128172021-05-25 18:49:01739 // The tree scope type of frame owner element, i.e. whether the element is in
740 // the document tree (https://dom.spec.whatwg.org/#document-trees) or the
741 // shadow tree (https://dom.spec.whatwg.org/#shadow-trees). This is only
742 // relevant for non-main frames.
743 const blink::mojom::TreeScopeType tree_scope_type_ =
744 blink::mojom::TreeScopeType::kDocument;
745
danakjc492bf82020-09-09 20:02:44746 // Track the pending sandbox flags and container policy for this frame. When a
747 // parent frame dynamically updates 'sandbox', 'allow', 'allowfullscreen',
748 // 'allowpaymentrequest' or 'src' attributes, the updated policy for the frame
Harkiran Bolaria4eacb3a2021-12-13 20:03:47749 // is stored here, and transferred into
750 // render_manager_.current_replication_state().frame_policy when they take
751 // effect on the next frame navigation.
danakjc492bf82020-09-09 20:02:44752 blink::FramePolicy pending_frame_policy_;
753
754 // Whether the frame was created by javascript. This is useful to prune
755 // history entries when the frame is removed (because frames created by
756 // scripts are never recreated with the same unique name - see
757 // https://crbug.com/500260).
arthursonzogni9816b9192021-03-29 16:09:19758 const bool is_created_by_script_;
danakjc492bf82020-09-09 20:02:44759
danakjc492bf82020-09-09 20:02:44760 // Tracks the scrolling and margin properties for this frame. These
761 // properties affect the child renderer but are stored on its parent's
762 // frame element. When this frame's parent dynamically updates these
763 // properties, we update them here too.
764 //
765 // Note that dynamic updates only take effect on the next frame navigation.
766 blink::mojom::FrameOwnerProperties frame_owner_properties_;
767
Yuzu Saijo03dbf9b2022-07-22 04:29:45768 // Contains the tracked HTML attributes of the corresponding iframe element,
769 // such as 'id' and 'src'.
770 blink::mojom::IframeAttributesPtr attributes_;
Antonio Sartori5abc8de2021-07-13 08:42:47771
danakjc492bf82020-09-09 20:02:44772 // Owns an ongoing NavigationRequest until it is ready to commit. It will then
773 // be reset and a RenderFrameHost will be responsible for the navigation.
774 std::unique_ptr<NavigationRequest> navigation_request_;
775
776 // List of objects observing this FrameTreeNode.
777 base::ObserverList<Observer>::Unchecked observers_;
778
779 base::TimeTicks last_focus_time_;
780
arthursonzogni9816b9192021-03-29 16:09:19781 bool was_discarded_ = false;
danakjc492bf82020-09-09 20:02:44782
Abhijeet Kandalkar3f29bc42022-09-23 12:39:58783 const FencedFrameStatus fenced_frame_status_ =
784 FencedFrameStatus::kNotNestedInFencedFrame;
Harkiran Bolaria16f2c48d2022-04-22 12:39:57785
Garrett Tanzerc69f4642022-08-15 22:15:14786 // If this is a fenced frame resulting from a urn:uuid navigation, this
787 // contains all the metadata specifying the resulting context.
Garrett Tanzer34cb92fe2022-09-28 17:50:54788 // TODO(crbug.com/1262022): Move this into the FrameTree once ShadowDOM
789 // and urn iframes are gone.
Garrett Tanzer29de7112022-12-06 21:26:32790 absl::optional<FencedFrameProperties> fenced_frame_properties_;
Garrett Tanzerc69f4642022-08-15 22:15:14791
Lukasz Anforowicz147141962020-12-16 18:03:24792 // Manages creation and swapping of RenderFrameHosts for this frame.
793 //
794 // This field needs to be declared last, because destruction of
795 // RenderFrameHostManager may call arbitrary callbacks (e.g. via
796 // WebContentsObserver::DidFinishNavigation fired after RenderFrameHostManager
797 // destructs a RenderFrameHostImpl and its NavigationRequest). Such callbacks
798 // may try to use FrameTreeNode's fields above - this would be an undefined
799 // behavior if the fields (even trivially-destructible ones) were destructed
800 // before the RenderFrameHostManager's destructor runs. See also
801 // https://crbug.com/1157988.
802 RenderFrameHostManager render_manager_;
danakjc492bf82020-09-09 20:02:44803};
804
805} // namespace content
806
807#endif // CONTENT_BROWSER_RENDERER_HOST_FRAME_TREE_NODE_H_