OLD | NEW |
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 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
194 const WebHistoryItem& item, | 194 const WebHistoryItem& item, |
195 WebHistoryCommitType commit_type, | 195 WebHistoryCommitType commit_type, |
196 bool navigation_within_page) { | 196 bool navigation_within_page) { |
197 switch (commit_type) { | 197 switch (commit_type) { |
198 case blink::WebBackForwardCommit: | 198 case blink::WebBackForwardCommit: |
199 if (!provisional_entry_) { | 199 if (!provisional_entry_) { |
200 // The provisional entry may have been discarded due to a navigation in | 200 // The provisional entry may have been discarded due to a navigation in |
201 // a different frame. For main frames, it is not safe to leave the | 201 // a different frame. For main frames, it is not safe to leave the |
202 // current_entry_ in place, which may have a cross-site page and will be | 202 // current_entry_ in place, which may have a cross-site page and will be |
203 // included in the PageState for this commit. Replace it with a new | 203 // included in the PageState for this commit. Replace it with a new |
204 // HistoryEntry corresponding to the commit. | 204 // HistoryEntry corresponding to the commit, and clear any stale |
| 205 // NavigationParams which might point to the wrong entry. |
205 // | 206 // |
206 // This will lack any subframe history items that were in the original | 207 // This will lack any subframe history items that were in the original |
207 // provisional entry, but we don't know what those were after discarding | 208 // provisional entry, but we don't know what those were after discarding |
208 // it. We'll load the default URL in those subframes instead. | 209 // it. We'll load the default URL in those subframes instead. |
209 // | 210 // |
210 // TODO(creis): It's also possible to get here for subframe commits. | 211 // TODO(creis): It's also possible to get here for subframe commits. |
211 // We'll leave a stale current_entry_ in that case, but that only causes | 212 // We'll leave a stale current_entry_ in that case, but that only causes |
212 // an earlier URL to load in the subframe when leaving and coming back, | 213 // an earlier URL to load in the subframe when leaving and coming back, |
213 // and only in rare cases. It does not risk a URL spoof, unlike the | 214 // and only in rare cases. It does not risk a URL spoof, unlike the |
214 // main frame case. Since this bug is not present in the new | 215 // main frame case. Since this bug is not present in the new |
215 // FrameNavigationEntry-based navigation path (https://crbug.com/236848) | 216 // FrameNavigationEntry-based navigation path (https://crbug.com/236848) |
216 // we'll wait for that to fix the subframe case. | 217 // we'll wait for that to fix the subframe case. |
217 if (frame->IsMainFrame()) | 218 if (frame->IsMainFrame()) { |
218 current_entry_.reset(new HistoryEntry(item)); | 219 current_entry_.reset(new HistoryEntry(item)); |
| 220 navigation_params_.reset(); |
| 221 } |
219 | 222 |
220 return; | 223 return; |
221 } | 224 } |
222 | 225 |
223 // If the current entry is null, this must be a main frame commit. | 226 // If the current entry is null, this must be a main frame commit. |
224 DCHECK(current_entry_ || frame->IsMainFrame()); | 227 DCHECK(current_entry_ || frame->IsMainFrame()); |
225 | 228 |
226 // Commit the provisional entry, but only if it is a plausible transition. | 229 // Commit the provisional entry, but only if it is a plausible transition. |
227 // Do not commit it if the navigation is in a subframe and the provisional | 230 // Do not commit it if the navigation is in a subframe and the provisional |
228 // entry's main frame item does not match the current entry's main frame, | 231 // entry's main frame item does not match the current entry's main frame, |
(...skipping 15 matching lines...) Expand all Loading... |
244 current_entry_->root().itemSequenceNumber() == | 247 current_entry_->root().itemSequenceNumber() == |
245 provisional_entry_->root().itemSequenceNumber()) { | 248 provisional_entry_->root().itemSequenceNumber()) { |
246 current_entry_.reset(provisional_entry_.release()); | 249 current_entry_.reset(provisional_entry_.release()); |
247 } | 250 } |
248 | 251 |
249 // We're guaranteed to have a current entry now. | 252 // We're guaranteed to have a current entry now. |
250 DCHECK(current_entry_); | 253 DCHECK(current_entry_); |
251 | 254 |
252 if (HistoryEntry::HistoryNode* node = | 255 if (HistoryEntry::HistoryNode* node = |
253 current_entry_->GetHistoryNodeForFrame(frame)) { | 256 current_entry_->GetHistoryNodeForFrame(frame)) { |
| 257 // Clear the children and any NavigationParams if this commit isn't for |
| 258 // the same item. Otherwise we might have stale data from a race. |
| 259 if (node->item().itemSequenceNumber() != item.itemSequenceNumber()) { |
| 260 node->RemoveChildren(); |
| 261 navigation_params_.reset(); |
| 262 } |
| 263 |
254 node->set_item(item); | 264 node->set_item(item); |
255 } | 265 } |
256 break; | 266 break; |
257 case blink::WebStandardCommit: | 267 case blink::WebStandardCommit: |
258 CreateNewBackForwardItem(frame, item, navigation_within_page); | 268 CreateNewBackForwardItem(frame, item, navigation_within_page); |
259 break; | 269 break; |
260 case blink::WebInitialCommitInChildFrame: | 270 case blink::WebInitialCommitInChildFrame: |
261 UpdateForInitialLoadInChildFrame(frame, item); | 271 UpdateForInitialLoadInChildFrame(frame, item); |
262 break; | 272 break; |
263 case blink::WebHistoryInertCommit: | 273 case blink::WebHistoryInertCommit: |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
309 bool clone_children_of_target) { | 319 bool clone_children_of_target) { |
310 if (!current_entry_) { | 320 if (!current_entry_) { |
311 current_entry_.reset(new HistoryEntry(new_item)); | 321 current_entry_.reset(new HistoryEntry(new_item)); |
312 } else { | 322 } else { |
313 current_entry_.reset(current_entry_->CloneAndReplace( | 323 current_entry_.reset(current_entry_->CloneAndReplace( |
314 new_item, clone_children_of_target, target_frame, render_view_)); | 324 new_item, clone_children_of_target, target_frame, render_view_)); |
315 } | 325 } |
316 } | 326 } |
317 | 327 |
318 } // namespace content | 328 } // namespace content |
OLD | NEW |