Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(76)

Side by Side Diff: content/renderer/history_controller.cc

Issue 1848813005: Fix HistoryEntry corruption when commit isn't for provisional entry (try #2). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix test nits Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « content/browser/frame_host/navigation_controller_impl_browsertest.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 /* 5 /*
6 * Copyright (C) 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. 6 * Copyright (C) 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
7 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) 7 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
8 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. 8 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved.
9 * (http://www.torchmobile.com/) 9 * (http://www.torchmobile.com/)
10 * 10 *
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 } 182 }
183 183
184 void HistoryController::UpdateForCommit(RenderFrameImpl* frame, 184 void HistoryController::UpdateForCommit(RenderFrameImpl* frame,
185 const WebHistoryItem& item, 185 const WebHistoryItem& item,
186 WebHistoryCommitType commit_type, 186 WebHistoryCommitType commit_type,
187 bool navigation_within_page) { 187 bool navigation_within_page) {
188 switch (commit_type) { 188 switch (commit_type) {
189 case blink::WebBackForwardCommit: 189 case blink::WebBackForwardCommit:
190 if (!provisional_entry_) 190 if (!provisional_entry_)
191 return; 191 return;
192 current_entry_.reset(provisional_entry_.release()); 192
193 // If the current entry is null, this must be a main frame commit.
194 DCHECK(current_entry_ || frame->IsMainFrame());
195
196 // Commit the provisional entry, but only if it is a plausible transition.
197 // Do not commit it if the navigation is in a subframe and the provisional
198 // entry's main frame item does not match the current entry's main frame,
199 // which can happen if multiple forward navigations occur. In that case,
200 // committing the provisional entry would corrupt it, leading to a URL
201 // spoof. See https://crbug.com/597322. (Note that the race in this bug
202 // does not affect main frame navigations, only navigations in subframes.)
203 //
204 // Note that we cannot compare the provisional entry against |item|, since
205 // |item| may have redirected to a different URL and ISN. We also cannot
206 // compare against the main frame's URL, since that may have changed due
207 // to a replaceState. (Even origin can change on replaceState in certain
208 // modes.)
209 //
210 // It would be safe to additionally check the ISNs of all parent frames
211 // (and not just the root), but that is less critical because it won't
212 // lead to a URL spoof.
213 if (frame->IsMainFrame() ||
214 current_entry_->root().itemSequenceNumber() ==
215 provisional_entry_->root().itemSequenceNumber()) {
216 current_entry_.reset(provisional_entry_.release());
217 }
218
219 // We're guaranteed to have a current entry now.
220 DCHECK(current_entry_);
221
193 if (HistoryEntry::HistoryNode* node = 222 if (HistoryEntry::HistoryNode* node =
194 current_entry_->GetHistoryNodeForFrame(frame)) { 223 current_entry_->GetHistoryNodeForFrame(frame)) {
195 node->set_item(item); 224 node->set_item(item);
196 } 225 }
197 break; 226 break;
198 case blink::WebStandardCommit: 227 case blink::WebStandardCommit:
199 CreateNewBackForwardItem(frame, item, navigation_within_page); 228 CreateNewBackForwardItem(frame, item, navigation_within_page);
200 break; 229 break;
201 case blink::WebInitialCommitInChildFrame: 230 case blink::WebInitialCommitInChildFrame:
202 UpdateForInitialLoadInChildFrame(frame, item); 231 UpdateForInitialLoadInChildFrame(frame, item);
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
250 bool clone_children_of_target) { 279 bool clone_children_of_target) {
251 if (!current_entry_) { 280 if (!current_entry_) {
252 current_entry_.reset(new HistoryEntry(new_item)); 281 current_entry_.reset(new HistoryEntry(new_item));
253 } else { 282 } else {
254 current_entry_.reset(current_entry_->CloneAndReplace( 283 current_entry_.reset(current_entry_->CloneAndReplace(
255 new_item, clone_children_of_target, target_frame, render_view_)); 284 new_item, clone_children_of_target, target_frame, render_view_));
256 } 285 }
257 } 286 }
258 287
259 } // namespace content 288 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/frame_host/navigation_controller_impl_browsertest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698