blob: cc6507f1ec7b7a99a768d081ff4f0106154291ea [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(
88 FrameTree* frame_tree,
89 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
121 FrameTree* frame_tree() const { return frame_tree_; }
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
231 // updates in an <iframe> element take effect on next navigation. To retrieve
232 // the currently active policy for this frame, use effective_frame_policy().
233 const blink::FramePolicy& pending_frame_policy() const {
234 return pending_frame_policy_;
235 }
236
237 // Update this frame's sandbox flags and container policy. This is called
238 // when a parent frame updates the "sandbox" attribute in the <iframe> element
239 // for this frame, or any of the attributes which affect the container policy
240 // ("allowfullscreen", "allowpaymentrequest", "allow", and "src".)
241 // These policies won't take effect until next navigation. If this frame's
242 // parent is itself sandboxed, the parent's sandbox flags are combined with
243 // those in |frame_policy|.
244 // Attempting to change the container policy on the main frame will have no
245 // effect.
246 void SetPendingFramePolicy(blink::FramePolicy frame_policy);
247
248 // Returns the currently active frame policy for this frame, including the
249 // sandbox flags which were present at the time the document was loaded, and
Charlie Hu5130d25e2021-03-05 21:53:39250 // the permissions policy container policy, which is set by the iframe's
danakjc492bf82020-09-09 20:02:44251 // allowfullscreen, allowpaymentrequest, and allow attributes, along with the
252 // origin of the iframe's src attribute (which may be different from the URL
253 // of the document currently loaded into the frame). This does not include
254 // policy changes that have been made by updating the containing iframe
255 // element attributes since the frame was last navigated; use
256 // pending_frame_policy() for those.
257 const blink::FramePolicy& effective_frame_policy() const {
Harkiran Bolaria4eacb3a2021-12-13 20:03:47258 return render_manager_.current_replication_state().frame_policy;
danakjc492bf82020-09-09 20:02:44259 }
260
danakjc492bf82020-09-09 20:02:44261 const blink::mojom::FrameOwnerProperties& frame_owner_properties() {
262 return frame_owner_properties_;
263 }
264
265 void set_frame_owner_properties(
266 const blink::mojom::FrameOwnerProperties& frame_owner_properties) {
267 frame_owner_properties_ = frame_owner_properties;
268 }
269
Yuzu Saijo03dbf9b2022-07-22 04:29:45270 // Reflects the attributes of the corresponding iframe html element, such
Arthur Sonzogni64457592022-11-22 11:08:59271 // as 'credentialless', 'id', 'name' and 'src'. These values should not be
Yuzu Saijo03dbf9b2022-07-22 04:29:45272 // exposed to cross-origin renderers.
273 const network::mojom::ContentSecurityPolicy* csp_attribute() const {
274 return attributes_->parsed_csp_attribute.get();
danakjc492bf82020-09-09 20:02:44275 }
Arthur Sonzogni64457592022-11-22 11:08:59276 bool credentialless() const { return attributes_->credentialless; }
Yuzu Saijo03dbf9b2022-07-22 04:29:45277 const std::string& html_id() const { return attributes_->id; }
278 // This tracks iframe's 'name' attribute instead of window.name, which is
279 // tracked in FrameReplicationState. See the comment for frame_name() for
280 // more details.
281 const std::string& html_name() const { return attributes_->name; }
282 const std::string& html_src() const { return attributes_->src; }
danakjc492bf82020-09-09 20:02:44283
Yuzu Saijo03dbf9b2022-07-22 04:29:45284 void SetAttributes(blink::mojom::IframeAttributesPtr attributes);
Antonio Sartori5abc8de2021-07-13 08:42:47285
danakjc492bf82020-09-09 20:02:44286 bool HasSameOrigin(const FrameTreeNode& node) const {
Harkiran Bolaria4eacb3a2021-12-13 20:03:47287 return render_manager_.current_replication_state().origin.IsSameOriginWith(
288 node.current_replication_state().origin);
danakjc492bf82020-09-09 20:02:44289 }
290
Gyuyoung Kimc16e52e92021-03-19 02:45:37291 const blink::mojom::FrameReplicationState& current_replication_state() const {
Harkiran Bolaria4eacb3a2021-12-13 20:03:47292 return render_manager_.current_replication_state();
danakjc492bf82020-09-09 20:02:44293 }
294
295 RenderFrameHostImpl* current_frame_host() const {
296 return render_manager_.current_frame_host();
297 }
298
danakjc492bf82020-09-09 20:02:44299 // Returns true if this node is in a loading state.
300 bool IsLoading() const;
301
Alex Moshchuk9b0fd822020-10-26 23:08:15302 // Returns true if this node has a cross-document navigation in progress.
303 bool HasPendingCrossDocumentNavigation() const;
304
danakjc492bf82020-09-09 20:02:44305 NavigationRequest* navigation_request() { return navigation_request_.get(); }
306
307 // Transfers the ownership of the NavigationRequest to |render_frame_host|.
308 // From ReadyToCommit to DidCommit, the NavigationRequest is owned by the
309 // RenderFrameHost that is committing the navigation.
310 void TransferNavigationRequestOwnership(
311 RenderFrameHostImpl* render_frame_host);
312
313 // Takes ownership of |navigation_request| and makes it the current
314 // NavigationRequest of this frame. This corresponds to the start of a new
315 // navigation. If there was an ongoing navigation request before calling this
316 // function, it is canceled. |navigation_request| should not be null.
317 void CreatedNavigationRequest(
318 std::unique_ptr<NavigationRequest> navigation_request);
319
Rakina Zata Amnif8f2bb62022-11-23 05:54:32320 // Resets the navigation request owned by `this` (which shouldn't have reached
321 // the "pending commit" stage yet) and any state created by it, including the
Rakina Zata Amni33175cb92022-11-24 02:46:03322 // speculative RenderFrameHost (if there are no other navigations associated
323 // with it). Note that this does not affect navigations that have reached the
324 // "pending commit" stage, which are owned by their corresponding
325 // RenderFrameHosts instead.
Daniel Cheng390e2a72022-09-28 06:07:53326 void ResetNavigationRequest(NavigationDiscardReason reason);
327
Rakina Zata Amnif8f2bb62022-11-23 05:54:32328 // Similar to `ResetNavigationRequest()`, but keeps the state created by the
Daniel Cheng390e2a72022-09-28 06:07:53329 // NavigationRequest (e.g. speculative RenderFrameHost, loading state).
330 void ResetNavigationRequestButKeepState();
danakjc492bf82020-09-09 20:02:44331
332 // A RenderFrameHost in this node started loading.
Nate Chapin9aabf5f2021-11-12 00:31:19333 // |should_show_loading_ui| indicates whether this navigation should be
334 // visible in the UI. True for cross-document navigations and navigations
Nate Chapin24295252022-09-27 18:31:08335 // intercepted by the navigation API's intercept().
danakjc492bf82020-09-09 20:02:44336 // |was_previously_loading| is false if the FrameTree was not loading before.
337 // The caller is required to provide this boolean as the delegate should only
338 // be notified if the FrameTree went from non-loading to loading state.
339 // However, when it is called, the FrameTree should be in a loading state.
Nate Chapin9aabf5f2021-11-12 00:31:19340 void DidStartLoading(bool should_show_loading_ui,
341 bool was_previously_loading);
danakjc492bf82020-09-09 20:02:44342
343 // A RenderFrameHost in this node stopped loading.
344 void DidStopLoading();
345
346 // The load progress for a RenderFrameHost in this node was updated to
347 // |load_progress|. This will notify the FrameTree which will in turn notify
348 // the WebContents.
349 void DidChangeLoadProgress(double load_progress);
350
351 // Called when the user directed the page to stop loading. Stops all loads
352 // happening in the FrameTreeNode. This method should be used with
353 // FrameTree::ForEach to stop all loads in the entire FrameTree.
354 bool StopLoading();
355
356 // Returns the time this frame was last focused.
357 base::TimeTicks last_focus_time() const { return last_focus_time_; }
358
359 // Called when this node becomes focused. Updates the node's last focused
360 // time and notifies observers.
361 void DidFocus();
362
363 // Called when the user closed the modal dialogue for BeforeUnload and
364 // cancelled the navigation. This should stop any load happening in the
365 // FrameTreeNode.
366 void BeforeUnloadCanceled();
367
danakjc492bf82020-09-09 20:02:44368 // Returns the sandbox flags currently in effect for this frame. This includes
369 // flags inherited from parent frames, the currently active flags from the
370 // <iframe> element hosting this frame, as well as any flags set from a
371 // Content-Security-Policy HTTP header. This does not include flags that have
372 // have been updated in an <iframe> element but have not taken effect yet; use
373 // pending_frame_policy() for those. To see the flags which will take effect
374 // on navigation (which does not include the CSP-set flags), use
375 // effective_frame_policy().
376 network::mojom::WebSandboxFlags active_sandbox_flags() const {
Harkiran Bolaria4eacb3a2021-12-13 20:03:47377 return render_manager_.current_replication_state().active_sandbox_flags;
danakjc492bf82020-09-09 20:02:44378 }
379
danakjc492bf82020-09-09 20:02:44380 // Returns whether the frame received a user gesture on a previous navigation
381 // on the same eTLD+1.
382 bool has_received_user_gesture_before_nav() const {
Harkiran Bolaria4eacb3a2021-12-13 20:03:47383 return render_manager_.current_replication_state()
384 .has_received_user_gesture_before_nav;
danakjc492bf82020-09-09 20:02:44385 }
386
387 // When a tab is discarded, WebContents sets was_discarded on its
388 // root FrameTreeNode.
389 // In addition, when a child frame is created, this bit is passed on from
390 // parent to child.
391 // When a navigation request is created, was_discarded is passed on to the
392 // request and reset to false in FrameTreeNode.
393 void set_was_discarded() { was_discarded_ = true; }
394 bool was_discarded() const { return was_discarded_; }
395
Miyoung Shin8a66ec022022-11-28 23:50:09396 // Deprecated. Use directly HasStickyUserActivation in RFHI.
danakjc492bf82020-09-09 20:02:44397 // Returns the sticky bit of the User Activation v2 state of the
398 // |FrameTreeNode|.
399 bool HasStickyUserActivation() const {
Miyoung Shin8a66ec022022-11-28 23:50:09400 return current_frame_host()->HasStickyUserActivation();
danakjc492bf82020-09-09 20:02:44401 }
402
Miyoung Shin8a66ec022022-11-28 23:50:09403 // Deprecated. Use directly HasStickyUserActivation in RFHI.
danakjc492bf82020-09-09 20:02:44404 // Returns the transient bit of the User Activation v2 state of the
405 // |FrameTreeNode|.
406 bool HasTransientUserActivation() {
Miyoung Shin8a66ec022022-11-28 23:50:09407 return current_frame_host()->HasTransientUserActivation();
danakjc492bf82020-09-09 20:02:44408 }
409
410 // Remove history entries for all frames created by script in this frame's
411 // subtree. If a frame created by a script is removed, then its history entry
412 // will never be reused - this saves memory.
413 void PruneChildFrameNavigationEntries(NavigationEntryImpl* entry);
414
Abhijeet Kandalkarb43affa72022-09-27 16:48:01415 using FencedFrameStatus = RenderFrameHostImpl::FencedFrameStatus;
Abhijeet Kandalkar3f29bc42022-09-23 12:39:58416 FencedFrameStatus fenced_frame_status() const { return fenced_frame_status_; }
417
Kevin McNee43fe8292021-10-04 22:59:41418 blink::FrameOwnerElementType frame_owner_element_type() const {
Daniel Cheng9bd90f92021-04-23 20:49:45419 return frame_owner_element_type_;
danakjc492bf82020-09-09 20:02:44420 }
danakjc492bf82020-09-09 20:02:44421
Daniel Cheng6ac128172021-05-25 18:49:01422 blink::mojom::TreeScopeType tree_scope_type() const {
423 return tree_scope_type_;
424 }
425
arthursonzogni034bb9c2020-10-01 08:29:56426 // The initial popup URL for new window opened using:
427 // `window.open(initial_popup_url)`.
428 // An empty GURL otherwise.
429 //
430 // [WARNING] There is no guarantee the FrameTreeNode will ever host a
431 // document served from this URL. The FrameTreeNode always starts hosting the
432 // initial empty document and attempts a navigation toward this URL. However
433 // the navigation might be delayed, redirected and even cancelled.
434 void SetInitialPopupURL(const GURL& initial_popup_url);
435 const GURL& initial_popup_url() const { return initial_popup_url_; }
436
437 // The origin of the document that used window.open() to create this frame.
438 // Otherwise, an opaque Origin with a nonce different from all previously
439 // existing Origins.
440 void SetPopupCreatorOrigin(const url::Origin& popup_creator_origin);
441 const url::Origin& popup_creator_origin() const {
442 return popup_creator_origin_;
443 }
444
Harkiran Bolaria59290d62021-03-17 01:53:01445 // Sets the associated FrameTree for this node. The node can change FrameTrees
446 // when blink::features::Prerender2 is enabled, which allows a page loaded in
447 // the prerendered FrameTree to be used for a navigation in the primary frame
448 // tree.
449 void SetFrameTree(FrameTree& frame_tree);
450
Alexander Timin074cd182022-03-23 18:11:22451 using TraceProto = perfetto::protos::pbzero::FrameTreeNodeInfo;
Alexander Timinf785f342021-03-18 00:00:56452 // Write a representation of this object into a trace.
Alexander Timin074cd182022-03-23 18:11:22453 void WriteIntoTrace(perfetto::TracedProto<TraceProto> proto) const;
Alexander Timinf785f342021-03-18 00:00:56454
Carlos Caballero76711352021-03-24 17:38:21455 // Returns true the node is navigating, i.e. it has an associated
456 // NavigationRequest.
457 bool HasNavigation();
458
shivanigithubf3ddff52021-07-03 22:06:30459 // Fenced frames (meta-bug crbug.com/1111084):
shivanigithub4cd016a2021-09-20 21:10:30460 // Note that these two functions cannot be invoked from a FrameTree's or
461 // its root node's constructor since they require the frame tree and the
462 // root node to be completely constructed.
463 //
shivanigithubf3ddff52021-07-03 22:06:30464 // Returns false if fenced frames are disabled. Returns true if the feature is
465 // enabled and if |this| is a fenced frame. Returns false for
466 // iframes embedded in a fenced frame. To clarify: for the MPArch
467 // implementation this only returns true if |this| is the actual
468 // root node of the inner FrameTree and not the proxy FrameTreeNode in the
469 // outer FrameTree.
Dominic Farolino4bc10ee2021-08-31 00:37:36470 bool IsFencedFrameRoot() const;
shivanigithubf3ddff52021-07-03 22:06:30471
472 // Returns false if fenced frames are disabled. Returns true if the
473 // feature is enabled and if |this| or any of its ancestor nodes is a
474 // fenced frame.
475 bool IsInFencedFrameTree() const;
476
shivanigithub4cd016a2021-09-20 21:10:30477 // Returns a valid nonce if `IsInFencedFrameTree()` returns true for `this`.
Garrett Tanzer34cb92fe2022-09-28 17:50:54478 // Returns nullopt otherwise.
479 //
480 // Nonce used in the net::IsolationInfo and blink::StorageKey for a fenced
481 // frame and any iframes nested within it. Not set if this frame is not in a
482 // fenced frame's FrameTree. Note that this could be a field in FrameTree for
483 // the MPArch version but for the shadow DOM version we need to keep it here
484 // since the fenced frame root is not a main frame for the latter. The value
485 // of the nonce will be the same for all of the the iframes inside a fenced
486 // frame tree. If there is a nested fenced frame it will have a different
487 // nonce than its parent fenced frame. The nonce will stay the same across
488 // navigations initiated from the fenced frame tree because it is always used
489 // in conjunction with other fields of the keys and would be good to access
490 // the same storage across same-origin navigations. If the navigation is
491 // same-origin/site then the same network stack partition/storage will be
492 // reused and if it's cross-origin/site then other parts of the key will
493 // change and so, even with the same nonce, another partition will be used.
494 // But if the navigation is initiated from the embedder, the nonce will be
495 // reinitialized irrespective of same or cross origin such that there is no
496 // privacy leak via storage shared between two embedder initiated navigations.
497 // Note that this reinitialization is implemented for all embedder-initiated
498 // navigations in MPArch, but only urn:uuid navigations in ShadowDOM.
499 absl::optional<base::UnguessableToken> GetFencedFrameNonce();
shivanigithub4cd016a2021-09-20 21:10:30500
Garrett Tanzer34cb92fe2022-09-28 17:50:54501 // If applicable, initialize the default fenced frame properties. Right now,
502 // this means setting a new fenced frame nonce. See comment on
shivanigithub4cd016a2021-09-20 21:10:30503 // fenced_frame_nonce() for when it is set to a non-null value. Invoked
504 // by FrameTree::Init() or FrameTree::AddFrame().
Garrett Tanzer34cb92fe2022-09-28 17:50:54505 void SetFencedFramePropertiesIfNeeded();
shivanigithub4cd016a2021-09-20 21:10:30506
Garrett Tanzera42fdef2022-06-13 16:09:14507 // Returns the mode attribute set on the fenced frame root if this frame is
508 // in a fenced frame tree, otherwise returns `absl::nullopt`.
Nan Line3767382022-03-25 22:05:41509 absl::optional<blink::mojom::FencedFrameMode> GetFencedFrameMode();
Nan Lin171fe9a2022-02-17 16:42:16510
Dave Tapuskac8de3b02021-12-03 21:51:01511 // Helper for GetParentOrOuterDocument/GetParentOrOuterDocumentOrEmbedder.
512 // Do not use directly.
513 RenderFrameHostImpl* GetParentOrOuterDocumentHelper(bool escape_guest_view);
514
Harkiran Bolariab4437fd2021-08-11 17:51:22515 // Sets the unique_name and name fields on replication_state_. To be used in
516 // prerender activation to make sure the FrameTreeNode replication state is
517 // correct after the RenderFrameHost is moved between FrameTreeNodes. The
518 // renderers should already have the correct value, so unlike
519 // FrameTreeNode::SetFrameName, we do not notify them here.
Harkiran Bolaria4eacb3a2021-12-13 20:03:47520 // TODO(https://crbug.com/1237091): Remove this once the BrowsingContextState
521 // is implemented to utilize the new path.
Harkiran Bolariab4437fd2021-08-11 17:51:22522 void set_frame_name_for_activation(const std::string& unique_name,
523 const std::string& name) {
Harkiran Bolaria0b3bdef02022-03-10 13:04:40524 current_frame_host()->browsing_context_state()->set_frame_name(unique_name,
525 name);
Harkiran Bolariab4437fd2021-08-11 17:51:22526 }
527
Nan Linaaf84f72021-12-02 22:31:56528 // Returns true if error page isolation is enabled.
529 bool IsErrorPageIsolationEnabled() const;
530
W. James MacLean81b8d01f2022-01-25 20:50:59531 // Functions to store and retrieve a frame's srcdoc value on this
532 // FrameTreeNode.
533 void SetSrcdocValue(const std::string& srcdoc_value);
534 const std::string& srcdoc_value() const { return srcdoc_value_; }
535
Garrett Tanzerc69f4642022-08-15 22:15:14536 void set_fenced_frame_properties(
537 absl::optional<FencedFrameURLMapping::FencedFrameProperties>&
538 fenced_frame_properties) {
Garrett Tanzer2975eea2022-08-22 16:34:01539 // TODO(crbug.com/1262022): Reenable this DCHECK once ShadowDOM and
540 // loading urns in iframes (for FLEDGE OT) are gone.
541 // DCHECK_EQ(fenced_frame_status_,
542 // RenderFrameHostImpl::FencedFrameStatus::kFencedFrameRoot);
Garrett Tanzerc69f4642022-08-15 22:15:14543 fenced_frame_properties_ = fenced_frame_properties;
544 }
545
Garrett Tanzer34cb92fe2022-09-28 17:50:54546 // Return the fenced frame properties for this fenced frame tree (if any).
547 // That is to say, this function returns the `fenced_frame_properties_`
548 // variable attached to the fenced frame root FrameTreeNode, which may be
549 // either this node or an ancestor of it.
Garrett Tanzerc69f4642022-08-15 22:15:14550 const absl::optional<FencedFrameURLMapping::FencedFrameProperties>&
Garrett Tanzer34cb92fe2022-09-28 17:50:54551 GetFencedFrameProperties();
Garrett Tanzerc69f4642022-08-15 22:15:14552
Yao Xiaoa2337ad2022-10-12 20:59:29553 // Return the number of fenced frame boundaries above this frame. The
554 // outermost main frame's frame tree has fenced frame depth 0, a topmost
555 // fenced frame tree embedded in the outermost main frame has fenced frame
556 // depth 1, etc.
557 size_t GetFencedFrameDepth();
558
559 // Traverse up from this node. Return all valid
560 // `node->fenced_frame_properties_->shared_storage_budget_metadata` (i.e. this
561 // node is subjected to the shared storage budgeting associated with those
562 // metadata). Every node that originates from sharedStorage.selectURL() will
563 // have an associated metadata. This indicates that the metadata can only
564 // possibly be associated with a fenced frame root, unless when
565 // `kAllowURNsInIframes` is enabled in which case they could be be associated
566 // with any node.
567 std::vector<const FencedFrameURLMapping::SharedStorageBudgetMetadata*>
Yao Xiao1ac702d2022-06-08 17:20:49568 FindSharedStorageBudgetMetadata();
569
Harkiran Bolariaebbe7702022-02-22 19:19:03570 // Accessor to BrowsingContextState for subframes only. Only main frame
571 // navigations can change BrowsingInstances and BrowsingContextStates,
572 // therefore for subframes associated BrowsingContextState never changes. This
573 // helper method makes this more explicit and guards against calling this on
574 // main frames (there an appropriate BrowsingContextState should be obtained
575 // from RenderFrameHost or from RenderFrameProxyHost as e.g. during
576 // cross-BrowsingInstance navigations multiple BrowsingContextStates exist in
577 // the same frame).
578 const scoped_refptr<BrowsingContextState>&
579 GetBrowsingContextStateForSubframe() const;
580
Arthur Hemerye4659282022-03-28 08:36:15581 // Clears the opener property of popups referencing this FrameTreeNode as
582 // their opener.
583 void ClearOpenerReferences();
584
Liam Bradyd2a41e152022-07-19 13:58:48585 // Calculates whether one of the ancestor frames or this frame has a CSPEE
586 // in place. This is eventually sent over to LocalFrame in the renderer where
587 // it will be used by HTMLFencedFrameElement::canLoadOpaqueURL for information
588 // it can't get on its own.
589 bool AncestorOrSelfHasCSPEE() const;
590
Miyoung Shin7cf88b42022-11-07 13:22:30591 // RenderFrameHostOwner implementation:
592 void RestartNavigationAsCrossDocument(
593 std::unique_ptr<NavigationRequest> navigation_request) override;
Julie Jeongeun Kimc1b07c32022-11-11 10:26:32594 Navigator& GetCurrentNavigator() override;
Miyoung Shine16cd2262022-11-30 05:52:16595 RenderFrameHostManager& GetRenderFrameHostManager() 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,
618 const net::IsolationInfo& isolation_info_for_subresources,
619 blink::mojom::ReferrerPtr referrer,
620 const ui::PageTransition& transition,
621 bool should_replace_current_entry,
622 const std::string& method,
623 bool has_transient_activation,
624 bool is_overriding_user_agent,
625 const std::vector<GURL>& redirects,
626 const GURL& original_url,
627 std::unique_ptr<CrossOriginEmbedderPolicyReporter> coep_reporter,
628 std::unique_ptr<WebBundleNavigationInfo> web_bundle_navigation_info,
629 std::unique_ptr<SubresourceWebBundleNavigationInfo>
630 subresource_web_bundle_navigation_info,
631 int http_response_code) override;
Miyoung Shinb5561802022-12-01 08:21:35632 void CancelNavigation() override;
Miyoung Shinff13ed22022-11-30 09:21:47633
danakjc492bf82020-09-09 20:02:44634 private:
Yuzu Saijo03dbf9b2022-07-22 04:29:45635 friend class CSPEmbeddedEnforcementUnitTest;
Charlie Hubb5943d2021-03-09 19:46:12636 FRIEND_TEST_ALL_PREFIXES(SitePerProcessPermissionsPolicyBrowserTest,
danakjc492bf82020-09-09 20:02:44637 ContainerPolicyDynamic);
Charlie Hubb5943d2021-03-09 19:46:12638 FRIEND_TEST_ALL_PREFIXES(SitePerProcessPermissionsPolicyBrowserTest,
danakjc492bf82020-09-09 20:02:44639 ContainerPolicySandboxDynamic);
Yuzu Saijo03dbf9b2022-07-22 04:29:45640 FRIEND_TEST_ALL_PREFIXES(NavigationRequestTest, StorageKeyToCommit);
Arthur Sonzogni64457592022-11-22 11:08:59641 FRIEND_TEST_ALL_PREFIXES(
642 NavigationRequestTest,
643 NavigationToCredentiallessDocumentNetworkIsolationInfo);
Yuzu Saijo03dbf9b2022-07-22 04:29:45644 FRIEND_TEST_ALL_PREFIXES(RenderFrameHostImplTest,
Arthur Sonzogni64457592022-11-22 11:08:59645 ChildOfCredentiallessIsCredentialless);
Yifan Luo86a79f42022-08-16 18:38:27646 FRIEND_TEST_ALL_PREFIXES(ContentPasswordManagerDriverTest,
Arthur Sonzogni64457592022-11-22 11:08:59647 PasswordAutofillDisabledOnCredentiallessIframe);
danakjc492bf82020-09-09 20:02:44648
Dominic Farolino8a2187b2021-12-24 20:44:21649 // Called by the destructor. When `this` is an outer dummy FrameTreeNode
650 // representing an inner FrameTree, this method destroys said inner FrameTree.
651 void DestroyInnerFrameTreeIfExists();
652
danakjc492bf82020-09-09 20:02:44653 class OpenerDestroyedObserver;
654
danakjc492bf82020-09-09 20:02:44655 // The |notification_type| parameter is used for histograms only.
656 bool NotifyUserActivation(
657 blink::mojom::UserActivationNotificationType notification_type);
658
659 bool ConsumeTransientUserActivation();
660
661 bool ClearUserActivation();
662
663 // Verify that the renderer process is allowed to set user activation on this
664 // frame by checking whether this frame's RenderWidgetHost had previously seen
665 // an input event that might lead to user activation. If user activation
666 // should be allowed, this returns true and also clears corresponding pending
667 // user activation state in the widget. Otherwise, this returns false.
668 bool VerifyUserActivation();
669
670 // The next available browser-global FrameTreeNode ID.
671 static int next_frame_tree_node_id_;
672
673 // The FrameTree that owns us.
Keishi Hattori0e45c022021-11-27 09:25:52674 raw_ptr<FrameTree> frame_tree_; // not owned.
danakjc492bf82020-09-09 20:02:44675
danakjc492bf82020-09-09 20:02:44676 // A browser-global identifier for the frame in the page, which stays stable
677 // even if the frame does a cross-process navigation.
678 const int frame_tree_node_id_;
679
680 // The RenderFrameHost owning this FrameTreeNode, which cannot change for the
681 // life of this FrameTreeNode. |nullptr| if this node is the root.
Keishi Hattori0e45c022021-11-27 09:25:52682 const raw_ptr<RenderFrameHostImpl> parent_;
danakjc492bf82020-09-09 20:02:44683
danakjc492bf82020-09-09 20:02:44684 // The frame that opened this frame, if any. Will be set to null if the
685 // opener is closed, or if this frame disowns its opener by setting its
686 // window.opener to null.
Keishi Hattori0e45c022021-11-27 09:25:52687 raw_ptr<FrameTreeNode> opener_ = nullptr;
danakjc492bf82020-09-09 20:02:44688
689 // An observer that clears this node's |opener_| if the opener is destroyed.
690 // This observer is added to the |opener_|'s observer list when the |opener_|
691 // is set to a non-null node, and it is removed from that list when |opener_|
692 // changes or when this node is destroyed. It is also cleared if |opener_|
693 // is disowned.
694 std::unique_ptr<OpenerDestroyedObserver> opener_observer_;
695
Rakina Zata Amni3a48ae42022-05-05 03:39:56696 // Unlike `opener_`, the "original opener chain" doesn't reflect
697 // window.opener, which can be suppressed or updated. The "original opener"
698 // is the main frame of the actual opener of this frame. This traces the all
699 // the way back, so if the original opener was closed (deleted or severed due
700 // to COOP), but _it_ had an original opener, this will return the original
701 // opener's original opener, etc. So this value will always be set as long as
702 // there is at least one live frame in the chain whose connection is not
703 // severed due to COOP.
704 raw_ptr<FrameTreeNode> first_live_main_frame_in_original_opener_chain_ =
705 nullptr;
danakjc492bf82020-09-09 20:02:44706
Wolfgang Beyerd8809db2020-09-30 15:29:39707 // The devtools frame token of the frame which opened this frame. This is
708 // not cleared even if the opener is destroyed or disowns the frame.
Anton Bikineevf62d1bf2021-05-15 17:56:07709 absl::optional<base::UnguessableToken> opener_devtools_frame_token_;
Wolfgang Beyerd8809db2020-09-30 15:29:39710
Rakina Zata Amni3a48ae42022-05-05 03:39:56711 // An observer that updates this node's
712 // |first_live_main_frame_in_original_opener_chain_| to the next original
713 // opener in the chain if the original opener is destroyed.
danakjc492bf82020-09-09 20:02:44714 std::unique_ptr<OpenerDestroyedObserver> original_opener_observer_;
715
arthursonzogni034bb9c2020-10-01 08:29:56716 // When created by an opener, the URL specified in window.open(url)
717 // Please refer to {Get,Set}InitialPopupURL() documentation.
718 GURL initial_popup_url_;
719
720 // When created using window.open, the origin of the creator.
721 // Please refer to {Get,Set}PopupCreatorOrigin() documentation.
722 url::Origin popup_creator_origin_;
723
W. James MacLean81b8d01f2022-01-25 20:50:59724 // If the url from the the last BeginNavigation is about:srcdoc, this value
725 // stores the srcdoc_attribute's value for re-use in history navigations.
726 std::string srcdoc_value_;
727
danakjc492bf82020-09-09 20:02:44728 // Whether the frame's owner element in the parent document is collapsed.
arthursonzogni9816b9192021-03-29 16:09:19729 bool is_collapsed_ = false;
danakjc492bf82020-09-09 20:02:44730
Daniel Cheng6ac128172021-05-25 18:49:01731 // The type of frame owner for this frame. This is only relevant for non-main
732 // frames.
Kevin McNee43fe8292021-10-04 22:59:41733 const blink::FrameOwnerElementType frame_owner_element_type_ =
734 blink::FrameOwnerElementType::kNone;
Daniel Cheng9bd90f92021-04-23 20:49:45735
Daniel Cheng6ac128172021-05-25 18:49:01736 // The tree scope type of frame owner element, i.e. whether the element is in
737 // the document tree (https://dom.spec.whatwg.org/#document-trees) or the
738 // shadow tree (https://dom.spec.whatwg.org/#shadow-trees). This is only
739 // relevant for non-main frames.
740 const blink::mojom::TreeScopeType tree_scope_type_ =
741 blink::mojom::TreeScopeType::kDocument;
742
danakjc492bf82020-09-09 20:02:44743 // Track the pending sandbox flags and container policy for this frame. When a
744 // parent frame dynamically updates 'sandbox', 'allow', 'allowfullscreen',
745 // 'allowpaymentrequest' or 'src' attributes, the updated policy for the frame
Harkiran Bolaria4eacb3a2021-12-13 20:03:47746 // is stored here, and transferred into
747 // render_manager_.current_replication_state().frame_policy when they take
748 // effect on the next frame navigation.
danakjc492bf82020-09-09 20:02:44749 blink::FramePolicy pending_frame_policy_;
750
751 // Whether the frame was created by javascript. This is useful to prune
752 // history entries when the frame is removed (because frames created by
753 // scripts are never recreated with the same unique name - see
754 // https://crbug.com/500260).
arthursonzogni9816b9192021-03-29 16:09:19755 const bool is_created_by_script_;
danakjc492bf82020-09-09 20:02:44756
danakjc492bf82020-09-09 20:02:44757 // Tracks the scrolling and margin properties for this frame. These
758 // properties affect the child renderer but are stored on its parent's
759 // frame element. When this frame's parent dynamically updates these
760 // properties, we update them here too.
761 //
762 // Note that dynamic updates only take effect on the next frame navigation.
763 blink::mojom::FrameOwnerProperties frame_owner_properties_;
764
Yuzu Saijo03dbf9b2022-07-22 04:29:45765 // Contains the tracked HTML attributes of the corresponding iframe element,
766 // such as 'id' and 'src'.
767 blink::mojom::IframeAttributesPtr attributes_;
Antonio Sartori5abc8de2021-07-13 08:42:47768
danakjc492bf82020-09-09 20:02:44769 // Owns an ongoing NavigationRequest until it is ready to commit. It will then
770 // be reset and a RenderFrameHost will be responsible for the navigation.
771 std::unique_ptr<NavigationRequest> navigation_request_;
772
773 // List of objects observing this FrameTreeNode.
774 base::ObserverList<Observer>::Unchecked observers_;
775
776 base::TimeTicks last_focus_time_;
777
arthursonzogni9816b9192021-03-29 16:09:19778 bool was_discarded_ = false;
danakjc492bf82020-09-09 20:02:44779
Abhijeet Kandalkar3f29bc42022-09-23 12:39:58780 const FencedFrameStatus fenced_frame_status_ =
781 FencedFrameStatus::kNotNestedInFencedFrame;
Harkiran Bolaria16f2c48d2022-04-22 12:39:57782
Garrett Tanzerc69f4642022-08-15 22:15:14783 // If this is a fenced frame resulting from a urn:uuid navigation, this
784 // contains all the metadata specifying the resulting context.
Garrett Tanzer34cb92fe2022-09-28 17:50:54785 // TODO(crbug.com/1262022): Move this into the FrameTree once ShadowDOM
786 // and urn iframes are gone.
Garrett Tanzerc69f4642022-08-15 22:15:14787 absl::optional<FencedFrameURLMapping::FencedFrameProperties>
788 fenced_frame_properties_;
789
Lukasz Anforowicz147141962020-12-16 18:03:24790 // Manages creation and swapping of RenderFrameHosts for this frame.
791 //
792 // This field needs to be declared last, because destruction of
793 // RenderFrameHostManager may call arbitrary callbacks (e.g. via
794 // WebContentsObserver::DidFinishNavigation fired after RenderFrameHostManager
795 // destructs a RenderFrameHostImpl and its NavigationRequest). Such callbacks
796 // may try to use FrameTreeNode's fields above - this would be an undefined
797 // behavior if the fields (even trivially-destructible ones) were destructed
798 // before the RenderFrameHostManager's destructor runs. See also
799 // https://crbug.com/1157988.
800 RenderFrameHostManager render_manager_;
danakjc492bf82020-09-09 20:02:44801};
802
803} // namespace content
804
805#endif // CONTENT_BROWSER_RENDERER_HOST_FRAME_TREE_NODE_H_