blob: 4462914d35a8eff13ea9f04150806f485f3f77d1 [file] [log] [blame]
[email protected]9b159a52013-10-03 17:24:551// 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
danakjc492bf82020-09-09 20:02:445#include "content/browser/renderer_host/frame_tree_node.h"
[email protected]9b159a52013-10-03 17:24:556
Daniel Cheng6ca7f1c92017-08-09 21:45:417#include <math.h>
8
[email protected]9b159a52013-10-03 17:24:559#include <queue>
Takuto Ikutaadf31eb2019-01-05 00:32:4810#include <unordered_map>
dcheng36b6aec92015-12-26 06:16:3611#include <utility>
[email protected]9b159a52013-10-03 17:24:5512
Mustaq Ahmeda5dfa60b2018-12-08 00:30:1413#include "base/feature_list.h"
scottmg6ece5ae2017-02-01 18:25:1914#include "base/lazy_instance.h"
avib7348942015-12-25 20:57:1015#include "base/macros.h"
Liviu Tintad9391fb92020-09-28 23:50:0716#include "base/metrics/histogram_functions.h"
dcheng23ca947d2016-05-04 20:04:1517#include "base/metrics/histogram_macros.h"
[email protected]9b159a52013-10-03 17:24:5518#include "base/stl_util.h"
Daniel Cheng6ca7f1c92017-08-09 21:45:4119#include "base/strings/string_util.h"
Andrey Kosyakovf2d4ff72018-10-29 20:09:5920#include "content/browser/devtools/devtools_instrumentation.h"
danakjc492bf82020-09-09 20:02:4421#include "content/browser/renderer_host/navigation_controller_impl.h"
22#include "content/browser/renderer_host/navigation_request.h"
23#include "content/browser/renderer_host/navigator.h"
24#include "content/browser/renderer_host/navigator_delegate.h"
25#include "content/browser/renderer_host/render_frame_host_impl.h"
[email protected]94d0cc12013-12-18 00:07:4126#include "content/browser/renderer_host/render_view_host_impl.h"
clamyf73862c42015-07-08 12:31:3327#include "content/common/frame_messages.h"
Lucas Furukawa Gadanief8290a2019-07-29 20:27:5128#include "content/common/navigation_params.h"
29#include "content/common/navigation_params_utils.h"
dmazzonie950ea232015-03-13 21:39:4530#include "content/public/browser/browser_thread.h"
Mustaq Ahmeda5dfa60b2018-12-08 00:30:1431#include "content/public/common/content_features.h"
arthursonzognib93a4472020-04-10 07:38:0032#include "services/network/public/cpp/web_sandbox_flags.h"
33#include "services/network/public/mojom/web_sandbox_flags.mojom-shared.h"
Antonio Gomes4b2c5132020-01-16 11:49:4834#include "third_party/blink/public/mojom/frame/user_activation_update_types.mojom.h"
Julie Jeongeun Kimd90e2dd2020-03-03 11:45:3735#include "third_party/blink/public/mojom/security_context/insecure_request_policy.mojom.h"
[email protected]9b159a52013-10-03 17:24:5536
37namespace content {
38
dmazzonie950ea232015-03-13 21:39:4539namespace {
40
41// This is a global map between frame_tree_node_ids and pointers to
42// FrameTreeNodes.
Takuto Ikutaadf31eb2019-01-05 00:32:4843typedef std::unordered_map<int, FrameTreeNode*> FrameTreeNodeIdMap;
dmazzonie950ea232015-03-13 21:39:4544
scottmg5e65e3a2017-03-08 08:48:4645base::LazyInstance<FrameTreeNodeIdMap>::DestructorAtExit
46 g_frame_tree_node_id_map = LAZY_INSTANCE_INITIALIZER;
dmazzonie950ea232015-03-13 21:39:4547
fdegansa696e5112015-04-17 01:57:5948// These values indicate the loading progress status. The minimum progress
49// value matches what Blink's ProgressTracker has traditionally used for a
50// minimum progress value.
fdegansa696e5112015-04-17 01:57:5951const double kLoadingProgressMinimum = 0.1;
52const double kLoadingProgressDone = 1.0;
dmazzonie950ea232015-03-13 21:39:4553
fdegansa696e5112015-04-17 01:57:5954} // namespace
fdegans1d16355162015-03-26 11:58:3455
alexmose201c7cd2015-06-10 17:14:2156// This observer watches the opener of its owner FrameTreeNode and clears the
57// owner's opener if the opener is destroyed.
58class FrameTreeNode::OpenerDestroyedObserver : public FrameTreeNode::Observer {
59 public:
jochen6004a362017-02-04 00:11:4060 OpenerDestroyedObserver(FrameTreeNode* owner, bool observing_original_opener)
61 : owner_(owner), observing_original_opener_(observing_original_opener) {}
alexmose201c7cd2015-06-10 17:14:2162
63 // FrameTreeNode::Observer
64 void OnFrameTreeNodeDestroyed(FrameTreeNode* node) override {
jochen6004a362017-02-04 00:11:4065 if (observing_original_opener_) {
Avi Drissman36465f332017-09-11 20:49:3966 // The "original owner" is special. It's used for attribution, and clients
67 // walk down the original owner chain. Therefore, if a link in the chain
68 // is being destroyed, reconnect the observation to the parent of the link
69 // being destroyed.
jochen6004a362017-02-04 00:11:4070 CHECK_EQ(owner_->original_opener(), node);
Avi Drissman36465f332017-09-11 20:49:3971 owner_->SetOriginalOpener(node->original_opener());
72 // |this| is deleted at this point.
jochen6004a362017-02-04 00:11:4073 } else {
74 CHECK_EQ(owner_->opener(), node);
75 owner_->SetOpener(nullptr);
Avi Drissman36465f332017-09-11 20:49:3976 // |this| is deleted at this point.
jochen6004a362017-02-04 00:11:4077 }
alexmose201c7cd2015-06-10 17:14:2178 }
79
80 private:
81 FrameTreeNode* owner_;
jochen6004a362017-02-04 00:11:4082 bool observing_original_opener_;
alexmose201c7cd2015-06-10 17:14:2183
84 DISALLOW_COPY_AND_ASSIGN(OpenerDestroyedObserver);
85};
86
Kevin McNee88e61552020-10-22 20:41:1187const int FrameTreeNode::kFrameTreeNodeInvalidId = -1;
88
89static_assert(FrameTreeNode::kFrameTreeNodeInvalidId ==
90 RenderFrameHost::kNoFrameTreeNodeId,
91 "Have consistent sentinel values for an invalid FTN id.");
92
vishal.b782eb5d2015-04-29 12:22:5793int FrameTreeNode::next_frame_tree_node_id_ = 1;
[email protected]9b159a52013-10-03 17:24:5594
dmazzonie950ea232015-03-13 21:39:4595// static
vishal.b782eb5d2015-04-29 12:22:5796FrameTreeNode* FrameTreeNode::GloballyFindByID(int frame_tree_node_id) {
mostynb366eaf12015-03-26 00:51:1997 DCHECK_CURRENTLY_ON(BrowserThread::UI);
rob97250742015-12-10 17:45:1598 FrameTreeNodeIdMap* nodes = g_frame_tree_node_id_map.Pointer();
jdoerrie55ec69d2018-10-08 13:34:4699 auto it = nodes->find(frame_tree_node_id);
dmazzonie950ea232015-03-13 21:39:45100 return it == nodes->end() ? nullptr : it->second;
101}
102
Alexander Timin381e7e182020-04-28 19:04:03103// static
104FrameTreeNode* FrameTreeNode::From(RenderFrameHost* rfh) {
105 if (!rfh)
106 return nullptr;
107 return static_cast<RenderFrameHostImpl*>(rfh)->frame_tree_node();
108}
109
Julie Jeongeun Kim70a2e4e2020-02-21 05:09:54110FrameTreeNode::FrameTreeNode(
111 FrameTree* frame_tree,
Alexander Timin381e7e182020-04-28 19:04:03112 RenderFrameHostImpl* parent,
Antonio Gomes9d5c1ef2020-04-30 20:56:41113 blink::mojom::TreeScopeType scope,
Julie Jeongeun Kim70a2e4e2020-02-21 05:09:54114 const std::string& name,
115 const std::string& unique_name,
116 bool is_created_by_script,
117 const base::UnguessableToken& devtools_frame_token,
118 const blink::mojom::FrameOwnerProperties& frame_owner_properties,
Antonio Gomes58d38062020-04-30 01:50:14119 blink::mojom::FrameOwnerElementType owner_type)
[email protected]bffc8302014-01-23 20:52:16120 : frame_tree_(frame_tree),
[email protected]bffc8302014-01-23 20:52:16121 frame_tree_node_id_(next_frame_tree_node_id_++),
xiaochengh98488162016-05-19 15:17:59122 parent_(parent),
Alexander Timin381e7e182020-04-28 19:04:03123 depth_(parent ? parent->frame_tree_node()->depth_ + 1 : 0u),
alexmose201c7cd2015-06-10 17:14:21124 opener_(nullptr),
jochen6004a362017-02-04 00:11:40125 original_opener_(nullptr),
creisf0f069a2015-07-23 23:51:53126 has_committed_real_load_(false),
engedy6e2e0992017-05-25 18:58:42127 is_collapsed_(false),
Antonio Sartori90f41212021-01-22 10:08:34128 replication_state_(mojom::FrameReplicationState::New(
129 url::Origin(),
estarka886b8d2015-12-18 21:53:08130 name,
lukasza464d8692016-02-22 19:26:32131 unique_name,
Charlie Hue24f04832021-03-04 21:07:06132 blink::ParsedPermissionsPolicy(),
Antonio Sartori90f41212021-01-22 10:08:34133 network::mojom::WebSandboxFlags::kNone,
134 blink::FramePolicy(),
Antonio Sartori90f41212021-01-22 10:08:34135 scope,
Julie Jeongeun Kimd90e2dd2020-03-03 11:45:37136 blink::mojom::InsecureRequestPolicy::
137 kLeaveInsecureRequestsAlone /* should enforce strict mixed content
138 checking */
139 ,
arthursonzogni4b62a5cb2018-01-17 14:14:26140 std::vector<uint32_t>()
141 /* hashes of hosts for insecure request upgrades */,
japhet61835ae12017-01-20 01:25:39142 false /* is a potentially trustworthy unique origin */,
danakj359a4342020-05-29 20:38:39143 false /* has an active user gesture */,
Ehsan Karamad192a8da2018-10-21 03:48:08144 false /* has received a user gesture before nav */,
Antonio Sartori90f41212021-01-22 10:08:34145 owner_type,
146 blink::mojom::AdFrameType::kNonAd)),
Lukasz Anforowicz7bfb2e92017-11-22 17:19:45147 is_created_by_script_(is_created_by_script),
Pavel Feldman25234722017-10-11 02:49:06148 devtools_frame_token_(devtools_frame_token),
lazyboy70605c32015-11-03 01:27:31149 frame_owner_properties_(frame_owner_properties),
Shubhie Panickerddf2a4e2018-03-06 00:09:06150 was_discarded_(false),
Lukasz Anforowicz147141962020-12-16 18:03:24151 blame_context_(frame_tree_node_id_, FrameTreeNode::From(parent)),
152 render_manager_(this, frame_tree->manager_delegate()) {
rob97250742015-12-10 17:45:15153 std::pair<FrameTreeNodeIdMap::iterator, bool> result =
dmazzonie950ea232015-03-13 21:39:45154 g_frame_tree_node_id_map.Get().insert(
155 std::make_pair(frame_tree_node_id_, this));
156 CHECK(result.second);
benjhaydend4da63d2016-03-11 21:29:33157
xiaochenghb9554bb2016-05-21 14:20:48158 // Note: this should always be done last in the constructor.
159 blame_context_.Initialize();
alexmos998581d2015-01-22 01:01:59160}
[email protected]9b159a52013-10-03 17:24:55161
162FrameTreeNode::~FrameTreeNode() {
Nasko Oskov252ae042018-10-04 21:44:12163 // Remove the children.
164 current_frame_host()->ResetChildren();
Lukasz Anforowicz7bfb2e92017-11-22 17:19:45165
Nate Chapin22ea6592019-03-05 22:29:02166 current_frame_host()->ResetLoadingState();
167
Lukasz Anforowicz7bfb2e92017-11-22 17:19:45168 // If the removed frame was created by a script, then its history entry will
169 // never be reused - we can save some memory by removing the history entry.
170 // See also https://crbug.com/784356.
171 if (is_created_by_script_ && parent_) {
Carlos Caballero04aab362021-02-15 17:38:16172 NavigationEntryImpl* nav_entry =
173 navigator().controller().GetLastCommittedEntry();
Lukasz Anforowicz7bfb2e92017-11-22 17:19:45174 if (nav_entry) {
175 nav_entry->RemoveEntryForFrame(this,
176 /* only_if_different_position = */ false);
177 }
178 }
179
dmazzonie950ea232015-03-13 21:39:45180 frame_tree_->FrameRemoved(this);
Carlos Caballero6ff6ace2021-02-05 16:53:00181
182 // Do not dispatch notification for the root frame as ~WebContentsImpl already
183 // dispatches it for now.
184 // TODO(https://crbug.com/1170277): This is only needed because the FrameTree
185 // is a member of WebContentsImpl and we would call back into it during
186 // destruction. We should clean up the FrameTree destruction code and call the
187 // delegate unconditionally.
188 if (parent())
189 render_manager_.delegate()->OnFrameTreeNodeDestroyed(this);
190
ericwilligers254597b2016-10-17 10:32:31191 for (auto& observer : observers_)
192 observer.OnFrameTreeNodeDestroyed(this);
Lukasz Anforowicz147141962020-12-16 18:03:24193 observers_.Clear();
alexmose201c7cd2015-06-10 17:14:21194
195 if (opener_)
196 opener_->RemoveObserver(opener_observer_.get());
jochen6004a362017-02-04 00:11:40197 if (original_opener_)
198 original_opener_->RemoveObserver(original_opener_observer_.get());
dmazzonie950ea232015-03-13 21:39:45199
200 g_frame_tree_node_id_map.Get().erase(frame_tree_node_id_);
jam39258caf2016-11-02 14:48:18201
danakjf9400602019-06-07 15:44:58202 bool did_stop_loading = false;
203
jam39258caf2016-11-02 14:48:18204 if (navigation_request_) {
danakjf9400602019-06-07 15:44:58205 navigation_request_.reset();
Arthur Hemery0dd65812019-08-01 14:18:45206 // If a frame with a pending navigation is detached, make sure the
207 // WebContents (and its observers) update their loading state.
danakjf9400602019-06-07 15:44:58208 did_stop_loading = true;
jam39258caf2016-11-02 14:48:18209 }
Nate Chapin22ea6592019-03-05 22:29:02210
danakjf9400602019-06-07 15:44:58211 // ~SiteProcessCountTracker DCHECKs in some tests if the speculative
212 // RenderFrameHostImpl is not destroyed last. Ideally this would be closer to
213 // (possible before) the ResetLoadingState() call above.
214 //
215 // There is an inherent race condition causing bugs 838348/915179/et al, where
216 // the renderer may have committed the speculative main frame and the browser
217 // has not heard about it yet. If this is a main frame, then in that case the
218 // speculative RenderFrame was unable to be deleted (it is owned by the
219 // renderer) and we should not be able to cancel the navigation at this point.
220 // CleanUpNavigation() would normally be called here but it will try to undo
221 // the navigation and expose the race condition. When it replaces the main
222 // frame with a RenderFrameProxy, that leaks the committed main frame, leaving
223 // the frame and its friend group with pointers that will become invalid
224 // shortly as we are shutting everything down and deleting the RenderView etc.
225 // We avoid this problematic situation by not calling CleanUpNavigation() or
226 // DiscardUnusedFrame() here. The speculative RenderFrameHost is simply
227 // returned and deleted immediately. This satisfies the requirement that the
228 // speculative RenderFrameHost is removed from the RenderFrameHostManager
229 // before it is destroyed.
230 if (render_manager_.speculative_frame_host()) {
231 did_stop_loading |= render_manager_.speculative_frame_host()->is_loading();
232 render_manager_.UnsetSpeculativeRenderFrameHost();
233 }
234
235 if (did_stop_loading)
236 DidStopLoading();
237
Nate Chapin22ea6592019-03-05 22:29:02238 DCHECK(!IsLoading());
[email protected]9b159a52013-10-03 17:24:55239}
240
alexmose201c7cd2015-06-10 17:14:21241void FrameTreeNode::AddObserver(Observer* observer) {
242 observers_.AddObserver(observer);
243}
244
245void FrameTreeNode::RemoveObserver(Observer* observer) {
246 observers_.RemoveObserver(observer);
247}
248
[email protected]94d0cc12013-12-18 00:07:41249bool FrameTreeNode::IsMainFrame() const {
250 return frame_tree_->root() == this;
251}
252
arthursonzogni76098e52020-11-25 14:18:45253void FrameTreeNode::ResetForNavigation(
Alexander Timin45b716c2020-11-06 01:40:31254 bool was_served_from_back_forward_cache) {
arthursonzogni76098e52020-11-25 14:18:45255 // This frame has had its user activation bits cleared in the renderer before
256 // arriving here. We just need to clear them here and in the other renderer
257 // processes that may have a reference to this frame.
Alexander Timin45b716c2020-11-06 01:40:31258 //
259 // We do not take user activation into account when calculating
260 // |ResetForNavigationResult|, as we are using it to determine bfcache
261 // eligibility and the page can get another user gesture after restore.
Antonio Gomes4b2c5132020-01-16 11:49:48262 UpdateUserActivationState(
Mustaq Ahmeddc195e5b2020-08-04 18:45:11263 blink::mojom::UserActivationUpdateType::kClearActivation,
264 blink::mojom::UserActivationNotificationType::kNone);
Ian Clelland5cbaaf82017-11-27 22:00:03265}
266
yilkal34a3d752019-08-30 18:20:30267size_t FrameTreeNode::GetFrameTreeSize() const {
268 if (is_collapsed())
269 return 0;
270
271 size_t size = 0;
272 for (size_t i = 0; i < child_count(); i++) {
273 size += child_at(i)->GetFrameTreeSize();
274 }
275
276 // Account for this node.
277 size++;
278 return size;
279}
280
alexmose201c7cd2015-06-10 17:14:21281void FrameTreeNode::SetOpener(FrameTreeNode* opener) {
282 if (opener_) {
283 opener_->RemoveObserver(opener_observer_.get());
284 opener_observer_.reset();
285 }
286
287 opener_ = opener;
288
289 if (opener_) {
Jeremy Roman04f27c372017-10-27 15:20:55290 opener_observer_ = std::make_unique<OpenerDestroyedObserver>(this, false);
alexmose201c7cd2015-06-10 17:14:21291 opener_->AddObserver(opener_observer_.get());
292 }
293}
294
Wolfgang Beyerd8809db2020-09-30 15:29:39295void FrameTreeNode::SetOpenerDevtoolsFrameToken(
296 base::UnguessableToken opener_devtools_frame_token) {
297 DCHECK(!opener_devtools_frame_token_ ||
298 opener_devtools_frame_token_->is_empty());
299 opener_devtools_frame_token_ = std::move(opener_devtools_frame_token);
300}
301
jochen6004a362017-02-04 00:11:40302void FrameTreeNode::SetOriginalOpener(FrameTreeNode* opener) {
Avi Drissman36465f332017-09-11 20:49:39303 // The original opener tracks main frames only.
avi8d1aa162017-03-27 18:27:37304 DCHECK(opener == nullptr || !opener->parent());
jochen6004a362017-02-04 00:11:40305
Avi Drissman36465f332017-09-11 20:49:39306 if (original_opener_) {
307 original_opener_->RemoveObserver(original_opener_observer_.get());
308 original_opener_observer_.reset();
309 }
310
jochen6004a362017-02-04 00:11:40311 original_opener_ = opener;
312
313 if (original_opener_) {
jochen6004a362017-02-04 00:11:40314 original_opener_observer_ =
Jeremy Roman04f27c372017-10-27 15:20:55315 std::make_unique<OpenerDestroyedObserver>(this, true);
jochen6004a362017-02-04 00:11:40316 original_opener_->AddObserver(original_opener_observer_.get());
317 }
318}
319
creisf0f069a2015-07-23 23:51:53320void FrameTreeNode::SetCurrentURL(const GURL& url) {
Balazs Engedyc8a7cccf2018-03-12 23:00:49321 if (!has_committed_real_load_ && !url.IsAboutBlank())
creisf0f069a2015-07-23 23:51:53322 has_committed_real_load_ = true;
Erik Chen173bf3042017-07-31 06:06:21323 current_frame_host()->SetLastCommittedUrl(url);
xiaochenghb9554bb2016-05-21 14:20:48324 blame_context_.TakeSnapshot();
creisf0f069a2015-07-23 23:51:53325}
326
estarkbd8e26f2016-03-16 23:30:37327void FrameTreeNode::SetCurrentOrigin(
328 const url::Origin& origin,
329 bool is_potentially_trustworthy_unique_origin) {
Antonio Sartori90f41212021-01-22 10:08:34330 if (!origin.IsSameOriginWith(replication_state_->origin) ||
331 replication_state_->has_potentially_trustworthy_unique_origin !=
estarkbd8e26f2016-03-16 23:30:37332 is_potentially_trustworthy_unique_origin) {
333 render_manager_.OnDidUpdateOrigin(origin,
334 is_potentially_trustworthy_unique_origin);
335 }
Antonio Sartori90f41212021-01-22 10:08:34336 replication_state_->origin = origin;
337 replication_state_->has_potentially_trustworthy_unique_origin =
estarkbd8e26f2016-03-16 23:30:37338 is_potentially_trustworthy_unique_origin;
alexmosa7a4ff822015-04-27 17:59:56339}
alexmosbe2f4c32015-03-10 02:30:23340
engedy6e2e0992017-05-25 18:58:42341void FrameTreeNode::SetCollapsed(bool collapsed) {
342 DCHECK(!IsMainFrame());
343 if (is_collapsed_ == collapsed)
344 return;
345
346 is_collapsed_ = collapsed;
347 render_manager_.OnDidChangeCollapsedState(collapsed);
348}
349
lukasza464d8692016-02-22 19:26:32350void FrameTreeNode::SetFrameName(const std::string& name,
351 const std::string& unique_name) {
Antonio Sartori90f41212021-01-22 10:08:34352 if (name == replication_state_->name) {
lukasza464d8692016-02-22 19:26:32353 // |unique_name| shouldn't change unless |name| changes.
Antonio Sartori90f41212021-01-22 10:08:34354 DCHECK_EQ(unique_name, replication_state_->unique_name);
lukasza464d8692016-02-22 19:26:32355 return;
356 }
lukasza5140a412016-09-15 21:12:30357
358 if (parent()) {
359 // Non-main frames should have a non-empty unique name.
360 DCHECK(!unique_name.empty());
361 } else {
362 // Unique name of main frames should always stay empty.
363 DCHECK(unique_name.empty());
364 }
365
Daniel Cheng6ca7f1c92017-08-09 21:45:41366 // Note the unique name should only be able to change before the first real
367 // load is committed, but that's not strongly enforced here.
lukasza464d8692016-02-22 19:26:32368 render_manager_.OnDidUpdateName(name, unique_name);
Antonio Sartori90f41212021-01-22 10:08:34369 replication_state_->name = name;
370 replication_state_->unique_name = unique_name;
alexmosbe2f4c32015-03-10 02:30:23371}
372
mkwstf672e7ef2016-06-09 20:51:07373void FrameTreeNode::SetInsecureRequestPolicy(
Julie Jeongeun Kimd90e2dd2020-03-03 11:45:37374 blink::mojom::InsecureRequestPolicy policy) {
Antonio Sartori90f41212021-01-22 10:08:34375 if (policy == replication_state_->insecure_request_policy)
estarka886b8d2015-12-18 21:53:08376 return;
mkwstf672e7ef2016-06-09 20:51:07377 render_manager_.OnEnforceInsecureRequestPolicy(policy);
Antonio Sartori90f41212021-01-22 10:08:34378 replication_state_->insecure_request_policy = policy;
estarka886b8d2015-12-18 21:53:08379}
380
arthursonzogni4b62a5cb2018-01-17 14:14:26381void FrameTreeNode::SetInsecureNavigationsSet(
382 const std::vector<uint32_t>& insecure_navigations_set) {
383 DCHECK(std::is_sorted(insecure_navigations_set.begin(),
384 insecure_navigations_set.end()));
Antonio Sartori90f41212021-01-22 10:08:34385 if (insecure_navigations_set == replication_state_->insecure_navigations_set)
arthursonzogni4b62a5cb2018-01-17 14:14:26386 return;
387 render_manager_.OnEnforceInsecureNavigationsSet(insecure_navigations_set);
Antonio Sartori90f41212021-01-22 10:08:34388 replication_state_->insecure_navigations_set = insecure_navigations_set;
arthursonzogni4b62a5cb2018-01-17 14:14:26389}
390
Luna Luc3fdacdf2017-11-08 04:48:53391void FrameTreeNode::SetPendingFramePolicy(blink::FramePolicy frame_policy) {
Ian Clellandcdc4f312017-10-13 22:24:12392 pending_frame_policy_.sandbox_flags = frame_policy.sandbox_flags;
Dave Tapuska9b153a942020-02-10 19:35:10393 pending_frame_policy_.disallow_document_access =
394 frame_policy.disallow_document_access;
alexmos6e940102016-01-19 22:47:25395
Ian Clellandcdc4f312017-10-13 22:24:12396 if (parent()) {
397 // Subframes should always inherit their parent's sandbox flags.
Alexander Timin381e7e182020-04-28 19:04:03398 pending_frame_policy_.sandbox_flags |=
399 parent()->frame_tree_node()->active_sandbox_flags();
Charlie Hue1b77ac2019-12-13 21:30:17400 // This is only applied on subframes; container policy and required document
401 // policy are not mutable on main frame.
Ian Clellandcdc4f312017-10-13 22:24:12402 pending_frame_policy_.container_policy = frame_policy.container_policy;
Charlie Hue1b77ac2019-12-13 21:30:17403 pending_frame_policy_.required_document_policy =
404 frame_policy.required_document_policy;
Ian Clellandcdc4f312017-10-13 22:24:12405 }
iclelland92f8c0b2017-04-19 12:43:05406}
407
alexmos9f8705a2015-05-06 19:58:59408FrameTreeNode* FrameTreeNode::PreviousSibling() const {
paulmeyer322777fb2016-05-16 23:15:39409 return GetSibling(-1);
410}
alexmos9f8705a2015-05-06 19:58:59411
paulmeyer322777fb2016-05-16 23:15:39412FrameTreeNode* FrameTreeNode::NextSibling() const {
413 return GetSibling(1);
alexmos9f8705a2015-05-06 19:58:59414}
415
fdegans4a49ce932015-03-12 17:11:37416bool FrameTreeNode::IsLoading() const {
417 RenderFrameHostImpl* current_frame_host =
418 render_manager_.current_frame_host();
fdegans4a49ce932015-03-12 17:11:37419
420 DCHECK(current_frame_host);
fdegans39ff0382015-04-29 19:04:39421
clamy610c63b32017-12-22 15:05:18422 if (navigation_request_)
423 return true;
clamy11e11512015-07-07 16:42:17424
clamy610c63b32017-12-22 15:05:18425 RenderFrameHostImpl* speculative_frame_host =
426 render_manager_.speculative_frame_host();
427 if (speculative_frame_host && speculative_frame_host->is_loading())
428 return true;
fdegans4a49ce932015-03-12 17:11:37429 return current_frame_host->is_loading();
430}
431
Alex Moshchuk9b0fd822020-10-26 23:08:15432bool FrameTreeNode::HasPendingCrossDocumentNavigation() const {
433 // Having a |navigation_request_| on FrameTreeNode implies that there's an
434 // ongoing navigation that hasn't reached the ReadyToCommit state. If the
435 // navigation is between ReadyToCommit and DidCommitNavigation, the
436 // NavigationRequest will be held by RenderFrameHost, which is checked below.
437 if (navigation_request_ && !navigation_request_->IsSameDocument())
438 return true;
439
440 // Having a speculative RenderFrameHost should imply a cross-document
441 // navigation.
442 if (render_manager_.speculative_frame_host())
443 return true;
444
445 return render_manager_.current_frame_host()
446 ->HasPendingCommitForCrossDocumentNavigation();
447}
448
Charlie Hu5ffc0152019-12-06 15:59:53449bool FrameTreeNode::CommitFramePolicy(
450 const blink::FramePolicy& new_frame_policy) {
451 bool did_change_flags = new_frame_policy.sandbox_flags !=
Antonio Sartori90f41212021-01-22 10:08:34452 replication_state_->frame_policy.sandbox_flags;
iclelland92f8c0b2017-04-19 12:43:05453 bool did_change_container_policy =
Charlie Hu5ffc0152019-12-06 15:59:53454 new_frame_policy.container_policy !=
Antonio Sartori90f41212021-01-22 10:08:34455 replication_state_->frame_policy.container_policy;
Charlie Hue1b77ac2019-12-13 21:30:17456 bool did_change_required_document_policy =
457 pending_frame_policy_.required_document_policy !=
Antonio Sartori90f41212021-01-22 10:08:34458 replication_state_->frame_policy.required_document_policy;
Dave Tapuska9b153a942020-02-10 19:35:10459 bool did_change_document_access =
460 new_frame_policy.disallow_document_access !=
Antonio Sartori90f41212021-01-22 10:08:34461 replication_state_->frame_policy.disallow_document_access;
462 if (did_change_flags) {
463 replication_state_->frame_policy.sandbox_flags =
Charlie Hu5ffc0152019-12-06 15:59:53464 new_frame_policy.sandbox_flags;
Antonio Sartori90f41212021-01-22 10:08:34465 }
466 if (did_change_container_policy) {
467 replication_state_->frame_policy.container_policy =
Charlie Hu5ffc0152019-12-06 15:59:53468 new_frame_policy.container_policy;
Antonio Sartori90f41212021-01-22 10:08:34469 }
470 if (did_change_required_document_policy) {
471 replication_state_->frame_policy.required_document_policy =
Charlie Hue1b77ac2019-12-13 21:30:17472 new_frame_policy.required_document_policy;
Antonio Sartori90f41212021-01-22 10:08:34473 }
474 if (did_change_document_access) {
475 replication_state_->frame_policy.disallow_document_access =
Dave Tapuska9b153a942020-02-10 19:35:10476 new_frame_policy.disallow_document_access;
Antonio Sartori90f41212021-01-22 10:08:34477 }
Charlie Hue1b77ac2019-12-13 21:30:17478
Charlie Hu5ffc0152019-12-06 15:59:53479 UpdateFramePolicyHeaders(new_frame_policy.sandbox_flags,
Charlie Hue20fe2f2021-03-07 03:39:59480 replication_state_->permissions_policy_header);
Charlie Hue1b77ac2019-12-13 21:30:17481 return did_change_flags || did_change_container_policy ||
Dave Tapuska9b153a942020-02-10 19:35:10482 did_change_required_document_policy || did_change_document_access;
alexmos6b294562015-03-05 19:24:10483}
484
Arthur Hemeryc3380172018-01-22 14:00:17485void FrameTreeNode::TransferNavigationRequestOwnership(
486 RenderFrameHostImpl* render_frame_host) {
Andrey Kosyakovf2d4ff72018-10-29 20:09:59487 devtools_instrumentation::OnResetNavigationRequest(navigation_request_.get());
Arthur Hemeryc3380172018-01-22 14:00:17488 render_frame_host->SetNavigationRequest(std::move(navigation_request_));
489}
490
carloskc49005eb2015-06-16 11:25:07491void FrameTreeNode::CreatedNavigationRequest(
dcheng9bfa5162016-04-09 01:00:57492 std::unique_ptr<NavigationRequest> navigation_request) {
arthursonzognic79c251c2016-08-18 15:00:37493 // This is never called when navigating to a Javascript URL. For the loading
494 // state, this matches what Blink is doing: Blink doesn't send throbber
495 // notifications for Javascript URLS.
496 DCHECK(!navigation_request->common_params().url.SchemeIs(
497 url::kJavaScriptScheme));
498
clamy44e84ce2016-02-22 15:38:25499 bool was_previously_loading = frame_tree()->IsLoading();
500
clamy82a2f4d2016-02-02 14:20:41501 // There's no need to reset the state: there's still an ongoing load, and the
502 // RenderFrameHostManager will take care of updates to the speculative
503 // RenderFrameHost in DidCreateNavigationRequest below.
jamcd0b7b22017-03-24 22:13:05504 if (was_previously_loading) {
Mohamed Abdelhalimf03d4a22019-10-01 13:34:31505 if (navigation_request_ && navigation_request_->IsNavigationStarted()) {
jamcd0b7b22017-03-24 22:13:05506 // Mark the old request as aborted.
Mohamed Abdelhalimb4db22a2019-06-18 10:46:52507 navigation_request_->set_net_error(net::ERR_ABORTED);
jamcd0b7b22017-03-24 22:13:05508 }
Arthur Hemery241b9392019-10-24 11:08:41509 ResetNavigationRequest(true);
jamcd0b7b22017-03-24 22:13:05510 }
clamy44e84ce2016-02-22 15:38:25511
512 navigation_request_ = std::move(navigation_request);
Shubhie Panickerddf2a4e2018-03-06 00:09:06513 if (was_discarded_) {
514 navigation_request_->set_was_discarded();
515 was_discarded_ = false;
516 }
clamy8e2e299202016-04-05 11:44:59517 render_manager()->DidCreateNavigationRequest(navigation_request_.get());
fdegans39ff0382015-04-29 19:04:39518
Lucas Furukawa Gadanief8290a2019-07-29 20:27:51519 bool to_different_document = !NavigationTypeUtils::IsSameDocument(
arthursonzogni92f18682017-02-08 23:00:04520 navigation_request_->common_params().navigation_type);
521
522 DidStartLoading(to_different_document, was_previously_loading);
clamydcb434c12015-04-16 19:29:16523}
524
Arthur Hemery241b9392019-10-24 11:08:41525void FrameTreeNode::ResetNavigationRequest(bool keep_state) {
fdegans39ff0382015-04-29 19:04:39526 if (!navigation_request_)
527 return;
John Abd-El-Malekdcc7bf42017-09-12 22:30:23528
Andrey Kosyakovf2d4ff72018-10-29 20:09:59529 devtools_instrumentation::OnResetNavigationRequest(navigation_request_.get());
clamydcb434c12015-04-16 19:29:16530 navigation_request_.reset();
fdegans39ff0382015-04-29 19:04:39531
clamy82a2f4d2016-02-02 14:20:41532 if (keep_state)
fdegans39ff0382015-04-29 19:04:39533 return;
534
clamy82a2f4d2016-02-02 14:20:41535 // The RenderFrameHostManager should clean up any speculative RenderFrameHost
536 // it created for the navigation. Also register that the load stopped.
fdegans39ff0382015-04-29 19:04:39537 DidStopLoading();
538 render_manager_.CleanUpNavigation();
clamydcb434c12015-04-16 19:29:16539}
540
clamy44e84ce2016-02-22 15:38:25541void FrameTreeNode::DidStartLoading(bool to_different_document,
542 bool was_previously_loading) {
Camille Lamyefd54b02018-10-04 16:54:14543 TRACE_EVENT2("navigation", "FrameTreeNode::DidStartLoading",
544 "frame_tree_node", frame_tree_node_id(), "to different document",
545 to_different_document);
fdegansa696e5112015-04-17 01:57:59546
Carlos Caballero03262522021-02-05 14:49:58547 frame_tree_->DidStartLoadingNode(*this, to_different_document,
548 was_previously_loading);
fdegansa696e5112015-04-17 01:57:59549
550 // Set initial load progress and update overall progress. This will notify
551 // the WebContents of the load progress change.
552 DidChangeLoadProgress(kLoadingProgressMinimum);
553
554 // Notify the RenderFrameHostManager of the event.
555 render_manager()->OnDidStartLoading();
556}
557
558void FrameTreeNode::DidStopLoading() {
Camille Lamyefd54b02018-10-04 16:54:14559 TRACE_EVENT1("navigation", "FrameTreeNode::DidStopLoading", "frame_tree_node",
560 frame_tree_node_id());
fdegansa696e5112015-04-17 01:57:59561 // Set final load progress and update overall progress. This will notify
562 // the WebContents of the load progress change.
563 DidChangeLoadProgress(kLoadingProgressDone);
564
Lucas Furukawa Gadani6faef602019-05-06 21:16:03565 // Notify the RenderFrameHostManager of the event.
566 render_manager()->OnDidStopLoading();
567
Carlos Caballero03262522021-02-05 14:49:58568 frame_tree_->DidStopLoadingNode(*this);
fdegansa696e5112015-04-17 01:57:59569}
570
571void FrameTreeNode::DidChangeLoadProgress(double load_progress) {
Nate Chapin93536702018-02-07 00:12:21572 DCHECK_GE(load_progress, kLoadingProgressMinimum);
573 DCHECK_LE(load_progress, kLoadingProgressDone);
Carlos Caballero03262522021-02-05 14:49:58574 frame_tree_->DidChangeLoadProgressForNode(*this, load_progress);
fdegansa696e5112015-04-17 01:57:59575}
576
clamyf73862c42015-07-08 12:31:33577bool FrameTreeNode::StopLoading() {
arthursonzogni66f711c2019-10-08 14:40:36578 if (navigation_request_ && navigation_request_->IsNavigationStarted())
579 navigation_request_->set_net_error(net::ERR_ABORTED);
Arthur Hemery241b9392019-10-24 11:08:41580 ResetNavigationRequest(false);
clamyf73862c42015-07-08 12:31:33581
clamyf73862c42015-07-08 12:31:33582 if (!IsMainFrame())
583 return true;
584
585 render_manager_.Stop();
586 return true;
587}
588
alexmos21acae52015-11-07 01:04:43589void FrameTreeNode::DidFocus() {
590 last_focus_time_ = base::TimeTicks::Now();
ericwilligers254597b2016-10-17 10:32:31591 for (auto& observer : observers_)
592 observer.OnFrameTreeNodeFocused(this);
alexmos21acae52015-11-07 01:04:43593}
594
clamy44e84ce2016-02-22 15:38:25595void FrameTreeNode::BeforeUnloadCanceled() {
596 // TODO(clamy): Support BeforeUnload in subframes.
597 if (!IsMainFrame())
598 return;
599
600 RenderFrameHostImpl* current_frame_host =
601 render_manager_.current_frame_host();
602 DCHECK(current_frame_host);
603 current_frame_host->ResetLoadingState();
604
clamy610c63b32017-12-22 15:05:18605 RenderFrameHostImpl* speculative_frame_host =
606 render_manager_.speculative_frame_host();
607 if (speculative_frame_host)
608 speculative_frame_host->ResetLoadingState();
Alexander Timin23c110b2021-01-14 02:39:04609 // Note: there is no need to set an error code on the NavigationHandle as
610 // the observers have not been notified about its creation.
611 // We also reset navigation request only when this navigation request was
612 // responsible for this dialog, as a new navigation request might cancel
613 // existing unrelated dialog.
614 if (navigation_request_ && navigation_request_->IsWaitingForBeforeUnload())
Arthur Hemery241b9392019-10-24 11:08:41615 ResetNavigationRequest(false);
clamy44e84ce2016-02-22 15:38:25616}
617
Mustaq Ahmedecb5c38e2020-07-29 00:34:30618bool FrameTreeNode::NotifyUserActivation(
619 blink::mojom::UserActivationNotificationType notification_type) {
Alexander Timina1dfadaa2020-04-28 13:30:06620 for (RenderFrameHostImpl* rfh = current_frame_host(); rfh;
621 rfh = rfh->GetParent()) {
622 if (!rfh->frame_tree_node()->user_activation_state_.HasBeenActive())
623 rfh->DidReceiveFirstUserActivation();
Mustaq Ahmedecb5c38e2020-07-29 00:34:30624 rfh->frame_tree_node()->user_activation_state_.Activate(notification_type);
John Delaneyedd8d6c2019-01-25 00:23:57625 }
Antonio Sartori90f41212021-01-22 10:08:34626 replication_state_->has_active_user_gesture = true;
Mustaq Ahmeda5dfa60b2018-12-08 00:30:14627
Mustaq Ahmed0180320f2019-03-21 16:07:01628 // See the "Same-origin Visibility" section in |UserActivationState| class
629 // doc.
Mustaq Ahmede5f12562019-10-30 18:02:03630 if (base::FeatureList::IsEnabled(
Mustaq Ahmeda5dfa60b2018-12-08 00:30:14631 features::kUserActivationSameOriginVisibility)) {
632 const url::Origin& current_origin =
633 this->current_frame_host()->GetLastCommittedOrigin();
634 for (FrameTreeNode* node : frame_tree()->Nodes()) {
635 if (node->current_frame_host()->GetLastCommittedOrigin().IsSameOriginWith(
636 current_origin)) {
Mustaq Ahmedecb5c38e2020-07-29 00:34:30637 node->user_activation_state_.Activate(notification_type);
Mustaq Ahmeda5dfa60b2018-12-08 00:30:14638 }
639 }
640 }
641
Carlos Caballero40b0efd2021-01-26 11:55:00642 navigator().controller().NotifyUserActivation();
Shivani Sharma194877032019-03-07 17:52:47643
Mustaq Ahmedc4cb7162018-06-05 16:28:36644 return true;
645}
646
647bool FrameTreeNode::ConsumeTransientUserActivation() {
648 bool was_active = user_activation_state_.IsActive();
649 for (FrameTreeNode* node : frame_tree()->Nodes())
650 node->user_activation_state_.ConsumeIfActive();
Antonio Sartori90f41212021-01-22 10:08:34651 replication_state_->has_active_user_gesture = false;
Mustaq Ahmedc4cb7162018-06-05 16:28:36652 return was_active;
653}
654
Shivani Sharmac4f561582018-11-15 15:58:39655bool FrameTreeNode::ClearUserActivation() {
Shivani Sharmac4f561582018-11-15 15:58:39656 for (FrameTreeNode* node : frame_tree()->SubtreeNodes(this))
657 node->user_activation_state_.Clear();
Antonio Sartori90f41212021-01-22 10:08:34658 replication_state_->has_active_user_gesture = false;
Shivani Sharmac4f561582018-11-15 15:58:39659 return true;
660}
661
Ella Ge9caed612019-08-09 16:17:25662bool FrameTreeNode::VerifyUserActivation() {
Ella Gea78f6772019-12-11 10:35:25663 DCHECK(base::FeatureList::IsEnabled(
664 features::kBrowserVerifiedUserActivationMouse) ||
665 base::FeatureList::IsEnabled(
666 features::kBrowserVerifiedUserActivationKeyboard));
667
Ella Ge9caed612019-08-09 16:17:25668 return render_manager_.current_frame_host()
669 ->GetRenderWidgetHost()
Mustaq Ahmed83bb1722019-10-22 20:00:10670 ->RemovePendingUserActivationIfAvailable();
Ella Ge9caed612019-08-09 16:17:25671}
672
Mustaq Ahmedc4cb7162018-06-05 16:28:36673bool FrameTreeNode::UpdateUserActivationState(
Mustaq Ahmeddc195e5b2020-08-04 18:45:11674 blink::mojom::UserActivationUpdateType update_type,
675 blink::mojom::UserActivationNotificationType notification_type) {
Ella Ge9caed612019-08-09 16:17:25676 bool update_result = false;
Mustaq Ahmedc4cb7162018-06-05 16:28:36677 switch (update_type) {
Antonio Gomes4b2c5132020-01-16 11:49:48678 case blink::mojom::UserActivationUpdateType::kConsumeTransientActivation:
Ella Ge9caed612019-08-09 16:17:25679 update_result = ConsumeTransientUserActivation();
680 break;
Antonio Gomes4b2c5132020-01-16 11:49:48681 case blink::mojom::UserActivationUpdateType::kNotifyActivation:
Mustaq Ahmeddc195e5b2020-08-04 18:45:11682 update_result = NotifyUserActivation(notification_type);
Ella Ge9caed612019-08-09 16:17:25683 break;
Antonio Gomes4b2c5132020-01-16 11:49:48684 case blink::mojom::UserActivationUpdateType::
Liviu Tintad9391fb92020-09-28 23:50:07685 kNotifyActivationPendingBrowserVerification: {
686 const bool user_activation_verified = VerifyUserActivation();
687 // Add UMA metric for when browser user activation verification succeeds
688 base::UmaHistogramBoolean("Event.BrowserVerifiedUserActivation",
689 user_activation_verified);
690 if (user_activation_verified) {
Mustaq Ahmedecb5c38e2020-07-29 00:34:30691 update_result = NotifyUserActivation(
Mustaq Ahmed2cfb0402020-09-29 19:24:35692 blink::mojom::UserActivationNotificationType::kInteraction);
Antonio Gomes4b2c5132020-01-16 11:49:48693 update_type = blink::mojom::UserActivationUpdateType::kNotifyActivation;
Ella Ge9caed612019-08-09 16:17:25694 } else {
695 // TODO(crbug.com/848778): We need to decide what to do when user
696 // activation verification failed. NOTREACHED here will make all
697 // unrelated tests that inject event to renderer fail.
698 return false;
699 }
Liviu Tintad9391fb92020-09-28 23:50:07700 } break;
Antonio Gomes4b2c5132020-01-16 11:49:48701 case blink::mojom::UserActivationUpdateType::kClearActivation:
Ella Ge9caed612019-08-09 16:17:25702 update_result = ClearUserActivation();
703 break;
Mustaq Ahmedc4cb7162018-06-05 16:28:36704 }
Mustaq Ahmeddc195e5b2020-08-04 18:45:11705 render_manager_.UpdateUserActivationState(update_type, notification_type);
Ella Ge9caed612019-08-09 16:17:25706 return update_result;
japhet61835ae12017-01-20 01:25:39707}
708
Mustaq Ahmed01261742019-12-16 15:49:06709void FrameTreeNode::OnSetHadStickyUserActivationBeforeNavigation(bool value) {
710 render_manager_.OnSetHadStickyUserActivationBeforeNavigation(value);
Antonio Sartori90f41212021-01-22 10:08:34711 replication_state_->has_received_user_gesture_before_nav = value;
Becca Hughes60af7d42017-12-12 10:53:15712}
713
paulmeyer322777fb2016-05-16 23:15:39714FrameTreeNode* FrameTreeNode::GetSibling(int relative_offset) const {
paulmeyerf3119f52016-05-17 17:37:19715 if (!parent_ || !parent_->child_count())
paulmeyer322777fb2016-05-16 23:15:39716 return nullptr;
717
718 for (size_t i = 0; i < parent_->child_count(); ++i) {
719 if (parent_->child_at(i) == this) {
720 if ((relative_offset < 0 && static_cast<size_t>(-relative_offset) > i) ||
721 i + relative_offset >= parent_->child_count()) {
722 return nullptr;
723 }
724 return parent_->child_at(i + relative_offset);
725 }
726 }
727
728 NOTREACHED() << "FrameTreeNode not found in its parent's children.";
729 return nullptr;
730}
731
Alexander Timin45b716c2020-11-06 01:40:31732bool FrameTreeNode::UpdateFramePolicyHeaders(
arthursonzognib93a4472020-04-10 07:38:00733 network::mojom::WebSandboxFlags sandbox_flags,
Charlie Hue24f04832021-03-04 21:07:06734 const blink::ParsedPermissionsPolicy& parsed_header) {
Ian Clellandedb8c5dd2018-03-01 17:01:37735 bool changed = false;
Charlie Hue20fe2f2021-03-07 03:39:59736 if (replication_state_->permissions_policy_header != parsed_header) {
737 replication_state_->permissions_policy_header = parsed_header;
Ian Clellandedb8c5dd2018-03-01 17:01:37738 changed = true;
739 }
Ian Clelland5cbaaf82017-11-27 22:00:03740 // TODO(iclelland): Kill the renderer if sandbox flags is not a subset of the
741 // currently effective sandbox flags from the frame. https://crbug.com/740556
arthursonzognib93a4472020-04-10 07:38:00742 network::mojom::WebSandboxFlags updated_flags =
Ian Clelland5cbaaf82017-11-27 22:00:03743 sandbox_flags | effective_frame_policy().sandbox_flags;
Antonio Sartori90f41212021-01-22 10:08:34744 if (replication_state_->active_sandbox_flags != updated_flags) {
745 replication_state_->active_sandbox_flags = updated_flags;
Ian Clellandedb8c5dd2018-03-01 17:01:37746 changed = true;
747 }
748 // Notify any proxies if the policies have been changed.
749 if (changed)
750 render_manager()->OnDidSetFramePolicyHeaders();
Alexander Timin45b716c2020-11-06 01:40:31751 return changed;
Ian Clelland5cbaaf82017-11-27 22:00:03752}
753
Arthur Sonzognif8840b92018-11-07 14:10:35754void FrameTreeNode::PruneChildFrameNavigationEntries(
755 NavigationEntryImpl* entry) {
756 for (size_t i = 0; i < current_frame_host()->child_count(); ++i) {
757 FrameTreeNode* child = current_frame_host()->child_at(i);
758 if (child->is_created_by_script_) {
759 entry->RemoveEntryForFrame(child,
760 /* only_if_different_position = */ false);
761 } else {
762 child->PruneChildFrameNavigationEntries(entry);
763 }
764 }
765}
766
Yao Xiao24ec9aa2020-01-28 16:36:00767void FrameTreeNode::SetAdFrameType(blink::mojom::AdFrameType ad_frame_type) {
768 DCHECK_NE(ad_frame_type, blink::mojom::AdFrameType::kNonAd);
Antonio Sartori90f41212021-01-22 10:08:34769 if (replication_state_->ad_frame_type == blink::mojom::AdFrameType::kNonAd) {
770 replication_state_->ad_frame_type = ad_frame_type;
Yao Xiao24ec9aa2020-01-28 16:36:00771 render_manager()->OnDidSetAdFrameType(ad_frame_type);
772 } else {
Antonio Sartori90f41212021-01-22 10:08:34773 DCHECK_EQ(ad_frame_type, replication_state_->ad_frame_type);
Yao Xiao24ec9aa2020-01-28 16:36:00774 }
775}
776
arthursonzogni034bb9c2020-10-01 08:29:56777void FrameTreeNode::SetInitialPopupURL(const GURL& initial_popup_url) {
778 DCHECK(initial_popup_url_.is_empty());
779 DCHECK(!has_committed_real_load_);
780 initial_popup_url_ = initial_popup_url;
781}
782
783void FrameTreeNode::SetPopupCreatorOrigin(
784 const url::Origin& popup_creator_origin) {
785 DCHECK(!has_committed_real_load_);
786 popup_creator_origin_ = popup_creator_origin;
787}
788
[email protected]9b159a52013-10-03 17:24:55789} // namespace content