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

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

Issue 16162003: Introduce content::PageState (again). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 7 years, 6 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
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_render_view_host.h" 5 #include "content/browser/renderer_host/test_render_view_host.h"
6 6
7 #include "content/browser/dom_storage/dom_storage_context_impl.h" 7 #include "content/browser/dom_storage/dom_storage_context_impl.h"
8 #include "content/browser/dom_storage/session_storage_namespace_impl.h" 8 #include "content/browser/dom_storage/session_storage_namespace_impl.h"
9 #include "content/browser/renderer_host/test_backing_store.h" 9 #include "content/browser/renderer_host/test_backing_store.h"
10 #include "content/browser/site_instance_impl.h" 10 #include "content/browser/site_instance_impl.h"
11 #include "content/common/view_messages.h" 11 #include "content/common/view_messages.h"
12 #include "content/public/browser/browser_context.h" 12 #include "content/public/browser/browser_context.h"
13 #include "content/public/browser/navigation_controller.h" 13 #include "content/public/browser/navigation_controller.h"
14 #include "content/public/browser/storage_partition.h" 14 #include "content/public/browser/storage_partition.h"
15 #include "content/public/common/content_client.h" 15 #include "content/public/common/content_client.h"
16 #include "content/public/common/page_state.h"
16 #include "content/public/common/password_form.h" 17 #include "content/public/common/password_form.h"
17 #include "content/test/test_web_contents.h" 18 #include "content/test/test_web_contents.h"
18 #include "media/base/video_frame.h" 19 #include "media/base/video_frame.h"
19 #include "ui/gfx/rect.h" 20 #include "ui/gfx/rect.h"
20 #include "webkit/dom_storage/dom_storage_types.h" 21 #include "webkit/dom_storage/dom_storage_types.h"
21 #include "webkit/glue/glue_serialize.h"
22 #include "webkit/glue/webpreferences.h" 22 #include "webkit/glue/webpreferences.h"
23 23
24 namespace content { 24 namespace content {
25 25
26 namespace { 26 namespace {
27 // Normally this is done by the NavigationController, but we'll fake it out 27 // Normally this is done by the NavigationController, but we'll fake it out
28 // here for testing. 28 // here for testing.
29 SessionStorageNamespaceImpl* CreateSessionStorageNamespace( 29 SessionStorageNamespaceImpl* CreateSessionStorageNamespace(
30 SiteInstance* instance) { 30 SiteInstance* instance) {
31 RenderProcessHost* process_host = instance->GetProcess(); 31 RenderProcessHost* process_host = instance->GetProcess();
(...skipping 19 matching lines...) Expand all
51 params->transition = transition; 51 params->transition = transition;
52 params->redirects = std::vector<GURL>(); 52 params->redirects = std::vector<GURL>();
53 params->should_update_history = false; 53 params->should_update_history = false;
54 params->searchable_form_url = GURL(); 54 params->searchable_form_url = GURL();
55 params->searchable_form_encoding = std::string(); 55 params->searchable_form_encoding = std::string();
56 params->password_form = PasswordForm(); 56 params->password_form = PasswordForm();
57 params->security_info = std::string(); 57 params->security_info = std::string();
58 params->gesture = NavigationGestureUser; 58 params->gesture = NavigationGestureUser;
59 params->was_within_same_page = false; 59 params->was_within_same_page = false;
60 params->is_post = false; 60 params->is_post = false;
61 params->content_state = webkit_glue::CreateHistoryStateForURL(GURL(url)); 61 params->page_state = PageState::CreateFromURL(url);
62 } 62 }
63 63
64 TestRenderWidgetHostView::TestRenderWidgetHostView(RenderWidgetHost* rwh) 64 TestRenderWidgetHostView::TestRenderWidgetHostView(RenderWidgetHost* rwh)
65 : rwh_(RenderWidgetHostImpl::From(rwh)), 65 : rwh_(RenderWidgetHostImpl::From(rwh)),
66 is_showing_(false) { 66 is_showing_(false) {
67 } 67 }
68 68
69 TestRenderWidgetHostView::~TestRenderWidgetHostView() { 69 TestRenderWidgetHostView::~TestRenderWidgetHostView() {
70 } 70 }
71 71
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after
336 params.contents_mime_type = contents_mime_type_; 336 params.contents_mime_type = contents_mime_type_;
337 params.is_post = false; 337 params.is_post = false;
338 params.was_within_same_page = false; 338 params.was_within_same_page = false;
339 params.http_status_code = response_code; 339 params.http_status_code = response_code;
340 params.socket_address.set_host("2001:db8::1"); 340 params.socket_address.set_host("2001:db8::1");
341 params.socket_address.set_port(80); 341 params.socket_address.set_port(80);
342 params.was_fetched_via_proxy = simulate_fetch_via_proxy_; 342 params.was_fetched_via_proxy = simulate_fetch_via_proxy_;
343 params.history_list_was_cleared = simulate_history_list_was_cleared_; 343 params.history_list_was_cleared = simulate_history_list_was_cleared_;
344 params.original_request_url = original_request_url; 344 params.original_request_url = original_request_url;
345 345
346 WebKit::WebHTTPBody http_body; 346 params.page_state = PageState::CreateForTesting(
347 http_body.initialize(); 347 url,
348 348 false,
349 WebKit::WebHistoryItem history_item; 349 file_path_for_history_item ? "data" : NULL,
350 history_item.initialize(); 350 file_path_for_history_item);
351 history_item.setURLString(WebKit::WebString::fromUTF8(url.spec()));
352 if (file_path_for_history_item) {
353 const char char_data[] = "data";
354 http_body.appendData(WebKit::WebData(char_data, arraysize(char_data)-1));
355 http_body.appendFile(WebKit::WebString::fromUTF8(
356 file_path_for_history_item->MaybeAsASCII()));
357 history_item.setHTTPBody(http_body);
358 }
359 params.content_state = webkit_glue::HistoryItemToString(history_item);
360 351
361 ViewHostMsg_FrameNavigate msg(1, params); 352 ViewHostMsg_FrameNavigate msg(1, params);
362 OnNavigate(msg); 353 OnNavigate(msg);
363 } 354 }
364 355
365 void TestRenderViewHost::SendShouldCloseACK(bool proceed) { 356 void TestRenderViewHost::SendShouldCloseACK(bool proceed) {
366 base::TimeTicks now = base::TimeTicks::Now(); 357 base::TimeTicks now = base::TimeTicks::Now();
367 OnShouldCloseACK(proceed, now, now); 358 OnShouldCloseACK(proceed, now, now);
368 } 359 }
369 360
(...skipping 17 matching lines...) Expand all
387 const WebDropData& drop_data) { 378 const WebDropData& drop_data) {
388 WebKit::WebDragOperationsMask drag_operation = WebKit::WebDragOperationEvery; 379 WebKit::WebDragOperationsMask drag_operation = WebKit::WebDragOperationEvery;
389 DragEventSourceInfo event_info; 380 DragEventSourceInfo event_info;
390 OnStartDragging(drop_data, drag_operation, SkBitmap(), gfx::Vector2d(), 381 OnStartDragging(drop_data, drag_operation, SkBitmap(), gfx::Vector2d(),
391 event_info); 382 event_info);
392 } 383 }
393 384
394 void TestRenderViewHost::TestOnUpdateStateWithFile( 385 void TestRenderViewHost::TestOnUpdateStateWithFile(
395 int process_id, 386 int process_id,
396 const base::FilePath& file_path) { 387 const base::FilePath& file_path) {
397 WebKit::WebHTTPBody http_body; 388 OnUpdateState(process_id,
398 http_body.initialize(); 389 PageState::CreateForTesting(GURL("http://www.google.com"),
399 const char char_data[] = "data"; 390 false,
400 http_body.appendData(WebKit::WebData(char_data, arraysize(char_data)-1)); 391 "data",
401 http_body.appendFile(WebKit::WebString::fromUTF8(file_path.MaybeAsASCII())); 392 &file_path));
402
403 WebKit::WebHistoryItem history_item;
404 history_item.initialize();
405 history_item.setURLString("http://www.google.com");
406 history_item.setHTTPBody(http_body);
407 OnUpdateState(process_id, webkit_glue::HistoryItemToString(history_item));
408 } 393 }
409 394
410 void TestRenderViewHost::set_simulate_fetch_via_proxy(bool proxy) { 395 void TestRenderViewHost::set_simulate_fetch_via_proxy(bool proxy) {
411 simulate_fetch_via_proxy_ = proxy; 396 simulate_fetch_via_proxy_ = proxy;
412 } 397 }
413 398
414 void TestRenderViewHost::set_simulate_history_list_was_cleared(bool cleared) { 399 void TestRenderViewHost::set_simulate_history_list_was_cleared(bool cleared) {
415 simulate_history_list_was_cleared_ = cleared; 400 simulate_history_list_was_cleared_ = cleared;
416 } 401 }
417 402
(...skipping 13 matching lines...) Expand all
431 416
432 TestRenderViewHost* RenderViewHostImplTestHarness::active_test_rvh() { 417 TestRenderViewHost* RenderViewHostImplTestHarness::active_test_rvh() {
433 return static_cast<TestRenderViewHost*>(active_rvh()); 418 return static_cast<TestRenderViewHost*>(active_rvh());
434 } 419 }
435 420
436 TestWebContents* RenderViewHostImplTestHarness::contents() { 421 TestWebContents* RenderViewHostImplTestHarness::contents() {
437 return static_cast<TestWebContents*>(web_contents()); 422 return static_cast<TestWebContents*>(web_contents());
438 } 423 }
439 424
440 } // namespace content 425 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698