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" |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
60 } | 60 } |
61 | 61 |
62 TestRenderViewHost* TestRenderViewHost::GetPendingForController( | 62 TestRenderViewHost* TestRenderViewHost::GetPendingForController( |
63 content::NavigationController* controller) { | 63 content::NavigationController* controller) { |
64 TabContents* tab_contents = static_cast<TabContents*>( | 64 TabContents* tab_contents = static_cast<TabContents*>( |
65 controller->GetWebContents()); | 65 controller->GetWebContents()); |
66 return static_cast<TestRenderViewHost*>( | 66 return static_cast<TestRenderViewHost*>( |
67 tab_contents->GetRenderManagerForTesting()->pending_render_view_host()); | 67 tab_contents->GetRenderManagerForTesting()->pending_render_view_host()); |
68 } | 68 } |
69 | 69 |
70 TestRenderViewHost::TestRenderViewHost(SiteInstance* instance, | 70 TestRenderViewHost::TestRenderViewHost(content::SiteInstance* instance, |
71 RenderViewHostDelegate* delegate, | 71 RenderViewHostDelegate* delegate, |
72 int routing_id) | 72 int routing_id) |
73 : RenderViewHost(instance, delegate, routing_id, | 73 : RenderViewHost(instance, delegate, routing_id, |
74 kInvalidSessionStorageNamespaceId), | 74 kInvalidSessionStorageNamespaceId), |
75 render_view_created_(false), | 75 render_view_created_(false), |
76 delete_counter_(NULL), | 76 delete_counter_(NULL), |
77 simulate_fetch_via_proxy_(false), | 77 simulate_fetch_via_proxy_(false), |
78 contents_mime_type_("text/html") { | 78 contents_mime_type_("text/html") { |
79 // For normal RenderViewHosts, this is freed when |Shutdown()| is called. | 79 // For normal RenderViewHosts, this is freed when |Shutdown()| is called. |
80 // For TestRenderViewHost, the view is explicitly deleted in the destructor | 80 // For TestRenderViewHost, the view is explicitly deleted in the destructor |
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
296 TestRenderViewHostFactory::~TestRenderViewHostFactory() { | 296 TestRenderViewHostFactory::~TestRenderViewHostFactory() { |
297 RenderViewHostFactory::UnregisterFactory(); | 297 RenderViewHostFactory::UnregisterFactory(); |
298 } | 298 } |
299 | 299 |
300 void TestRenderViewHostFactory::set_render_process_host_factory( | 300 void TestRenderViewHostFactory::set_render_process_host_factory( |
301 content::RenderProcessHostFactory* rph_factory) { | 301 content::RenderProcessHostFactory* rph_factory) { |
302 render_process_host_factory_ = rph_factory; | 302 render_process_host_factory_ = rph_factory; |
303 } | 303 } |
304 | 304 |
305 RenderViewHost* TestRenderViewHostFactory::CreateRenderViewHost( | 305 RenderViewHost* TestRenderViewHostFactory::CreateRenderViewHost( |
306 SiteInstance* instance, | 306 content::SiteInstance* instance, |
307 RenderViewHostDelegate* delegate, | 307 RenderViewHostDelegate* delegate, |
308 int routing_id, | 308 int routing_id, |
309 SessionStorageNamespace* session_storage) { | 309 SessionStorageNamespace* session_storage) { |
310 // See declaration of render_process_host_factory_ below. | 310 // See declaration of render_process_host_factory_ below. |
311 instance->set_render_process_host_factory(render_process_host_factory_); | 311 reinterpret_cast<SiteInstanceImpl*>(instance)-> |
jam
2012/01/24 03:29:33
nit: ditto
ananta
2012/01/24 23:46:26
Done.
| |
312 set_render_process_host_factory(render_process_host_factory_); | |
312 return new TestRenderViewHost(instance, delegate, routing_id); | 313 return new TestRenderViewHost(instance, delegate, routing_id); |
313 } | 314 } |
314 | 315 |
315 RenderViewHostTestHarness::RenderViewHostTestHarness() | 316 RenderViewHostTestHarness::RenderViewHostTestHarness() |
316 : rph_factory_(), | 317 : rph_factory_(), |
317 rvh_factory_(&rph_factory_), | 318 rvh_factory_(&rph_factory_), |
318 contents_(NULL) { | 319 contents_(NULL) { |
319 } | 320 } |
320 | 321 |
321 RenderViewHostTestHarness::~RenderViewHostTestHarness() { | 322 RenderViewHostTestHarness::~RenderViewHostTestHarness() { |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
359 void RenderViewHostTestHarness::SetContents(TestTabContents* contents) { | 360 void RenderViewHostTestHarness::SetContents(TestTabContents* contents) { |
360 contents_.reset(contents); | 361 contents_.reset(contents); |
361 } | 362 } |
362 | 363 |
363 TestTabContents* RenderViewHostTestHarness::CreateTestTabContents() { | 364 TestTabContents* RenderViewHostTestHarness::CreateTestTabContents() { |
364 // See comment above browser_context_ decl for why we check for NULL here. | 365 // See comment above browser_context_ decl for why we check for NULL here. |
365 if (!browser_context_.get()) | 366 if (!browser_context_.get()) |
366 browser_context_.reset(new TestBrowserContext()); | 367 browser_context_.reset(new TestBrowserContext()); |
367 | 368 |
368 // This will be deleted when the TabContents goes away. | 369 // This will be deleted when the TabContents goes away. |
369 SiteInstance* instance = | 370 content::SiteInstance* instance = |
370 SiteInstance::CreateSiteInstance(browser_context_.get()); | 371 content::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 |