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

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

Issue 281653003: DRAFT CL: Add FrameNavigationEntry and track subframe session histories. Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 5 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « content/renderer/history_controller.h ('k') | content/renderer/history_entry.h » ('j') | 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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 46
47 namespace content { 47 namespace content {
48 48
49 HistoryController::HistoryController(RenderViewImpl* render_view) 49 HistoryController::HistoryController(RenderViewImpl* render_view)
50 : render_view_(render_view) { 50 : render_view_(render_view) {
51 } 51 }
52 52
53 HistoryController::~HistoryController() { 53 HistoryController::~HistoryController() {
54 } 54 }
55 55
56 void HistoryController::GoToEntry(scoped_ptr<HistoryEntry> target_entry,
57 WebURLRequest::CachePolicy cache_policy) {
58 HistoryFrameLoadVector same_document_loads;
59 HistoryFrameLoadVector different_document_loads;
60
61 provisional_entry_ = target_entry.Pass();
62
63 WebFrame* main_frame = render_view_->GetMainRenderFrame()->GetWebFrame();
64 if (current_entry_) {
65 RecursiveGoToEntry(
66 main_frame, same_document_loads, different_document_loads);
67 }
68
69 if (same_document_loads.empty() && different_document_loads.empty()) {
70 // If we don't have any frames to navigate at this point, either
71 // (1) there is no previous history entry to compare against, or
72 // (2) we were unable to match any frames by name. In the first case,
73 // doing a different document navigation to the root item is the only valid
74 // thing to do. In the second case, we should have been able to find a
75 // frame to navigate based on names if this were a same document
76 // navigation, so we can safely assume this is the different document case.
77 different_document_loads.push_back(
78 std::make_pair(main_frame, provisional_entry_->root()));
79 }
80
81 for (size_t i = 0; i < same_document_loads.size(); ++i) {
82 WebFrame* frame = same_document_loads[i].first;
83 if (!RenderFrameImpl::FromWebFrame(frame))
84 continue;
85 frame->loadHistoryItem(same_document_loads[i].second,
86 blink::WebHistorySameDocumentLoad,
87 cache_policy);
88 }
89 for (size_t i = 0; i < different_document_loads.size(); ++i) {
90 WebFrame* frame = different_document_loads[i].first;
91 if (!RenderFrameImpl::FromWebFrame(frame))
92 continue;
93 frame->loadHistoryItem(different_document_loads[i].second,
94 blink::WebHistoryDifferentDocumentLoad,
95 cache_policy);
96 }
97 }
98
99 void HistoryController::RecursiveGoToEntry(
100 WebFrame* frame,
101 HistoryFrameLoadVector& same_document_loads,
102 HistoryFrameLoadVector& different_document_loads) {
103 DCHECK(provisional_entry_);
104 DCHECK(current_entry_);
105 RenderFrameImpl* render_frame = RenderFrameImpl::FromWebFrame(frame);
106 const WebHistoryItem& new_item =
107 provisional_entry_->GetItemForFrame(render_frame);
108 const WebHistoryItem& old_item =
109 current_entry_->GetItemForFrame(render_frame);
110 if (new_item.isNull())
111 return;
112
113 if (old_item.isNull() ||
114 new_item.itemSequenceNumber() != old_item.itemSequenceNumber()) {
115 if (!old_item.isNull() &&
116 new_item.documentSequenceNumber() == old_item.documentSequenceNumber())
117 same_document_loads.push_back(std::make_pair(frame, new_item));
118 else
119 different_document_loads.push_back(std::make_pair(frame, new_item));
120 return;
121 }
122
123 for (WebFrame* child = frame->firstChild(); child;
124 child = child->nextSibling()) {
125 RecursiveGoToEntry(child, same_document_loads, different_document_loads);
126 }
127 }
128
129 void HistoryController::UpdateForInitialLoadInChildFrame( 56 void HistoryController::UpdateForInitialLoadInChildFrame(
130 RenderFrameImpl* frame, 57 RenderFrameImpl* frame,
131 const WebHistoryItem& item) { 58 const WebHistoryItem& item) {
132 DCHECK_NE(frame->GetWebFrame()->top(), frame->GetWebFrame()); 59 DCHECK_NE(frame->GetWebFrame()->top(), frame->GetWebFrame());
133 if (!current_entry_) 60 if (!current_entry_)
134 return; 61 return;
135 if (HistoryEntry::HistoryNode* existing_node = 62 if (HistoryEntry::HistoryNode* existing_node =
136 current_entry_->GetHistoryNodeForFrame(frame)) { 63 current_entry_->GetHistoryNodeForFrame(frame)) {
137 existing_node->set_item(item); 64 existing_node->set_item(item);
138 return; 65 return;
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 if (!current_entry_) { 113 if (!current_entry_) {
187 current_entry_.reset( 114 current_entry_.reset(
188 new HistoryEntry(new_item, target_frame->GetRoutingID())); 115 new HistoryEntry(new_item, target_frame->GetRoutingID()));
189 } else { 116 } else {
190 current_entry_.reset(current_entry_->CloneAndReplace( 117 current_entry_.reset(current_entry_->CloneAndReplace(
191 new_item, clone_children_of_target, target_frame, render_view_)); 118 new_item, clone_children_of_target, target_frame, render_view_));
192 } 119 }
193 } 120 }
194 121
195 } // namespace content 122 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/history_controller.h ('k') | content/renderer/history_entry.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698