danakj | c492bf8 | 2020-09-09 20:02:44 | [diff] [blame] | 1 | // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #ifndef CONTENT_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> |
| 12 | #include <vector> |
| 13 | |
| 14 | #include "base/gtest_prod_util.h" |
danakj | c492bf8 | 2020-09-09 20:02:44 | [diff] [blame] | 15 | #include "base/memory/ref_counted.h" |
| 16 | #include "content/browser/renderer_host/frame_tree.h" |
| 17 | #include "content/browser/renderer_host/frame_tree_node_blame_context.h" |
| 18 | #include "content/browser/renderer_host/navigator.h" |
| 19 | #include "content/browser/renderer_host/render_frame_host_impl.h" |
| 20 | #include "content/browser/renderer_host/render_frame_host_manager.h" |
| 21 | #include "content/common/content_export.h" |
danakj | c492bf8 | 2020-09-09 20:02:44 | [diff] [blame] | 22 | #include "services/network/public/mojom/content_security_policy.mojom-forward.h" |
Lei Zhang | 698df03c | 2021-05-21 04:23:34 | [diff] [blame] | 23 | #include "third_party/abseil-cpp/absl/types/optional.h" |
Kevin McNee | 43fe829 | 2021-10-04 22:59:41 | [diff] [blame] | 24 | #include "third_party/blink/public/common/frame/frame_owner_element_type.h" |
danakj | c492bf8 | 2020-09-09 20:02:44 | [diff] [blame] | 25 | #include "third_party/blink/public/common/frame/frame_policy.h" |
| 26 | #include "third_party/blink/public/common/frame/user_activation_state.h" |
danakj | c492bf8 | 2020-09-09 20:02:44 | [diff] [blame] | 27 | #include "third_party/blink/public/mojom/frame/frame_owner_properties.mojom.h" |
Gyuyoung Kim | c16e52e9 | 2021-03-19 02:45:37 | [diff] [blame] | 28 | #include "third_party/blink/public/mojom/frame/frame_replication_state.mojom-forward.h" |
Daniel Cheng | 6ac12817 | 2021-05-25 18:49:01 | [diff] [blame] | 29 | #include "third_party/blink/public/mojom/frame/tree_scope_type.mojom.h" |
danakj | c492bf8 | 2020-09-09 20:02:44 | [diff] [blame] | 30 | #include "third_party/blink/public/mojom/frame/user_activation_update_types.mojom.h" |
| 31 | #include "third_party/blink/public/mojom/security_context/insecure_request_policy.mojom-forward.h" |
| 32 | |
| 33 | #include "url/gurl.h" |
| 34 | #include "url/origin.h" |
| 35 | |
| 36 | namespace content { |
| 37 | |
| 38 | class NavigationRequest; |
| 39 | class RenderFrameHostImpl; |
| 40 | class NavigationEntryImpl; |
| 41 | |
| 42 | // When a page contains iframes, its renderer process maintains a tree structure |
| 43 | // of those frames. We are mirroring this tree in the browser process. This |
| 44 | // class represents a node in this tree and is a wrapper for all objects that |
| 45 | // are frame-specific (as opposed to page-specific). |
| 46 | // |
| 47 | // Each FrameTreeNode has a current RenderFrameHost, which can change over |
| 48 | // time as the frame is navigated. Any immediate subframes of the current |
| 49 | // document are tracked using FrameTreeNodes owned by the current |
| 50 | // RenderFrameHost, rather than as children of FrameTreeNode itself. This |
| 51 | // allows subframe FrameTreeNodes to stay alive while a RenderFrameHost is |
| 52 | // still alive - for example while pending deletion, after a new current |
| 53 | // RenderFrameHost has replaced it. |
| 54 | class CONTENT_EXPORT FrameTreeNode { |
| 55 | public: |
| 56 | class Observer { |
| 57 | public: |
| 58 | // Invoked when a FrameTreeNode is being destroyed. |
| 59 | virtual void OnFrameTreeNodeDestroyed(FrameTreeNode* node) {} |
| 60 | |
| 61 | // Invoked when a FrameTreeNode becomes focused. |
| 62 | virtual void OnFrameTreeNodeFocused(FrameTreeNode* node) {} |
| 63 | |
Fergal Daly | a1d56997 | 2021-03-16 03:24:53 | [diff] [blame] | 64 | virtual ~Observer() = default; |
danakj | c492bf8 | 2020-09-09 20:02:44 | [diff] [blame] | 65 | }; |
| 66 | |
| 67 | static const int kFrameTreeNodeInvalidId; |
| 68 | |
| 69 | // Returns the FrameTreeNode with the given global |frame_tree_node_id|, |
| 70 | // regardless of which FrameTree it is in. |
| 71 | static FrameTreeNode* GloballyFindByID(int frame_tree_node_id); |
| 72 | |
| 73 | // Returns the FrameTreeNode for the given |rfh|. Same as |
| 74 | // rfh->frame_tree_node(), but also supports nullptrs. |
| 75 | static FrameTreeNode* From(RenderFrameHost* rfh); |
| 76 | |
| 77 | // Callers are are expected to initialize sandbox flags separately after |
| 78 | // calling the constructor. |
| 79 | FrameTreeNode( |
| 80 | FrameTree* frame_tree, |
| 81 | RenderFrameHostImpl* parent, |
Daniel Cheng | 6ac12817 | 2021-05-25 18:49:01 | [diff] [blame] | 82 | blink::mojom::TreeScopeType tree_scope_type, |
danakj | c492bf8 | 2020-09-09 20:02:44 | [diff] [blame] | 83 | const std::string& name, |
| 84 | const std::string& unique_name, |
| 85 | bool is_created_by_script, |
| 86 | const base::UnguessableToken& devtools_frame_token, |
| 87 | const blink::mojom::FrameOwnerProperties& frame_owner_properties, |
Kevin McNee | 43fe829 | 2021-10-04 22:59:41 | [diff] [blame] | 88 | blink::FrameOwnerElementType owner_type, |
Dominic Farolino | 08662c8 | 2021-06-11 07:36:34 | [diff] [blame] | 89 | const blink::FramePolicy& frame_owner); |
danakj | c492bf8 | 2020-09-09 20:02:44 | [diff] [blame] | 90 | |
Peter Boström | 828b902 | 2021-09-21 02:28:43 | [diff] [blame] | 91 | FrameTreeNode(const FrameTreeNode&) = delete; |
| 92 | FrameTreeNode& operator=(const FrameTreeNode&) = delete; |
| 93 | |
danakj | c492bf8 | 2020-09-09 20:02:44 | [diff] [blame] | 94 | ~FrameTreeNode(); |
| 95 | |
| 96 | void AddObserver(Observer* observer); |
| 97 | void RemoveObserver(Observer* observer); |
| 98 | |
| 99 | bool IsMainFrame() const; |
| 100 | |
arthursonzogni | 76098e5 | 2020-11-25 14:18:45 | [diff] [blame] | 101 | // Clears any state in this node which was set by the document itself (CSP & |
| 102 | // UserActivationState) and notifies proxies as appropriate. Invoked after |
| 103 | // committing navigation to a new document (since the new document comes with |
| 104 | // a fresh set of CSP). |
| 105 | // TODO(arthursonzogni): Remove this function. The frame/document must not be |
| 106 | // left temporarily with lax state. |
Hiroki Nakagawa | ab30962 | 2021-05-19 16:38:13 | [diff] [blame] | 107 | void ResetForNavigation(); |
danakj | c492bf8 | 2020-09-09 20:02:44 | [diff] [blame] | 108 | |
| 109 | FrameTree* frame_tree() const { return frame_tree_; } |
| 110 | Navigator& navigator() { return frame_tree()->navigator(); } |
| 111 | |
| 112 | RenderFrameHostManager* render_manager() { return &render_manager_; } |
| 113 | int frame_tree_node_id() const { return frame_tree_node_id_; } |
Antonio Sartori | 90f4121 | 2021-01-22 10:08:34 | [diff] [blame] | 114 | const std::string& frame_name() const { return replication_state_->name; } |
danakj | c492bf8 | 2020-09-09 20:02:44 | [diff] [blame] | 115 | |
| 116 | const std::string& unique_name() const { |
Antonio Sartori | 90f4121 | 2021-01-22 10:08:34 | [diff] [blame] | 117 | return replication_state_->unique_name; |
danakj | c492bf8 | 2020-09-09 20:02:44 | [diff] [blame] | 118 | } |
| 119 | |
| 120 | // See comment on the member declaration. |
| 121 | const base::UnguessableToken& devtools_frame_token() const { |
| 122 | return devtools_frame_token_; |
| 123 | } |
| 124 | |
| 125 | size_t child_count() const { return current_frame_host()->child_count(); } |
| 126 | |
danakj | c492bf8 | 2020-09-09 20:02:44 | [diff] [blame] | 127 | RenderFrameHostImpl* parent() const { return parent_; } |
| 128 | |
| 129 | FrameTreeNode* opener() const { return opener_; } |
| 130 | |
| 131 | FrameTreeNode* original_opener() const { return original_opener_; } |
| 132 | |
Anton Bikineev | f62d1bf | 2021-05-15 17:56:07 | [diff] [blame] | 133 | const absl::optional<base::UnguessableToken>& opener_devtools_frame_token() { |
Wolfgang Beyer | d8809db | 2020-09-30 15:29:39 | [diff] [blame] | 134 | return opener_devtools_frame_token_; |
| 135 | } |
| 136 | |
danakj | c492bf8 | 2020-09-09 20:02:44 | [diff] [blame] | 137 | // Gets the total number of descendants to this FrameTreeNode in addition to |
| 138 | // this node. |
| 139 | size_t GetFrameTreeSize() const; |
| 140 | |
| 141 | // Assigns a new opener for this node and, if |opener| is non-null, registers |
| 142 | // an observer that will clear this node's opener if |opener| is ever |
| 143 | // destroyed. |
| 144 | void SetOpener(FrameTreeNode* opener); |
| 145 | |
| 146 | // Assigns the initial opener for this node, and if |opener| is non-null, |
| 147 | // registers an observer that will clear this node's opener if |opener| is |
| 148 | // ever destroyed. The value set here is the root of the tree. |
| 149 | // |
| 150 | // It is not possible to change the opener once it was set. |
| 151 | void SetOriginalOpener(FrameTreeNode* opener); |
| 152 | |
Wolfgang Beyer | d8809db | 2020-09-30 15:29:39 | [diff] [blame] | 153 | // Assigns an opener frame id for this node. This string id is only set once |
| 154 | // and cannot be changed. It persists, even if the |opener| is destroyed. It |
| 155 | // is used for attribution in the DevTools frontend. |
| 156 | void SetOpenerDevtoolsFrameToken( |
| 157 | base::UnguessableToken opener_devtools_frame_token); |
| 158 | |
danakj | c492bf8 | 2020-09-09 20:02:44 | [diff] [blame] | 159 | FrameTreeNode* child_at(size_t index) const { |
| 160 | return current_frame_host()->child_at(index); |
| 161 | } |
| 162 | |
| 163 | // Returns the URL of the last committed page in the current frame. |
| 164 | const GURL& current_url() const { |
| 165 | return current_frame_host()->GetLastCommittedURL(); |
| 166 | } |
| 167 | |
Rakina Zata Amni | 86c88fa | 2021-11-01 01:27:30 | [diff] [blame] | 168 | // Sets the last committed URL for this frame. |
danakj | c492bf8 | 2020-09-09 20:02:44 | [diff] [blame] | 169 | void SetCurrentURL(const GURL& url); |
| 170 | |
Rakina Zata Amni | 86c88fa | 2021-11-01 01:27:30 | [diff] [blame] | 171 | // The frame committed a document that is not the initial empty document. |
| 172 | // Update `has_committed_real_load_` and `is_on_initial_empty_document_` |
| 173 | // accordingly. |
| 174 | void DidCommitNonInitialEmptyDocument(); |
| 175 | |
| 176 | // Returns true if the frame has committed a document that is not the initial |
Rakina Zata Amni | 86c88fa | 2021-11-01 01:27:30 | [diff] [blame] | 177 | // empty document, or if the current document's input stream has been opened |
| 178 | // with document.open(), causing the document to lose its "initial empty |
| 179 | // document" status. For more details, see the definition of |
| 180 | // `is_on_initial_empty_document_`. |
| 181 | bool is_on_initial_empty_document() const { |
| 182 | return is_on_initial_empty_document_; |
Rakina Zata Amni | fc4cc3d4 | 2021-06-10 09:03:56 | [diff] [blame] | 183 | } |
| 184 | |
Rakina Zata Amni | 86c88fa | 2021-11-01 01:27:30 | [diff] [blame] | 185 | // Sets `is_on_initial_empty_document_` to |
Rakina Zata Amni | fc4cc3d4 | 2021-06-10 09:03:56 | [diff] [blame] | 186 | // false. Must only be called after the current document's input stream has |
| 187 | // been opened with document.open(). |
Rakina Zata Amni | 86c88fa | 2021-11-01 01:27:30 | [diff] [blame] | 188 | void DidOpenDocumentInputStream() { is_on_initial_empty_document_ = false; } |
Rakina Zata Amni | d09b611 | 2021-06-05 06:20:14 | [diff] [blame] | 189 | |
danakj | c492bf8 | 2020-09-09 20:02:44 | [diff] [blame] | 190 | // Returns whether the frame's owner element in the parent document is |
| 191 | // collapsed, that is, removed from the layout as if it did not exist, as per |
| 192 | // request by the embedder (of the content/ layer). |
| 193 | bool is_collapsed() const { return is_collapsed_; } |
| 194 | |
| 195 | // Sets whether to collapse the frame's owner element in the parent document, |
| 196 | // that is, to remove it from the layout as if it did not exist, as per |
| 197 | // request by the embedder (of the content/ layer). Cannot be called for main |
| 198 | // frames. |
| 199 | // |
| 200 | // This only has an effect for <iframe> owner elements, and is a no-op when |
| 201 | // called on sub-frames hosted in <frame>, <object>, and <embed> elements. |
| 202 | void SetCollapsed(bool collapsed); |
| 203 | |
| 204 | // Returns the origin of the last committed page in this frame. |
| 205 | // WARNING: To get the last committed origin for a particular |
| 206 | // RenderFrameHost, use RenderFrameHost::GetLastCommittedOrigin() instead, |
| 207 | // which will behave correctly even when the RenderFrameHost is not the |
| 208 | // current one for this frame (such as when it's pending deletion). |
| 209 | const url::Origin& current_origin() const { |
Antonio Sartori | 90f4121 | 2021-01-22 10:08:34 | [diff] [blame] | 210 | return replication_state_->origin; |
danakj | c492bf8 | 2020-09-09 20:02:44 | [diff] [blame] | 211 | } |
| 212 | |
| 213 | // Set the current origin and notify proxies about the update. |
| 214 | void SetCurrentOrigin(const url::Origin& origin, |
| 215 | bool is_potentially_trustworthy_unique_origin); |
| 216 | |
| 217 | // Set the current name and notify proxies about the update. |
| 218 | void SetFrameName(const std::string& name, const std::string& unique_name); |
| 219 | |
danakj | c492bf8 | 2020-09-09 20:02:44 | [diff] [blame] | 220 | // Sets the current insecure request policy, and notifies proxies about the |
| 221 | // update. |
| 222 | void SetInsecureRequestPolicy(blink::mojom::InsecureRequestPolicy policy); |
| 223 | |
| 224 | // Sets the current set of insecure urls to upgrade, and notifies proxies |
| 225 | // about the update. |
| 226 | void SetInsecureNavigationsSet( |
| 227 | const std::vector<uint32_t>& insecure_navigations_set); |
| 228 | |
| 229 | // Returns the latest frame policy (sandbox flags and container policy) for |
| 230 | // this frame. This includes flags inherited from parent frames and the latest |
| 231 | // flags from the <iframe> element hosting this frame. The returned policies |
| 232 | // may not yet have taken effect, since "sandbox" and "allow" attribute |
| 233 | // updates in an <iframe> element take effect on next navigation. To retrieve |
| 234 | // the currently active policy for this frame, use effective_frame_policy(). |
| 235 | 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 Hu | 5130d25e | 2021-03-05 21:53:39 | [diff] [blame] | 252 | // the permissions policy container policy, which is set by the iframe's |
danakj | c492bf8 | 2020-09-09 20:02:44 | [diff] [blame] | 253 | // 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 { |
Antonio Sartori | 90f4121 | 2021-01-22 10:08:34 | [diff] [blame] | 260 | return replication_state_->frame_policy; |
danakj | c492bf8 | 2020-09-09 20:02:44 | [diff] [blame] | 261 | } |
| 262 | |
| 263 | // Set the frame_policy provided in function parameter as active frame policy, |
| 264 | // while leaving pending_frame_policy_ untouched. |
| 265 | bool CommitFramePolicy(const blink::FramePolicy& frame_policy); |
| 266 | |
| 267 | const blink::mojom::FrameOwnerProperties& frame_owner_properties() { |
| 268 | return frame_owner_properties_; |
| 269 | } |
| 270 | |
| 271 | void set_frame_owner_properties( |
| 272 | const blink::mojom::FrameOwnerProperties& frame_owner_properties) { |
| 273 | frame_owner_properties_ = frame_owner_properties; |
| 274 | } |
| 275 | |
| 276 | const network::mojom::ContentSecurityPolicy* csp_attribute() { |
| 277 | return csp_attribute_.get(); |
| 278 | } |
| 279 | |
| 280 | void set_csp_attribute( |
| 281 | network::mojom::ContentSecurityPolicyPtr parsed_csp_attribute) { |
| 282 | csp_attribute_ = std::move(parsed_csp_attribute); |
| 283 | } |
| 284 | |
Antonio Sartori | 5abc8de | 2021-07-13 08:42:47 | [diff] [blame] | 285 | // Reflects the 'anonymous' attribute of the corresponding iframe html |
| 286 | // element. |
| 287 | bool anonymous() const { return anonymous_; } |
| 288 | void set_anonymous(bool anonymous) { anonymous_ = anonymous; } |
| 289 | |
danakj | c492bf8 | 2020-09-09 20:02:44 | [diff] [blame] | 290 | bool HasSameOrigin(const FrameTreeNode& node) const { |
Antonio Sartori | 90f4121 | 2021-01-22 10:08:34 | [diff] [blame] | 291 | return replication_state_->origin.IsSameOriginWith( |
| 292 | node.replication_state_->origin); |
danakj | c492bf8 | 2020-09-09 20:02:44 | [diff] [blame] | 293 | } |
| 294 | |
Gyuyoung Kim | c16e52e9 | 2021-03-19 02:45:37 | [diff] [blame] | 295 | const blink::mojom::FrameReplicationState& current_replication_state() const { |
Antonio Sartori | 90f4121 | 2021-01-22 10:08:34 | [diff] [blame] | 296 | return *replication_state_; |
danakj | c492bf8 | 2020-09-09 20:02:44 | [diff] [blame] | 297 | } |
| 298 | |
| 299 | RenderFrameHostImpl* current_frame_host() const { |
| 300 | return render_manager_.current_frame_host(); |
| 301 | } |
| 302 | |
danakj | c492bf8 | 2020-09-09 20:02:44 | [diff] [blame] | 303 | // Returns true if this node is in a loading state. |
| 304 | bool IsLoading() const; |
| 305 | |
Alex Moshchuk | 9b0fd82 | 2020-10-26 23:08:15 | [diff] [blame] | 306 | // Returns true if this node has a cross-document navigation in progress. |
| 307 | bool HasPendingCrossDocumentNavigation() const; |
| 308 | |
danakj | c492bf8 | 2020-09-09 20:02:44 | [diff] [blame] | 309 | NavigationRequest* navigation_request() { return navigation_request_.get(); } |
| 310 | |
| 311 | // Transfers the ownership of the NavigationRequest to |render_frame_host|. |
| 312 | // From ReadyToCommit to DidCommit, the NavigationRequest is owned by the |
| 313 | // RenderFrameHost that is committing the navigation. |
| 314 | void TransferNavigationRequestOwnership( |
| 315 | RenderFrameHostImpl* render_frame_host); |
| 316 | |
| 317 | // Takes ownership of |navigation_request| and makes it the current |
| 318 | // NavigationRequest of this frame. This corresponds to the start of a new |
| 319 | // navigation. If there was an ongoing navigation request before calling this |
| 320 | // function, it is canceled. |navigation_request| should not be null. |
| 321 | void CreatedNavigationRequest( |
| 322 | std::unique_ptr<NavigationRequest> navigation_request); |
| 323 | |
| 324 | // Resets the current navigation request. If |keep_state| is true, any state |
| 325 | // created by the NavigationRequest (e.g. speculative RenderFrameHost, |
| 326 | // loading state) will not be reset by the function. |
| 327 | void ResetNavigationRequest(bool keep_state); |
| 328 | |
| 329 | // A RenderFrameHost in this node started loading. |
Nate Chapin | 9aabf5f | 2021-11-12 00:31:19 | [diff] [blame^] | 330 | // |should_show_loading_ui| indicates whether this navigation should be |
| 331 | // visible in the UI. True for cross-document navigations and navigations |
| 332 | // intercepted by appHistory's transitionWhile(). |
danakj | c492bf8 | 2020-09-09 20:02:44 | [diff] [blame] | 333 | // |was_previously_loading| is false if the FrameTree was not loading before. |
| 334 | // The caller is required to provide this boolean as the delegate should only |
| 335 | // be notified if the FrameTree went from non-loading to loading state. |
| 336 | // However, when it is called, the FrameTree should be in a loading state. |
Nate Chapin | 9aabf5f | 2021-11-12 00:31:19 | [diff] [blame^] | 337 | void DidStartLoading(bool should_show_loading_ui, |
| 338 | bool was_previously_loading); |
danakj | c492bf8 | 2020-09-09 20:02:44 | [diff] [blame] | 339 | |
| 340 | // A RenderFrameHost in this node stopped loading. |
| 341 | void DidStopLoading(); |
| 342 | |
| 343 | // The load progress for a RenderFrameHost in this node was updated to |
| 344 | // |load_progress|. This will notify the FrameTree which will in turn notify |
| 345 | // the WebContents. |
| 346 | void DidChangeLoadProgress(double load_progress); |
| 347 | |
| 348 | // Called when the user directed the page to stop loading. Stops all loads |
| 349 | // happening in the FrameTreeNode. This method should be used with |
| 350 | // FrameTree::ForEach to stop all loads in the entire FrameTree. |
| 351 | bool StopLoading(); |
| 352 | |
| 353 | // Returns the time this frame was last focused. |
| 354 | base::TimeTicks last_focus_time() const { return last_focus_time_; } |
| 355 | |
| 356 | // Called when this node becomes focused. Updates the node's last focused |
| 357 | // time and notifies observers. |
| 358 | void DidFocus(); |
| 359 | |
| 360 | // Called when the user closed the modal dialogue for BeforeUnload and |
| 361 | // cancelled the navigation. This should stop any load happening in the |
| 362 | // FrameTreeNode. |
| 363 | void BeforeUnloadCanceled(); |
| 364 | |
| 365 | // Returns the BlameContext associated with this node. |
| 366 | FrameTreeNodeBlameContext& blame_context() { return blame_context_; } |
| 367 | |
| 368 | // Updates the user activation state in the browser frame tree and in the |
| 369 | // frame trees in all renderer processes except the renderer for this node |
| 370 | // (which initiated the update). Returns |false| if the update tries to |
| 371 | // consume an already consumed/expired transient state, |true| otherwise. See |
| 372 | // the comment on user_activation_state_ below. |
| 373 | // |
| 374 | // The |notification_type| parameter is used for histograms, only for the case |
| 375 | // |update_state == kNotifyActivation|. |
| 376 | bool UpdateUserActivationState( |
| 377 | blink::mojom::UserActivationUpdateType update_type, |
| 378 | blink::mojom::UserActivationNotificationType notification_type); |
| 379 | |
| 380 | void OnSetHadStickyUserActivationBeforeNavigation(bool value); |
| 381 | |
| 382 | // Returns the sandbox flags currently in effect for this frame. This includes |
| 383 | // flags inherited from parent frames, the currently active flags from the |
| 384 | // <iframe> element hosting this frame, as well as any flags set from a |
| 385 | // Content-Security-Policy HTTP header. This does not include flags that have |
| 386 | // have been updated in an <iframe> element but have not taken effect yet; use |
| 387 | // pending_frame_policy() for those. To see the flags which will take effect |
| 388 | // on navigation (which does not include the CSP-set flags), use |
| 389 | // effective_frame_policy(). |
| 390 | network::mojom::WebSandboxFlags active_sandbox_flags() const { |
Antonio Sartori | 90f4121 | 2021-01-22 10:08:34 | [diff] [blame] | 391 | return replication_state_->active_sandbox_flags; |
danakj | c492bf8 | 2020-09-09 20:02:44 | [diff] [blame] | 392 | } |
| 393 | |
| 394 | // Updates the active sandbox flags in this frame, in response to a |
| 395 | // Content-Security-Policy header adding additional flags, in addition to |
| 396 | // those given to this frame by its parent, or in response to the |
Charlie Hu | 5130d25e | 2021-03-05 21:53:39 | [diff] [blame] | 397 | // Permissions-Policy header being set. Note that on navigation, these updates |
danakj | c492bf8 | 2020-09-09 20:02:44 | [diff] [blame] | 398 | // will be cleared, and the flags in the pending frame policy will be applied |
| 399 | // to the frame. |
Alexander Timin | 45b716c | 2020-11-06 01:40:31 | [diff] [blame] | 400 | // Returns true iff this operation has changed state of either sandbox flags |
Charlie Hu | 5130d25e | 2021-03-05 21:53:39 | [diff] [blame] | 401 | // or permissions policy. |
Alexander Timin | 45b716c | 2020-11-06 01:40:31 | [diff] [blame] | 402 | bool UpdateFramePolicyHeaders( |
danakj | c492bf8 | 2020-09-09 20:02:44 | [diff] [blame] | 403 | network::mojom::WebSandboxFlags sandbox_flags, |
Charlie Hu | e24f0483 | 2021-03-04 21:07:06 | [diff] [blame] | 404 | const blink::ParsedPermissionsPolicy& parsed_header); |
danakj | c492bf8 | 2020-09-09 20:02:44 | [diff] [blame] | 405 | |
| 406 | // Returns whether the frame received a user gesture on a previous navigation |
| 407 | // on the same eTLD+1. |
| 408 | bool has_received_user_gesture_before_nav() const { |
Antonio Sartori | 90f4121 | 2021-01-22 10:08:34 | [diff] [blame] | 409 | return replication_state_->has_received_user_gesture_before_nav; |
danakj | c492bf8 | 2020-09-09 20:02:44 | [diff] [blame] | 410 | } |
| 411 | |
| 412 | // When a tab is discarded, WebContents sets was_discarded on its |
| 413 | // root FrameTreeNode. |
| 414 | // In addition, when a child frame is created, this bit is passed on from |
| 415 | // parent to child. |
| 416 | // When a navigation request is created, was_discarded is passed on to the |
| 417 | // request and reset to false in FrameTreeNode. |
| 418 | void set_was_discarded() { was_discarded_ = true; } |
| 419 | bool was_discarded() const { return was_discarded_; } |
| 420 | |
| 421 | // Returns the sticky bit of the User Activation v2 state of the |
| 422 | // |FrameTreeNode|. |
| 423 | bool HasStickyUserActivation() const { |
| 424 | return user_activation_state_.HasBeenActive(); |
| 425 | } |
| 426 | |
| 427 | // Returns the transient bit of the User Activation v2 state of the |
| 428 | // |FrameTreeNode|. |
| 429 | bool HasTransientUserActivation() { |
| 430 | return user_activation_state_.IsActive(); |
| 431 | } |
| 432 | |
| 433 | // Remove history entries for all frames created by script in this frame's |
| 434 | // subtree. If a frame created by a script is removed, then its history entry |
| 435 | // will never be reused - this saves memory. |
| 436 | void PruneChildFrameNavigationEntries(NavigationEntryImpl* entry); |
| 437 | |
Kevin McNee | 43fe829 | 2021-10-04 22:59:41 | [diff] [blame] | 438 | blink::FrameOwnerElementType frame_owner_element_type() const { |
Daniel Cheng | 9bd90f9 | 2021-04-23 20:49:45 | [diff] [blame] | 439 | return frame_owner_element_type_; |
danakj | c492bf8 | 2020-09-09 20:02:44 | [diff] [blame] | 440 | } |
danakj | c492bf8 | 2020-09-09 20:02:44 | [diff] [blame] | 441 | |
Daniel Cheng | 6ac12817 | 2021-05-25 18:49:01 | [diff] [blame] | 442 | blink::mojom::TreeScopeType tree_scope_type() const { |
| 443 | return tree_scope_type_; |
| 444 | } |
| 445 | |
Alex Turner | 10d557a4 | 2021-06-01 19:06:49 | [diff] [blame] | 446 | void SetIsAdSubframe(bool is_ad_subframe); |
danakj | c492bf8 | 2020-09-09 20:02:44 | [diff] [blame] | 447 | |
arthursonzogni | 034bb9c | 2020-10-01 08:29:56 | [diff] [blame] | 448 | // The initial popup URL for new window opened using: |
| 449 | // `window.open(initial_popup_url)`. |
| 450 | // An empty GURL otherwise. |
| 451 | // |
| 452 | // [WARNING] There is no guarantee the FrameTreeNode will ever host a |
| 453 | // document served from this URL. The FrameTreeNode always starts hosting the |
| 454 | // initial empty document and attempts a navigation toward this URL. However |
| 455 | // the navigation might be delayed, redirected and even cancelled. |
| 456 | void SetInitialPopupURL(const GURL& initial_popup_url); |
| 457 | const GURL& initial_popup_url() const { return initial_popup_url_; } |
| 458 | |
| 459 | // The origin of the document that used window.open() to create this frame. |
| 460 | // Otherwise, an opaque Origin with a nonce different from all previously |
| 461 | // existing Origins. |
| 462 | void SetPopupCreatorOrigin(const url::Origin& popup_creator_origin); |
| 463 | const url::Origin& popup_creator_origin() const { |
| 464 | return popup_creator_origin_; |
| 465 | } |
| 466 | |
Harkiran Bolaria | 59290d6 | 2021-03-17 01:53:01 | [diff] [blame] | 467 | // Sets the associated FrameTree for this node. The node can change FrameTrees |
| 468 | // when blink::features::Prerender2 is enabled, which allows a page loaded in |
| 469 | // the prerendered FrameTree to be used for a navigation in the primary frame |
| 470 | // tree. |
| 471 | void SetFrameTree(FrameTree& frame_tree); |
| 472 | |
Alexander Timin | f785f34 | 2021-03-18 00:00:56 | [diff] [blame] | 473 | // Write a representation of this object into a trace. |
Alexander Timin | bebb200 | 2021-04-20 15:42:24 | [diff] [blame] | 474 | void WriteIntoTrace(perfetto::TracedValue context) const; |
Rakina Zata Amni | 4b1968d | 2021-09-09 03:29:47 | [diff] [blame] | 475 | void WriteIntoTrace( |
| 476 | perfetto::TracedProto<perfetto::protos::pbzero::FrameTreeNodeInfo> proto); |
Alexander Timin | f785f34 | 2021-03-18 00:00:56 | [diff] [blame] | 477 | |
Carlos Caballero | 7671135 | 2021-03-24 17:38:21 | [diff] [blame] | 478 | // Returns true the node is navigating, i.e. it has an associated |
| 479 | // NavigationRequest. |
| 480 | bool HasNavigation(); |
| 481 | |
shivanigithub | f3ddff5 | 2021-07-03 22:06:30 | [diff] [blame] | 482 | // Fenced frames (meta-bug crbug.com/1111084): |
shivanigithub | 4cd016a | 2021-09-20 21:10:30 | [diff] [blame] | 483 | // Note that these two functions cannot be invoked from a FrameTree's or |
| 484 | // its root node's constructor since they require the frame tree and the |
| 485 | // root node to be completely constructed. |
| 486 | // |
shivanigithub | f3ddff5 | 2021-07-03 22:06:30 | [diff] [blame] | 487 | // Returns false if fenced frames are disabled. Returns true if the feature is |
| 488 | // enabled and if |this| is a fenced frame. Returns false for |
| 489 | // iframes embedded in a fenced frame. To clarify: for the MPArch |
| 490 | // implementation this only returns true if |this| is the actual |
| 491 | // root node of the inner FrameTree and not the proxy FrameTreeNode in the |
| 492 | // outer FrameTree. |
Dominic Farolino | 4bc10ee | 2021-08-31 00:37:36 | [diff] [blame] | 493 | bool IsFencedFrameRoot() const; |
shivanigithub | f3ddff5 | 2021-07-03 22:06:30 | [diff] [blame] | 494 | |
| 495 | // Returns false if fenced frames are disabled. Returns true if the |
| 496 | // feature is enabled and if |this| or any of its ancestor nodes is a |
| 497 | // fenced frame. |
| 498 | bool IsInFencedFrameTree() const; |
| 499 | |
shivanigithub | 4cd016a | 2021-09-20 21:10:30 | [diff] [blame] | 500 | // Returns a valid nonce if `IsInFencedFrameTree()` returns true for `this`. |
| 501 | // Returns nullopt otherwise. See comments on `fenced_frame_nonce_` for more |
| 502 | // details. |
| 503 | absl::optional<base::UnguessableToken> fenced_frame_nonce() { |
| 504 | return fenced_frame_nonce_; |
| 505 | } |
| 506 | |
| 507 | // If applicable, set the fenced frame nonce. See comment on |
| 508 | // fenced_frame_nonce() for when it is set to a non-null value. Invoked |
| 509 | // by FrameTree::Init() or FrameTree::AddFrame(). |
| 510 | void SetFencedFrameNonceIfNeeded(); |
| 511 | |
Harkiran Bolaria | b4437fd | 2021-08-11 17:51:22 | [diff] [blame] | 512 | // Sets the unique_name and name fields on replication_state_. To be used in |
| 513 | // prerender activation to make sure the FrameTreeNode replication state is |
| 514 | // correct after the RenderFrameHost is moved between FrameTreeNodes. The |
| 515 | // renderers should already have the correct value, so unlike |
| 516 | // FrameTreeNode::SetFrameName, we do not notify them here. |
| 517 | // TODO(https://crbug.com/1237091): Remove this once the Browsing Instance |
| 518 | // Frame State is implemented. |
| 519 | void set_frame_name_for_activation(const std::string& unique_name, |
| 520 | const std::string& name) { |
| 521 | replication_state_->unique_name = unique_name; |
| 522 | replication_state_->name = name; |
| 523 | } |
| 524 | |
danakj | c492bf8 | 2020-09-09 20:02:44 | [diff] [blame] | 525 | private: |
Charlie Hu | bb5943d | 2021-03-09 19:46:12 | [diff] [blame] | 526 | FRIEND_TEST_ALL_PREFIXES(SitePerProcessPermissionsPolicyBrowserTest, |
danakj | c492bf8 | 2020-09-09 20:02:44 | [diff] [blame] | 527 | ContainerPolicyDynamic); |
Charlie Hu | bb5943d | 2021-03-09 19:46:12 | [diff] [blame] | 528 | FRIEND_TEST_ALL_PREFIXES(SitePerProcessPermissionsPolicyBrowserTest, |
danakj | c492bf8 | 2020-09-09 20:02:44 | [diff] [blame] | 529 | ContainerPolicySandboxDynamic); |
| 530 | |
| 531 | class OpenerDestroyedObserver; |
| 532 | |
danakj | c492bf8 | 2020-09-09 20:02:44 | [diff] [blame] | 533 | // The |notification_type| parameter is used for histograms only. |
| 534 | bool NotifyUserActivation( |
| 535 | blink::mojom::UserActivationNotificationType notification_type); |
| 536 | |
| 537 | bool ConsumeTransientUserActivation(); |
| 538 | |
| 539 | bool ClearUserActivation(); |
| 540 | |
| 541 | // Verify that the renderer process is allowed to set user activation on this |
| 542 | // frame by checking whether this frame's RenderWidgetHost had previously seen |
| 543 | // an input event that might lead to user activation. If user activation |
| 544 | // should be allowed, this returns true and also clears corresponding pending |
| 545 | // user activation state in the widget. Otherwise, this returns false. |
| 546 | bool VerifyUserActivation(); |
| 547 | |
| 548 | // The next available browser-global FrameTreeNode ID. |
| 549 | static int next_frame_tree_node_id_; |
| 550 | |
| 551 | // The FrameTree that owns us. |
| 552 | FrameTree* frame_tree_; // not owned. |
| 553 | |
danakj | c492bf8 | 2020-09-09 20:02:44 | [diff] [blame] | 554 | // A browser-global identifier for the frame in the page, which stays stable |
| 555 | // even if the frame does a cross-process navigation. |
| 556 | const int frame_tree_node_id_; |
| 557 | |
| 558 | // The RenderFrameHost owning this FrameTreeNode, which cannot change for the |
| 559 | // life of this FrameTreeNode. |nullptr| if this node is the root. |
| 560 | RenderFrameHostImpl* const parent_; |
| 561 | |
danakj | c492bf8 | 2020-09-09 20:02:44 | [diff] [blame] | 562 | // The frame that opened this frame, if any. Will be set to null if the |
| 563 | // opener is closed, or if this frame disowns its opener by setting its |
| 564 | // window.opener to null. |
arthursonzogni | 9816b919 | 2021-03-29 16:09:19 | [diff] [blame] | 565 | FrameTreeNode* opener_ = nullptr; |
danakj | c492bf8 | 2020-09-09 20:02:44 | [diff] [blame] | 566 | |
| 567 | // An observer that clears this node's |opener_| if the opener is destroyed. |
| 568 | // This observer is added to the |opener_|'s observer list when the |opener_| |
| 569 | // is set to a non-null node, and it is removed from that list when |opener_| |
| 570 | // changes or when this node is destroyed. It is also cleared if |opener_| |
| 571 | // is disowned. |
| 572 | std::unique_ptr<OpenerDestroyedObserver> opener_observer_; |
| 573 | |
| 574 | // The frame that opened this frame, if any. Contrary to opener_, this |
| 575 | // cannot be changed unless the original opener is destroyed. |
arthursonzogni | 9816b919 | 2021-03-29 16:09:19 | [diff] [blame] | 576 | FrameTreeNode* original_opener_ = nullptr; |
danakj | c492bf8 | 2020-09-09 20:02:44 | [diff] [blame] | 577 | |
Wolfgang Beyer | d8809db | 2020-09-30 15:29:39 | [diff] [blame] | 578 | // The devtools frame token of the frame which opened this frame. This is |
| 579 | // not cleared even if the opener is destroyed or disowns the frame. |
Anton Bikineev | f62d1bf | 2021-05-15 17:56:07 | [diff] [blame] | 580 | absl::optional<base::UnguessableToken> opener_devtools_frame_token_; |
Wolfgang Beyer | d8809db | 2020-09-30 15:29:39 | [diff] [blame] | 581 | |
danakj | c492bf8 | 2020-09-09 20:02:44 | [diff] [blame] | 582 | // An observer that clears this node's |original_opener_| if the opener is |
| 583 | // destroyed. |
| 584 | std::unique_ptr<OpenerDestroyedObserver> original_opener_observer_; |
| 585 | |
arthursonzogni | 034bb9c | 2020-10-01 08:29:56 | [diff] [blame] | 586 | // When created by an opener, the URL specified in window.open(url) |
| 587 | // Please refer to {Get,Set}InitialPopupURL() documentation. |
| 588 | GURL initial_popup_url_; |
| 589 | |
| 590 | // When created using window.open, the origin of the creator. |
| 591 | // Please refer to {Get,Set}PopupCreatorOrigin() documentation. |
| 592 | url::Origin popup_creator_origin_; |
| 593 | |
Rakina Zata Amni | 86c88fa | 2021-11-01 01:27:30 | [diff] [blame] | 594 | // Whether this frame is still on the initial about:blank document or the |
| 595 | // synchronously committed about:blank document committed at frame creation, |
| 596 | // and its "initial empty document"-ness is still true. |
| 597 | // This will be false if either of these has happened: |
| 598 | // - SetCurrentUrl() was called after committing a document that is not the |
| 599 | // initial about:blank document or the synchronously committed about:blank |
| 600 | // document, per |
| 601 | // https://html.spec.whatwg.org/multipage/browsers.html#creating-browsing-contexts:is-initial-about:blank |
| 602 | // - The document's input stream has been opened with document.open(), per |
| 603 | // https://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#opening-the-input-stream:is-initial-about:blank |
| 604 | // NOTE: we treat both the "initial about:blank document" and the |
| 605 | // "synchronously committed about:blank document" as the initial empty |
| 606 | // document. In the future, we plan to remove the synchronous about:blank |
| 607 | // commit so that this state will only be true if the frame is on the |
| 608 | // "initial about:blank document". See also: |
| 609 | // - https://github.com/whatwg/html/issues/6863 |
| 610 | // - https://crbug.com/1215096 |
| 611 | bool is_on_initial_empty_document_ = true; |
Rakina Zata Amni | fc4cc3d4 | 2021-06-10 09:03:56 | [diff] [blame] | 612 | |
danakj | c492bf8 | 2020-09-09 20:02:44 | [diff] [blame] | 613 | // Whether the frame's owner element in the parent document is collapsed. |
arthursonzogni | 9816b919 | 2021-03-29 16:09:19 | [diff] [blame] | 614 | bool is_collapsed_ = false; |
danakj | c492bf8 | 2020-09-09 20:02:44 | [diff] [blame] | 615 | |
Daniel Cheng | 6ac12817 | 2021-05-25 18:49:01 | [diff] [blame] | 616 | // The type of frame owner for this frame. This is only relevant for non-main |
| 617 | // frames. |
Kevin McNee | 43fe829 | 2021-10-04 22:59:41 | [diff] [blame] | 618 | const blink::FrameOwnerElementType frame_owner_element_type_ = |
| 619 | blink::FrameOwnerElementType::kNone; |
Daniel Cheng | 9bd90f9 | 2021-04-23 20:49:45 | [diff] [blame] | 620 | |
Daniel Cheng | 6ac12817 | 2021-05-25 18:49:01 | [diff] [blame] | 621 | // The tree scope type of frame owner element, i.e. whether the element is in |
| 622 | // the document tree (https://dom.spec.whatwg.org/#document-trees) or the |
| 623 | // shadow tree (https://dom.spec.whatwg.org/#shadow-trees). This is only |
| 624 | // relevant for non-main frames. |
| 625 | const blink::mojom::TreeScopeType tree_scope_type_ = |
| 626 | blink::mojom::TreeScopeType::kDocument; |
| 627 | |
danakj | c492bf8 | 2020-09-09 20:02:44 | [diff] [blame] | 628 | // Track information that needs to be replicated to processes that have |
| 629 | // proxies for this frame. |
Gyuyoung Kim | c16e52e9 | 2021-03-19 02:45:37 | [diff] [blame] | 630 | blink::mojom::FrameReplicationStatePtr replication_state_; |
danakj | c492bf8 | 2020-09-09 20:02:44 | [diff] [blame] | 631 | |
| 632 | // Track the pending sandbox flags and container policy for this frame. When a |
| 633 | // parent frame dynamically updates 'sandbox', 'allow', 'allowfullscreen', |
| 634 | // 'allowpaymentrequest' or 'src' attributes, the updated policy for the frame |
Antonio Sartori | 90f4121 | 2021-01-22 10:08:34 | [diff] [blame] | 635 | // is stored here, and transferred into replication_state_->frame_policy when |
danakj | c492bf8 | 2020-09-09 20:02:44 | [diff] [blame] | 636 | // they take effect on the next frame navigation. |
| 637 | blink::FramePolicy pending_frame_policy_; |
| 638 | |
| 639 | // Whether the frame was created by javascript. This is useful to prune |
| 640 | // history entries when the frame is removed (because frames created by |
| 641 | // scripts are never recreated with the same unique name - see |
| 642 | // https://crbug.com/500260). |
arthursonzogni | 9816b919 | 2021-03-29 16:09:19 | [diff] [blame] | 643 | const bool is_created_by_script_; |
danakj | c492bf8 | 2020-09-09 20:02:44 | [diff] [blame] | 644 | |
| 645 | // Used for devtools instrumentation and trace-ability. The token is |
| 646 | // propagated to Blink's LocalFrame and both Blink and content/ |
| 647 | // can tag calls and requests with this token in order to attribute them |
| 648 | // to the context frame. |
| 649 | // |devtools_frame_token_| is only defined by the browser process and is never |
| 650 | // sent back from the renderer in the control calls. It should be never used |
| 651 | // to look up the FrameTreeNode instance. |
arthursonzogni | 9816b919 | 2021-03-29 16:09:19 | [diff] [blame] | 652 | const base::UnguessableToken devtools_frame_token_; |
danakj | c492bf8 | 2020-09-09 20:02:44 | [diff] [blame] | 653 | |
| 654 | // Tracks the scrolling and margin properties for this frame. These |
| 655 | // properties affect the child renderer but are stored on its parent's |
| 656 | // frame element. When this frame's parent dynamically updates these |
| 657 | // properties, we update them here too. |
| 658 | // |
| 659 | // Note that dynamic updates only take effect on the next frame navigation. |
| 660 | blink::mojom::FrameOwnerProperties frame_owner_properties_; |
| 661 | |
| 662 | // Contains the current parsed value of the 'csp' attribute of this frame. |
| 663 | network::mojom::ContentSecurityPolicyPtr csp_attribute_; |
| 664 | |
Antonio Sartori | 5abc8de | 2021-07-13 08:42:47 | [diff] [blame] | 665 | // Reflects the 'anonymous' attribute of the corresponding iframe html |
| 666 | // element. |
| 667 | bool anonymous_ = false; |
| 668 | |
danakj | c492bf8 | 2020-09-09 20:02:44 | [diff] [blame] | 669 | // Owns an ongoing NavigationRequest until it is ready to commit. It will then |
| 670 | // be reset and a RenderFrameHost will be responsible for the navigation. |
| 671 | std::unique_ptr<NavigationRequest> navigation_request_; |
| 672 | |
| 673 | // List of objects observing this FrameTreeNode. |
| 674 | base::ObserverList<Observer>::Unchecked observers_; |
| 675 | |
| 676 | base::TimeTicks last_focus_time_; |
| 677 | |
arthursonzogni | 9816b919 | 2021-03-29 16:09:19 | [diff] [blame] | 678 | bool was_discarded_ = false; |
danakj | c492bf8 | 2020-09-09 20:02:44 | [diff] [blame] | 679 | |
| 680 | // The user activation state of the current frame. See |UserActivationState| |
| 681 | // for details on how this state is maintained. |
| 682 | blink::UserActivationState user_activation_state_; |
| 683 | |
| 684 | // A helper for tracing the snapshots of this FrameTreeNode and attributing |
| 685 | // browser process activities to this node (when possible). It is unrelated |
| 686 | // to the core logic of FrameTreeNode. |
| 687 | FrameTreeNodeBlameContext blame_context_; |
| 688 | |
shivanigithub | 4cd016a | 2021-09-20 21:10:30 | [diff] [blame] | 689 | // Fenced Frames: |
| 690 | // Nonce used in the net::IsolationInfo and blink::StorageKey for a fenced |
| 691 | // frame and any iframes nested within it. Not set if this frame is not in a |
| 692 | // fenced frame's FrameTree. Note that this could be a field in FrameTree for |
| 693 | // the MPArch version but for the shadow DOM version we need to keep it here |
| 694 | // since the fenced frame root is not a main frame for the latter. The value |
| 695 | // of the nonce will be the same for all of the the frames inside a fenced |
| 696 | // frame tree. If there is a nested fenced frame it will have a different |
| 697 | // nonce than its parent fenced frame. The nonce will stay the same across |
| 698 | // navigations because it is always used in conjunction with other fields of |
| 699 | // the keys. If the navigation is same-origin/site then the same network stack |
| 700 | // partition/storage will be reused and if it's cross-origin/site then other |
| 701 | // parts of the key will change and so, even with the same nonce, another |
| 702 | // partition will be used. |
| 703 | absl::optional<base::UnguessableToken> fenced_frame_nonce_; |
| 704 | |
Lukasz Anforowicz | 14714196 | 2020-12-16 18:03:24 | [diff] [blame] | 705 | // Manages creation and swapping of RenderFrameHosts for this frame. |
| 706 | // |
| 707 | // This field needs to be declared last, because destruction of |
| 708 | // RenderFrameHostManager may call arbitrary callbacks (e.g. via |
| 709 | // WebContentsObserver::DidFinishNavigation fired after RenderFrameHostManager |
| 710 | // destructs a RenderFrameHostImpl and its NavigationRequest). Such callbacks |
| 711 | // may try to use FrameTreeNode's fields above - this would be an undefined |
| 712 | // behavior if the fields (even trivially-destructible ones) were destructed |
| 713 | // before the RenderFrameHostManager's destructor runs. See also |
| 714 | // https://crbug.com/1157988. |
| 715 | RenderFrameHostManager render_manager_; |
danakj | c492bf8 | 2020-09-09 20:02:44 | [diff] [blame] | 716 | }; |
| 717 | |
| 718 | } // namespace content |
| 719 | |
| 720 | #endif // CONTENT_BROWSER_RENDERER_HOST_FRAME_TREE_NODE_H_ |