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

Side by Side Diff: content/test/test_render_view_host.cc

Issue 135723003: Move DidCommitProvisionalLoad code from RenderView to RenderFrame. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixing final nits. Created 6 years, 10 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/test/test_render_view_host.h ('k') | content/test/test_web_contents.cc » ('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 (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/test/test_render_view_host.h" 5 #include "content/test/test_render_view_host.h"
6 6
7 #include "base/memory/scoped_ptr.h" 7 #include "base/memory/scoped_ptr.h"
8 #include "content/browser/dom_storage/dom_storage_context_wrapper.h" 8 #include "content/browser/dom_storage/dom_storage_context_wrapper.h"
9 #include "content/browser/dom_storage/session_storage_namespace_impl.h" 9 #include "content/browser/dom_storage/session_storage_namespace_impl.h"
10 #include "content/browser/site_instance_impl.h" 10 #include "content/browser/site_instance_impl.h"
11 #include "content/common/dom_storage/dom_storage_types.h" 11 #include "content/common/dom_storage/dom_storage_types.h"
12 #include "content/common/frame_messages.h"
12 #include "content/common/view_messages.h" 13 #include "content/common/view_messages.h"
13 #include "content/public/browser/browser_context.h" 14 #include "content/public/browser/browser_context.h"
14 #include "content/public/browser/navigation_controller.h" 15 #include "content/public/browser/navigation_controller.h"
15 #include "content/public/browser/storage_partition.h" 16 #include "content/public/browser/storage_partition.h"
16 #include "content/public/common/content_client.h" 17 #include "content/public/common/content_client.h"
17 #include "content/public/common/page_state.h" 18 #include "content/public/common/page_state.h"
18 #include "content/test/test_backing_store.h" 19 #include "content/test/test_backing_store.h"
19 #include "content/test/test_web_contents.h" 20 #include "content/test/test_web_contents.h"
20 #include "media/base/video_frame.h" 21 #include "media/base/video_frame.h"
21 #include "ui/gfx/rect.h" 22 #include "ui/gfx/rect.h"
22 #include "webkit/common/webpreferences.h" 23 #include "webkit/common/webpreferences.h"
23 24
24 namespace content { 25 namespace content {
25 26
26 namespace { 27 namespace {
27 28
28 const int64 kFrameId = 13UL; 29 const int64 kFrameId = 13UL;
29 30
30 } // namespace 31 } // namespace
31 32
32 33
33 void InitNavigateParams(ViewHostMsg_FrameNavigate_Params* params, 34 void InitNavigateParams(FrameHostMsg_DidCommitProvisionalLoad_Params* params,
34 int page_id, 35 int page_id,
35 const GURL& url, 36 const GURL& url,
36 PageTransition transition) { 37 PageTransition transition) {
37 params->page_id = page_id; 38 params->page_id = page_id;
38 params->url = url; 39 params->url = url;
39 params->referrer = Referrer(); 40 params->referrer = Referrer();
40 params->transition = transition; 41 params->transition = transition;
41 params->redirects = std::vector<GURL>(); 42 params->redirects = std::vector<GURL>();
42 params->should_update_history = false; 43 params->should_update_history = false;
43 params->searchable_form_url = GURL(); 44 params->searchable_form_url = GURL();
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
267 render_view_created_ = true; 268 render_view_created_ = true;
268 opener_route_id_ = opener_route_id; 269 opener_route_id_ = opener_route_id;
269 return true; 270 return true;
270 } 271 }
271 272
272 bool TestRenderViewHost::IsRenderViewLive() const { 273 bool TestRenderViewHost::IsRenderViewLive() const {
273 return render_view_created_; 274 return render_view_created_;
274 } 275 }
275 276
276 void TestRenderViewHost::SendNavigate(int page_id, const GURL& url) { 277 void TestRenderViewHost::SendNavigate(int page_id, const GURL& url) {
277 SendNavigateWithTransition(page_id, url, PAGE_TRANSITION_LINK); 278 main_render_frame_host_->SendNavigate(page_id, url);
278 } 279 }
279 280
280 void TestRenderViewHost::SendFailedNavigate(int page_id, const GURL& url) { 281 void TestRenderViewHost::SendFailedNavigate(int page_id, const GURL& url) {
281 SendNavigateWithTransitionAndResponseCode( 282 main_render_frame_host_->SendFailedNavigate(page_id, url);
282 page_id, url, PAGE_TRANSITION_LINK, 500);
283 } 283 }
284 284
285 void TestRenderViewHost::SendNavigateWithTransition( 285 void TestRenderViewHost::SendNavigateWithTransition(
286 int page_id, const GURL& url, PageTransition transition) { 286 int page_id,
287 SendNavigateWithTransitionAndResponseCode(page_id, url, transition, 200); 287 const GURL& url,
288 PageTransition transition) {
289 main_render_frame_host_->SendNavigateWithTransition(page_id, url, transition);
288 } 290 }
289 291
290 void TestRenderViewHost::SendNavigateWithOriginalRequestURL( 292 void TestRenderViewHost::SendNavigateWithOriginalRequestURL(
291 int page_id, const GURL& url, const GURL& original_request_url) { 293 int page_id,
292 main_render_frame_host()->OnDidStartProvisionalLoadForFrame( 294 const GURL& url,
293 kFrameId, -1, true, url); 295 const GURL& original_request_url) {
294 SendNavigateWithParameters(page_id, url, PAGE_TRANSITION_LINK, 296 main_render_frame_host_->SendNavigateWithOriginalRequestURL(
295 original_request_url, 200, 0); 297 page_id, url, original_request_url);
296 } 298 }
297 299
298 void TestRenderViewHost::SendNavigateWithFile( 300 void TestRenderViewHost::SendNavigateWithFile(
299 int page_id, const GURL& url, const base::FilePath& file_path) { 301 int page_id,
300 SendNavigateWithParameters(page_id, url, PAGE_TRANSITION_LINK, 302 const GURL& url,
301 url, 200, &file_path); 303 const base::FilePath& file_path) {
304 main_render_frame_host_->SendNavigateWithFile(page_id, url, file_path);
302 } 305 }
303 306
304 void TestRenderViewHost::SendNavigateWithParams( 307 void TestRenderViewHost::SendNavigateWithParams(
305 ViewHostMsg_FrameNavigate_Params* params) { 308 FrameHostMsg_DidCommitProvisionalLoad_Params* params) {
306 params->frame_id = kFrameId; 309 main_render_frame_host_->SendNavigateWithParams(params);
307 ViewHostMsg_FrameNavigate msg(1, *params);
308 OnNavigate(msg);
309 } 310 }
310 311
311 void TestRenderViewHost::SendNavigateWithTransitionAndResponseCode( 312 void TestRenderViewHost::SendNavigateWithTransitionAndResponseCode(
312 int page_id, const GURL& url, PageTransition transition, 313 int page_id,
314 const GURL& url,
315 PageTransition transition,
313 int response_code) { 316 int response_code) {
314 // DidStartProvisionalLoad may delete the pending entry that holds |url|, 317 main_render_frame_host_->SendNavigateWithTransitionAndResponseCode(
315 // so we keep a copy of it to use in SendNavigateWithParameters. 318 page_id, url, transition, response_code);
316 GURL url_copy(url);
317 main_render_frame_host()->OnDidStartProvisionalLoadForFrame(
318 kFrameId, -1, true, url_copy);
319 SendNavigateWithParameters(page_id, url_copy, transition, url_copy,
320 response_code, 0);
321 } 319 }
322 320
323 void TestRenderViewHost::SendNavigateWithParameters( 321 void TestRenderViewHost::SendNavigateWithParameters(
324 int page_id, const GURL& url, PageTransition transition, 322 int page_id,
325 const GURL& original_request_url, int response_code, 323 const GURL& url,
324 PageTransition transition,
325 const GURL& original_request_url,
326 int response_code,
326 const base::FilePath* file_path_for_history_item) { 327 const base::FilePath* file_path_for_history_item) {
327 ViewHostMsg_FrameNavigate_Params params;
328 params.page_id = page_id;
329 params.frame_id = kFrameId;
330 params.url = url;
331 params.referrer = Referrer();
332 params.transition = transition;
333 params.redirects = std::vector<GURL>();
334 params.should_update_history = true;
335 params.searchable_form_url = GURL();
336 params.searchable_form_encoding = std::string();
337 params.security_info = std::string();
338 params.gesture = NavigationGestureUser;
339 params.contents_mime_type = contents_mime_type_;
340 params.is_post = false;
341 params.was_within_same_page = false;
342 params.http_status_code = response_code;
343 params.socket_address.set_host("2001:db8::1");
344 params.socket_address.set_port(80);
345 params.was_fetched_via_proxy = simulate_fetch_via_proxy_;
346 params.history_list_was_cleared = simulate_history_list_was_cleared_;
347 params.original_request_url = original_request_url;
348 328
349 params.page_state = PageState::CreateForTesting( 329 main_render_frame_host_->SendNavigateWithParameters(
350 url, 330 page_id, url, transition, original_request_url, response_code,
351 false,
352 file_path_for_history_item ? "data" : NULL,
353 file_path_for_history_item); 331 file_path_for_history_item);
354
355 ViewHostMsg_FrameNavigate msg(1, params);
356 OnNavigate(msg);
357 } 332 }
358 333
359 void TestRenderViewHost::SendShouldCloseACK(bool proceed) { 334 void TestRenderViewHost::SendShouldCloseACK(bool proceed) {
360 base::TimeTicks now = base::TimeTicks::Now(); 335 base::TimeTicks now = base::TimeTicks::Now();
361 OnShouldCloseACK(proceed, now, now); 336 OnShouldCloseACK(proceed, now, now);
362 } 337 }
363 338
364 void TestRenderViewHost::SetContentsMimeType(const std::string& mime_type) { 339 void TestRenderViewHost::SetContentsMimeType(const std::string& mime_type) {
365 contents_mime_type_ = mime_type; 340 contents_mime_type_ = mime_type;
341 main_render_frame_host_->set_contents_mime_type(mime_type);
366 } 342 }
367 343
368 void TestRenderViewHost::SimulateSwapOutACK() { 344 void TestRenderViewHost::SimulateSwapOutACK() {
369 OnSwappedOut(false); 345 OnSwappedOut(false);
370 } 346 }
371 347
372 void TestRenderViewHost::SimulateWasHidden() { 348 void TestRenderViewHost::SimulateWasHidden() {
373 WasHidden(); 349 WasHidden();
374 } 350 }
375 351
(...skipping 18 matching lines...) Expand all
394 "data", 370 "data",
395 &file_path)); 371 &file_path));
396 } 372 }
397 373
398 void TestRenderViewHost::set_simulate_fetch_via_proxy(bool proxy) { 374 void TestRenderViewHost::set_simulate_fetch_via_proxy(bool proxy) {
399 simulate_fetch_via_proxy_ = proxy; 375 simulate_fetch_via_proxy_ = proxy;
400 } 376 }
401 377
402 void TestRenderViewHost::set_simulate_history_list_was_cleared(bool cleared) { 378 void TestRenderViewHost::set_simulate_history_list_was_cleared(bool cleared) {
403 simulate_history_list_was_cleared_ = cleared; 379 simulate_history_list_was_cleared_ = cleared;
380 main_render_frame_host_->set_simulate_history_list_was_cleared(cleared);
404 } 381 }
405 382
406 RenderViewHostImplTestHarness::RenderViewHostImplTestHarness() { 383 RenderViewHostImplTestHarness::RenderViewHostImplTestHarness() {
407 std::vector<ui::ScaleFactor> scale_factors; 384 std::vector<ui::ScaleFactor> scale_factors;
408 scale_factors.push_back(ui::SCALE_FACTOR_100P); 385 scale_factors.push_back(ui::SCALE_FACTOR_100P);
409 scoped_set_supported_scale_factors_.reset( 386 scoped_set_supported_scale_factors_.reset(
410 new ui::test::ScopedSetSupportedScaleFactors(scale_factors)); 387 new ui::test::ScopedSetSupportedScaleFactors(scale_factors));
411 } 388 }
412 389
413 RenderViewHostImplTestHarness::~RenderViewHostImplTestHarness() { 390 RenderViewHostImplTestHarness::~RenderViewHostImplTestHarness() {
(...skipping 13 matching lines...) Expand all
427 404
428 TestRenderFrameHost* RenderViewHostImplTestHarness::main_test_rfh() { 405 TestRenderFrameHost* RenderViewHostImplTestHarness::main_test_rfh() {
429 return static_cast<TestRenderFrameHost*>(main_rfh()); 406 return static_cast<TestRenderFrameHost*>(main_rfh());
430 } 407 }
431 408
432 TestWebContents* RenderViewHostImplTestHarness::contents() { 409 TestWebContents* RenderViewHostImplTestHarness::contents() {
433 return static_cast<TestWebContents*>(web_contents()); 410 return static_cast<TestWebContents*>(web_contents());
434 } 411 }
435 412
436 } // namespace content 413 } // namespace content
OLDNEW
« no previous file with comments | « content/test/test_render_view_host.h ('k') | content/test/test_web_contents.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698