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