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

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

Issue 14985014: Introduce content::PageState (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add comments to the top of page_state.h Created 7 years, 7 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 258 matching lines...) Expand 10 before | Expand all | Expand 10 after
330 params.contents_mime_type = contents_mime_type_; 330 params.contents_mime_type = contents_mime_type_;
331 params.is_post = false; 331 params.is_post = false;
332 params.was_within_same_page = false; 332 params.was_within_same_page = false;
333 params.http_status_code = response_code; 333 params.http_status_code = response_code;
334 params.socket_address.set_host("2001:db8::1"); 334 params.socket_address.set_host("2001:db8::1");
335 params.socket_address.set_port(80); 335 params.socket_address.set_port(80);
336 params.was_fetched_via_proxy = simulate_fetch_via_proxy_; 336 params.was_fetched_via_proxy = simulate_fetch_via_proxy_;
337 params.history_list_was_cleared = simulate_history_list_was_cleared_; 337 params.history_list_was_cleared = simulate_history_list_was_cleared_;
338 params.original_request_url = original_request_url; 338 params.original_request_url = original_request_url;
339 339
340 WebKit::WebHTTPBody http_body; 340 params.page_state = PageState::CreateForTesting(
341 http_body.initialize(); 341 url,
342 342 false,
343 WebKit::WebHistoryItem history_item; 343 file_path_for_history_item ? "data" : NULL,
344 history_item.initialize(); 344 file_path_for_history_item);
345 history_item.setURLString(WebKit::WebString::fromUTF8(url.spec()));
346 if (file_path_for_history_item) {
347 const char char_data[] = "data";
348 http_body.appendData(WebKit::WebData(char_data, arraysize(char_data)-1));
349 http_body.appendFile(WebKit::WebString::fromUTF8(
350 file_path_for_history_item->MaybeAsASCII()));
351 history_item.setHTTPBody(http_body);
352 }
353 params.content_state = webkit_glue::HistoryItemToString(history_item);
354 345
355 ViewHostMsg_FrameNavigate msg(1, params); 346 ViewHostMsg_FrameNavigate msg(1, params);
356 OnNavigate(msg); 347 OnNavigate(msg);
357 } 348 }
358 349
359 void TestRenderViewHost::SendShouldCloseACK(bool proceed) { 350 void TestRenderViewHost::SendShouldCloseACK(bool proceed) {
360 base::TimeTicks now = base::TimeTicks::Now(); 351 base::TimeTicks now = base::TimeTicks::Now();
361 OnShouldCloseACK(proceed, now, now); 352 OnShouldCloseACK(proceed, now, now);
362 } 353 }
363 354
(...skipping 17 matching lines...) Expand all
381 const WebDropData& drop_data) { 372 const WebDropData& drop_data) {
382 WebKit::WebDragOperationsMask drag_operation = WebKit::WebDragOperationEvery; 373 WebKit::WebDragOperationsMask drag_operation = WebKit::WebDragOperationEvery;
383 DragEventSourceInfo event_info; 374 DragEventSourceInfo event_info;
384 OnStartDragging(drop_data, drag_operation, SkBitmap(), gfx::Vector2d(), 375 OnStartDragging(drop_data, drag_operation, SkBitmap(), gfx::Vector2d(),
385 event_info); 376 event_info);
386 } 377 }
387 378
388 void TestRenderViewHost::TestOnUpdateStateWithFile( 379 void TestRenderViewHost::TestOnUpdateStateWithFile(
389 int process_id, 380 int process_id,
390 const base::FilePath& file_path) { 381 const base::FilePath& file_path) {
391 WebKit::WebHTTPBody http_body; 382 OnUpdateState(process_id,
392 http_body.initialize(); 383 PageState::CreateForTesting(GURL("http://www.google.com"),
393 const char char_data[] = "data"; 384 false,
394 http_body.appendData(WebKit::WebData(char_data, arraysize(char_data)-1)); 385 "data",
395 http_body.appendFile(WebKit::WebString::fromUTF8(file_path.MaybeAsASCII())); 386 &file_path));
396
397 WebKit::WebHistoryItem history_item;
398 history_item.initialize();
399 history_item.setURLString("http://www.google.com");
400 history_item.setHTTPBody(http_body);
401 OnUpdateState(process_id, webkit_glue::HistoryItemToString(history_item));
402 } 387 }
403 388
404 void TestRenderViewHost::set_simulate_fetch_via_proxy(bool proxy) { 389 void TestRenderViewHost::set_simulate_fetch_via_proxy(bool proxy) {
405 simulate_fetch_via_proxy_ = proxy; 390 simulate_fetch_via_proxy_ = proxy;
406 } 391 }
407 392
408 void TestRenderViewHost::set_simulate_history_list_was_cleared(bool cleared) { 393 void TestRenderViewHost::set_simulate_history_list_was_cleared(bool cleared) {
409 simulate_history_list_was_cleared_ = cleared; 394 simulate_history_list_was_cleared_ = cleared;
410 } 395 }
411 396
(...skipping 13 matching lines...) Expand all
425 410
426 TestRenderViewHost* RenderViewHostImplTestHarness::active_test_rvh() { 411 TestRenderViewHost* RenderViewHostImplTestHarness::active_test_rvh() {
427 return static_cast<TestRenderViewHost*>(active_rvh()); 412 return static_cast<TestRenderViewHost*>(active_rvh());
428 } 413 }
429 414
430 TestWebContents* RenderViewHostImplTestHarness::contents() { 415 TestWebContents* RenderViewHostImplTestHarness::contents() {
431 return static_cast<TestWebContents*>(web_contents()); 416 return static_cast<TestWebContents*>(web_contents());
432 } 417 }
433 418
434 } // namespace content 419 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698