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

Unified Diff: content/renderer/history_controller.cc

Issue 1112823005: Ensure that HistoryController's current entry is updated on inert commits. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Use switch statement. Created 5 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 side-by-side diff with in-line comments
Download patch
Index: content/renderer/history_controller.cc
diff --git a/content/renderer/history_controller.cc b/content/renderer/history_controller.cc
index 35f072ad78cf736ac7c15869f2871287f7e2f089..f2d3d96d341213eeb0ceda09b3d1aa2d1c9fd9e3 100644
--- a/content/renderer/history_controller.cc
+++ b/content/renderer/history_controller.cc
@@ -161,14 +161,30 @@ void HistoryController::UpdateForCommit(RenderFrameImpl* frame,
const WebHistoryItem& item,
WebHistoryCommitType commit_type,
bool navigation_within_page) {
- if (commit_type == blink::WebBackForwardCommit) {
- if (!provisional_entry_)
- return;
- current_entry_.reset(provisional_entry_.release());
- } else if (commit_type == blink::WebStandardCommit) {
- CreateNewBackForwardItem(frame, item, navigation_within_page);
- } else if (commit_type == blink::WebInitialCommitInChildFrame) {
- UpdateForInitialLoadInChildFrame(frame, item);
+ switch (commit_type) {
+ case blink::WebBackForwardCommit:
+ if (!provisional_entry_)
+ return;
+ current_entry_.reset(provisional_entry_.release());
+ break;
+ case blink::WebStandardCommit:
+ CreateNewBackForwardItem(frame, item, navigation_within_page);
+ break;
+ case blink::WebInitialCommitInChildFrame:
+ UpdateForInitialLoadInChildFrame(frame, item);
+ break;
+ case blink::WebHistoryInertCommit:
+ // Even for inert commits (e.g., location.replace, client redirects), make
+ // sure the current entry gets updated, if there is one.
+ if (current_entry_) {
+ if (HistoryEntry::HistoryNode* node =
+ current_entry_->GetHistoryNodeForFrame(frame)) {
+ node->set_item(item);
+ }
+ }
+ break;
+ default:
+ NOTREACHED() << "Invalid commit type: " << commit_type;
}
}

Powered by Google App Engine
This is Rietveld 408576698