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

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

Issue 1027863002: Move provisional navigation parameters to RenderFrame, and use the HistoryController to distribute … (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fixes 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
« no previous file with comments | « content/renderer/history_controller.h ('k') | content/renderer/render_frame_impl.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 17 matching lines...) Expand all
28 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 28 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 29 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 30 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 31 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 32 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
33 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 33 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34 */ 34 */
35 35
36 #include "content/renderer/history_controller.h" 36 #include "content/renderer/history_controller.h"
37 37
38 #include "content/common/navigation_params.h"
38 #include "content/renderer/render_frame_impl.h" 39 #include "content/renderer/render_frame_impl.h"
39 #include "content/renderer/render_view_impl.h" 40 #include "content/renderer/render_view_impl.h"
40 #include "third_party/WebKit/public/web/WebLocalFrame.h" 41 #include "third_party/WebKit/public/web/WebLocalFrame.h"
41 42
42 using blink::WebFrame; 43 using blink::WebFrame;
43 using blink::WebHistoryCommitType; 44 using blink::WebHistoryCommitType;
44 using blink::WebHistoryItem; 45 using blink::WebHistoryItem;
45 using blink::WebURLRequest; 46 using blink::WebURLRequest;
46 47
47 namespace content { 48 namespace content {
48 49
49 HistoryController::HistoryController(RenderViewImpl* render_view) 50 HistoryController::HistoryController(RenderViewImpl* render_view)
50 : render_view_(render_view) { 51 : render_view_(render_view) {
51 } 52 }
52 53
53 HistoryController::~HistoryController() { 54 HistoryController::~HistoryController() {
54 } 55 }
55 56
56 void HistoryController::GoToEntry(scoped_ptr<HistoryEntry> target_entry, 57 void HistoryController::GoToEntry(
57 WebURLRequest::CachePolicy cache_policy) { 58 scoped_ptr<HistoryEntry> target_entry,
59 scoped_ptr<NavigationParams> navigation_params,
60 WebURLRequest::CachePolicy cache_policy) {
58 HistoryFrameLoadVector same_document_loads; 61 HistoryFrameLoadVector same_document_loads;
59 HistoryFrameLoadVector different_document_loads; 62 HistoryFrameLoadVector different_document_loads;
60 63
61 provisional_entry_ = target_entry.Pass(); 64 provisional_entry_ = target_entry.Pass();
65 navigation_params_ = navigation_params.Pass();
62 66
63 WebFrame* main_frame = render_view_->GetMainRenderFrame()->GetWebFrame(); 67 WebFrame* main_frame = render_view_->GetMainRenderFrame()->GetWebFrame();
64 if (current_entry_) { 68 if (current_entry_) {
65 RecursiveGoToEntry( 69 RecursiveGoToEntry(
66 main_frame, same_document_loads, different_document_loads); 70 main_frame, same_document_loads, different_document_loads);
67 } 71 }
68 72
69 if (same_document_loads.empty() && different_document_loads.empty()) { 73 if (same_document_loads.empty() && different_document_loads.empty()) {
70 // If we don't have any frames to navigate at this point, either 74 // 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 75 // (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, 76 // (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 77 // 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 78 // 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 79 // 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. 80 // navigation, so we can safely assume this is the different document case.
77 different_document_loads.push_back( 81 different_document_loads.push_back(
78 std::make_pair(main_frame, provisional_entry_->root())); 82 std::make_pair(main_frame, provisional_entry_->root()));
79 } 83 }
80 84
81 for (size_t i = 0; i < same_document_loads.size(); ++i) { 85 for (const auto& item : same_document_loads) {
82 WebFrame* frame = same_document_loads[i].first; 86 WebFrame* frame = item.first;
83 if (!RenderFrameImpl::FromWebFrame(frame)) 87 RenderFrameImpl* render_frame = RenderFrameImpl::FromWebFrame(frame);
88 if (!render_frame)
84 continue; 89 continue;
85 frame->loadHistoryItem(same_document_loads[i].second, 90 render_frame->SetPendingNavigationParams(make_scoped_ptr(
91 new NavigationParams(*navigation_params_.get())));
92 frame->loadHistoryItem(item.second,
86 blink::WebHistorySameDocumentLoad, 93 blink::WebHistorySameDocumentLoad,
87 cache_policy); 94 cache_policy);
88 } 95 }
89 for (size_t i = 0; i < different_document_loads.size(); ++i) { 96 for (const auto& item : different_document_loads) {
90 WebFrame* frame = different_document_loads[i].first; 97 WebFrame* frame = item.first;
91 if (!RenderFrameImpl::FromWebFrame(frame)) 98 RenderFrameImpl* render_frame = RenderFrameImpl::FromWebFrame(frame);
99 if (!render_frame)
92 continue; 100 continue;
93 frame->loadHistoryItem(different_document_loads[i].second, 101 render_frame->SetPendingNavigationParams(make_scoped_ptr(
102 new NavigationParams(*navigation_params_.get())));
103 frame->loadHistoryItem(item.second,
94 blink::WebHistoryDifferentDocumentLoad, 104 blink::WebHistoryDifferentDocumentLoad,
95 cache_policy); 105 cache_policy);
96 } 106 }
97 } 107 }
98 108
99 void HistoryController::RecursiveGoToEntry( 109 void HistoryController::RecursiveGoToEntry(
100 WebFrame* frame, 110 WebFrame* frame,
101 HistoryFrameLoadVector& same_document_loads, 111 HistoryFrameLoadVector& same_document_loads,
102 HistoryFrameLoadVector& different_document_loads) { 112 HistoryFrameLoadVector& different_document_loads) {
103 DCHECK(provisional_entry_); 113 DCHECK(provisional_entry_);
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 UpdateForInitialLoadInChildFrame(frame, item); 169 UpdateForInitialLoadInChildFrame(frame, item);
160 } 170 }
161 } 171 }
162 172
163 HistoryEntry* HistoryController::GetCurrentEntry() { 173 HistoryEntry* HistoryController::GetCurrentEntry() {
164 return current_entry_.get(); 174 return current_entry_.get();
165 } 175 }
166 176
167 WebHistoryItem HistoryController::GetItemForNewChildFrame( 177 WebHistoryItem HistoryController::GetItemForNewChildFrame(
168 RenderFrameImpl* frame) const { 178 RenderFrameImpl* frame) const {
179 if (navigation_params_.get()) {
180 frame->SetPendingNavigationParams(make_scoped_ptr(
181 new NavigationParams(*navigation_params_.get())));
182 }
183
169 if (!current_entry_) 184 if (!current_entry_)
170 return WebHistoryItem(); 185 return WebHistoryItem();
171 return current_entry_->GetItemForFrame(frame); 186 return current_entry_->GetItemForFrame(frame);
172 } 187 }
173 188
174 void HistoryController::RemoveChildrenForRedirect(RenderFrameImpl* frame) { 189 void HistoryController::RemoveChildrenForRedirect(RenderFrameImpl* frame) {
175 if (!provisional_entry_) 190 if (!provisional_entry_)
176 return; 191 return;
177 if (HistoryEntry::HistoryNode* node = 192 if (HistoryEntry::HistoryNode* node =
178 provisional_entry_->GetHistoryNodeForFrame(frame)) 193 provisional_entry_->GetHistoryNodeForFrame(frame))
179 node->RemoveChildren(); 194 node->RemoveChildren();
180 } 195 }
181 196
182 void HistoryController::CreateNewBackForwardItem( 197 void HistoryController::CreateNewBackForwardItem(
183 RenderFrameImpl* target_frame, 198 RenderFrameImpl* target_frame,
184 const WebHistoryItem& new_item, 199 const WebHistoryItem& new_item,
185 bool clone_children_of_target) { 200 bool clone_children_of_target) {
186 if (!current_entry_) { 201 if (!current_entry_) {
187 current_entry_.reset( 202 current_entry_.reset(
188 new HistoryEntry(new_item, target_frame->GetRoutingID())); 203 new HistoryEntry(new_item, target_frame->GetRoutingID()));
189 } else { 204 } else {
190 current_entry_.reset(current_entry_->CloneAndReplace( 205 current_entry_.reset(current_entry_->CloneAndReplace(
191 new_item, clone_children_of_target, target_frame, render_view_)); 206 new_item, clone_children_of_target, target_frame, render_view_));
192 } 207 }
193 } 208 }
194 209
195 } // namespace content 210 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/history_controller.h ('k') | content/renderer/render_frame_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698