blob: 8f2ea0891e9d4da336af3724b9b37a0cebb62c9d [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 Saijodc870f92023-01-20 03:39:11278 const absl::optional<std::string> html_id() const { return attributes_->id; }
Yuzu Saijo03dbf9b2022-07-22 04:29:45279 // 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.
Yuzu Saijodc870f92023-01-20 03:39:11282 const absl::optional<std::string> html_name() const {
283 return attributes_->name;
284 }
285 const absl::optional<std::string> html_src() const {
286 return attributes_->src;
287 }
danakjc492bf82020-09-09 20:02:44288
Yuzu Saijo03dbf9b2022-07-22 04:29:45289 void SetAttributes(blink::mojom::IframeAttributesPtr attributes);
Antonio Sartori5abc8de2021-07-13 08:42:47290
danakjc492bf82020-09-09 20:02:44291 bool HasSameOrigin(const FrameTreeNode& node) const {
Harkiran Bolaria4eacb3a2021-12-13 20:03:47292 return render_manager_.current_replication_state().origin.IsSameOriginWith(
293 node.current_replication_state().origin);
danakjc492bf82020-09-09 20:02:44294 }
295
Gyuyoung Kimc16e52e92021-03-19 02:45:37296 const blink::mojom::FrameReplicationState& current_replication_state() const {
Harkiran Bolaria4eacb3a2021-12-13 20:03:47297 return render_manager_.current_replication_state();
danakjc492bf82020-09-09 20:02:44298 }
299
300 RenderFrameHostImpl* current_frame_host() const {
301 return render_manager_.current_frame_host();
302 }
303
danakjc492bf82020-09-09 20:02:44304 // Returns true if this node is in a loading state.
305 bool IsLoading() const;
306
Alex Moshchuk9b0fd822020-10-26 23:08:15307 // Returns true if this node has a cross-document navigation in progress.
308 bool HasPendingCrossDocumentNavigation() const;
309
danakjc492bf82020-09-09 20:02:44310 NavigationRequest* navigation_request() { return navigation_request_.get(); }
311
312 // Transfers the ownership of the NavigationRequest to |render_frame_host|.
313 // From ReadyToCommit to DidCommit, the NavigationRequest is owned by the
314 // RenderFrameHost that is committing the navigation.
315 void TransferNavigationRequestOwnership(
316 RenderFrameHostImpl* render_frame_host);
317
318 // Takes ownership of |navigation_request| and makes it the current
319 // NavigationRequest of this frame. This corresponds to the start of a new
320 // navigation. If there was an ongoing navigation request before calling this
321 // function, it is canceled. |navigation_request| should not be null.
Charlie Reis09952ee2022-12-08 16:35:07322 void TakeNavigationRequest(
danakjc492bf82020-09-09 20:02:44323 std::unique_ptr<NavigationRequest> navigation_request);
324
Rakina Zata Amnif8f2bb62022-11-23 05:54:32325 // Resets the navigation request owned by `this` (which shouldn't have reached
326 // the "pending commit" stage yet) and any state created by it, including the
Rakina Zata Amni33175cb92022-11-24 02:46:03327 // speculative RenderFrameHost (if there are no other navigations associated
328 // with it). Note that this does not affect navigations that have reached the
329 // "pending commit" stage, which are owned by their corresponding
330 // RenderFrameHosts instead.
Daniel Cheng390e2a72022-09-28 06:07:53331 void ResetNavigationRequest(NavigationDiscardReason reason);
332
Rakina Zata Amnif8f2bb62022-11-23 05:54:32333 // Similar to `ResetNavigationRequest()`, but keeps the state created by the
Daniel Cheng390e2a72022-09-28 06:07:53334 // NavigationRequest (e.g. speculative RenderFrameHost, loading state).
335 void ResetNavigationRequestButKeepState();
danakjc492bf82020-09-09 20:02:44336
danakjc492bf82020-09-09 20:02:44337 // The load progress for a RenderFrameHost in this node was updated to
338 // |load_progress|. This will notify the FrameTree which will in turn notify
339 // the WebContents.
340 void DidChangeLoadProgress(double load_progress);
341
342 // Called when the user directed the page to stop loading. Stops all loads
343 // happening in the FrameTreeNode. This method should be used with
344 // FrameTree::ForEach to stop all loads in the entire FrameTree.
345 bool StopLoading();
346
347 // Returns the time this frame was last focused.
348 base::TimeTicks last_focus_time() const { return last_focus_time_; }
349
350 // Called when this node becomes focused. Updates the node's last focused
351 // time and notifies observers.
352 void DidFocus();
353
354 // Called when the user closed the modal dialogue for BeforeUnload and
355 // cancelled the navigation. This should stop any load happening in the
356 // FrameTreeNode.
357 void BeforeUnloadCanceled();
358
danakjc492bf82020-09-09 20:02:44359 // Returns the sandbox flags currently in effect for this frame. This includes
360 // flags inherited from parent frames, the currently active flags from the
361 // <iframe> element hosting this frame, as well as any flags set from a
362 // Content-Security-Policy HTTP header. This does not include flags that have
363 // have been updated in an <iframe> element but have not taken effect yet; use
364 // pending_frame_policy() for those. To see the flags which will take effect
365 // on navigation (which does not include the CSP-set flags), use
366 // effective_frame_policy().
367 network::mojom::WebSandboxFlags active_sandbox_flags() const {
Harkiran Bolaria4eacb3a2021-12-13 20:03:47368 return render_manager_.current_replication_state().active_sandbox_flags;
danakjc492bf82020-09-09 20:02:44369 }
370
danakjc492bf82020-09-09 20:02:44371 // Returns whether the frame received a user gesture on a previous navigation
372 // on the same eTLD+1.
373 bool has_received_user_gesture_before_nav() const {
Harkiran Bolaria4eacb3a2021-12-13 20:03:47374 return render_manager_.current_replication_state()
375 .has_received_user_gesture_before_nav;
danakjc492bf82020-09-09 20:02:44376 }
377
378 // When a tab is discarded, WebContents sets was_discarded on its
379 // root FrameTreeNode.
380 // In addition, when a child frame is created, this bit is passed on from
381 // parent to child.
382 // When a navigation request is created, was_discarded is passed on to the
383 // request and reset to false in FrameTreeNode.
384 void set_was_discarded() { was_discarded_ = true; }
385 bool was_discarded() const { return was_discarded_; }
386
Miyoung Shin8a66ec022022-11-28 23:50:09387 // Deprecated. Use directly HasStickyUserActivation in RFHI.
danakjc492bf82020-09-09 20:02:44388 // Returns the sticky bit of the User Activation v2 state of the
389 // |FrameTreeNode|.
390 bool HasStickyUserActivation() const {
Miyoung Shin8a66ec022022-11-28 23:50:09391 return current_frame_host()->HasStickyUserActivation();
danakjc492bf82020-09-09 20:02:44392 }
393
Miyoung Shin8a66ec022022-11-28 23:50:09394 // Deprecated. Use directly HasStickyUserActivation in RFHI.
danakjc492bf82020-09-09 20:02:44395 // Returns the transient bit of the User Activation v2 state of the
396 // |FrameTreeNode|.
397 bool HasTransientUserActivation() {
Miyoung Shin8a66ec022022-11-28 23:50:09398 return current_frame_host()->HasTransientUserActivation();
danakjc492bf82020-09-09 20:02:44399 }
400
401 // Remove history entries for all frames created by script in this frame's
402 // subtree. If a frame created by a script is removed, then its history entry
403 // will never be reused - this saves memory.
404 void PruneChildFrameNavigationEntries(NavigationEntryImpl* entry);
405
Abhijeet Kandalkarb43affa72022-09-27 16:48:01406 using FencedFrameStatus = RenderFrameHostImpl::FencedFrameStatus;
Abhijeet Kandalkar3f29bc42022-09-23 12:39:58407 FencedFrameStatus fenced_frame_status() const { return fenced_frame_status_; }
408
Kevin McNee43fe8292021-10-04 22:59:41409 blink::FrameOwnerElementType frame_owner_element_type() const {
Daniel Cheng9bd90f92021-04-23 20:49:45410 return frame_owner_element_type_;
danakjc492bf82020-09-09 20:02:44411 }
danakjc492bf82020-09-09 20:02:44412
Daniel Cheng6ac128172021-05-25 18:49:01413 blink::mojom::TreeScopeType tree_scope_type() const {
414 return tree_scope_type_;
415 }
416
arthursonzogni034bb9c2020-10-01 08:29:56417 // The initial popup URL for new window opened using:
418 // `window.open(initial_popup_url)`.
419 // An empty GURL otherwise.
420 //
421 // [WARNING] There is no guarantee the FrameTreeNode will ever host a
422 // document served from this URL. The FrameTreeNode always starts hosting the
423 // initial empty document and attempts a navigation toward this URL. However
424 // the navigation might be delayed, redirected and even cancelled.
425 void SetInitialPopupURL(const GURL& initial_popup_url);
426 const GURL& initial_popup_url() const { return initial_popup_url_; }
427
428 // The origin of the document that used window.open() to create this frame.
429 // Otherwise, an opaque Origin with a nonce different from all previously
430 // existing Origins.
431 void SetPopupCreatorOrigin(const url::Origin& popup_creator_origin);
432 const url::Origin& popup_creator_origin() const {
433 return popup_creator_origin_;
434 }
435
Harkiran Bolaria59290d62021-03-17 01:53:01436 // Sets the associated FrameTree for this node. The node can change FrameTrees
437 // when blink::features::Prerender2 is enabled, which allows a page loaded in
438 // the prerendered FrameTree to be used for a navigation in the primary frame
439 // tree.
440 void SetFrameTree(FrameTree& frame_tree);
441
Alexander Timin074cd182022-03-23 18:11:22442 using TraceProto = perfetto::protos::pbzero::FrameTreeNodeInfo;
Alexander Timinf785f342021-03-18 00:00:56443 // Write a representation of this object into a trace.
Alexander Timin074cd182022-03-23 18:11:22444 void WriteIntoTrace(perfetto::TracedProto<TraceProto> proto) const;
Alexander Timinf785f342021-03-18 00:00:56445
Carlos Caballero76711352021-03-24 17:38:21446 // Returns true the node is navigating, i.e. it has an associated
447 // NavigationRequest.
448 bool HasNavigation();
449
shivanigithubf3ddff52021-07-03 22:06:30450 // Fenced frames (meta-bug crbug.com/1111084):
shivanigithub4cd016a2021-09-20 21:10:30451 // Note that these two functions cannot be invoked from a FrameTree's or
452 // its root node's constructor since they require the frame tree and the
453 // root node to be completely constructed.
454 //
shivanigithubf3ddff52021-07-03 22:06:30455 // Returns false if fenced frames are disabled. Returns true if the feature is
456 // enabled and if |this| is a fenced frame. Returns false for
457 // iframes embedded in a fenced frame. To clarify: for the MPArch
458 // implementation this only returns true if |this| is the actual
459 // root node of the inner FrameTree and not the proxy FrameTreeNode in the
460 // outer FrameTree.
Dominic Farolino4bc10ee2021-08-31 00:37:36461 bool IsFencedFrameRoot() const;
shivanigithubf3ddff52021-07-03 22:06:30462
463 // Returns false if fenced frames are disabled. Returns true if the
464 // feature is enabled and if |this| or any of its ancestor nodes is a
465 // fenced frame.
466 bool IsInFencedFrameTree() const;
467
shivanigithub4cd016a2021-09-20 21:10:30468 // Returns a valid nonce if `IsInFencedFrameTree()` returns true for `this`.
Garrett Tanzer34cb92fe2022-09-28 17:50:54469 // Returns nullopt otherwise.
470 //
471 // Nonce used in the net::IsolationInfo and blink::StorageKey for a fenced
472 // frame and any iframes nested within it. Not set if this frame is not in a
473 // fenced frame's FrameTree. Note that this could be a field in FrameTree for
474 // the MPArch version but for the shadow DOM version we need to keep it here
475 // since the fenced frame root is not a main frame for the latter. The value
476 // of the nonce will be the same for all of the the iframes inside a fenced
477 // frame tree. If there is a nested fenced frame it will have a different
478 // nonce than its parent fenced frame. The nonce will stay the same across
479 // navigations initiated from the fenced frame tree because it is always used
480 // in conjunction with other fields of the keys and would be good to access
481 // the same storage across same-origin navigations. If the navigation is
482 // same-origin/site then the same network stack partition/storage will be
483 // reused and if it's cross-origin/site then other parts of the key will
484 // change and so, even with the same nonce, another partition will be used.
485 // But if the navigation is initiated from the embedder, the nonce will be
486 // reinitialized irrespective of same or cross origin such that there is no
487 // privacy leak via storage shared between two embedder initiated navigations.
488 // Note that this reinitialization is implemented for all embedder-initiated
489 // navigations in MPArch, but only urn:uuid navigations in ShadowDOM.
490 absl::optional<base::UnguessableToken> GetFencedFrameNonce();
shivanigithub4cd016a2021-09-20 21:10:30491
Garrett Tanzer34cb92fe2022-09-28 17:50:54492 // If applicable, initialize the default fenced frame properties. Right now,
493 // this means setting a new fenced frame nonce. See comment on
shivanigithub4cd016a2021-09-20 21:10:30494 // fenced_frame_nonce() for when it is set to a non-null value. Invoked
495 // by FrameTree::Init() or FrameTree::AddFrame().
Garrett Tanzer34cb92fe2022-09-28 17:50:54496 void SetFencedFramePropertiesIfNeeded();
shivanigithub4cd016a2021-09-20 21:10:30497
Garrett Tanzera42fdef2022-06-13 16:09:14498 // Returns the mode attribute set on the fenced frame root if this frame is
499 // in a fenced frame tree, otherwise returns `absl::nullopt`.
Nan Line376738a2022-03-25 22:05:41500 absl::optional<blink::mojom::FencedFrameMode> GetFencedFrameMode();
Nan Lin171fe9a2022-02-17 16:42:16501
Dave Tapuskac8de3b02021-12-03 21:51:01502 // Helper for GetParentOrOuterDocument/GetParentOrOuterDocumentOrEmbedder.
503 // Do not use directly.
504 RenderFrameHostImpl* GetParentOrOuterDocumentHelper(bool escape_guest_view);
505
Harkiran Bolariab4437fd2021-08-11 17:51:22506 // Sets the unique_name and name fields on replication_state_. To be used in
507 // prerender activation to make sure the FrameTreeNode replication state is
508 // correct after the RenderFrameHost is moved between FrameTreeNodes. The
509 // renderers should already have the correct value, so unlike
510 // FrameTreeNode::SetFrameName, we do not notify them here.
Harkiran Bolaria4eacb3a2021-12-13 20:03:47511 // TODO(https://crbug.com/1237091): Remove this once the BrowsingContextState
512 // is implemented to utilize the new path.
Harkiran Bolariab4437fd2021-08-11 17:51:22513 void set_frame_name_for_activation(const std::string& unique_name,
514 const std::string& name) {
Harkiran Bolaria0b3bdef02022-03-10 13:04:40515 current_frame_host()->browsing_context_state()->set_frame_name(unique_name,
516 name);
Harkiran Bolariab4437fd2021-08-11 17:51:22517 }
518
Nan Linaaf84f72021-12-02 22:31:56519 // Returns true if error page isolation is enabled.
520 bool IsErrorPageIsolationEnabled() const;
521
W. James MacLean81b8d01f2022-01-25 20:50:59522 // Functions to store and retrieve a frame's srcdoc value on this
523 // FrameTreeNode.
524 void SetSrcdocValue(const std::string& srcdoc_value);
525 const std::string& srcdoc_value() const { return srcdoc_value_; }
526
Garrett Tanzerc69f4642022-08-15 22:15:14527 void set_fenced_frame_properties(
Garrett Tanzer29de7112022-12-06 21:26:32528 const absl::optional<FencedFrameProperties>& fenced_frame_properties) {
Garrett Tanzer2975eeac2022-08-22 16:34:01529 // TODO(crbug.com/1262022): Reenable this DCHECK once ShadowDOM and
530 // loading urns in iframes (for FLEDGE OT) are gone.
531 // DCHECK_EQ(fenced_frame_status_,
532 // RenderFrameHostImpl::FencedFrameStatus::kFencedFrameRoot);
Garrett Tanzerc69f4642022-08-15 22:15:14533 fenced_frame_properties_ = fenced_frame_properties;
534 }
535
Garrett Tanzer34cb92fe2022-09-28 17:50:54536 // Return the fenced frame properties for this fenced frame tree (if any).
537 // That is to say, this function returns the `fenced_frame_properties_`
538 // variable attached to the fenced frame root FrameTreeNode, which may be
539 // either this node or an ancestor of it.
Garrett Tanzer29de7112022-12-06 21:26:32540 const absl::optional<FencedFrameProperties>& GetFencedFrameProperties();
Garrett Tanzerc69f4642022-08-15 22:15:14541
Liam Brady6da2cc9e2023-01-30 17:09:43542 // Called from the currently active document via the
543 // `Fence.setReportEventDataForAutomaticBeacons` JS API.
544 void SetFencedFrameAutomaticBeaconReportEventData(
545 const std::string& event_data,
546 const std::vector<blink::FencedFrame::ReportingDestination>& destination)
547 override;
548
Yao Xiaoa2337ad2022-10-12 20:59:29549 // Return the number of fenced frame boundaries above this frame. The
550 // outermost main frame's frame tree has fenced frame depth 0, a topmost
551 // fenced frame tree embedded in the outermost main frame has fenced frame
552 // depth 1, etc.
553 size_t GetFencedFrameDepth();
554
555 // Traverse up from this node. Return all valid
556 // `node->fenced_frame_properties_->shared_storage_budget_metadata` (i.e. this
557 // node is subjected to the shared storage budgeting associated with those
558 // metadata). Every node that originates from sharedStorage.selectURL() will
559 // have an associated metadata. This indicates that the metadata can only
560 // possibly be associated with a fenced frame root, unless when
561 // `kAllowURNsInIframes` is enabled in which case they could be be associated
562 // with any node.
Garrett Tanzer29de7112022-12-06 21:26:32563 std::vector<const SharedStorageBudgetMetadata*>
Yao Xiao1ac702d2022-06-08 17:20:49564 FindSharedStorageBudgetMetadata();
565
Harkiran Bolariaebbe7702022-02-22 19:19:03566 // Accessor to BrowsingContextState for subframes only. Only main frame
567 // navigations can change BrowsingInstances and BrowsingContextStates,
568 // therefore for subframes associated BrowsingContextState never changes. This
569 // helper method makes this more explicit and guards against calling this on
570 // main frames (there an appropriate BrowsingContextState should be obtained
571 // from RenderFrameHost or from RenderFrameProxyHost as e.g. during
572 // cross-BrowsingInstance navigations multiple BrowsingContextStates exist in
573 // the same frame).
574 const scoped_refptr<BrowsingContextState>&
575 GetBrowsingContextStateForSubframe() const;
576
Arthur Hemerye4659282022-03-28 08:36:15577 // Clears the opener property of popups referencing this FrameTreeNode as
578 // their opener.
579 void ClearOpenerReferences();
580
Liam Bradyd2a41e152022-07-19 13:58:48581 // Calculates whether one of the ancestor frames or this frame has a CSPEE
582 // in place. This is eventually sent over to LocalFrame in the renderer where
583 // it will be used by HTMLFencedFrameElement::canLoadOpaqueURL for information
584 // it can't get on its own.
585 bool AncestorOrSelfHasCSPEE() const;
586
Arthur Sonzogni8e8eb1f2023-01-10 14:51:01587 // Reset every navigation in this frame, and its descendants. This is called
588 // after the <iframe> element has been removed, or after the document owning
589 // this frame has been navigated away.
590 //
591 // This takes into account:
592 // - Non-pending commit NavigationRequest owned by the FrameTreeNode
593 // - Pending commit NavigationRequest owned by the current RenderFrameHost
594 // - Speculative RenderFrameHost and its pending commit NavigationRequests.
595 void ResetAllNavigationsForFrameDetach();
596
Miyoung Shin7cf88b42022-11-07 13:22:30597 // RenderFrameHostOwner implementation:
Julie Jeongeun Kim07c077bd2022-12-05 08:40:31598 void DidStartLoading(bool should_show_loading_ui,
599 bool was_previously_loading) override;
600 void DidStopLoading() override;
Miyoung Shin7cf88b42022-11-07 13:22:30601 void RestartNavigationAsCrossDocument(
602 std::unique_ptr<NavigationRequest> navigation_request) override;
Miyoung Shin1504eb712022-12-07 10:32:18603 bool Reload() override;
Julie Jeongeun Kimc1b07c32022-11-11 10:26:32604 Navigator& GetCurrentNavigator() override;
Miyoung Shine16cd2262022-11-30 05:52:16605 RenderFrameHostManager& GetRenderFrameHostManager() override;
Miyoung Shin64fd1bea2023-01-04 04:22:08606 FrameTreeNode* GetOpener() const override;
Julie Jeongeun Kim2132b37f82022-11-23 08:30:46607 void SetFocusedFrame(SiteInstanceGroup* source) override;
Julie Jeongeun Kim0e242242022-11-30 10:45:09608 void DidChangeReferrerPolicy(
609 network::mojom::ReferrerPolicy referrer_policy) override;
Miyoung Shin7cf88b42022-11-07 13:22:30610
Miyoung Shin8a66ec022022-11-28 23:50:09611 // Updates the user activation state in the browser frame tree and in the
612 // frame trees in all renderer processes except the renderer for this node
613 // (which initiated the update). Returns |false| if the update tries to
614 // consume an already consumed/expired transient state, |true| otherwise. See
615 // the comment on `user_activation_state_` in RenderFrameHostImpl.
616 //
617 // The |notification_type| parameter is used for histograms, only for the case
618 // |update_state == kNotifyActivation|.
619 bool UpdateUserActivationState(
620 blink::mojom::UserActivationUpdateType update_type,
621 blink::mojom::UserActivationNotificationType notification_type) override;
622
Miyoung Shinff13ed22022-11-30 09:21:47623 std::unique_ptr<NavigationRequest>
624 CreateNavigationRequestForSynchronousRendererCommit(
625 RenderFrameHostImpl* render_frame_host,
626 bool is_same_document,
627 const GURL& url,
628 const url::Origin& origin,
W. James MacLean23e90a12022-12-21 04:38:21629 const absl::optional<GURL>& initiator_base_url,
Miyoung Shinff13ed22022-11-30 09:21:47630 const net::IsolationInfo& isolation_info_for_subresources,
631 blink::mojom::ReferrerPtr referrer,
632 const ui::PageTransition& transition,
633 bool should_replace_current_entry,
634 const std::string& method,
635 bool has_transient_activation,
636 bool is_overriding_user_agent,
637 const std::vector<GURL>& redirects,
638 const GURL& original_url,
639 std::unique_ptr<CrossOriginEmbedderPolicyReporter> coep_reporter,
640 std::unique_ptr<WebBundleNavigationInfo> web_bundle_navigation_info,
641 std::unique_ptr<SubresourceWebBundleNavigationInfo>
642 subresource_web_bundle_navigation_info,
643 int http_response_code) override;
Miyoung Shinb5561802022-12-01 08:21:35644 void CancelNavigation() override;
Miyoung Shinc9ff4812023-01-05 08:58:05645 bool Credentialless() const override;
Miyoung Shinff13ed22022-11-30 09:21:47646
danakjc492bf82020-09-09 20:02:44647 private:
Yuzu Saijo03dbf9b2022-07-22 04:29:45648 friend class CSPEmbeddedEnforcementUnitTest;
Charlie Hubb5943d2021-03-09 19:46:12649 FRIEND_TEST_ALL_PREFIXES(SitePerProcessPermissionsPolicyBrowserTest,
danakjc492bf82020-09-09 20:02:44650 ContainerPolicyDynamic);
Charlie Hubb5943d2021-03-09 19:46:12651 FRIEND_TEST_ALL_PREFIXES(SitePerProcessPermissionsPolicyBrowserTest,
danakjc492bf82020-09-09 20:02:44652 ContainerPolicySandboxDynamic);
Yuzu Saijo03dbf9b2022-07-22 04:29:45653 FRIEND_TEST_ALL_PREFIXES(NavigationRequestTest, StorageKeyToCommit);
Arthur Sonzogni64457592022-11-22 11:08:59654 FRIEND_TEST_ALL_PREFIXES(
655 NavigationRequestTest,
656 NavigationToCredentiallessDocumentNetworkIsolationInfo);
Yuzu Saijo03dbf9b2022-07-22 04:29:45657 FRIEND_TEST_ALL_PREFIXES(RenderFrameHostImplTest,
Arthur Sonzogni64457592022-11-22 11:08:59658 ChildOfCredentiallessIsCredentialless);
Yifan Luo86a79f42022-08-16 18:38:27659 FRIEND_TEST_ALL_PREFIXES(ContentPasswordManagerDriverTest,
Arthur Sonzogni64457592022-11-22 11:08:59660 PasswordAutofillDisabledOnCredentiallessIframe);
danakjc492bf82020-09-09 20:02:44661
Dominic Farolino8a2187b2021-12-24 20:44:21662 // Called by the destructor. When `this` is an outer dummy FrameTreeNode
663 // representing an inner FrameTree, this method destroys said inner FrameTree.
664 void DestroyInnerFrameTreeIfExists();
665
danakjc492bf82020-09-09 20:02:44666 class OpenerDestroyedObserver;
667
danakjc492bf82020-09-09 20:02:44668 // The |notification_type| parameter is used for histograms only.
669 bool NotifyUserActivation(
670 blink::mojom::UserActivationNotificationType notification_type);
671
672 bool ConsumeTransientUserActivation();
673
674 bool ClearUserActivation();
675
676 // Verify that the renderer process is allowed to set user activation on this
677 // frame by checking whether this frame's RenderWidgetHost had previously seen
678 // an input event that might lead to user activation. If user activation
679 // should be allowed, this returns true and also clears corresponding pending
680 // user activation state in the widget. Otherwise, this returns false.
681 bool VerifyUserActivation();
682
Liam Brady6da2cc9e2023-01-30 17:09:43683 absl::optional<FencedFrameProperties>& GetFencedFramePropertiesForEditing();
684
danakjc492bf82020-09-09 20:02:44685 // The next available browser-global FrameTreeNode ID.
686 static int next_frame_tree_node_id_;
687
Arthur Sonzognif6785ec2022-12-05 10:11:50688 // The FrameTree owning |this|. It can change with Prerender2 during
689 // activation.
690 raw_ref<FrameTree> frame_tree_;
danakjc492bf82020-09-09 20:02:44691
danakjc492bf82020-09-09 20:02:44692 // A browser-global identifier for the frame in the page, which stays stable
693 // even if the frame does a cross-process navigation.
694 const int frame_tree_node_id_;
695
696 // The RenderFrameHost owning this FrameTreeNode, which cannot change for the
697 // life of this FrameTreeNode. |nullptr| if this node is the root.
Keishi Hattori0e45c022021-11-27 09:25:52698 const raw_ptr<RenderFrameHostImpl> parent_;
danakjc492bf82020-09-09 20:02:44699
danakjc492bf82020-09-09 20:02:44700 // The frame that opened this frame, if any. Will be set to null if the
701 // opener is closed, or if this frame disowns its opener by setting its
702 // window.opener to null.
Keishi Hattori0e45c022021-11-27 09:25:52703 raw_ptr<FrameTreeNode> opener_ = nullptr;
danakjc492bf82020-09-09 20:02:44704
705 // An observer that clears this node's |opener_| if the opener is destroyed.
706 // This observer is added to the |opener_|'s observer list when the |opener_|
707 // is set to a non-null node, and it is removed from that list when |opener_|
708 // changes or when this node is destroyed. It is also cleared if |opener_|
709 // is disowned.
710 std::unique_ptr<OpenerDestroyedObserver> opener_observer_;
711
Rakina Zata Amni3a48ae42022-05-05 03:39:56712 // Unlike `opener_`, the "original opener chain" doesn't reflect
713 // window.opener, which can be suppressed or updated. The "original opener"
714 // is the main frame of the actual opener of this frame. This traces the all
715 // the way back, so if the original opener was closed (deleted or severed due
716 // to COOP), but _it_ had an original opener, this will return the original
717 // opener's original opener, etc. So this value will always be set as long as
718 // there is at least one live frame in the chain whose connection is not
719 // severed due to COOP.
720 raw_ptr<FrameTreeNode> first_live_main_frame_in_original_opener_chain_ =
721 nullptr;
danakjc492bf82020-09-09 20:02:44722
Wolfgang Beyerd8809db2020-09-30 15:29:39723 // The devtools frame token of the frame which opened this frame. This is
724 // not cleared even if the opener is destroyed or disowns the frame.
Anton Bikineevf62d1bf2021-05-15 17:56:07725 absl::optional<base::UnguessableToken> opener_devtools_frame_token_;
Wolfgang Beyerd8809db2020-09-30 15:29:39726
Rakina Zata Amni3a48ae42022-05-05 03:39:56727 // An observer that updates this node's
728 // |first_live_main_frame_in_original_opener_chain_| to the next original
729 // opener in the chain if the original opener is destroyed.
danakjc492bf82020-09-09 20:02:44730 std::unique_ptr<OpenerDestroyedObserver> original_opener_observer_;
731
arthursonzogni034bb9c2020-10-01 08:29:56732 // When created by an opener, the URL specified in window.open(url)
733 // Please refer to {Get,Set}InitialPopupURL() documentation.
734 GURL initial_popup_url_;
735
736 // When created using window.open, the origin of the creator.
737 // Please refer to {Get,Set}PopupCreatorOrigin() documentation.
738 url::Origin popup_creator_origin_;
739
W. James MacLean81b8d01f2022-01-25 20:50:59740 // If the url from the the last BeginNavigation is about:srcdoc, this value
741 // stores the srcdoc_attribute's value for re-use in history navigations.
742 std::string srcdoc_value_;
743
danakjc492bf82020-09-09 20:02:44744 // Whether the frame's owner element in the parent document is collapsed.
arthursonzogni9816b9192021-03-29 16:09:19745 bool is_collapsed_ = false;
danakjc492bf82020-09-09 20:02:44746
Daniel Cheng6ac128172021-05-25 18:49:01747 // The type of frame owner for this frame. This is only relevant for non-main
748 // frames.
Kevin McNee43fe8292021-10-04 22:59:41749 const blink::FrameOwnerElementType frame_owner_element_type_ =
750 blink::FrameOwnerElementType::kNone;
Daniel Cheng9bd90f92021-04-23 20:49:45751
Daniel Cheng6ac128172021-05-25 18:49:01752 // The tree scope type of frame owner element, i.e. whether the element is in
753 // the document tree (https://dom.spec.whatwg.org/#document-trees) or the
754 // shadow tree (https://dom.spec.whatwg.org/#shadow-trees). This is only
755 // relevant for non-main frames.
756 const blink::mojom::TreeScopeType tree_scope_type_ =
757 blink::mojom::TreeScopeType::kDocument;
758
danakjc492bf82020-09-09 20:02:44759 // Track the pending sandbox flags and container policy for this frame. When a
760 // parent frame dynamically updates 'sandbox', 'allow', 'allowfullscreen',
761 // 'allowpaymentrequest' or 'src' attributes, the updated policy for the frame
Harkiran Bolaria4eacb3a2021-12-13 20:03:47762 // is stored here, and transferred into
763 // render_manager_.current_replication_state().frame_policy when they take
764 // effect on the next frame navigation.
danakjc492bf82020-09-09 20:02:44765 blink::FramePolicy pending_frame_policy_;
766
767 // Whether the frame was created by javascript. This is useful to prune
768 // history entries when the frame is removed (because frames created by
769 // scripts are never recreated with the same unique name - see
770 // https://crbug.com/500260).
arthursonzogni9816b9192021-03-29 16:09:19771 const bool is_created_by_script_;
danakjc492bf82020-09-09 20:02:44772
danakjc492bf82020-09-09 20:02:44773 // Tracks the scrolling and margin properties for this frame. These
774 // properties affect the child renderer but are stored on its parent's
775 // frame element. When this frame's parent dynamically updates these
776 // properties, we update them here too.
777 //
778 // Note that dynamic updates only take effect on the next frame navigation.
779 blink::mojom::FrameOwnerProperties frame_owner_properties_;
780
Yuzu Saijo03dbf9b2022-07-22 04:29:45781 // Contains the tracked HTML attributes of the corresponding iframe element,
782 // such as 'id' and 'src'.
783 blink::mojom::IframeAttributesPtr attributes_;
Antonio Sartori5abc8de2021-07-13 08:42:47784
danakjc492bf82020-09-09 20:02:44785 // Owns an ongoing NavigationRequest until it is ready to commit. It will then
786 // be reset and a RenderFrameHost will be responsible for the navigation.
787 std::unique_ptr<NavigationRequest> navigation_request_;
788
789 // List of objects observing this FrameTreeNode.
790 base::ObserverList<Observer>::Unchecked observers_;
791
792 base::TimeTicks last_focus_time_;
793
arthursonzogni9816b9192021-03-29 16:09:19794 bool was_discarded_ = false;
danakjc492bf82020-09-09 20:02:44795
Abhijeet Kandalkar3f29bc42022-09-23 12:39:58796 const FencedFrameStatus fenced_frame_status_ =
797 FencedFrameStatus::kNotNestedInFencedFrame;
Harkiran Bolaria16f2c48d2022-04-22 12:39:57798
Garrett Tanzerc69f4642022-08-15 22:15:14799 // If this is a fenced frame resulting from a urn:uuid navigation, this
800 // contains all the metadata specifying the resulting context.
Garrett Tanzer34cb92fe2022-09-28 17:50:54801 // TODO(crbug.com/1262022): Move this into the FrameTree once ShadowDOM
802 // and urn iframes are gone.
Garrett Tanzer29de7112022-12-06 21:26:32803 absl::optional<FencedFrameProperties> fenced_frame_properties_;
Garrett Tanzerc69f4642022-08-15 22:15:14804
Lukasz Anforowicz147141962020-12-16 18:03:24805 // Manages creation and swapping of RenderFrameHosts for this frame.
806 //
807 // This field needs to be declared last, because destruction of
808 // RenderFrameHostManager may call arbitrary callbacks (e.g. via
809 // WebContentsObserver::DidFinishNavigation fired after RenderFrameHostManager
810 // destructs a RenderFrameHostImpl and its NavigationRequest). Such callbacks
811 // may try to use FrameTreeNode's fields above - this would be an undefined
812 // behavior if the fields (even trivially-destructible ones) were destructed
813 // before the RenderFrameHostManager's destructor runs. See also
814 // https://crbug.com/1157988.
815 RenderFrameHostManager render_manager_;
danakjc492bf82020-09-09 20:02:44816};
817
818} // namespace content
819
820#endif // CONTENT_BROWSER_RENDERER_HOST_FRAME_TREE_NODE_H_