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

Side by Side Diff: content/browser/renderer_host/test_render_view_host.cc

Issue 10704048: [RDS] Reloads a page using the original request URL (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Adding unit test & removing public function Created 8 years, 5 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 #include "content/browser/renderer_host/test_backing_store.h" 5 #include "content/browser/renderer_host/test_backing_store.h"
6 #include "content/browser/renderer_host/test_render_view_host.h" 6 #include "content/browser/renderer_host/test_render_view_host.h"
7 #include "content/browser/site_instance_impl.h" 7 #include "content/browser/site_instance_impl.h"
8 #include "content/browser/web_contents/navigation_controller_impl.h" 8 #include "content/browser/web_contents/navigation_controller_impl.h"
9 #include "content/browser/web_contents/test_web_contents.h" 9 #include "content/browser/web_contents/test_web_contents.h"
10 #include "content/common/view_messages.h" 10 #include "content/common/view_messages.h"
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
214 bool swapped_out) 214 bool swapped_out)
215 : RenderViewHostImpl(instance, 215 : RenderViewHostImpl(instance,
216 delegate, 216 delegate,
217 widget_delegate, 217 widget_delegate,
218 routing_id, 218 routing_id,
219 swapped_out, 219 swapped_out,
220 dom_storage::kInvalidSessionStorageNamespaceId), 220 dom_storage::kInvalidSessionStorageNamespaceId),
221 render_view_created_(false), 221 render_view_created_(false),
222 delete_counter_(NULL), 222 delete_counter_(NULL),
223 simulate_fetch_via_proxy_(false), 223 simulate_fetch_via_proxy_(false),
224 contents_mime_type_("text/html") { 224 contents_mime_type_("text/html"),
225 last_params_(new ViewMsg_Navigate_Params) {
225 // For normal RenderViewHosts, this is freed when |Shutdown()| is 226 // For normal RenderViewHosts, this is freed when |Shutdown()| is
226 // called. For TestRenderViewHost, the view is explicitly 227 // called. For TestRenderViewHost, the view is explicitly
227 // deleted in the destructor below, because 228 // deleted in the destructor below, because
228 // TestRenderWidgetHostView::Destroy() doesn't |delete this|. 229 // TestRenderWidgetHostView::Destroy() doesn't |delete this|.
229 SetView(new TestRenderWidgetHostView(this)); 230 SetView(new TestRenderWidgetHostView(this));
230 } 231 }
231 232
232 TestRenderViewHost::~TestRenderViewHost() { 233 TestRenderViewHost::~TestRenderViewHost() {
233 if (delete_counter_) 234 if (delete_counter_)
234 ++*delete_counter_; 235 ++*delete_counter_;
235 236
236 // Since this isn't a traditional view, we have to delete it. 237 // Since this isn't a traditional view, we have to delete it.
237 delete GetView(); 238 delete GetView();
239 delete last_params_;
238 } 240 }
239 241
240 bool TestRenderViewHost::CreateRenderView( 242 bool TestRenderViewHost::CreateRenderView(
241 const string16& frame_name, 243 const string16& frame_name,
242 int opener_route_id, 244 int opener_route_id,
243 int32 max_page_id, 245 int32 max_page_id,
244 const std::string& embedder_channel_name, 246 const std::string& embedder_channel_name,
245 int embedder_container_id) { 247 int embedder_container_id) {
246 DCHECK(!render_view_created_); 248 DCHECK(!render_view_created_);
247 render_view_created_ = true; 249 render_view_created_ = true;
248 return true; 250 return true;
249 } 251 }
250 252
251 bool TestRenderViewHost::IsRenderViewLive() const { 253 bool TestRenderViewHost::IsRenderViewLive() const {
252 return render_view_created_; 254 return render_view_created_;
253 } 255 }
254 256
257 void TestRenderViewHost::Navigate(const ViewMsg_Navigate_Params& params) {
258 *last_params_ = params;
jam 2012/07/03 05:50:12 i think there's a simpler way to get the url inste
gone 2012/07/03 18:24:39 Done.
259 RenderViewHostImpl::Navigate(params);
260 }
261
255 void TestRenderViewHost::SendNavigate(int page_id, const GURL& url) { 262 void TestRenderViewHost::SendNavigate(int page_id, const GURL& url) {
256 SendNavigateWithTransition(page_id, url, PAGE_TRANSITION_LINK); 263 SendNavigateWithTransition(page_id, url, PAGE_TRANSITION_LINK);
257 } 264 }
258 265
259 void TestRenderViewHost::SendNavigateWithTransition( 266 void TestRenderViewHost::SendNavigateWithTransition(
260 int page_id, const GURL& url, PageTransition transition) { 267 int page_id, const GURL& url, PageTransition transition) {
268 SendNavigateWithParameters(page_id, url, transition, url);
269 }
270
271 void TestRenderViewHost::SendNavigateWithOriginalRequestURL(
272 int page_id, const GURL& url, const GURL& original_request_url) {
273 SendNavigateWithParameters(page_id, url, PAGE_TRANSITION_LINK,
274 original_request_url);
275 }
276
277 void TestRenderViewHost::SendNavigateWithParameters(
278 int page_id, const GURL& url, PageTransition transition,
279 const GURL& original_request_url) {
261 ViewHostMsg_FrameNavigate_Params params; 280 ViewHostMsg_FrameNavigate_Params params;
262 281
263 params.page_id = page_id; 282 params.page_id = page_id;
264 params.url = url; 283 params.url = url;
265 params.referrer = Referrer(); 284 params.referrer = Referrer();
266 params.transition = transition; 285 params.transition = transition;
267 params.redirects = std::vector<GURL>(); 286 params.redirects = std::vector<GURL>();
268 params.should_update_history = true; 287 params.should_update_history = true;
269 params.searchable_form_url = GURL(); 288 params.searchable_form_url = GURL();
270 params.searchable_form_encoding = std::string(); 289 params.searchable_form_encoding = std::string();
271 params.password_form = PasswordForm(); 290 params.password_form = PasswordForm();
272 params.security_info = std::string(); 291 params.security_info = std::string();
273 params.gesture = NavigationGestureUser; 292 params.gesture = NavigationGestureUser;
274 params.contents_mime_type = contents_mime_type_; 293 params.contents_mime_type = contents_mime_type_;
275 params.is_post = false; 294 params.is_post = false;
276 params.was_within_same_page = false; 295 params.was_within_same_page = false;
277 params.http_status_code = 0; 296 params.http_status_code = 0;
278 params.socket_address.set_host("2001:db8::1"); 297 params.socket_address.set_host("2001:db8::1");
279 params.socket_address.set_port(80); 298 params.socket_address.set_port(80);
280 params.was_fetched_via_proxy = simulate_fetch_via_proxy_; 299 params.was_fetched_via_proxy = simulate_fetch_via_proxy_;
281 params.content_state = webkit_glue::CreateHistoryStateForURL(GURL(url)); 300 params.content_state = webkit_glue::CreateHistoryStateForURL(GURL(url));
301 params.original_request_url = original_request_url;
282 302
283 ViewHostMsg_FrameNavigate msg(1, params); 303 ViewHostMsg_FrameNavigate msg(1, params);
284 OnMsgNavigate(msg); 304 OnMsgNavigate(msg);
285 } 305 }
286 306
287 void TestRenderViewHost::SendShouldCloseACK(bool proceed) { 307 void TestRenderViewHost::SendShouldCloseACK(bool proceed) {
288 OnMsgShouldCloseACK(proceed, base::TimeTicks(), base::TimeTicks()); 308 OnMsgShouldCloseACK(proceed, base::TimeTicks(), base::TimeTicks());
289 } 309 }
290 310
291 void TestRenderViewHost::SetContentsMimeType(const std::string& mime_type) { 311 void TestRenderViewHost::SetContentsMimeType(const std::string& mime_type) {
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
330 350
331 TestRenderViewHost* RenderViewHostImplTestHarness::active_test_rvh() { 351 TestRenderViewHost* RenderViewHostImplTestHarness::active_test_rvh() {
332 return static_cast<TestRenderViewHost*>(active_rvh()); 352 return static_cast<TestRenderViewHost*>(active_rvh());
333 } 353 }
334 354
335 TestWebContents* RenderViewHostImplTestHarness::contents() { 355 TestWebContents* RenderViewHostImplTestHarness::contents() {
336 return static_cast<TestWebContents*>(web_contents()); 356 return static_cast<TestWebContents*>(web_contents());
337 } 357 }
338 358
339 } // namespace content 359 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698