OLD | NEW |
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_backing_store.h" | 5 #include "content/browser/renderer_host/test_backing_store.h" |
6 #include "content/browser/renderer_host/test_render_view_host.h" | 6 #include "content/browser/renderer_host/test_render_view_host.h" |
7 #include "content/browser/site_instance_impl.h" | 7 #include "content/browser/site_instance_impl.h" |
| 8 #include "content/browser/dom_storage/dom_storage_context_impl.h" |
| 9 #include "content/browser/dom_storage/session_storage_namespace_impl.h" |
8 #include "content/browser/web_contents/navigation_controller_impl.h" | 10 #include "content/browser/web_contents/navigation_controller_impl.h" |
9 #include "content/browser/web_contents/test_web_contents.h" | 11 #include "content/browser/web_contents/test_web_contents.h" |
10 #include "content/common/view_messages.h" | 12 #include "content/common/view_messages.h" |
| 13 #include "content/public/browser/browser_context.h" |
11 #include "content/public/browser/navigation_controller.h" | 14 #include "content/public/browser/navigation_controller.h" |
12 #include "content/public/common/content_client.h" | 15 #include "content/public/common/content_client.h" |
13 #include "ui/gfx/rect.h" | 16 #include "ui/gfx/rect.h" |
14 #include "webkit/dom_storage/dom_storage_types.h" | 17 #include "webkit/dom_storage/dom_storage_types.h" |
15 #include "webkit/forms/password_form.h" | 18 #include "webkit/forms/password_form.h" |
16 #include "webkit/glue/webkit_glue.h" | 19 #include "webkit/glue/webkit_glue.h" |
17 #include "webkit/glue/webpreferences.h" | 20 #include "webkit/glue/webpreferences.h" |
18 | 21 |
19 using content::NativeWebKeyboardEvent; | 22 using content::NativeWebKeyboardEvent; |
20 using webkit::forms::PasswordForm; | 23 using webkit::forms::PasswordForm; |
21 | 24 |
22 namespace content { | 25 namespace content { |
23 | 26 |
| 27 namespace { |
| 28 // Normally this is done by the NavigationController, but we'll fake it out |
| 29 // here for testing. |
| 30 SessionStorageNamespaceImpl* CreateSessionStorageNamespace( |
| 31 SiteInstance* instance) { |
| 32 RenderProcessHost* process_host = instance->GetProcess(); |
| 33 DOMStorageContext* dom_storage_context = |
| 34 BrowserContext::GetDOMStorageContext(process_host->GetBrowserContext(), |
| 35 process_host->GetID()); |
| 36 return new SessionStorageNamespaceImpl( |
| 37 static_cast<DOMStorageContextImpl*>(dom_storage_context)); |
| 38 } |
| 39 } // namespace |
| 40 |
| 41 |
24 void InitNavigateParams(ViewHostMsg_FrameNavigate_Params* params, | 42 void InitNavigateParams(ViewHostMsg_FrameNavigate_Params* params, |
25 int page_id, | 43 int page_id, |
26 const GURL& url, | 44 const GURL& url, |
27 PageTransition transition) { | 45 PageTransition transition) { |
28 params->page_id = page_id; | 46 params->page_id = page_id; |
29 params->url = url; | 47 params->url = url; |
30 params->referrer = Referrer(); | 48 params->referrer = Referrer(); |
31 params->transition = transition; | 49 params->transition = transition; |
32 params->redirects = std::vector<GURL>(); | 50 params->redirects = std::vector<GURL>(); |
33 params->should_update_history = false; | 51 params->should_update_history = false; |
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
214 SiteInstance* instance, | 232 SiteInstance* instance, |
215 RenderViewHostDelegate* delegate, | 233 RenderViewHostDelegate* delegate, |
216 RenderWidgetHostDelegate* widget_delegate, | 234 RenderWidgetHostDelegate* widget_delegate, |
217 int routing_id, | 235 int routing_id, |
218 bool swapped_out) | 236 bool swapped_out) |
219 : RenderViewHostImpl(instance, | 237 : RenderViewHostImpl(instance, |
220 delegate, | 238 delegate, |
221 widget_delegate, | 239 widget_delegate, |
222 routing_id, | 240 routing_id, |
223 swapped_out, | 241 swapped_out, |
224 dom_storage::kInvalidSessionStorageNamespaceId), | 242 CreateSessionStorageNamespace(instance)), |
225 render_view_created_(false), | 243 render_view_created_(false), |
226 delete_counter_(NULL), | 244 delete_counter_(NULL), |
227 simulate_fetch_via_proxy_(false), | 245 simulate_fetch_via_proxy_(false), |
228 contents_mime_type_("text/html") { | 246 contents_mime_type_("text/html") { |
229 // For normal RenderViewHosts, this is freed when |Shutdown()| is | 247 // For normal RenderViewHosts, this is freed when |Shutdown()| is |
230 // called. For TestRenderViewHost, the view is explicitly | 248 // called. For TestRenderViewHost, the view is explicitly |
231 // deleted in the destructor below, because | 249 // deleted in the destructor below, because |
232 // TestRenderWidgetHostView::Destroy() doesn't |delete this|. | 250 // TestRenderWidgetHostView::Destroy() doesn't |delete this|. |
233 SetView(new TestRenderWidgetHostView(this)); | 251 SetView(new TestRenderWidgetHostView(this)); |
234 } | 252 } |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
337 | 355 |
338 TestRenderViewHost* RenderViewHostImplTestHarness::active_test_rvh() { | 356 TestRenderViewHost* RenderViewHostImplTestHarness::active_test_rvh() { |
339 return static_cast<TestRenderViewHost*>(active_rvh()); | 357 return static_cast<TestRenderViewHost*>(active_rvh()); |
340 } | 358 } |
341 | 359 |
342 TestWebContents* RenderViewHostImplTestHarness::contents() { | 360 TestWebContents* RenderViewHostImplTestHarness::contents() { |
343 return static_cast<TestWebContents*>(web_contents()); | 361 return static_cast<TestWebContents*>(web_contents()); |
344 } | 362 } |
345 | 363 |
346 } // namespace content | 364 } // namespace content |
OLD | NEW |