[email protected] | 9b159a5 | 2013-10-03 17:24:55 | [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 | |
danakj | c492bf8 | 2020-09-09 20:02:44 | [diff] [blame] | 5 | #include "content/browser/renderer_host/frame_tree_node.h" |
[email protected] | 9b159a5 | 2013-10-03 17:24:55 | [diff] [blame] | 6 | |
Daniel Cheng | 6ca7f1c9 | 2017-08-09 21:45:41 | [diff] [blame] | 7 | #include <math.h> |
[email protected] | 9b159a5 | 2013-10-03 17:24:55 | [diff] [blame] | 8 | #include <queue> |
Takuto Ikuta | adf31eb | 2019-01-05 00:32:48 | [diff] [blame] | 9 | #include <unordered_map> |
dcheng | 36b6aec9 | 2015-12-26 06:16:36 | [diff] [blame] | 10 | #include <utility> |
[email protected] | 9b159a5 | 2013-10-03 17:24:55 | [diff] [blame] | 11 | |
Mustaq Ahmed | a5dfa60b | 2018-12-08 00:30:14 | [diff] [blame] | 12 | #include "base/feature_list.h" |
scottmg | 6ece5ae | 2017-02-01 18:25:19 | [diff] [blame] | 13 | #include "base/lazy_instance.h" |
avi | b734894 | 2015-12-25 20:57:10 | [diff] [blame] | 14 | #include "base/macros.h" |
Liviu Tinta | d9391fb9 | 2020-09-28 23:50:07 | [diff] [blame] | 15 | #include "base/metrics/histogram_functions.h" |
dcheng | 23ca947d | 2016-05-04 20:04:15 | [diff] [blame] | 16 | #include "base/metrics/histogram_macros.h" |
Daniel Cheng | 6ca7f1c9 | 2017-08-09 21:45:41 | [diff] [blame] | 17 | #include "base/strings/string_util.h" |
Andrey Kosyakov | f2d4ff7 | 2018-10-29 20:09:59 | [diff] [blame] | 18 | #include "content/browser/devtools/devtools_instrumentation.h" |
danakj | c492bf8 | 2020-09-09 20:02:44 | [diff] [blame] | 19 | #include "content/browser/renderer_host/navigation_controller_impl.h" |
| 20 | #include "content/browser/renderer_host/navigation_request.h" |
| 21 | #include "content/browser/renderer_host/navigator.h" |
| 22 | #include "content/browser/renderer_host/navigator_delegate.h" |
| 23 | #include "content/browser/renderer_host/render_frame_host_impl.h" |
[email protected] | 94d0cc1 | 2013-12-18 00:07:41 | [diff] [blame] | 24 | #include "content/browser/renderer_host/render_view_host_impl.h" |
Lucas Furukawa Gadani | ef8290a | 2019-07-29 20:27:51 | [diff] [blame] | 25 | #include "content/common/navigation_params.h" |
| 26 | #include "content/common/navigation_params_utils.h" |
dmazzoni | e950ea23 | 2015-03-13 21:39:45 | [diff] [blame] | 27 | #include "content/public/browser/browser_thread.h" |
Mustaq Ahmed | a5dfa60b | 2018-12-08 00:30:14 | [diff] [blame] | 28 | #include "content/public/common/content_features.h" |
arthursonzogni | b93a447 | 2020-04-10 07:38:00 | [diff] [blame] | 29 | #include "services/network/public/cpp/web_sandbox_flags.h" |
| 30 | #include "services/network/public/mojom/web_sandbox_flags.mojom-shared.h" |
Harkiran Bolaria | 59290d6 | 2021-03-17 01:53:01 | [diff] [blame] | 31 | #include "third_party/blink/public/common/features.h" |
Antonio Gomes | 4b2c513 | 2020-01-16 11:49:48 | [diff] [blame] | 32 | #include "third_party/blink/public/mojom/frame/user_activation_update_types.mojom.h" |
Julie Jeongeun Kim | d90e2dd | 2020-03-03 11:45:37 | [diff] [blame] | 33 | #include "third_party/blink/public/mojom/security_context/insecure_request_policy.mojom.h" |
[email protected] | 9b159a5 | 2013-10-03 17:24:55 | [diff] [blame] | 34 | |
| 35 | namespace content { |
| 36 | |
dmazzoni | e950ea23 | 2015-03-13 21:39:45 | [diff] [blame] | 37 | namespace { |
| 38 | |
| 39 | // This is a global map between frame_tree_node_ids and pointers to |
| 40 | // FrameTreeNodes. |
Takuto Ikuta | adf31eb | 2019-01-05 00:32:48 | [diff] [blame] | 41 | typedef std::unordered_map<int, FrameTreeNode*> FrameTreeNodeIdMap; |
dmazzoni | e950ea23 | 2015-03-13 21:39:45 | [diff] [blame] | 42 | |
scottmg | 5e65e3a | 2017-03-08 08:48:46 | [diff] [blame] | 43 | base::LazyInstance<FrameTreeNodeIdMap>::DestructorAtExit |
| 44 | g_frame_tree_node_id_map = LAZY_INSTANCE_INITIALIZER; |
dmazzoni | e950ea23 | 2015-03-13 21:39:45 | [diff] [blame] | 45 | |
fdegans | a696e511 | 2015-04-17 01:57:59 | [diff] [blame] | 46 | // These values indicate the loading progress status. The minimum progress |
| 47 | // value matches what Blink's ProgressTracker has traditionally used for a |
| 48 | // minimum progress value. |
fdegans | a696e511 | 2015-04-17 01:57:59 | [diff] [blame] | 49 | const double kLoadingProgressMinimum = 0.1; |
| 50 | const double kLoadingProgressDone = 1.0; |
dmazzoni | e950ea23 | 2015-03-13 21:39:45 | [diff] [blame] | 51 | |
fdegans | a696e511 | 2015-04-17 01:57:59 | [diff] [blame] | 52 | } // namespace |
fdegans | 1d1635516 | 2015-03-26 11:58:34 | [diff] [blame] | 53 | |
alexmos | e201c7cd | 2015-06-10 17:14:21 | [diff] [blame] | 54 | // This observer watches the opener of its owner FrameTreeNode and clears the |
| 55 | // owner's opener if the opener is destroyed. |
| 56 | class FrameTreeNode::OpenerDestroyedObserver : public FrameTreeNode::Observer { |
| 57 | public: |
jochen | 6004a36 | 2017-02-04 00:11:40 | [diff] [blame] | 58 | OpenerDestroyedObserver(FrameTreeNode* owner, bool observing_original_opener) |
| 59 | : owner_(owner), observing_original_opener_(observing_original_opener) {} |
alexmos | e201c7cd | 2015-06-10 17:14:21 | [diff] [blame] | 60 | |
| 61 | // FrameTreeNode::Observer |
| 62 | void OnFrameTreeNodeDestroyed(FrameTreeNode* node) override { |
jochen | 6004a36 | 2017-02-04 00:11:40 | [diff] [blame] | 63 | if (observing_original_opener_) { |
Avi Drissman | 36465f33 | 2017-09-11 20:49:39 | [diff] [blame] | 64 | // The "original owner" is special. It's used for attribution, and clients |
| 65 | // walk down the original owner chain. Therefore, if a link in the chain |
| 66 | // is being destroyed, reconnect the observation to the parent of the link |
| 67 | // being destroyed. |
jochen | 6004a36 | 2017-02-04 00:11:40 | [diff] [blame] | 68 | CHECK_EQ(owner_->original_opener(), node); |
Avi Drissman | 36465f33 | 2017-09-11 20:49:39 | [diff] [blame] | 69 | owner_->SetOriginalOpener(node->original_opener()); |
| 70 | // |this| is deleted at this point. |
jochen | 6004a36 | 2017-02-04 00:11:40 | [diff] [blame] | 71 | } else { |
| 72 | CHECK_EQ(owner_->opener(), node); |
| 73 | owner_->SetOpener(nullptr); |
Avi Drissman | 36465f33 | 2017-09-11 20:49:39 | [diff] [blame] | 74 | // |this| is deleted at this point. |
jochen | 6004a36 | 2017-02-04 00:11:40 | [diff] [blame] | 75 | } |
alexmos | e201c7cd | 2015-06-10 17:14:21 | [diff] [blame] | 76 | } |
| 77 | |
| 78 | private: |
| 79 | FrameTreeNode* owner_; |
jochen | 6004a36 | 2017-02-04 00:11:40 | [diff] [blame] | 80 | bool observing_original_opener_; |
alexmos | e201c7cd | 2015-06-10 17:14:21 | [diff] [blame] | 81 | |
| 82 | DISALLOW_COPY_AND_ASSIGN(OpenerDestroyedObserver); |
| 83 | }; |
| 84 | |
Kevin McNee | 88e6155 | 2020-10-22 20:41:11 | [diff] [blame] | 85 | const int FrameTreeNode::kFrameTreeNodeInvalidId = -1; |
| 86 | |
| 87 | static_assert(FrameTreeNode::kFrameTreeNodeInvalidId == |
| 88 | RenderFrameHost::kNoFrameTreeNodeId, |
| 89 | "Have consistent sentinel values for an invalid FTN id."); |
| 90 | |
vishal.b | 782eb5d | 2015-04-29 12:22:57 | [diff] [blame] | 91 | int FrameTreeNode::next_frame_tree_node_id_ = 1; |
[email protected] | 9b159a5 | 2013-10-03 17:24:55 | [diff] [blame] | 92 | |
dmazzoni | e950ea23 | 2015-03-13 21:39:45 | [diff] [blame] | 93 | // static |
vishal.b | 782eb5d | 2015-04-29 12:22:57 | [diff] [blame] | 94 | FrameTreeNode* FrameTreeNode::GloballyFindByID(int frame_tree_node_id) { |
mostynb | 366eaf1 | 2015-03-26 00:51:19 | [diff] [blame] | 95 | DCHECK_CURRENTLY_ON(BrowserThread::UI); |
rob | 9725074 | 2015-12-10 17:45:15 | [diff] [blame] | 96 | FrameTreeNodeIdMap* nodes = g_frame_tree_node_id_map.Pointer(); |
jdoerrie | 55ec69d | 2018-10-08 13:34:46 | [diff] [blame] | 97 | auto it = nodes->find(frame_tree_node_id); |
dmazzoni | e950ea23 | 2015-03-13 21:39:45 | [diff] [blame] | 98 | return it == nodes->end() ? nullptr : it->second; |
| 99 | } |
| 100 | |
Alexander Timin | 381e7e18 | 2020-04-28 19:04:03 | [diff] [blame] | 101 | // static |
| 102 | FrameTreeNode* FrameTreeNode::From(RenderFrameHost* rfh) { |
| 103 | if (!rfh) |
| 104 | return nullptr; |
| 105 | return static_cast<RenderFrameHostImpl*>(rfh)->frame_tree_node(); |
| 106 | } |
| 107 | |
Julie Jeongeun Kim | 70a2e4e | 2020-02-21 05:09:54 | [diff] [blame] | 108 | FrameTreeNode::FrameTreeNode( |
| 109 | FrameTree* frame_tree, |
Alexander Timin | 381e7e18 | 2020-04-28 19:04:03 | [diff] [blame] | 110 | RenderFrameHostImpl* parent, |
Daniel Cheng | 6ac12817 | 2021-05-25 18:49:01 | [diff] [blame] | 111 | blink::mojom::TreeScopeType tree_scope_type, |
Julie Jeongeun Kim | 70a2e4e | 2020-02-21 05:09:54 | [diff] [blame] | 112 | const std::string& name, |
| 113 | const std::string& unique_name, |
| 114 | bool is_created_by_script, |
| 115 | const base::UnguessableToken& devtools_frame_token, |
| 116 | const blink::mojom::FrameOwnerProperties& frame_owner_properties, |
Dominic Farolino | 08662c8 | 2021-06-11 07:36:34 | [diff] [blame^] | 117 | blink::mojom::FrameOwnerElementType owner_type, |
| 118 | const blink::FramePolicy& frame_policy) |
[email protected] | bffc830 | 2014-01-23 20:52:16 | [diff] [blame] | 119 | : frame_tree_(frame_tree), |
[email protected] | bffc830 | 2014-01-23 20:52:16 | [diff] [blame] | 120 | frame_tree_node_id_(next_frame_tree_node_id_++), |
xiaochengh | 9848816 | 2016-05-19 15:17:59 | [diff] [blame] | 121 | parent_(parent), |
Alexander Timin | 381e7e18 | 2020-04-28 19:04:03 | [diff] [blame] | 122 | depth_(parent ? parent->frame_tree_node()->depth_ + 1 : 0u), |
Daniel Cheng | 9bd90f9 | 2021-04-23 20:49:45 | [diff] [blame] | 123 | frame_owner_element_type_(owner_type), |
Daniel Cheng | 6ac12817 | 2021-05-25 18:49:01 | [diff] [blame] | 124 | tree_scope_type_(tree_scope_type), |
Gyuyoung Kim | c16e52e9 | 2021-03-19 02:45:37 | [diff] [blame] | 125 | replication_state_(blink::mojom::FrameReplicationState::New( |
Antonio Sartori | 90f4121 | 2021-01-22 10:08:34 | [diff] [blame] | 126 | url::Origin(), |
estark | a886b8d | 2015-12-18 21:53:08 | [diff] [blame] | 127 | name, |
lukasza | 464d869 | 2016-02-22 19:26:32 | [diff] [blame] | 128 | unique_name, |
Charlie Hu | e24f0483 | 2021-03-04 21:07:06 | [diff] [blame] | 129 | blink::ParsedPermissionsPolicy(), |
Antonio Sartori | 90f4121 | 2021-01-22 10:08:34 | [diff] [blame] | 130 | network::mojom::WebSandboxFlags::kNone, |
Dominic Farolino | 08662c8 | 2021-06-11 07:36:34 | [diff] [blame^] | 131 | frame_policy, |
Daniel Cheng | 9bd90f9 | 2021-04-23 20:49:45 | [diff] [blame] | 132 | // should enforce strict mixed content checking |
| 133 | blink::mojom::InsecureRequestPolicy::kLeaveInsecureRequestsAlone, |
| 134 | // hashes of hosts for insecure request upgrades |
| 135 | std::vector<uint32_t>(), |
japhet | 61835ae1 | 2017-01-20 01:25:39 | [diff] [blame] | 136 | false /* is a potentially trustworthy unique origin */, |
danakj | 359a434 | 2020-05-29 20:38:39 | [diff] [blame] | 137 | false /* has an active user gesture */, |
Ehsan Karamad | 192a8da | 2018-10-21 03:48:08 | [diff] [blame] | 138 | false /* has received a user gesture before nav */, |
Alex Turner | 10d557a4 | 2021-06-01 19:06:49 | [diff] [blame] | 139 | false /* is_ad_subframe */)), |
Dominic Farolino | 08662c8 | 2021-06-11 07:36:34 | [diff] [blame^] | 140 | pending_frame_policy_(frame_policy), |
Lukasz Anforowicz | 7bfb2e9 | 2017-11-22 17:19:45 | [diff] [blame] | 141 | is_created_by_script_(is_created_by_script), |
Pavel Feldman | 2523472 | 2017-10-11 02:49:06 | [diff] [blame] | 142 | devtools_frame_token_(devtools_frame_token), |
lazyboy | 70605c3 | 2015-11-03 01:27:31 | [diff] [blame] | 143 | frame_owner_properties_(frame_owner_properties), |
Lukasz Anforowicz | 14714196 | 2020-12-16 18:03:24 | [diff] [blame] | 144 | blame_context_(frame_tree_node_id_, FrameTreeNode::From(parent)), |
| 145 | render_manager_(this, frame_tree->manager_delegate()) { |
rob | 9725074 | 2015-12-10 17:45:15 | [diff] [blame] | 146 | std::pair<FrameTreeNodeIdMap::iterator, bool> result = |
dmazzoni | e950ea23 | 2015-03-13 21:39:45 | [diff] [blame] | 147 | g_frame_tree_node_id_map.Get().insert( |
| 148 | std::make_pair(frame_tree_node_id_, this)); |
| 149 | CHECK(result.second); |
benjhayden | d4da63d | 2016-03-11 21:29:33 | [diff] [blame] | 150 | |
xiaochengh | b9554bb | 2016-05-21 14:20:48 | [diff] [blame] | 151 | // Note: this should always be done last in the constructor. |
| 152 | blame_context_.Initialize(); |
alexmos | 998581d | 2015-01-22 01:01:59 | [diff] [blame] | 153 | } |
[email protected] | 9b159a5 | 2013-10-03 17:24:55 | [diff] [blame] | 154 | |
| 155 | FrameTreeNode::~FrameTreeNode() { |
Harkiran Bolaria | 59290d6 | 2021-03-17 01:53:01 | [diff] [blame] | 156 | // The current frame host may be null when destroying the old frame tree |
| 157 | // during prerender activation. However, in such cases, the FrameTree and its |
| 158 | // root FrameTreeNode objects are deleted immediately with activation. In all |
| 159 | // other cases, there should always be a current frame host. |
Harkiran Bolaria | 59290d6 | 2021-03-17 01:53:01 | [diff] [blame] | 160 | if (current_frame_host()) { |
| 161 | // Remove the children. |
| 162 | current_frame_host()->ResetChildren(); |
Lukasz Anforowicz | 7bfb2e9 | 2017-11-22 17:19:45 | [diff] [blame] | 163 | |
Harkiran Bolaria | 59290d6 | 2021-03-17 01:53:01 | [diff] [blame] | 164 | current_frame_host()->ResetLoadingState(); |
| 165 | } else { |
Hiroki Nakagawa | 0a90bd4 | 2021-04-21 01:53:05 | [diff] [blame] | 166 | DCHECK(blink::features::IsPrerender2Enabled()); |
Harkiran Bolaria | 59290d6 | 2021-03-17 01:53:01 | [diff] [blame] | 167 | DCHECK(!parent()); // Only main documents can be activated. |
| 168 | DCHECK(!opener()); // Prerendered frame trees can't have openers. |
| 169 | |
| 170 | // Activation is not allowed during ongoing navigations. |
| 171 | DCHECK(!navigation_request_); |
| 172 | |
Carlos Caballero | d1c8043 | 2021-04-20 08:16:32 | [diff] [blame] | 173 | // TODO(https://crbug.com/1199693): Need to determine how to handle pending |
Harkiran Bolaria | 59290d6 | 2021-03-17 01:53:01 | [diff] [blame] | 174 | // deletions, as observers will be notified. |
| 175 | DCHECK(!render_manager()->speculative_frame_host()); |
| 176 | } |
Nate Chapin | 22ea659 | 2019-03-05 22:29:02 | [diff] [blame] | 177 | |
Lukasz Anforowicz | 7bfb2e9 | 2017-11-22 17:19:45 | [diff] [blame] | 178 | // If the removed frame was created by a script, then its history entry will |
| 179 | // never be reused - we can save some memory by removing the history entry. |
| 180 | // See also https://crbug.com/784356. |
| 181 | if (is_created_by_script_ && parent_) { |
Carlos Caballero | 04aab36 | 2021-02-15 17:38:16 | [diff] [blame] | 182 | NavigationEntryImpl* nav_entry = |
| 183 | navigator().controller().GetLastCommittedEntry(); |
Lukasz Anforowicz | 7bfb2e9 | 2017-11-22 17:19:45 | [diff] [blame] | 184 | if (nav_entry) { |
| 185 | nav_entry->RemoveEntryForFrame(this, |
| 186 | /* only_if_different_position = */ false); |
| 187 | } |
| 188 | } |
| 189 | |
dmazzoni | e950ea23 | 2015-03-13 21:39:45 | [diff] [blame] | 190 | frame_tree_->FrameRemoved(this); |
Carlos Caballero | 6ff6ace | 2021-02-05 16:53:00 | [diff] [blame] | 191 | |
| 192 | // Do not dispatch notification for the root frame as ~WebContentsImpl already |
| 193 | // dispatches it for now. |
| 194 | // TODO(https://crbug.com/1170277): This is only needed because the FrameTree |
| 195 | // is a member of WebContentsImpl and we would call back into it during |
| 196 | // destruction. We should clean up the FrameTree destruction code and call the |
| 197 | // delegate unconditionally. |
| 198 | if (parent()) |
| 199 | render_manager_.delegate()->OnFrameTreeNodeDestroyed(this); |
| 200 | |
ericwilligers | 254597b | 2016-10-17 10:32:31 | [diff] [blame] | 201 | for (auto& observer : observers_) |
| 202 | observer.OnFrameTreeNodeDestroyed(this); |
Lukasz Anforowicz | 14714196 | 2020-12-16 18:03:24 | [diff] [blame] | 203 | observers_.Clear(); |
alexmos | e201c7cd | 2015-06-10 17:14:21 | [diff] [blame] | 204 | |
| 205 | if (opener_) |
| 206 | opener_->RemoveObserver(opener_observer_.get()); |
jochen | 6004a36 | 2017-02-04 00:11:40 | [diff] [blame] | 207 | if (original_opener_) |
| 208 | original_opener_->RemoveObserver(original_opener_observer_.get()); |
dmazzoni | e950ea23 | 2015-03-13 21:39:45 | [diff] [blame] | 209 | |
| 210 | g_frame_tree_node_id_map.Get().erase(frame_tree_node_id_); |
jam | 39258caf | 2016-11-02 14:48:18 | [diff] [blame] | 211 | |
danakj | f940060 | 2019-06-07 15:44:58 | [diff] [blame] | 212 | bool did_stop_loading = false; |
| 213 | |
jam | 39258caf | 2016-11-02 14:48:18 | [diff] [blame] | 214 | if (navigation_request_) { |
danakj | f940060 | 2019-06-07 15:44:58 | [diff] [blame] | 215 | navigation_request_.reset(); |
Arthur Hemery | 0dd6581 | 2019-08-01 14:18:45 | [diff] [blame] | 216 | // If a frame with a pending navigation is detached, make sure the |
| 217 | // WebContents (and its observers) update their loading state. |
danakj | f940060 | 2019-06-07 15:44:58 | [diff] [blame] | 218 | did_stop_loading = true; |
jam | 39258caf | 2016-11-02 14:48:18 | [diff] [blame] | 219 | } |
Nate Chapin | 22ea659 | 2019-03-05 22:29:02 | [diff] [blame] | 220 | |
danakj | f940060 | 2019-06-07 15:44:58 | [diff] [blame] | 221 | // ~SiteProcessCountTracker DCHECKs in some tests if the speculative |
| 222 | // RenderFrameHostImpl is not destroyed last. Ideally this would be closer to |
| 223 | // (possible before) the ResetLoadingState() call above. |
| 224 | // |
| 225 | // There is an inherent race condition causing bugs 838348/915179/et al, where |
| 226 | // the renderer may have committed the speculative main frame and the browser |
| 227 | // has not heard about it yet. If this is a main frame, then in that case the |
| 228 | // speculative RenderFrame was unable to be deleted (it is owned by the |
| 229 | // renderer) and we should not be able to cancel the navigation at this point. |
| 230 | // CleanUpNavigation() would normally be called here but it will try to undo |
| 231 | // the navigation and expose the race condition. When it replaces the main |
| 232 | // frame with a RenderFrameProxy, that leaks the committed main frame, leaving |
| 233 | // the frame and its friend group with pointers that will become invalid |
| 234 | // shortly as we are shutting everything down and deleting the RenderView etc. |
| 235 | // We avoid this problematic situation by not calling CleanUpNavigation() or |
| 236 | // DiscardUnusedFrame() here. The speculative RenderFrameHost is simply |
| 237 | // returned and deleted immediately. This satisfies the requirement that the |
| 238 | // speculative RenderFrameHost is removed from the RenderFrameHostManager |
| 239 | // before it is destroyed. |
| 240 | if (render_manager_.speculative_frame_host()) { |
| 241 | did_stop_loading |= render_manager_.speculative_frame_host()->is_loading(); |
| 242 | render_manager_.UnsetSpeculativeRenderFrameHost(); |
| 243 | } |
| 244 | |
| 245 | if (did_stop_loading) |
| 246 | DidStopLoading(); |
| 247 | |
Harkiran Bolaria | 59290d6 | 2021-03-17 01:53:01 | [diff] [blame] | 248 | // IsLoading() requires that current_frame_host() is non-null. |
| 249 | DCHECK(!current_frame_host() || !IsLoading()); |
[email protected] | 9b159a5 | 2013-10-03 17:24:55 | [diff] [blame] | 250 | } |
| 251 | |
alexmos | e201c7cd | 2015-06-10 17:14:21 | [diff] [blame] | 252 | void FrameTreeNode::AddObserver(Observer* observer) { |
| 253 | observers_.AddObserver(observer); |
| 254 | } |
| 255 | |
| 256 | void FrameTreeNode::RemoveObserver(Observer* observer) { |
| 257 | observers_.RemoveObserver(observer); |
| 258 | } |
| 259 | |
[email protected] | 94d0cc1 | 2013-12-18 00:07:41 | [diff] [blame] | 260 | bool FrameTreeNode::IsMainFrame() const { |
| 261 | return frame_tree_->root() == this; |
| 262 | } |
| 263 | |
Hiroki Nakagawa | ab30962 | 2021-05-19 16:38:13 | [diff] [blame] | 264 | void FrameTreeNode::ResetForNavigation() { |
arthursonzogni | 76098e5 | 2020-11-25 14:18:45 | [diff] [blame] | 265 | // This frame has had its user activation bits cleared in the renderer before |
| 266 | // arriving here. We just need to clear them here and in the other renderer |
| 267 | // processes that may have a reference to this frame. |
Alexander Timin | 45b716c | 2020-11-06 01:40:31 | [diff] [blame] | 268 | // |
| 269 | // We do not take user activation into account when calculating |
| 270 | // |ResetForNavigationResult|, as we are using it to determine bfcache |
| 271 | // eligibility and the page can get another user gesture after restore. |
Antonio Gomes | 4b2c513 | 2020-01-16 11:49:48 | [diff] [blame] | 272 | UpdateUserActivationState( |
Mustaq Ahmed | dc195e5b | 2020-08-04 18:45:11 | [diff] [blame] | 273 | blink::mojom::UserActivationUpdateType::kClearActivation, |
| 274 | blink::mojom::UserActivationNotificationType::kNone); |
Ian Clelland | 5cbaaf8 | 2017-11-27 22:00:03 | [diff] [blame] | 275 | } |
| 276 | |
yilkal | 34a3d75 | 2019-08-30 18:20:30 | [diff] [blame] | 277 | size_t FrameTreeNode::GetFrameTreeSize() const { |
| 278 | if (is_collapsed()) |
| 279 | return 0; |
| 280 | |
| 281 | size_t size = 0; |
| 282 | for (size_t i = 0; i < child_count(); i++) { |
| 283 | size += child_at(i)->GetFrameTreeSize(); |
| 284 | } |
| 285 | |
| 286 | // Account for this node. |
| 287 | size++; |
| 288 | return size; |
| 289 | } |
| 290 | |
alexmos | e201c7cd | 2015-06-10 17:14:21 | [diff] [blame] | 291 | void FrameTreeNode::SetOpener(FrameTreeNode* opener) { |
| 292 | if (opener_) { |
| 293 | opener_->RemoveObserver(opener_observer_.get()); |
| 294 | opener_observer_.reset(); |
| 295 | } |
| 296 | |
| 297 | opener_ = opener; |
| 298 | |
| 299 | if (opener_) { |
Jeremy Roman | 04f27c37 | 2017-10-27 15:20:55 | [diff] [blame] | 300 | opener_observer_ = std::make_unique<OpenerDestroyedObserver>(this, false); |
alexmos | e201c7cd | 2015-06-10 17:14:21 | [diff] [blame] | 301 | opener_->AddObserver(opener_observer_.get()); |
| 302 | } |
| 303 | } |
| 304 | |
Wolfgang Beyer | d8809db | 2020-09-30 15:29:39 | [diff] [blame] | 305 | void FrameTreeNode::SetOpenerDevtoolsFrameToken( |
| 306 | base::UnguessableToken opener_devtools_frame_token) { |
| 307 | DCHECK(!opener_devtools_frame_token_ || |
| 308 | opener_devtools_frame_token_->is_empty()); |
| 309 | opener_devtools_frame_token_ = std::move(opener_devtools_frame_token); |
| 310 | } |
| 311 | |
jochen | 6004a36 | 2017-02-04 00:11:40 | [diff] [blame] | 312 | void FrameTreeNode::SetOriginalOpener(FrameTreeNode* opener) { |
Avi Drissman | 36465f33 | 2017-09-11 20:49:39 | [diff] [blame] | 313 | // The original opener tracks main frames only. |
avi | 8d1aa16 | 2017-03-27 18:27:37 | [diff] [blame] | 314 | DCHECK(opener == nullptr || !opener->parent()); |
jochen | 6004a36 | 2017-02-04 00:11:40 | [diff] [blame] | 315 | |
Avi Drissman | 36465f33 | 2017-09-11 20:49:39 | [diff] [blame] | 316 | if (original_opener_) { |
| 317 | original_opener_->RemoveObserver(original_opener_observer_.get()); |
| 318 | original_opener_observer_.reset(); |
| 319 | } |
| 320 | |
jochen | 6004a36 | 2017-02-04 00:11:40 | [diff] [blame] | 321 | original_opener_ = opener; |
| 322 | |
| 323 | if (original_opener_) { |
jochen | 6004a36 | 2017-02-04 00:11:40 | [diff] [blame] | 324 | original_opener_observer_ = |
Jeremy Roman | 04f27c37 | 2017-10-27 15:20:55 | [diff] [blame] | 325 | std::make_unique<OpenerDestroyedObserver>(this, true); |
jochen | 6004a36 | 2017-02-04 00:11:40 | [diff] [blame] | 326 | original_opener_->AddObserver(original_opener_observer_.get()); |
| 327 | } |
| 328 | } |
| 329 | |
creis | f0f069a | 2015-07-23 23:51:53 | [diff] [blame] | 330 | void FrameTreeNode::SetCurrentURL(const GURL& url) { |
Rakina Zata Amni | fc4cc3d4 | 2021-06-10 09:03:56 | [diff] [blame] | 331 | if (!has_committed_real_load_ && !url.IsAboutBlank()) { |
creis | f0f069a | 2015-07-23 23:51:53 | [diff] [blame] | 332 | has_committed_real_load_ = true; |
Rakina Zata Amni | fc4cc3d4 | 2021-06-10 09:03:56 | [diff] [blame] | 333 | is_on_initial_empty_document_or_subsequent_empty_documents_ = false; |
| 334 | } |
Erik Chen | 173bf304 | 2017-07-31 06:06:21 | [diff] [blame] | 335 | current_frame_host()->SetLastCommittedUrl(url); |
xiaochengh | b9554bb | 2016-05-21 14:20:48 | [diff] [blame] | 336 | blame_context_.TakeSnapshot(); |
creis | f0f069a | 2015-07-23 23:51:53 | [diff] [blame] | 337 | } |
| 338 | |
estark | bd8e26f | 2016-03-16 23:30:37 | [diff] [blame] | 339 | void FrameTreeNode::SetCurrentOrigin( |
| 340 | const url::Origin& origin, |
| 341 | bool is_potentially_trustworthy_unique_origin) { |
Antonio Sartori | 90f4121 | 2021-01-22 10:08:34 | [diff] [blame] | 342 | if (!origin.IsSameOriginWith(replication_state_->origin) || |
| 343 | replication_state_->has_potentially_trustworthy_unique_origin != |
estark | bd8e26f | 2016-03-16 23:30:37 | [diff] [blame] | 344 | is_potentially_trustworthy_unique_origin) { |
| 345 | render_manager_.OnDidUpdateOrigin(origin, |
| 346 | is_potentially_trustworthy_unique_origin); |
| 347 | } |
Antonio Sartori | 90f4121 | 2021-01-22 10:08:34 | [diff] [blame] | 348 | replication_state_->origin = origin; |
| 349 | replication_state_->has_potentially_trustworthy_unique_origin = |
estark | bd8e26f | 2016-03-16 23:30:37 | [diff] [blame] | 350 | is_potentially_trustworthy_unique_origin; |
alexmos | a7a4ff82 | 2015-04-27 17:59:56 | [diff] [blame] | 351 | } |
alexmos | be2f4c3 | 2015-03-10 02:30:23 | [diff] [blame] | 352 | |
engedy | 6e2e099 | 2017-05-25 18:58:42 | [diff] [blame] | 353 | void FrameTreeNode::SetCollapsed(bool collapsed) { |
| 354 | DCHECK(!IsMainFrame()); |
| 355 | if (is_collapsed_ == collapsed) |
| 356 | return; |
| 357 | |
| 358 | is_collapsed_ = collapsed; |
| 359 | render_manager_.OnDidChangeCollapsedState(collapsed); |
| 360 | } |
| 361 | |
Harkiran Bolaria | 59290d6 | 2021-03-17 01:53:01 | [diff] [blame] | 362 | void FrameTreeNode::SetFrameTree(FrameTree& frame_tree) { |
Hiroki Nakagawa | 0a90bd4 | 2021-04-21 01:53:05 | [diff] [blame] | 363 | DCHECK(blink::features::IsPrerender2Enabled()); |
Harkiran Bolaria | 59290d6 | 2021-03-17 01:53:01 | [diff] [blame] | 364 | frame_tree_ = &frame_tree; |
| 365 | } |
| 366 | |
lukasza | 464d869 | 2016-02-22 19:26:32 | [diff] [blame] | 367 | void FrameTreeNode::SetFrameName(const std::string& name, |
| 368 | const std::string& unique_name) { |
Antonio Sartori | 90f4121 | 2021-01-22 10:08:34 | [diff] [blame] | 369 | if (name == replication_state_->name) { |
lukasza | 464d869 | 2016-02-22 19:26:32 | [diff] [blame] | 370 | // |unique_name| shouldn't change unless |name| changes. |
Antonio Sartori | 90f4121 | 2021-01-22 10:08:34 | [diff] [blame] | 371 | DCHECK_EQ(unique_name, replication_state_->unique_name); |
lukasza | 464d869 | 2016-02-22 19:26:32 | [diff] [blame] | 372 | return; |
| 373 | } |
lukasza | 5140a41 | 2016-09-15 21:12:30 | [diff] [blame] | 374 | |
| 375 | if (parent()) { |
| 376 | // Non-main frames should have a non-empty unique name. |
| 377 | DCHECK(!unique_name.empty()); |
| 378 | } else { |
| 379 | // Unique name of main frames should always stay empty. |
| 380 | DCHECK(unique_name.empty()); |
| 381 | } |
| 382 | |
Daniel Cheng | 6ca7f1c9 | 2017-08-09 21:45:41 | [diff] [blame] | 383 | // Note the unique name should only be able to change before the first real |
| 384 | // load is committed, but that's not strongly enforced here. |
lukasza | 464d869 | 2016-02-22 19:26:32 | [diff] [blame] | 385 | render_manager_.OnDidUpdateName(name, unique_name); |
Antonio Sartori | 90f4121 | 2021-01-22 10:08:34 | [diff] [blame] | 386 | replication_state_->name = name; |
| 387 | replication_state_->unique_name = unique_name; |
alexmos | be2f4c3 | 2015-03-10 02:30:23 | [diff] [blame] | 388 | } |
| 389 | |
mkwst | f672e7ef | 2016-06-09 20:51:07 | [diff] [blame] | 390 | void FrameTreeNode::SetInsecureRequestPolicy( |
Julie Jeongeun Kim | d90e2dd | 2020-03-03 11:45:37 | [diff] [blame] | 391 | blink::mojom::InsecureRequestPolicy policy) { |
Antonio Sartori | 90f4121 | 2021-01-22 10:08:34 | [diff] [blame] | 392 | if (policy == replication_state_->insecure_request_policy) |
estark | a886b8d | 2015-12-18 21:53:08 | [diff] [blame] | 393 | return; |
mkwst | f672e7ef | 2016-06-09 20:51:07 | [diff] [blame] | 394 | render_manager_.OnEnforceInsecureRequestPolicy(policy); |
Antonio Sartori | 90f4121 | 2021-01-22 10:08:34 | [diff] [blame] | 395 | replication_state_->insecure_request_policy = policy; |
estark | a886b8d | 2015-12-18 21:53:08 | [diff] [blame] | 396 | } |
| 397 | |
arthursonzogni | 4b62a5cb | 2018-01-17 14:14:26 | [diff] [blame] | 398 | void FrameTreeNode::SetInsecureNavigationsSet( |
| 399 | const std::vector<uint32_t>& insecure_navigations_set) { |
| 400 | DCHECK(std::is_sorted(insecure_navigations_set.begin(), |
| 401 | insecure_navigations_set.end())); |
Antonio Sartori | 90f4121 | 2021-01-22 10:08:34 | [diff] [blame] | 402 | if (insecure_navigations_set == replication_state_->insecure_navigations_set) |
arthursonzogni | 4b62a5cb | 2018-01-17 14:14:26 | [diff] [blame] | 403 | return; |
| 404 | render_manager_.OnEnforceInsecureNavigationsSet(insecure_navigations_set); |
Antonio Sartori | 90f4121 | 2021-01-22 10:08:34 | [diff] [blame] | 405 | replication_state_->insecure_navigations_set = insecure_navigations_set; |
arthursonzogni | 4b62a5cb | 2018-01-17 14:14:26 | [diff] [blame] | 406 | } |
| 407 | |
Luna Lu | c3fdacdf | 2017-11-08 04:48:53 | [diff] [blame] | 408 | void FrameTreeNode::SetPendingFramePolicy(blink::FramePolicy frame_policy) { |
Dominic Farolino | 08662c8 | 2021-06-11 07:36:34 | [diff] [blame^] | 409 | // The |is_fenced| bit should never be able to transition from what its |
| 410 | // initial value was. Since we never expect to be in a position where it can |
| 411 | // even be updated to new value, if we catch this happening we have to kill |
| 412 | // the renderer and refuse to accept any other frame policy changes here. |
| 413 | if (pending_frame_policy_.is_fenced != frame_policy.is_fenced) { |
| 414 | mojo::ReportBadMessage( |
| 415 | "The `is_fenced` FramePolicy bit is const and should never be changed"); |
| 416 | return; |
| 417 | } |
| 418 | |
Ian Clelland | cdc4f31 | 2017-10-13 22:24:12 | [diff] [blame] | 419 | pending_frame_policy_.sandbox_flags = frame_policy.sandbox_flags; |
alexmos | 6e94010 | 2016-01-19 22:47:25 | [diff] [blame] | 420 | |
Ian Clelland | cdc4f31 | 2017-10-13 22:24:12 | [diff] [blame] | 421 | if (parent()) { |
| 422 | // Subframes should always inherit their parent's sandbox flags. |
Alexander Timin | 381e7e18 | 2020-04-28 19:04:03 | [diff] [blame] | 423 | pending_frame_policy_.sandbox_flags |= |
| 424 | parent()->frame_tree_node()->active_sandbox_flags(); |
Charlie Hu | e1b77ac | 2019-12-13 21:30:17 | [diff] [blame] | 425 | // This is only applied on subframes; container policy and required document |
| 426 | // policy are not mutable on main frame. |
Ian Clelland | cdc4f31 | 2017-10-13 22:24:12 | [diff] [blame] | 427 | pending_frame_policy_.container_policy = frame_policy.container_policy; |
Charlie Hu | e1b77ac | 2019-12-13 21:30:17 | [diff] [blame] | 428 | pending_frame_policy_.required_document_policy = |
| 429 | frame_policy.required_document_policy; |
Ian Clelland | cdc4f31 | 2017-10-13 22:24:12 | [diff] [blame] | 430 | } |
iclelland | 92f8c0b | 2017-04-19 12:43:05 | [diff] [blame] | 431 | } |
| 432 | |
alexmos | 9f8705a | 2015-05-06 19:58:59 | [diff] [blame] | 433 | FrameTreeNode* FrameTreeNode::PreviousSibling() const { |
paulmeyer | 322777fb | 2016-05-16 23:15:39 | [diff] [blame] | 434 | return GetSibling(-1); |
| 435 | } |
alexmos | 9f8705a | 2015-05-06 19:58:59 | [diff] [blame] | 436 | |
paulmeyer | 322777fb | 2016-05-16 23:15:39 | [diff] [blame] | 437 | FrameTreeNode* FrameTreeNode::NextSibling() const { |
| 438 | return GetSibling(1); |
alexmos | 9f8705a | 2015-05-06 19:58:59 | [diff] [blame] | 439 | } |
| 440 | |
fdegans | 4a49ce93 | 2015-03-12 17:11:37 | [diff] [blame] | 441 | bool FrameTreeNode::IsLoading() const { |
| 442 | RenderFrameHostImpl* current_frame_host = |
| 443 | render_manager_.current_frame_host(); |
fdegans | 4a49ce93 | 2015-03-12 17:11:37 | [diff] [blame] | 444 | |
| 445 | DCHECK(current_frame_host); |
fdegans | 39ff038 | 2015-04-29 19:04:39 | [diff] [blame] | 446 | |
clamy | 610c63b3 | 2017-12-22 15:05:18 | [diff] [blame] | 447 | if (navigation_request_) |
| 448 | return true; |
clamy | 11e1151 | 2015-07-07 16:42:17 | [diff] [blame] | 449 | |
clamy | 610c63b3 | 2017-12-22 15:05:18 | [diff] [blame] | 450 | RenderFrameHostImpl* speculative_frame_host = |
| 451 | render_manager_.speculative_frame_host(); |
| 452 | if (speculative_frame_host && speculative_frame_host->is_loading()) |
| 453 | return true; |
fdegans | 4a49ce93 | 2015-03-12 17:11:37 | [diff] [blame] | 454 | return current_frame_host->is_loading(); |
| 455 | } |
| 456 | |
Alex Moshchuk | 9b0fd82 | 2020-10-26 23:08:15 | [diff] [blame] | 457 | bool FrameTreeNode::HasPendingCrossDocumentNavigation() const { |
| 458 | // Having a |navigation_request_| on FrameTreeNode implies that there's an |
| 459 | // ongoing navigation that hasn't reached the ReadyToCommit state. If the |
| 460 | // navigation is between ReadyToCommit and DidCommitNavigation, the |
| 461 | // NavigationRequest will be held by RenderFrameHost, which is checked below. |
| 462 | if (navigation_request_ && !navigation_request_->IsSameDocument()) |
| 463 | return true; |
| 464 | |
| 465 | // Having a speculative RenderFrameHost should imply a cross-document |
| 466 | // navigation. |
| 467 | if (render_manager_.speculative_frame_host()) |
| 468 | return true; |
| 469 | |
| 470 | return render_manager_.current_frame_host() |
| 471 | ->HasPendingCommitForCrossDocumentNavigation(); |
| 472 | } |
| 473 | |
Charlie Hu | 5ffc015 | 2019-12-06 15:59:53 | [diff] [blame] | 474 | bool FrameTreeNode::CommitFramePolicy( |
| 475 | const blink::FramePolicy& new_frame_policy) { |
| 476 | bool did_change_flags = new_frame_policy.sandbox_flags != |
Antonio Sartori | 90f4121 | 2021-01-22 10:08:34 | [diff] [blame] | 477 | replication_state_->frame_policy.sandbox_flags; |
iclelland | 92f8c0b | 2017-04-19 12:43:05 | [diff] [blame] | 478 | bool did_change_container_policy = |
Charlie Hu | 5ffc015 | 2019-12-06 15:59:53 | [diff] [blame] | 479 | new_frame_policy.container_policy != |
Antonio Sartori | 90f4121 | 2021-01-22 10:08:34 | [diff] [blame] | 480 | replication_state_->frame_policy.container_policy; |
Charlie Hu | e1b77ac | 2019-12-13 21:30:17 | [diff] [blame] | 481 | bool did_change_required_document_policy = |
| 482 | pending_frame_policy_.required_document_policy != |
Antonio Sartori | 90f4121 | 2021-01-22 10:08:34 | [diff] [blame] | 483 | replication_state_->frame_policy.required_document_policy; |
Dominic Farolino | 08662c8 | 2021-06-11 07:36:34 | [diff] [blame^] | 484 | DCHECK_EQ(new_frame_policy.is_fenced, |
| 485 | replication_state_->frame_policy.is_fenced); |
Antonio Sartori | 90f4121 | 2021-01-22 10:08:34 | [diff] [blame] | 486 | if (did_change_flags) { |
| 487 | replication_state_->frame_policy.sandbox_flags = |
Charlie Hu | 5ffc015 | 2019-12-06 15:59:53 | [diff] [blame] | 488 | new_frame_policy.sandbox_flags; |
Antonio Sartori | 90f4121 | 2021-01-22 10:08:34 | [diff] [blame] | 489 | } |
| 490 | if (did_change_container_policy) { |
| 491 | replication_state_->frame_policy.container_policy = |
Charlie Hu | 5ffc015 | 2019-12-06 15:59:53 | [diff] [blame] | 492 | new_frame_policy.container_policy; |
Antonio Sartori | 90f4121 | 2021-01-22 10:08:34 | [diff] [blame] | 493 | } |
| 494 | if (did_change_required_document_policy) { |
| 495 | replication_state_->frame_policy.required_document_policy = |
Charlie Hu | e1b77ac | 2019-12-13 21:30:17 | [diff] [blame] | 496 | new_frame_policy.required_document_policy; |
Antonio Sartori | 90f4121 | 2021-01-22 10:08:34 | [diff] [blame] | 497 | } |
Charlie Hu | e1b77ac | 2019-12-13 21:30:17 | [diff] [blame] | 498 | |
Charlie Hu | 5ffc015 | 2019-12-06 15:59:53 | [diff] [blame] | 499 | UpdateFramePolicyHeaders(new_frame_policy.sandbox_flags, |
Charlie Hu | e20fe2f | 2021-03-07 03:39:59 | [diff] [blame] | 500 | replication_state_->permissions_policy_header); |
Charlie Hu | e1b77ac | 2019-12-13 21:30:17 | [diff] [blame] | 501 | return did_change_flags || did_change_container_policy || |
Dave Tapuska | 7fdfc2f | 2021-06-08 17:38:40 | [diff] [blame] | 502 | did_change_required_document_policy; |
alexmos | 6b29456 | 2015-03-05 19:24:10 | [diff] [blame] | 503 | } |
| 504 | |
Arthur Hemery | c338017 | 2018-01-22 14:00:17 | [diff] [blame] | 505 | void FrameTreeNode::TransferNavigationRequestOwnership( |
| 506 | RenderFrameHostImpl* render_frame_host) { |
Andrey Kosyakov | f2d4ff7 | 2018-10-29 20:09:59 | [diff] [blame] | 507 | devtools_instrumentation::OnResetNavigationRequest(navigation_request_.get()); |
Arthur Hemery | c338017 | 2018-01-22 14:00:17 | [diff] [blame] | 508 | render_frame_host->SetNavigationRequest(std::move(navigation_request_)); |
| 509 | } |
| 510 | |
carlosk | c49005eb | 2015-06-16 11:25:07 | [diff] [blame] | 511 | void FrameTreeNode::CreatedNavigationRequest( |
dcheng | 9bfa516 | 2016-04-09 01:00:57 | [diff] [blame] | 512 | std::unique_ptr<NavigationRequest> navigation_request) { |
arthursonzogni | c79c251c | 2016-08-18 15:00:37 | [diff] [blame] | 513 | // This is never called when navigating to a Javascript URL. For the loading |
| 514 | // state, this matches what Blink is doing: Blink doesn't send throbber |
| 515 | // notifications for Javascript URLS. |
| 516 | DCHECK(!navigation_request->common_params().url.SchemeIs( |
| 517 | url::kJavaScriptScheme)); |
| 518 | |
clamy | 44e84ce | 2016-02-22 15:38:25 | [diff] [blame] | 519 | bool was_previously_loading = frame_tree()->IsLoading(); |
| 520 | |
clamy | 82a2f4d | 2016-02-02 14:20:41 | [diff] [blame] | 521 | // There's no need to reset the state: there's still an ongoing load, and the |
| 522 | // RenderFrameHostManager will take care of updates to the speculative |
| 523 | // RenderFrameHost in DidCreateNavigationRequest below. |
jam | cd0b7b2 | 2017-03-24 22:13:05 | [diff] [blame] | 524 | if (was_previously_loading) { |
Mohamed Abdelhalim | f03d4a2 | 2019-10-01 13:34:31 | [diff] [blame] | 525 | if (navigation_request_ && navigation_request_->IsNavigationStarted()) { |
jam | cd0b7b2 | 2017-03-24 22:13:05 | [diff] [blame] | 526 | // Mark the old request as aborted. |
Mohamed Abdelhalim | b4db22a | 2019-06-18 10:46:52 | [diff] [blame] | 527 | navigation_request_->set_net_error(net::ERR_ABORTED); |
jam | cd0b7b2 | 2017-03-24 22:13:05 | [diff] [blame] | 528 | } |
Arthur Hemery | 241b939 | 2019-10-24 11:08:41 | [diff] [blame] | 529 | ResetNavigationRequest(true); |
jam | cd0b7b2 | 2017-03-24 22:13:05 | [diff] [blame] | 530 | } |
clamy | 44e84ce | 2016-02-22 15:38:25 | [diff] [blame] | 531 | |
| 532 | navigation_request_ = std::move(navigation_request); |
Shubhie Panicker | ddf2a4e | 2018-03-06 00:09:06 | [diff] [blame] | 533 | if (was_discarded_) { |
| 534 | navigation_request_->set_was_discarded(); |
| 535 | was_discarded_ = false; |
| 536 | } |
clamy | 8e2e29920 | 2016-04-05 11:44:59 | [diff] [blame] | 537 | render_manager()->DidCreateNavigationRequest(navigation_request_.get()); |
fdegans | 39ff038 | 2015-04-29 19:04:39 | [diff] [blame] | 538 | |
Lucas Furukawa Gadani | ef8290a | 2019-07-29 20:27:51 | [diff] [blame] | 539 | bool to_different_document = !NavigationTypeUtils::IsSameDocument( |
arthursonzogni | 92f1868 | 2017-02-08 23:00:04 | [diff] [blame] | 540 | navigation_request_->common_params().navigation_type); |
| 541 | |
| 542 | DidStartLoading(to_different_document, was_previously_loading); |
clamy | dcb434c1 | 2015-04-16 19:29:16 | [diff] [blame] | 543 | } |
| 544 | |
Arthur Hemery | 241b939 | 2019-10-24 11:08:41 | [diff] [blame] | 545 | void FrameTreeNode::ResetNavigationRequest(bool keep_state) { |
fdegans | 39ff038 | 2015-04-29 19:04:39 | [diff] [blame] | 546 | if (!navigation_request_) |
| 547 | return; |
John Abd-El-Malek | dcc7bf4 | 2017-09-12 22:30:23 | [diff] [blame] | 548 | |
Andrey Kosyakov | f2d4ff7 | 2018-10-29 20:09:59 | [diff] [blame] | 549 | devtools_instrumentation::OnResetNavigationRequest(navigation_request_.get()); |
clamy | dcb434c1 | 2015-04-16 19:29:16 | [diff] [blame] | 550 | navigation_request_.reset(); |
fdegans | 39ff038 | 2015-04-29 19:04:39 | [diff] [blame] | 551 | |
clamy | 82a2f4d | 2016-02-02 14:20:41 | [diff] [blame] | 552 | if (keep_state) |
fdegans | 39ff038 | 2015-04-29 19:04:39 | [diff] [blame] | 553 | return; |
| 554 | |
clamy | 82a2f4d | 2016-02-02 14:20:41 | [diff] [blame] | 555 | // The RenderFrameHostManager should clean up any speculative RenderFrameHost |
| 556 | // it created for the navigation. Also register that the load stopped. |
fdegans | 39ff038 | 2015-04-29 19:04:39 | [diff] [blame] | 557 | DidStopLoading(); |
| 558 | render_manager_.CleanUpNavigation(); |
clamy | dcb434c1 | 2015-04-16 19:29:16 | [diff] [blame] | 559 | } |
| 560 | |
clamy | 44e84ce | 2016-02-22 15:38:25 | [diff] [blame] | 561 | void FrameTreeNode::DidStartLoading(bool to_different_document, |
| 562 | bool was_previously_loading) { |
Camille Lamy | efd54b0 | 2018-10-04 16:54:14 | [diff] [blame] | 563 | TRACE_EVENT2("navigation", "FrameTreeNode::DidStartLoading", |
| 564 | "frame_tree_node", frame_tree_node_id(), "to different document", |
| 565 | to_different_document); |
fdegans | a696e511 | 2015-04-17 01:57:59 | [diff] [blame] | 566 | |
Carlos Caballero | 0326252 | 2021-02-05 14:49:58 | [diff] [blame] | 567 | frame_tree_->DidStartLoadingNode(*this, to_different_document, |
| 568 | was_previously_loading); |
fdegans | a696e511 | 2015-04-17 01:57:59 | [diff] [blame] | 569 | |
| 570 | // Set initial load progress and update overall progress. This will notify |
| 571 | // the WebContents of the load progress change. |
| 572 | DidChangeLoadProgress(kLoadingProgressMinimum); |
| 573 | |
| 574 | // Notify the RenderFrameHostManager of the event. |
| 575 | render_manager()->OnDidStartLoading(); |
| 576 | } |
| 577 | |
| 578 | void FrameTreeNode::DidStopLoading() { |
Camille Lamy | efd54b0 | 2018-10-04 16:54:14 | [diff] [blame] | 579 | TRACE_EVENT1("navigation", "FrameTreeNode::DidStopLoading", "frame_tree_node", |
| 580 | frame_tree_node_id()); |
fdegans | a696e511 | 2015-04-17 01:57:59 | [diff] [blame] | 581 | // Set final load progress and update overall progress. This will notify |
| 582 | // the WebContents of the load progress change. |
| 583 | DidChangeLoadProgress(kLoadingProgressDone); |
| 584 | |
Lucas Furukawa Gadani | 6faef60 | 2019-05-06 21:16:03 | [diff] [blame] | 585 | // Notify the RenderFrameHostManager of the event. |
| 586 | render_manager()->OnDidStopLoading(); |
| 587 | |
Carlos Caballero | 0326252 | 2021-02-05 14:49:58 | [diff] [blame] | 588 | frame_tree_->DidStopLoadingNode(*this); |
fdegans | a696e511 | 2015-04-17 01:57:59 | [diff] [blame] | 589 | } |
| 590 | |
| 591 | void FrameTreeNode::DidChangeLoadProgress(double load_progress) { |
Nate Chapin | 9353670 | 2018-02-07 00:12:21 | [diff] [blame] | 592 | DCHECK_GE(load_progress, kLoadingProgressMinimum); |
| 593 | DCHECK_LE(load_progress, kLoadingProgressDone); |
Carlos Caballero | 0326252 | 2021-02-05 14:49:58 | [diff] [blame] | 594 | frame_tree_->DidChangeLoadProgressForNode(*this, load_progress); |
fdegans | a696e511 | 2015-04-17 01:57:59 | [diff] [blame] | 595 | } |
| 596 | |
clamy | f73862c4 | 2015-07-08 12:31:33 | [diff] [blame] | 597 | bool FrameTreeNode::StopLoading() { |
arthursonzogni | 66f711c | 2019-10-08 14:40:36 | [diff] [blame] | 598 | if (navigation_request_ && navigation_request_->IsNavigationStarted()) |
| 599 | navigation_request_->set_net_error(net::ERR_ABORTED); |
Arthur Hemery | 241b939 | 2019-10-24 11:08:41 | [diff] [blame] | 600 | ResetNavigationRequest(false); |
clamy | f73862c4 | 2015-07-08 12:31:33 | [diff] [blame] | 601 | |
clamy | f73862c4 | 2015-07-08 12:31:33 | [diff] [blame] | 602 | if (!IsMainFrame()) |
| 603 | return true; |
| 604 | |
| 605 | render_manager_.Stop(); |
| 606 | return true; |
| 607 | } |
| 608 | |
alexmos | 21acae5 | 2015-11-07 01:04:43 | [diff] [blame] | 609 | void FrameTreeNode::DidFocus() { |
| 610 | last_focus_time_ = base::TimeTicks::Now(); |
ericwilligers | 254597b | 2016-10-17 10:32:31 | [diff] [blame] | 611 | for (auto& observer : observers_) |
| 612 | observer.OnFrameTreeNodeFocused(this); |
alexmos | 21acae5 | 2015-11-07 01:04:43 | [diff] [blame] | 613 | } |
| 614 | |
clamy | 44e84ce | 2016-02-22 15:38:25 | [diff] [blame] | 615 | void FrameTreeNode::BeforeUnloadCanceled() { |
| 616 | // TODO(clamy): Support BeforeUnload in subframes. |
| 617 | if (!IsMainFrame()) |
| 618 | return; |
| 619 | |
| 620 | RenderFrameHostImpl* current_frame_host = |
| 621 | render_manager_.current_frame_host(); |
| 622 | DCHECK(current_frame_host); |
| 623 | current_frame_host->ResetLoadingState(); |
| 624 | |
clamy | 610c63b3 | 2017-12-22 15:05:18 | [diff] [blame] | 625 | RenderFrameHostImpl* speculative_frame_host = |
| 626 | render_manager_.speculative_frame_host(); |
| 627 | if (speculative_frame_host) |
| 628 | speculative_frame_host->ResetLoadingState(); |
Alexander Timin | 23c110b | 2021-01-14 02:39:04 | [diff] [blame] | 629 | // Note: there is no need to set an error code on the NavigationHandle as |
| 630 | // the observers have not been notified about its creation. |
| 631 | // We also reset navigation request only when this navigation request was |
| 632 | // responsible for this dialog, as a new navigation request might cancel |
| 633 | // existing unrelated dialog. |
| 634 | if (navigation_request_ && navigation_request_->IsWaitingForBeforeUnload()) |
Arthur Hemery | 241b939 | 2019-10-24 11:08:41 | [diff] [blame] | 635 | ResetNavigationRequest(false); |
clamy | 44e84ce | 2016-02-22 15:38:25 | [diff] [blame] | 636 | } |
| 637 | |
Mustaq Ahmed | ecb5c38e | 2020-07-29 00:34:30 | [diff] [blame] | 638 | bool FrameTreeNode::NotifyUserActivation( |
| 639 | blink::mojom::UserActivationNotificationType notification_type) { |
Alex Moshchuk | 0390419 | 2021-04-02 07:29:08 | [diff] [blame] | 640 | // User Activation V2 requires activating all ancestor frames in addition to |
| 641 | // the current frame. See |
| 642 | // https://html.spec.whatwg.org/multipage/interaction.html#tracking-user-activation. |
Alexander Timin | a1dfadaa | 2020-04-28 13:30:06 | [diff] [blame] | 643 | for (RenderFrameHostImpl* rfh = current_frame_host(); rfh; |
| 644 | rfh = rfh->GetParent()) { |
John Delaney | b625dca9 | 2021-04-14 17:00:34 | [diff] [blame] | 645 | rfh->DidReceiveUserActivation(); |
Mustaq Ahmed | ecb5c38e | 2020-07-29 00:34:30 | [diff] [blame] | 646 | rfh->frame_tree_node()->user_activation_state_.Activate(notification_type); |
John Delaney | edd8d6c | 2019-01-25 00:23:57 | [diff] [blame] | 647 | } |
Alex Moshchuk | 0390419 | 2021-04-02 07:29:08 | [diff] [blame] | 648 | |
Antonio Sartori | 90f4121 | 2021-01-22 10:08:34 | [diff] [blame] | 649 | replication_state_->has_active_user_gesture = true; |
Mustaq Ahmed | a5dfa60b | 2018-12-08 00:30:14 | [diff] [blame] | 650 | |
Mustaq Ahmed | 0180320f | 2019-03-21 16:07:01 | [diff] [blame] | 651 | // See the "Same-origin Visibility" section in |UserActivationState| class |
| 652 | // doc. |
Mustaq Ahmed | e5f1256 | 2019-10-30 18:02:03 | [diff] [blame] | 653 | if (base::FeatureList::IsEnabled( |
Mustaq Ahmed | a5dfa60b | 2018-12-08 00:30:14 | [diff] [blame] | 654 | features::kUserActivationSameOriginVisibility)) { |
| 655 | const url::Origin& current_origin = |
| 656 | this->current_frame_host()->GetLastCommittedOrigin(); |
| 657 | for (FrameTreeNode* node : frame_tree()->Nodes()) { |
| 658 | if (node->current_frame_host()->GetLastCommittedOrigin().IsSameOriginWith( |
| 659 | current_origin)) { |
Mustaq Ahmed | ecb5c38e | 2020-07-29 00:34:30 | [diff] [blame] | 660 | node->user_activation_state_.Activate(notification_type); |
Mustaq Ahmed | a5dfa60b | 2018-12-08 00:30:14 | [diff] [blame] | 661 | } |
| 662 | } |
| 663 | } |
| 664 | |
Carlos Caballero | 40b0efd | 2021-01-26 11:55:00 | [diff] [blame] | 665 | navigator().controller().NotifyUserActivation(); |
Alex Moshchuk | 0390419 | 2021-04-02 07:29:08 | [diff] [blame] | 666 | current_frame_host()->MaybeIsolateForUserActivation(); |
Shivani Sharma | 19487703 | 2019-03-07 17:52:47 | [diff] [blame] | 667 | |
Mustaq Ahmed | c4cb716 | 2018-06-05 16:28:36 | [diff] [blame] | 668 | return true; |
| 669 | } |
| 670 | |
| 671 | bool FrameTreeNode::ConsumeTransientUserActivation() { |
| 672 | bool was_active = user_activation_state_.IsActive(); |
| 673 | for (FrameTreeNode* node : frame_tree()->Nodes()) |
| 674 | node->user_activation_state_.ConsumeIfActive(); |
Antonio Sartori | 90f4121 | 2021-01-22 10:08:34 | [diff] [blame] | 675 | replication_state_->has_active_user_gesture = false; |
Mustaq Ahmed | c4cb716 | 2018-06-05 16:28:36 | [diff] [blame] | 676 | return was_active; |
| 677 | } |
| 678 | |
Shivani Sharma | c4f56158 | 2018-11-15 15:58:39 | [diff] [blame] | 679 | bool FrameTreeNode::ClearUserActivation() { |
Shivani Sharma | c4f56158 | 2018-11-15 15:58:39 | [diff] [blame] | 680 | for (FrameTreeNode* node : frame_tree()->SubtreeNodes(this)) |
| 681 | node->user_activation_state_.Clear(); |
Antonio Sartori | 90f4121 | 2021-01-22 10:08:34 | [diff] [blame] | 682 | replication_state_->has_active_user_gesture = false; |
Shivani Sharma | c4f56158 | 2018-11-15 15:58:39 | [diff] [blame] | 683 | return true; |
| 684 | } |
| 685 | |
Ella Ge | 9caed61 | 2019-08-09 16:17:25 | [diff] [blame] | 686 | bool FrameTreeNode::VerifyUserActivation() { |
Ella Ge | a78f677 | 2019-12-11 10:35:25 | [diff] [blame] | 687 | DCHECK(base::FeatureList::IsEnabled( |
| 688 | features::kBrowserVerifiedUserActivationMouse) || |
| 689 | base::FeatureList::IsEnabled( |
| 690 | features::kBrowserVerifiedUserActivationKeyboard)); |
| 691 | |
Ella Ge | 9caed61 | 2019-08-09 16:17:25 | [diff] [blame] | 692 | return render_manager_.current_frame_host() |
| 693 | ->GetRenderWidgetHost() |
Mustaq Ahmed | 83bb172 | 2019-10-22 20:00:10 | [diff] [blame] | 694 | ->RemovePendingUserActivationIfAvailable(); |
Ella Ge | 9caed61 | 2019-08-09 16:17:25 | [diff] [blame] | 695 | } |
| 696 | |
Mustaq Ahmed | c4cb716 | 2018-06-05 16:28:36 | [diff] [blame] | 697 | bool FrameTreeNode::UpdateUserActivationState( |
Mustaq Ahmed | dc195e5b | 2020-08-04 18:45:11 | [diff] [blame] | 698 | blink::mojom::UserActivationUpdateType update_type, |
| 699 | blink::mojom::UserActivationNotificationType notification_type) { |
Ella Ge | 9caed61 | 2019-08-09 16:17:25 | [diff] [blame] | 700 | bool update_result = false; |
Mustaq Ahmed | c4cb716 | 2018-06-05 16:28:36 | [diff] [blame] | 701 | switch (update_type) { |
Antonio Gomes | 4b2c513 | 2020-01-16 11:49:48 | [diff] [blame] | 702 | case blink::mojom::UserActivationUpdateType::kConsumeTransientActivation: |
Ella Ge | 9caed61 | 2019-08-09 16:17:25 | [diff] [blame] | 703 | update_result = ConsumeTransientUserActivation(); |
| 704 | break; |
Antonio Gomes | 4b2c513 | 2020-01-16 11:49:48 | [diff] [blame] | 705 | case blink::mojom::UserActivationUpdateType::kNotifyActivation: |
Mustaq Ahmed | dc195e5b | 2020-08-04 18:45:11 | [diff] [blame] | 706 | update_result = NotifyUserActivation(notification_type); |
Ella Ge | 9caed61 | 2019-08-09 16:17:25 | [diff] [blame] | 707 | break; |
Antonio Gomes | 4b2c513 | 2020-01-16 11:49:48 | [diff] [blame] | 708 | case blink::mojom::UserActivationUpdateType:: |
Liviu Tinta | d9391fb9 | 2020-09-28 23:50:07 | [diff] [blame] | 709 | kNotifyActivationPendingBrowserVerification: { |
| 710 | const bool user_activation_verified = VerifyUserActivation(); |
| 711 | // Add UMA metric for when browser user activation verification succeeds |
| 712 | base::UmaHistogramBoolean("Event.BrowserVerifiedUserActivation", |
| 713 | user_activation_verified); |
| 714 | if (user_activation_verified) { |
Mustaq Ahmed | ecb5c38e | 2020-07-29 00:34:30 | [diff] [blame] | 715 | update_result = NotifyUserActivation( |
Mustaq Ahmed | 2cfb040 | 2020-09-29 19:24:35 | [diff] [blame] | 716 | blink::mojom::UserActivationNotificationType::kInteraction); |
Antonio Gomes | 4b2c513 | 2020-01-16 11:49:48 | [diff] [blame] | 717 | update_type = blink::mojom::UserActivationUpdateType::kNotifyActivation; |
Ella Ge | 9caed61 | 2019-08-09 16:17:25 | [diff] [blame] | 718 | } else { |
arthursonzogni | 9816b919 | 2021-03-29 16:09:19 | [diff] [blame] | 719 | // TODO(https://crbug.com/848778): We need to decide what to do when |
| 720 | // user activation verification failed. NOTREACHED here will make all |
Ella Ge | 9caed61 | 2019-08-09 16:17:25 | [diff] [blame] | 721 | // unrelated tests that inject event to renderer fail. |
| 722 | return false; |
| 723 | } |
Liviu Tinta | d9391fb9 | 2020-09-28 23:50:07 | [diff] [blame] | 724 | } break; |
Antonio Gomes | 4b2c513 | 2020-01-16 11:49:48 | [diff] [blame] | 725 | case blink::mojom::UserActivationUpdateType::kClearActivation: |
Ella Ge | 9caed61 | 2019-08-09 16:17:25 | [diff] [blame] | 726 | update_result = ClearUserActivation(); |
| 727 | break; |
Mustaq Ahmed | c4cb716 | 2018-06-05 16:28:36 | [diff] [blame] | 728 | } |
Mustaq Ahmed | dc195e5b | 2020-08-04 18:45:11 | [diff] [blame] | 729 | render_manager_.UpdateUserActivationState(update_type, notification_type); |
Ella Ge | 9caed61 | 2019-08-09 16:17:25 | [diff] [blame] | 730 | return update_result; |
japhet | 61835ae1 | 2017-01-20 01:25:39 | [diff] [blame] | 731 | } |
| 732 | |
Mustaq Ahmed | 0126174 | 2019-12-16 15:49:06 | [diff] [blame] | 733 | void FrameTreeNode::OnSetHadStickyUserActivationBeforeNavigation(bool value) { |
| 734 | render_manager_.OnSetHadStickyUserActivationBeforeNavigation(value); |
Antonio Sartori | 90f4121 | 2021-01-22 10:08:34 | [diff] [blame] | 735 | replication_state_->has_received_user_gesture_before_nav = value; |
Becca Hughes | 60af7d4 | 2017-12-12 10:53:15 | [diff] [blame] | 736 | } |
| 737 | |
paulmeyer | 322777fb | 2016-05-16 23:15:39 | [diff] [blame] | 738 | FrameTreeNode* FrameTreeNode::GetSibling(int relative_offset) const { |
paulmeyer | f3119f5 | 2016-05-17 17:37:19 | [diff] [blame] | 739 | if (!parent_ || !parent_->child_count()) |
paulmeyer | 322777fb | 2016-05-16 23:15:39 | [diff] [blame] | 740 | return nullptr; |
| 741 | |
| 742 | for (size_t i = 0; i < parent_->child_count(); ++i) { |
| 743 | if (parent_->child_at(i) == this) { |
| 744 | if ((relative_offset < 0 && static_cast<size_t>(-relative_offset) > i) || |
| 745 | i + relative_offset >= parent_->child_count()) { |
| 746 | return nullptr; |
| 747 | } |
| 748 | return parent_->child_at(i + relative_offset); |
| 749 | } |
| 750 | } |
| 751 | |
| 752 | NOTREACHED() << "FrameTreeNode not found in its parent's children."; |
| 753 | return nullptr; |
| 754 | } |
| 755 | |
Alexander Timin | 45b716c | 2020-11-06 01:40:31 | [diff] [blame] | 756 | bool FrameTreeNode::UpdateFramePolicyHeaders( |
arthursonzogni | b93a447 | 2020-04-10 07:38:00 | [diff] [blame] | 757 | network::mojom::WebSandboxFlags sandbox_flags, |
Charlie Hu | e24f0483 | 2021-03-04 21:07:06 | [diff] [blame] | 758 | const blink::ParsedPermissionsPolicy& parsed_header) { |
Ian Clelland | edb8c5dd | 2018-03-01 17:01:37 | [diff] [blame] | 759 | bool changed = false; |
Charlie Hu | e20fe2f | 2021-03-07 03:39:59 | [diff] [blame] | 760 | if (replication_state_->permissions_policy_header != parsed_header) { |
| 761 | replication_state_->permissions_policy_header = parsed_header; |
Ian Clelland | edb8c5dd | 2018-03-01 17:01:37 | [diff] [blame] | 762 | changed = true; |
| 763 | } |
Ian Clelland | 5cbaaf8 | 2017-11-27 22:00:03 | [diff] [blame] | 764 | // TODO(iclelland): Kill the renderer if sandbox flags is not a subset of the |
| 765 | // currently effective sandbox flags from the frame. https://crbug.com/740556 |
arthursonzogni | b93a447 | 2020-04-10 07:38:00 | [diff] [blame] | 766 | network::mojom::WebSandboxFlags updated_flags = |
Ian Clelland | 5cbaaf8 | 2017-11-27 22:00:03 | [diff] [blame] | 767 | sandbox_flags | effective_frame_policy().sandbox_flags; |
Antonio Sartori | 90f4121 | 2021-01-22 10:08:34 | [diff] [blame] | 768 | if (replication_state_->active_sandbox_flags != updated_flags) { |
| 769 | replication_state_->active_sandbox_flags = updated_flags; |
Ian Clelland | edb8c5dd | 2018-03-01 17:01:37 | [diff] [blame] | 770 | changed = true; |
| 771 | } |
| 772 | // Notify any proxies if the policies have been changed. |
| 773 | if (changed) |
| 774 | render_manager()->OnDidSetFramePolicyHeaders(); |
Alexander Timin | 45b716c | 2020-11-06 01:40:31 | [diff] [blame] | 775 | return changed; |
Ian Clelland | 5cbaaf8 | 2017-11-27 22:00:03 | [diff] [blame] | 776 | } |
| 777 | |
Arthur Sonzogni | f8840b9 | 2018-11-07 14:10:35 | [diff] [blame] | 778 | void FrameTreeNode::PruneChildFrameNavigationEntries( |
| 779 | NavigationEntryImpl* entry) { |
| 780 | for (size_t i = 0; i < current_frame_host()->child_count(); ++i) { |
| 781 | FrameTreeNode* child = current_frame_host()->child_at(i); |
| 782 | if (child->is_created_by_script_) { |
| 783 | entry->RemoveEntryForFrame(child, |
| 784 | /* only_if_different_position = */ false); |
| 785 | } else { |
| 786 | child->PruneChildFrameNavigationEntries(entry); |
| 787 | } |
| 788 | } |
| 789 | } |
| 790 | |
Alex Turner | 10d557a4 | 2021-06-01 19:06:49 | [diff] [blame] | 791 | void FrameTreeNode::SetIsAdSubframe(bool is_ad_subframe) { |
| 792 | if (is_ad_subframe == replication_state_->is_ad_subframe) |
Alex Turner | 5a09c46 | 2021-03-17 17:07:35 | [diff] [blame] | 793 | return; |
| 794 | |
Alex Turner | 10d557a4 | 2021-06-01 19:06:49 | [diff] [blame] | 795 | replication_state_->is_ad_subframe = is_ad_subframe; |
| 796 | render_manager()->OnDidSetIsAdSubframe(is_ad_subframe); |
Yao Xiao | 24ec9aa | 2020-01-28 16:36:00 | [diff] [blame] | 797 | } |
| 798 | |
arthursonzogni | 034bb9c | 2020-10-01 08:29:56 | [diff] [blame] | 799 | void FrameTreeNode::SetInitialPopupURL(const GURL& initial_popup_url) { |
| 800 | DCHECK(initial_popup_url_.is_empty()); |
| 801 | DCHECK(!has_committed_real_load_); |
| 802 | initial_popup_url_ = initial_popup_url; |
| 803 | } |
| 804 | |
| 805 | void FrameTreeNode::SetPopupCreatorOrigin( |
| 806 | const url::Origin& popup_creator_origin) { |
| 807 | DCHECK(!has_committed_real_load_); |
| 808 | popup_creator_origin_ = popup_creator_origin; |
| 809 | } |
| 810 | |
Alexander Timin | bebb200 | 2021-04-20 15:42:24 | [diff] [blame] | 811 | void FrameTreeNode::WriteIntoTrace(perfetto::TracedValue context) const { |
Alexander Timin | f785f34 | 2021-03-18 00:00:56 | [diff] [blame] | 812 | auto dict = std::move(context).WriteDictionary(); |
| 813 | dict.Add("id", frame_tree_node_id()); |
| 814 | dict.Add("is_main_frame", IsMainFrame()); |
| 815 | } |
| 816 | |
Carlos Caballero | 7671135 | 2021-03-24 17:38:21 | [diff] [blame] | 817 | bool FrameTreeNode::HasNavigation() { |
| 818 | if (navigation_request()) |
| 819 | return true; |
| 820 | |
| 821 | // Same-RenderFrameHost navigation is committing: |
| 822 | if (current_frame_host()->HasPendingCommitNavigation()) |
| 823 | return true; |
| 824 | |
| 825 | // Cross-RenderFrameHost navigation is committing: |
| 826 | if (render_manager()->speculative_frame_host()) |
| 827 | return true; |
| 828 | |
| 829 | return false; |
| 830 | } |
| 831 | |
[email protected] | 9b159a5 | 2013-10-03 17:24:55 | [diff] [blame] | 832 | } // namespace content |