OLD | NEW |
1 | 1 |
2 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 2 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
3 // Use of this source code is governed by a BSD-style license that can be | 3 // Use of this source code is governed by a BSD-style license that can be |
4 // found in the LICENSE file. | 4 // found in the LICENSE file. |
5 | 5 |
6 #include "content/browser/browser_url_handler.h" | 6 #include "content/browser/browser_url_handler.h" |
7 #include "content/browser/renderer_host/test_backing_store.h" | 7 #include "content/browser/renderer_host/test_backing_store.h" |
8 #include "content/browser/renderer_host/test_render_view_host.h" | 8 #include "content/browser/renderer_host/test_render_view_host.h" |
9 #include "content/browser/site_instance.h" | 9 #include "content/browser/site_instance_impl.h" |
10 #include "content/browser/tab_contents/navigation_controller_impl.h" | 10 #include "content/browser/tab_contents/navigation_controller_impl.h" |
11 #include "content/browser/tab_contents/navigation_entry_impl.h" | 11 #include "content/browser/tab_contents/navigation_entry_impl.h" |
12 #include "content/browser/tab_contents/test_tab_contents.h" | 12 #include "content/browser/tab_contents/test_tab_contents.h" |
13 #include "content/common/dom_storage_common.h" | 13 #include "content/common/dom_storage_common.h" |
14 #include "content/common/view_messages.h" | 14 #include "content/common/view_messages.h" |
15 #include "content/public/browser/navigation_controller.h" | 15 #include "content/public/browser/navigation_controller.h" |
16 #include "content/public/common/content_client.h" | 16 #include "content/public/common/content_client.h" |
17 #include "content/test/test_browser_context.h" | 17 #include "content/test/test_browser_context.h" |
18 #include "ui/gfx/rect.h" | 18 #include "ui/gfx/rect.h" |
19 #include "webkit/forms/password_form.h" | 19 #include "webkit/forms/password_form.h" |
20 #include "webkit/glue/webkit_glue.h" | 20 #include "webkit/glue/webkit_glue.h" |
21 #include "webkit/glue/webpreferences.h" | 21 #include "webkit/glue/webpreferences.h" |
22 | 22 |
23 using content::NavigationController; | 23 using content::NavigationController; |
24 using content::NavigationEntry; | 24 using content::NavigationEntry; |
25 using content::RenderViewHostDelegate; | 25 using content::RenderViewHostDelegate; |
| 26 using content::SiteInstance; |
26 using webkit::forms::PasswordForm; | 27 using webkit::forms::PasswordForm; |
27 | 28 |
28 void InitNavigateParams(ViewHostMsg_FrameNavigate_Params* params, | 29 void InitNavigateParams(ViewHostMsg_FrameNavigate_Params* params, |
29 int page_id, | 30 int page_id, |
30 const GURL& url, | 31 const GURL& url, |
31 content::PageTransition transition) { | 32 content::PageTransition transition) { |
32 params->page_id = page_id; | 33 params->page_id = page_id; |
33 params->url = url; | 34 params->url = url; |
34 params->referrer = content::Referrer(); | 35 params->referrer = content::Referrer(); |
35 params->transition = transition; | 36 params->transition = transition; |
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
301 content::RenderProcessHostFactory* rph_factory) { | 302 content::RenderProcessHostFactory* rph_factory) { |
302 render_process_host_factory_ = rph_factory; | 303 render_process_host_factory_ = rph_factory; |
303 } | 304 } |
304 | 305 |
305 RenderViewHost* TestRenderViewHostFactory::CreateRenderViewHost( | 306 RenderViewHost* TestRenderViewHostFactory::CreateRenderViewHost( |
306 SiteInstance* instance, | 307 SiteInstance* instance, |
307 RenderViewHostDelegate* delegate, | 308 RenderViewHostDelegate* delegate, |
308 int routing_id, | 309 int routing_id, |
309 SessionStorageNamespace* session_storage) { | 310 SessionStorageNamespace* session_storage) { |
310 // See declaration of render_process_host_factory_ below. | 311 // See declaration of render_process_host_factory_ below. |
311 instance->set_render_process_host_factory(render_process_host_factory_); | 312 static_cast<SiteInstanceImpl*>(instance)-> |
| 313 set_render_process_host_factory(render_process_host_factory_); |
312 return new TestRenderViewHost(instance, delegate, routing_id); | 314 return new TestRenderViewHost(instance, delegate, routing_id); |
313 } | 315 } |
314 | 316 |
315 RenderViewHostTestHarness::RenderViewHostTestHarness() | 317 RenderViewHostTestHarness::RenderViewHostTestHarness() |
316 : rph_factory_(), | 318 : rph_factory_(), |
317 rvh_factory_(&rph_factory_), | 319 rvh_factory_(&rph_factory_), |
318 contents_(NULL) { | 320 contents_(NULL) { |
319 } | 321 } |
320 | 322 |
321 RenderViewHostTestHarness::~RenderViewHostTestHarness() { | 323 RenderViewHostTestHarness::~RenderViewHostTestHarness() { |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
359 void RenderViewHostTestHarness::SetContents(TestTabContents* contents) { | 361 void RenderViewHostTestHarness::SetContents(TestTabContents* contents) { |
360 contents_.reset(contents); | 362 contents_.reset(contents); |
361 } | 363 } |
362 | 364 |
363 TestTabContents* RenderViewHostTestHarness::CreateTestTabContents() { | 365 TestTabContents* RenderViewHostTestHarness::CreateTestTabContents() { |
364 // See comment above browser_context_ decl for why we check for NULL here. | 366 // See comment above browser_context_ decl for why we check for NULL here. |
365 if (!browser_context_.get()) | 367 if (!browser_context_.get()) |
366 browser_context_.reset(new TestBrowserContext()); | 368 browser_context_.reset(new TestBrowserContext()); |
367 | 369 |
368 // This will be deleted when the TabContents goes away. | 370 // This will be deleted when the TabContents goes away. |
369 SiteInstance* instance = | 371 SiteInstance* instance = SiteInstance::Create(browser_context_.get()); |
370 SiteInstance::CreateSiteInstance(browser_context_.get()); | |
371 | 372 |
372 return new TestTabContents(browser_context_.get(), instance); | 373 return new TestTabContents(browser_context_.get(), instance); |
373 } | 374 } |
374 | 375 |
375 void RenderViewHostTestHarness::NavigateAndCommit(const GURL& url) { | 376 void RenderViewHostTestHarness::NavigateAndCommit(const GURL& url) { |
376 contents()->NavigateAndCommit(url); | 377 contents()->NavigateAndCommit(url); |
377 } | 378 } |
378 | 379 |
379 void RenderViewHostTestHarness::Reload() { | 380 void RenderViewHostTestHarness::Reload() { |
380 NavigationEntry* entry = controller().GetLastCommittedEntry(); | 381 NavigationEntry* entry = controller().GetLastCommittedEntry(); |
(...skipping 10 matching lines...) Expand all Loading... |
391 SetContents(NULL); | 392 SetContents(NULL); |
392 | 393 |
393 // Make sure that we flush any messages related to TabContents destruction | 394 // Make sure that we flush any messages related to TabContents destruction |
394 // before we destroy the browser context. | 395 // before we destroy the browser context. |
395 MessageLoop::current()->RunAllPending(); | 396 MessageLoop::current()->RunAllPending(); |
396 | 397 |
397 // Release the browser context on the UI thread. | 398 // Release the browser context on the UI thread. |
398 message_loop_.DeleteSoon(FROM_HERE, browser_context_.release()); | 399 message_loop_.DeleteSoon(FROM_HERE, browser_context_.release()); |
399 message_loop_.RunAllPending(); | 400 message_loop_.RunAllPending(); |
400 } | 401 } |
OLD | NEW |