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

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

Issue 1873783003: Convert //content/renderer from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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 unified diff | Download patch
« 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 19 matching lines...) Expand all
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 <utility> 38 #include <utility>
39 39
40 #include "base/memory/ptr_util.h"
40 #include "content/common/navigation_params.h" 41 #include "content/common/navigation_params.h"
41 #include "content/common/site_isolation_policy.h" 42 #include "content/common/site_isolation_policy.h"
42 #include "content/renderer/render_frame_impl.h" 43 #include "content/renderer/render_frame_impl.h"
43 #include "content/renderer/render_view_impl.h" 44 #include "content/renderer/render_view_impl.h"
44 #include "third_party/WebKit/public/web/WebFrameLoadType.h" 45 #include "third_party/WebKit/public/web/WebFrameLoadType.h"
45 #include "third_party/WebKit/public/web/WebLocalFrame.h" 46 #include "third_party/WebKit/public/web/WebLocalFrame.h"
46 47
47 using blink::WebCachePolicy; 48 using blink::WebCachePolicy;
48 using blink::WebFrame; 49 using blink::WebFrame;
49 using blink::WebHistoryCommitType; 50 using blink::WebHistoryCommitType;
50 using blink::WebHistoryItem; 51 using blink::WebHistoryItem;
51 using blink::WebURLRequest; 52 using blink::WebURLRequest;
52 53
53 namespace content { 54 namespace content {
54 55
55 HistoryController::HistoryController(RenderViewImpl* render_view) 56 HistoryController::HistoryController(RenderViewImpl* render_view)
56 : render_view_(render_view) { 57 : render_view_(render_view) {
57 // We don't use HistoryController in OOPIF enabled modes. 58 // We don't use HistoryController in OOPIF enabled modes.
58 DCHECK(!SiteIsolationPolicy::UseSubframeNavigationEntries()); 59 DCHECK(!SiteIsolationPolicy::UseSubframeNavigationEntries());
59 } 60 }
60 61
61 HistoryController::~HistoryController() { 62 HistoryController::~HistoryController() {
62 } 63 }
63 64
64 bool HistoryController::GoToEntry( 65 bool HistoryController::GoToEntry(
65 blink::WebLocalFrame* main_frame, 66 blink::WebLocalFrame* main_frame,
66 scoped_ptr<HistoryEntry> target_entry, 67 std::unique_ptr<HistoryEntry> target_entry,
67 scoped_ptr<NavigationParams> navigation_params, 68 std::unique_ptr<NavigationParams> navigation_params,
68 WebCachePolicy cache_policy) { 69 WebCachePolicy cache_policy) {
69 DCHECK(!main_frame->parent()); 70 DCHECK(!main_frame->parent());
70 HistoryFrameLoadVector same_document_loads; 71 HistoryFrameLoadVector same_document_loads;
71 HistoryFrameLoadVector different_document_loads; 72 HistoryFrameLoadVector different_document_loads;
72 73
73 set_provisional_entry(std::move(target_entry)); 74 set_provisional_entry(std::move(target_entry));
74 navigation_params_ = std::move(navigation_params); 75 navigation_params_ = std::move(navigation_params);
75 76
76 if (current_entry_) { 77 if (current_entry_) {
77 RecursiveGoToEntry( 78 RecursiveGoToEntry(
(...skipping 11 matching lines...) Expand all
89 different_document_loads.push_back( 90 different_document_loads.push_back(
90 std::make_pair(main_frame, provisional_entry_->root())); 91 std::make_pair(main_frame, provisional_entry_->root()));
91 } 92 }
92 93
93 bool has_main_frame_request = false; 94 bool has_main_frame_request = false;
94 for (const auto& item : same_document_loads) { 95 for (const auto& item : same_document_loads) {
95 WebFrame* frame = item.first; 96 WebFrame* frame = item.first;
96 RenderFrameImpl* render_frame = RenderFrameImpl::FromWebFrame(frame); 97 RenderFrameImpl* render_frame = RenderFrameImpl::FromWebFrame(frame);
97 if (!render_frame) 98 if (!render_frame)
98 continue; 99 continue;
99 render_frame->SetPendingNavigationParams(make_scoped_ptr( 100 render_frame->SetPendingNavigationParams(
100 new NavigationParams(*navigation_params_.get()))); 101 base::WrapUnique(new NavigationParams(*navigation_params_.get())));
101 WebURLRequest request = frame->toWebLocalFrame()->requestFromHistoryItem( 102 WebURLRequest request = frame->toWebLocalFrame()->requestFromHistoryItem(
102 item.second, cache_policy); 103 item.second, cache_policy);
103 frame->toWebLocalFrame()->load( 104 frame->toWebLocalFrame()->load(
104 request, blink::WebFrameLoadType::BackForward, item.second, 105 request, blink::WebFrameLoadType::BackForward, item.second,
105 blink::WebHistorySameDocumentLoad); 106 blink::WebHistorySameDocumentLoad);
106 if (frame == main_frame) 107 if (frame == main_frame)
107 has_main_frame_request = true; 108 has_main_frame_request = true;
108 } 109 }
109 for (const auto& item : different_document_loads) { 110 for (const auto& item : different_document_loads) {
110 WebFrame* frame = item.first; 111 WebFrame* frame = item.first;
111 RenderFrameImpl* render_frame = RenderFrameImpl::FromWebFrame(frame); 112 RenderFrameImpl* render_frame = RenderFrameImpl::FromWebFrame(frame);
112 if (!render_frame) 113 if (!render_frame)
113 continue; 114 continue;
114 render_frame->SetPendingNavigationParams(make_scoped_ptr( 115 render_frame->SetPendingNavigationParams(
115 new NavigationParams(*navigation_params_.get()))); 116 base::WrapUnique(new NavigationParams(*navigation_params_.get())));
116 WebURLRequest request = frame->toWebLocalFrame()->requestFromHistoryItem( 117 WebURLRequest request = frame->toWebLocalFrame()->requestFromHistoryItem(
117 item.second, cache_policy); 118 item.second, cache_policy);
118 frame->toWebLocalFrame()->load( 119 frame->toWebLocalFrame()->load(
119 request, blink::WebFrameLoadType::BackForward, item.second, 120 request, blink::WebFrameLoadType::BackForward, item.second,
120 blink::WebHistoryDifferentDocumentLoad); 121 blink::WebHistoryDifferentDocumentLoad);
121 if (frame == main_frame) 122 if (frame == main_frame)
122 has_main_frame_request = true; 123 has_main_frame_request = true;
123 } 124 }
124 125
125 return has_main_frame_request; 126 return has_main_frame_request;
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
219 } 220 }
220 } 221 }
221 222
222 HistoryEntry* HistoryController::GetCurrentEntry() { 223 HistoryEntry* HistoryController::GetCurrentEntry() {
223 return current_entry_.get(); 224 return current_entry_.get();
224 } 225 }
225 226
226 WebHistoryItem HistoryController::GetItemForNewChildFrame( 227 WebHistoryItem HistoryController::GetItemForNewChildFrame(
227 RenderFrameImpl* frame) const { 228 RenderFrameImpl* frame) const {
228 if (navigation_params_.get()) { 229 if (navigation_params_.get()) {
229 frame->SetPendingNavigationParams(make_scoped_ptr( 230 frame->SetPendingNavigationParams(
230 new NavigationParams(*navigation_params_.get()))); 231 base::WrapUnique(new NavigationParams(*navigation_params_.get())));
231 } 232 }
232 233
233 if (!current_entry_) 234 if (!current_entry_)
234 return WebHistoryItem(); 235 return WebHistoryItem();
235 return current_entry_->GetItemForFrame(frame); 236 return current_entry_->GetItemForFrame(frame);
236 } 237 }
237 238
238 void HistoryController::RemoveChildrenForRedirect(RenderFrameImpl* frame) { 239 void HistoryController::RemoveChildrenForRedirect(RenderFrameImpl* frame) {
239 if (!provisional_entry_) 240 if (!provisional_entry_)
240 return; 241 return;
241 if (HistoryEntry::HistoryNode* node = 242 if (HistoryEntry::HistoryNode* node =
242 provisional_entry_->GetHistoryNodeForFrame(frame)) 243 provisional_entry_->GetHistoryNodeForFrame(frame))
243 node->RemoveChildren(); 244 node->RemoveChildren();
244 } 245 }
245 246
246 void HistoryController::CreateNewBackForwardItem( 247 void HistoryController::CreateNewBackForwardItem(
247 RenderFrameImpl* target_frame, 248 RenderFrameImpl* target_frame,
248 const WebHistoryItem& new_item, 249 const WebHistoryItem& new_item,
249 bool clone_children_of_target) { 250 bool clone_children_of_target) {
250 if (!current_entry_) { 251 if (!current_entry_) {
251 current_entry_.reset(new HistoryEntry(new_item)); 252 current_entry_.reset(new HistoryEntry(new_item));
252 } else { 253 } else {
253 current_entry_.reset(current_entry_->CloneAndReplace( 254 current_entry_.reset(current_entry_->CloneAndReplace(
254 new_item, clone_children_of_target, target_frame, render_view_)); 255 new_item, clone_children_of_target, target_frame, render_view_));
255 } 256 }
256 } 257 }
257 258
258 } // namespace content 259 } // 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