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 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
189 parent_history_node->AddChild(item); | 189 parent_history_node->AddChild(item); |
190 } | 190 } |
191 } | 191 } |
192 | 192 |
193 void HistoryController::UpdateForCommit(RenderFrameImpl* frame, | 193 void HistoryController::UpdateForCommit(RenderFrameImpl* frame, |
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 | |
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 | |
203 // included in the PageState for this commit. Replace it with a new | |
204 // HistoryEntry corresponding to the commit. | |
205 // | |
206 // 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 // it. We'll load the default URL in those subframes instead. | |
209 // | |
210 // TODO(creis): It's also possible to get here for subframes commits. | |
ncarter (slow)
2016/07/08 21:09:22
"subframes" -> "subframe", right?
Charlie Reis
2016/07/08 21:15:06
Done.
| |
211 // 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 // 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 // FrameNavigationEntry-based navigation path (https://crbug.com/236848) | |
216 // we'll wait for that to fix the subframe case. | |
217 if (frame->IsMainFrame()) | |
218 current_entry_.reset(new HistoryEntry(item)); | |
Charlie Reis
2016/07/08 18:11:12
For main frames, this should be equivalent to what
| |
219 | |
200 return; | 220 return; |
221 } | |
201 | 222 |
202 // If the current entry is null, this must be a main frame commit. | 223 // If the current entry is null, this must be a main frame commit. |
203 DCHECK(current_entry_ || frame->IsMainFrame()); | 224 DCHECK(current_entry_ || frame->IsMainFrame()); |
204 | 225 |
205 // Commit the provisional entry, but only if it is a plausible transition. | 226 // Commit the provisional entry, but only if it is a plausible transition. |
206 // Do not commit it if the navigation is in a subframe and the provisional | 227 // Do not commit it if the navigation is in a subframe and the provisional |
207 // entry's main frame item does not match the current entry's main frame, | 228 // entry's main frame item does not match the current entry's main frame, |
208 // which can happen if multiple forward navigations occur. In that case, | 229 // which can happen if multiple forward navigations occur. In that case, |
209 // committing the provisional entry would corrupt it, leading to a URL | 230 // committing the provisional entry would corrupt it, leading to a URL |
210 // spoof. See https://crbug.com/597322. (Note that the race in this bug | 231 // spoof. See https://crbug.com/597322. (Note that the race in this bug |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
288 bool clone_children_of_target) { | 309 bool clone_children_of_target) { |
289 if (!current_entry_) { | 310 if (!current_entry_) { |
290 current_entry_.reset(new HistoryEntry(new_item)); | 311 current_entry_.reset(new HistoryEntry(new_item)); |
291 } else { | 312 } else { |
292 current_entry_.reset(current_entry_->CloneAndReplace( | 313 current_entry_.reset(current_entry_->CloneAndReplace( |
293 new_item, clone_children_of_target, target_frame, render_view_)); | 314 new_item, clone_children_of_target, target_frame, render_view_)); |
294 } | 315 } |
295 } | 316 } |
296 | 317 |
297 } // namespace content | 318 } // namespace content |
OLD | NEW |