| 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/public/test/layouttest_support.h" | 5 #include "content/public/test/layouttest_support.h" |
| 6 | 6 |
| 7 #include "base/callback.h" | 7 #include "base/callback.h" |
| 8 #include "base/lazy_instance.h" | 8 #include "base/lazy_instance.h" |
| 9 #include "content/renderer/render_view_impl.h" | 9 #include "content/renderer/render_view_impl.h" |
| 10 #include "third_party/WebKit/Tools/DumpRenderTree/chromium/TestRunner/public/Web
TestProxy.h" | 10 #include "third_party/WebKit/Tools/DumpRenderTree/chromium/TestRunner/public/Web
TestProxy.h" |
| 11 | 11 |
| 12 using WebTestRunner::WebTestProxy; | 12 using WebTestRunner::WebTestProxy; |
| 13 using WebTestRunner::WebTestProxyBase; | 13 using WebTestRunner::WebTestProxyBase; |
| 14 | 14 |
| 15 namespace content { | 15 namespace content { |
| 16 | 16 |
| 17 namespace { | 17 namespace { |
| 18 | 18 |
| 19 base::LazyInstance<base::Callback<void(WebTestProxyBase*)> >::Leaky g_callback; | 19 base::LazyInstance<base::Callback<void(RenderView*, WebTestProxyBase*)> >::Leaky |
| 20 g_callback; |
| 20 | 21 |
| 21 RenderViewImpl* CreateWebTestProxy(RenderViewImplParams* params) { | 22 RenderViewImpl* CreateWebTestProxy(RenderViewImplParams* params) { |
| 22 typedef WebTestProxy<RenderViewImpl, RenderViewImplParams*> ProxyType; | 23 typedef WebTestProxy<RenderViewImpl, RenderViewImplParams*> ProxyType; |
| 23 ProxyType* render_view_proxy = new ProxyType( | 24 ProxyType* render_view_proxy = new ProxyType( |
| 24 reinterpret_cast<RenderViewImplParams*>(params)); | 25 reinterpret_cast<RenderViewImplParams*>(params)); |
| 25 if (g_callback == 0) | 26 if (g_callback == 0) |
| 26 return render_view_proxy; | 27 return render_view_proxy; |
| 27 g_callback.Get().Run(render_view_proxy); | 28 g_callback.Get().Run( |
| 29 static_cast<RenderView*>(render_view_proxy), render_view_proxy); |
| 28 return render_view_proxy; | 30 return render_view_proxy; |
| 29 } | 31 } |
| 30 | 32 |
| 31 } // namespace | 33 } // namespace |
| 32 | 34 |
| 33 | 35 |
| 34 void EnableWebTestProxyCreation( | 36 void EnableWebTestProxyCreation( |
| 35 const base::Callback<void(WebTestProxyBase*)>& callback) { | 37 const base::Callback<void(RenderView*, WebTestProxyBase*)>& callback) { |
| 36 g_callback.Get() = callback; | 38 g_callback.Get() = callback; |
| 37 RenderViewImpl::InstallCreateHook(CreateWebTestProxy); | 39 RenderViewImpl::InstallCreateHook(CreateWebTestProxy); |
| 38 } | 40 } |
| 39 | 41 |
| 40 } // namespace content | 42 } // namespace content |
| OLD | NEW |