blob: 020a243216827a05b16fed13fa3dd648a49741e9 [file] [log] [blame]
danakjc492bf82020-09-09 20:02:441// 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_H_
6#define CONTENT_BROWSER_RENDERER_HOST_FRAME_TREE_H_
7
8#include <stdint.h>
9
10#include <iterator>
11#include <memory>
12#include <string>
13#include <unordered_map>
14
15#include "base/callback.h"
16#include "base/containers/queue.h"
Carlos Caballero101ac26b2021-03-24 11:54:0517#include "base/dcheck_is_on.h"
danakjc492bf82020-09-09 20:02:4418#include "base/gtest_prod_util.h"
19#include "base/macros.h"
20#include "content/browser/renderer_host/navigator.h"
21#include "content/browser/renderer_host/navigator_delegate.h"
22#include "content/browser/renderer_host/render_frame_host_manager.h"
23#include "content/common/content_export.h"
24#include "mojo/public/cpp/bindings/pending_receiver.h"
25#include "services/service_manager/public/mojom/interface_provider.mojom.h"
Chris Hamilton3ff6ed0e2021-02-19 03:54:0426#include "third_party/blink/public/common/tokens/tokens.h"
danakjc492bf82020-09-09 20:02:4427#include "third_party/blink/public/mojom/frame/frame_owner_element_type.mojom.h"
28#include "third_party/blink/public/mojom/frame/frame_owner_properties.mojom-forward.h"
29
30namespace blink {
Lei Zhang4a867672021-07-19 06:30:1431namespace mojom {
32class BrowserInterfaceBroker;
33enum class TreeScopeType;
34} // namespace mojom
35
danakjc492bf82020-09-09 20:02:4436struct FramePolicy;
37} // namespace blink
38
39namespace content {
40
Carlos Caballero40b0efd2021-01-26 11:55:0041class BrowserContext;
Jeremy Roman2d8dfe132021-07-06 20:51:2642class PageDelegate;
Lei Zhang4a867672021-07-19 06:30:1443class PageImpl;
danakjc492bf82020-09-09 20:02:4444class RenderFrameHostDelegate;
45class RenderViewHostDelegate;
46class RenderViewHostImpl;
47class RenderFrameHostManager;
48class RenderWidgetHostDelegate;
Carlos Caballero40b0efd2021-01-26 11:55:0049class SiteInstance;
danakjc492bf82020-09-09 20:02:4450
51// Represents the frame tree for a page. With the exception of the main frame,
52// all FrameTreeNodes will be created/deleted in response to frame attach and
53// detach events in the DOM.
54//
55// The main frame's FrameTreeNode is special in that it is reused. This allows
56// it to serve as an anchor for state that needs to persist across top-level
57// page navigations.
58//
59// TODO(ajwong): Move NavigationController ownership to the main frame
60// FrameTreeNode. Possibly expose access to it from here.
61//
62// This object is only used on the UI thread.
63class CONTENT_EXPORT FrameTree {
64 public:
65 class NodeRange;
66
67 class CONTENT_EXPORT NodeIterator
68 : public std::iterator<std::forward_iterator_tag, FrameTreeNode> {
69 public:
70 NodeIterator(const NodeIterator& other);
71 ~NodeIterator();
72
73 NodeIterator& operator++();
Kevin McNee5f594382021-05-06 23:18:2374 // Advances the iterator and excludes the children of the current node
75 NodeIterator& AdvanceSkippingChildren();
danakjc492bf82020-09-09 20:02:4476
77 bool operator==(const NodeIterator& rhs) const;
78 bool operator!=(const NodeIterator& rhs) const { return !(*this == rhs); }
79
80 FrameTreeNode* operator*() { return current_node_; }
81
82 private:
Jayson Adams4db0bfe22021-07-15 19:24:0783 friend class FrameTreeTest;
danakjc492bf82020-09-09 20:02:4484 friend class NodeRange;
85
Kevin McNee5f594382021-05-06 23:18:2386 NodeIterator(const std::vector<FrameTreeNode*>& starting_nodes,
87 const FrameTreeNode* root_of_subtree_to_skip,
88 bool should_descend_into_inner_trees);
89
90 void AdvanceNode();
danakjc492bf82020-09-09 20:02:4491
92 FrameTreeNode* current_node_;
Kevin McNee5f594382021-05-06 23:18:2393 const FrameTreeNode* const root_of_subtree_to_skip_;
94 const bool should_descend_into_inner_trees_;
Jayson Adams4db0bfe22021-07-15 19:24:0795 base::circular_deque<FrameTreeNode*> queue_;
danakjc492bf82020-09-09 20:02:4496 };
97
98 class CONTENT_EXPORT NodeRange {
99 public:
Kevin McNee5f594382021-05-06 23:18:23100 NodeRange(const NodeRange&);
101 ~NodeRange();
102
danakjc492bf82020-09-09 20:02:44103 NodeIterator begin();
104 NodeIterator end();
105
106 private:
107 friend class FrameTree;
108
Kevin McNee5f594382021-05-06 23:18:23109 NodeRange(const std::vector<FrameTreeNode*>& starting_nodes,
110 const FrameTreeNode* root_of_subtree_to_skip,
111 bool should_descend_into_inner_trees);
danakjc492bf82020-09-09 20:02:44112
Kevin McNee5f594382021-05-06 23:18:23113 const std::vector<FrameTreeNode*> starting_nodes_;
114 const FrameTreeNode* const root_of_subtree_to_skip_;
115 const bool should_descend_into_inner_trees_;
danakjc492bf82020-09-09 20:02:44116 };
117
Carlos Caballero03262522021-02-05 14:49:58118 class CONTENT_EXPORT Delegate {
119 public:
120 // A RenderFrameHost in the specified |frame_tree_node| started loading a
121 // new document. This corresponds to browser UI starting to show a spinner
122 // or other visual indicator for loading. This method is only invoked if the
123 // FrameTree hadn't been previously loading. |to_different_document| will be
124 // true unless the load is a fragment navigation, or triggered by
125 // history.pushState/replaceState.
126 virtual void DidStartLoading(FrameTreeNode* frame_tree_node,
127 bool to_different_document) = 0;
128
Takashi Toyoshima74090df62021-03-09 14:34:57129 // This is called when all nodes in the FrameTree stopped loading. This
Carlos Caballero03262522021-02-05 14:49:58130 // corresponds to the browser UI stop showing a spinner or other visual
131 // indicator for loading.
132 virtual void DidStopLoading() = 0;
133
134 // The load progress was changed.
135 virtual void DidChangeLoadProgress() = 0;
Carlos Caballero6ff6ace2021-02-05 16:53:00136
137 // Returns true when the active RenderWidgetHostView should be hidden.
138 virtual bool IsHidden() = 0;
Sreeja Kamishettya21b4f62021-06-25 07:48:25139
Sreeja Kamishetty53468972021-07-13 11:53:32140 // Called when current Page of this frame tree changes to `page`.
141 virtual void NotifyPageChanged(PageImpl& page) = 0;
Dominic Farolinoedf44ee2021-07-20 23:50:59142
143 // If the FrameTree using this delegate is an inner/nested FrameTree, then
144 // there may be a FrameTreeNode in the outer FrameTree that is considered
145 // our outer delegate FrameTreeNode. This method returns the outer delegate
146 // FrameTreeNode ID if one exists. If we don't have a an outer delegate
147 // FrameTreeNode, this method returns
148 // FrameTreeNode::kFrameTreeNodeInvalidId.
149 virtual int GetOuterDelegateFrameTreeNodeId() = 0;
Carlos Caballero03262522021-02-05 14:49:58150 };
151
Sreeja Kamishetty74bacd522021-03-22 17:04:24152 // Type of FrameTree instance.
153 enum class Type {
154 // This FrameTree is the primary frame tree for the WebContents, whose main
155 // document URL is shown in the Omnibox.
156 kPrimary,
157
158 // This FrameTree is used to prerender a page in the background which is
159 // invisible to the user.
Dominic Farolino4bc10ee2021-08-31 00:37:36160 kPrerender,
161
162 // This FrameTree is used to host the contents of a <fencedframe> element.
163 // Even for <fencedframe>s hosted inside a prerendered page, the FrameTree
164 // associated with the fenced frame will be kFencedFrame, but the
165 // RenderFrameHosts inside of it will have their lifecycle state set to
166 // `RenderFrameHost::LifecycleState::kActive`.
167 //
168 // TODO(crbug.com/1232528, crbug.com/1244274): We should either:
169 // * Fully support nested FrameTrees inside prerendered pages, in which
170 // case all of the RenderFrameHosts inside the nested trees should have
171 // their lifecycle state set to kPrerendering, or...
172 // * Ban nested FrameTrees in prerendered pages, and therefore obsolete the
173 // above paragraph about <fencedframe>s hosted in prerendered pages.
174 kFencedFrame
Sreeja Kamishetty74bacd522021-03-22 17:04:24175 };
Sreeja Kamishetty837a10402021-04-23 12:41:59176
177 // A set of delegates are remembered here so that we can create
178 // RenderFrameHostManagers.
179 FrameTree(BrowserContext* browser_context,
180 Delegate* delegate,
181 NavigationControllerDelegate* navigation_controller_delegate,
182 NavigatorDelegate* navigator_delegate,
183 RenderFrameHostDelegate* render_frame_delegate,
184 RenderViewHostDelegate* render_view_delegate,
185 RenderWidgetHostDelegate* render_widget_delegate,
186 RenderFrameHostManager::Delegate* manager_delegate,
Jeremy Roman2d8dfe132021-07-06 20:51:26187 PageDelegate* page_delegate,
Sreeja Kamishetty837a10402021-04-23 12:41:59188 Type type);
Peter Boström828b9022021-09-21 02:28:43189
190 FrameTree(const FrameTree&) = delete;
191 FrameTree& operator=(const FrameTree&) = delete;
192
Sreeja Kamishetty837a10402021-04-23 12:41:59193 ~FrameTree();
Sreeja Kamishetty74bacd522021-03-22 17:04:24194
Carlos Caballero40b0efd2021-01-26 11:55:00195 // Initializes the main frame for this FrameTree. That is it creates the
196 // initial RenderFrameHost in the root node's RenderFrameHostManager. This
197 // method will call back into the delegates so it should only be called once
198 // they have completed their initialization.
199 // TODO(carlscab): It would be great if initialization could happened in the
200 // constructor so we do not leave objects in a half initialized state.
201 void Init(SiteInstance* main_frame_site_instance,
202 bool renderer_initiated_creation,
Sreeja Kamishetty837a10402021-04-23 12:41:59203 const std::string& main_frame_name);
204
205 Type type() const { return type_; }
Carlos Caballero40b0efd2021-01-26 11:55:00206
danakjc492bf82020-09-09 20:02:44207 FrameTreeNode* root() const { return root_; }
208
Sreeja Kamishetty74bacd522021-03-22 17:04:24209 bool is_prerendering() const { return type_ == FrameTree::Type::kPrerender; }
Sreeja Kamishetty46f762c2021-02-05 07:52:46210
Carlos Caballero03262522021-02-05 14:49:58211 Delegate* delegate() { return delegate_; }
212
Jeremy Roman2d8dfe132021-07-06 20:51:26213 // Delegates for various objects. These can be kept centrally on the
214 // FrameTree because they are expected to be the same for all frames on a
215 // given FrameTree.
danakjc492bf82020-09-09 20:02:44216 RenderFrameHostDelegate* render_frame_delegate() {
217 return render_frame_delegate_;
218 }
219 RenderViewHostDelegate* render_view_delegate() {
220 return render_view_delegate_;
221 }
222 RenderWidgetHostDelegate* render_widget_delegate() {
223 return render_widget_delegate_;
224 }
225 RenderFrameHostManager::Delegate* manager_delegate() {
226 return manager_delegate_;
227 }
Jeremy Roman2d8dfe132021-07-06 20:51:26228 PageDelegate* page_delegate() { return page_delegate_; }
Aaron Colwell78b4bde2021-03-16 16:16:09229
Albert J. Wong1b6dc962021-07-09 18:06:57230 using RenderViewHostMapId = base::IdType32<class RenderViewHostMap>;
Aaron Colwell78b4bde2021-03-16 16:16:09231 using RenderViewHostMap = std::unordered_map<RenderViewHostMapId,
232 RenderViewHostImpl*,
233 RenderViewHostMapId::Hasher>;
234 const RenderViewHostMap& render_view_hosts() const {
danakjc492bf82020-09-09 20:02:44235 return render_view_host_map_;
236 }
237
238 // Returns the FrameTreeNode with the given |frame_tree_node_id| if it is part
239 // of this FrameTree.
240 FrameTreeNode* FindByID(int frame_tree_node_id);
241
242 // Returns the FrameTreeNode with the given renderer-specific |routing_id|.
243 FrameTreeNode* FindByRoutingID(int process_id, int routing_id);
244
245 // Returns the first frame in this tree with the given |name|, or the main
246 // frame if |name| is empty.
247 // Note that this does NOT support pseudo-names like _self, _top, and _blank,
248 // nor searching other FrameTrees (unlike blink::WebView::findFrameByName).
249 FrameTreeNode* FindByName(const std::string& name);
250
251 // Returns a range to iterate over all FrameTreeNodes in the frame tree in
252 // breadth-first traversal order.
253 NodeRange Nodes();
254
255 // Returns a range to iterate over all FrameTreeNodes in a subtree of the
256 // frame tree, starting from |subtree_root|.
257 NodeRange SubtreeNodes(FrameTreeNode* subtree_root);
258
Kevin McNee5f594382021-05-06 23:18:23259 // Returns a range to iterate over all FrameTreeNodes in a subtree, starting
260 // from, but not including |parent|, as well as any FrameTreeNodes of inner
261 // frame trees.
262 static NodeRange SubtreeAndInnerTreeNodes(RenderFrameHostImpl* parent);
263
danakjc492bf82020-09-09 20:02:44264 // Adds a new child frame to the frame tree. |process_id| is required to
265 // disambiguate |new_routing_id|, and it must match the process of the
266 // |parent| node. Otherwise no child is added and this method returns false.
267 // |interface_provider_receiver| is the receiver end of the InterfaceProvider
268 // interface through which the child RenderFrame can access Mojo services
269 // exposed by the corresponding RenderFrameHost. The caller takes care of
Antonio Sartoridb967c52021-01-20 09:54:30270 // sending the client end of the interface down to the
271 // RenderFrame. |policy_container_bind_params|, if not null, is used for
272 // binding Blink's policy container to the new RenderFrameHost's
273 // PolicyContainerHost. This is only needed if this frame is the result of the
274 // CreateChildFrame mojo call, which also delivers the
275 // |policy_container_bind_params|.
danakjc492bf82020-09-09 20:02:44276 FrameTreeNode* AddFrame(
277 RenderFrameHostImpl* parent,
278 int process_id,
279 int new_routing_id,
danakj0bdfacd2021-01-20 19:27:18280 mojo::PendingAssociatedRemote<mojom::Frame> frame_remote,
danakjc492bf82020-09-09 20:02:44281 mojo::PendingReceiver<blink::mojom::BrowserInterfaceBroker>
282 browser_interface_broker_receiver,
Antonio Sartoridb967c52021-01-20 09:54:30283 blink::mojom::PolicyContainerBindParamsPtr policy_container_bind_params,
danakjc492bf82020-09-09 20:02:44284 blink::mojom::TreeScopeType scope,
285 const std::string& frame_name,
286 const std::string& frame_unique_name,
287 bool is_created_by_script,
Chris Hamilton3ff6ed0e2021-02-19 03:54:04288 const blink::LocalFrameToken& frame_token,
danakjc492bf82020-09-09 20:02:44289 const base::UnguessableToken& devtools_frame_token,
290 const blink::FramePolicy& frame_policy,
291 const blink::mojom::FrameOwnerProperties& frame_owner_properties,
292 bool was_discarded,
293 blink::mojom::FrameOwnerElementType owner_type);
294
295 // Removes a frame from the frame tree. |child|, its children, and objects
296 // owned by their RenderFrameHostManagers are immediately deleted. The root
297 // node cannot be removed this way.
298 void RemoveFrame(FrameTreeNode* child);
299
300 // This method walks the entire frame tree and creates a RenderFrameProxyHost
301 // for the given |site_instance| in each node except the |source| one --
302 // the source will have a RenderFrameHost. |source| may be null if there is
303 // no node navigating in this frame tree (such as when this is called
304 // for an opener's frame tree), in which case no nodes are skipped for
305 // RenderFrameProxyHost creation.
306 void CreateProxiesForSiteInstance(FrameTreeNode* source,
307 SiteInstance* site_instance);
308
309 // Convenience accessor for the main frame's RenderFrameHostImpl.
310 RenderFrameHostImpl* GetMainFrame() const;
311
312 // Returns the focused frame.
313 FrameTreeNode* GetFocusedFrame();
314
315 // Sets the focused frame to |node|. |source| identifies the SiteInstance
316 // that initiated this focus change. If this FrameTree has SiteInstances
317 // other than |source|, those SiteInstances will be notified about the new
318 // focused frame. Note that |source| may differ from |node|'s current
319 // SiteInstance (e.g., this happens for cross-process window.focus() calls).
320 void SetFocusedFrame(FrameTreeNode* node, SiteInstance* source);
321
danakjc492bf82020-09-09 20:02:44322 // Creates a RenderViewHostImpl for a given |site_instance| in the tree.
323 //
324 // The RenderFrameHostImpls and the RenderFrameProxyHosts will share ownership
325 // of this object.
326 scoped_refptr<RenderViewHostImpl> CreateRenderViewHost(
327 SiteInstance* site_instance,
328 int32_t main_frame_routing_id,
danakj08eb51d2020-12-30 20:15:23329 bool swapped_out,
330 bool renderer_initiated_creation);
danakjc492bf82020-09-09 20:02:44331
332 // Returns the existing RenderViewHost for a new RenderFrameHost.
333 // There should always be such a RenderViewHost, because the main frame
334 // RenderFrameHost for each SiteInstance should be created before subframes.
335 scoped_refptr<RenderViewHostImpl> GetRenderViewHost(
336 SiteInstance* site_instance);
337
Aaron Colwell78b4bde2021-03-16 16:16:09338 // Returns the ID used for the RenderViewHost associated with |site_instance|.
339 // Note: Callers should not assume that there is a 1:1 mapping between
340 // SiteInstances and IDs returned by this function, since several
341 // SiteInstances may share a RenderViewHost.
342 RenderViewHostMapId GetRenderViewHostMapId(SiteInstance* site_instance) const;
343
danakjc492bf82020-09-09 20:02:44344 // Registers a RenderViewHost so that it can be reused by other frames
Aaron Colwell78b4bde2021-03-16 16:16:09345 // whose SiteInstance maps to the same RenderViewHostMapId.
danakjc492bf82020-09-09 20:02:44346 //
347 // This method does not take ownership of|rvh|.
348 //
349 // NOTE: This method CHECK fails if a RenderViewHost is already registered for
350 // |rvh|'s SiteInstance.
351 //
352 // ALSO NOTE: After calling RegisterRenderViewHost, UnregisterRenderViewHost
353 // *must* be called for |rvh| when it is destroyed or put into the
354 // BackForwardCache, to prevent FrameTree::CreateRenderViewHost from trying to
355 // reuse it.
Aaron Colwell78b4bde2021-03-16 16:16:09356 void RegisterRenderViewHost(RenderViewHostMapId id, RenderViewHostImpl* rvh);
danakjc492bf82020-09-09 20:02:44357
358 // Unregisters the RenderViewHostImpl that's available for reuse for a
Aaron Colwell78b4bde2021-03-16 16:16:09359 // particular RenderViewHostMapId. NOTE: This method CHECK fails if it is
360 // called for a |render_view_host| that is not currently set for reuse.
361 void UnregisterRenderViewHost(RenderViewHostMapId id,
Aaron Colwellc4bd7d62021-01-29 04:23:13362 RenderViewHostImpl* render_view_host);
danakjc492bf82020-09-09 20:02:44363
364 // This is called when the frame is about to be removed and started to run
365 // unload handlers.
366 void FrameUnloading(FrameTreeNode* frame);
367
368 // This is only meant to be called by FrameTreeNode. Triggers calling
369 // the listener installed by SetFrameRemoveListener.
370 void FrameRemoved(FrameTreeNode* frame);
371
Carlos Caballero03262522021-02-05 14:49:58372 void DidStartLoadingNode(FrameTreeNode& node,
373 bool to_different_document,
374 bool was_previously_loading);
375 void DidStopLoadingNode(FrameTreeNode& node);
Carlos Caballero03262522021-02-05 14:49:58376 void DidCancelLoading();
danakjc492bf82020-09-09 20:02:44377
Sreeja Kamishetty0be3b1b2021-08-12 17:04:15378 // Returns this FrameTree's total load progress. If the `root_` FrameTreeNode
379 // is navigating returns `blink::kInitialLoadProgress`.
380 double GetLoadProgress();
danakjc492bf82020-09-09 20:02:44381
382 // Returns true if at least one of the nodes in this FrameTree is loading.
383 bool IsLoading() const;
384
385 // Set page-level focus in all SiteInstances involved in rendering
386 // this FrameTree, not including the current main frame's
387 // SiteInstance. The focus update will be sent via the main frame's proxies
388 // in those SiteInstances.
389 void ReplicatePageFocus(bool is_focused);
390
391 // Updates page-level focus for this FrameTree in the subframe renderer
392 // identified by |instance|.
393 void SetPageFocus(SiteInstance* instance, bool is_focused);
394
395 // Walks the current frame tree and registers any origins matching |origin|,
396 // either the last committed origin of a RenderFrameHost or the origin
397 // associated with a NavigationRequest that has been assigned to a
398 // SiteInstance, as not-opted-in for origin isolation.
399 void RegisterExistingOriginToPreventOptInIsolation(
400 const url::Origin& previously_visited_origin,
401 NavigationRequest* navigation_request_to_exclude);
402
Carlos Caballero40b0efd2021-01-26 11:55:00403 NavigationControllerImpl& controller() { return navigator_.controller(); }
danakjc492bf82020-09-09 20:02:44404 Navigator& navigator() { return navigator_; }
405
Carlos Caballeroede6f8c2021-01-28 11:01:50406 // Another page accessed the initial empty main document, which means it
407 // is no longer safe to display a pending URL without risking a URL spoof.
408 void DidAccessInitialMainDocument();
409
410 bool has_accessed_initial_main_document() const {
411 return has_accessed_initial_main_document_;
412 }
413
414 void ResetHasAccessedInitialMainDocument() {
415 has_accessed_initial_main_document_ = false;
416 }
417
Carlos Caballero6ff6ace2021-02-05 16:53:00418 bool IsHidden() const { return delegate_->IsHidden(); }
419
Carlos Caballero03262522021-02-05 14:49:58420 // Stops all ongoing navigations in each of the nodes of this FrameTree.
421 void StopLoading();
422
Carlos Caballero101ac26b2021-03-24 11:54:05423 // Prepares this frame tree for destruction, cleaning up the internal state
424 // and firing the appropriate events like FrameDeleted.
425 // Must be called before FrameTree is destroyed.
426 void Shutdown();
427
Takashi Toyoshimaea534ef22021-07-21 03:27:59428 bool IsBeingDestroyed() const { return is_being_destroyed_; }
429
danakjc492bf82020-09-09 20:02:44430 private:
431 friend class FrameTreeTest;
432 FRIEND_TEST_ALL_PREFIXES(RenderFrameHostImplBrowserTest, RemoveFocusedFrame);
433
434 // Returns a range to iterate over all FrameTreeNodes in the frame tree in
435 // breadth-first traversal order, skipping the subtree rooted at
436 // |node|, but including |node| itself.
437 NodeRange NodesExceptSubtree(FrameTreeNode* node);
438
Carlos Caballero03262522021-02-05 14:49:58439 Delegate* const delegate_;
440
danakjc492bf82020-09-09 20:02:44441 // These delegates are installed into all the RenderViewHosts and
442 // RenderFrameHosts that we create.
443 RenderFrameHostDelegate* render_frame_delegate_;
444 RenderViewHostDelegate* render_view_delegate_;
445 RenderWidgetHostDelegate* render_widget_delegate_;
446 RenderFrameHostManager::Delegate* manager_delegate_;
Jeremy Roman2d8dfe132021-07-06 20:51:26447 PageDelegate* page_delegate_;
danakjc492bf82020-09-09 20:02:44448
449 // The Navigator object responsible for managing navigations on this frame
Carlos Caballero40b0efd2021-01-26 11:55:00450 // tree. Each FrameTreeNode will default to using it for navigation tasks in
451 // the frame.
danakjc492bf82020-09-09 20:02:44452 Navigator navigator_;
453
Aaron Colwell78b4bde2021-03-16 16:16:09454 // Map of RenderViewHostMapId to RenderViewHost. This allows us to look up the
danakjc492bf82020-09-09 20:02:44455 // RenderViewHost for a given SiteInstance when creating RenderFrameHosts.
456 // Each RenderViewHost maintains a refcount and is deleted when there are no
457 // more RenderFrameHosts or RenderFrameProxyHosts using it.
Aaron Colwell78b4bde2021-03-16 16:16:09458 RenderViewHostMap render_view_host_map_;
danakjc492bf82020-09-09 20:02:44459
460 // This is an owned ptr to the root FrameTreeNode, which never changes over
461 // the lifetime of the FrameTree. It is not a scoped_ptr because we need the
462 // pointer to remain valid even while the FrameTreeNode is being destroyed,
463 // since it's common for a node to test whether it's the root node.
464 FrameTreeNode* root_;
465
466 int focused_frame_tree_node_id_;
467
danakjc492bf82020-09-09 20:02:44468 // Overall load progress.
469 double load_progress_;
470
Carlos Caballeroede6f8c2021-01-28 11:01:50471 // Whether the initial empty page has been accessed by another page, making it
472 // unsafe to show the pending URL. Usually false unless another window tries
473 // to modify the blank page. Always false after the first commit.
474 bool has_accessed_initial_main_document_ = false;
475
Sreeja Kamishetty837a10402021-04-23 12:41:59476 // Indicates type of frame tree.
477 const Type type_;
Sreeja Kamishetty74bacd522021-03-22 17:04:24478
Takashi Toyoshimaea534ef22021-07-21 03:27:59479 bool is_being_destroyed_ = false;
480
Carlos Caballero101ac26b2021-03-24 11:54:05481#if DCHECK_IS_ON()
482 // Whether Shutdown() was called.
483 bool was_shut_down_ = false;
484#endif
danakjc492bf82020-09-09 20:02:44485};
486
487} // namespace content
488
489#endif // CONTENT_BROWSER_RENDERER_HOST_FRAME_TREE_H_