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 <stddef.h> | 7 #include <stddef.h> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 using blink::WebDeviceOrientationData; | 52 using blink::WebDeviceOrientationData; |
53 using blink::WebGamepad; | 53 using blink::WebGamepad; |
54 using blink::WebGamepads; | 54 using blink::WebGamepads; |
55 using blink::WebRect; | 55 using blink::WebRect; |
56 using blink::WebSize; | 56 using blink::WebSize; |
57 | 57 |
58 namespace content { | 58 namespace content { |
59 | 59 |
60 namespace { | 60 namespace { |
61 | 61 |
62 base::LazyInstance< | 62 base::LazyInstance<ViewProxyCreationCallback>::Leaky |
63 base::Callback<void(RenderView*, test_runner::WebTestProxyBase*)>>::Leaky | 63 g_view_test_proxy_callback = LAZY_INSTANCE_INITIALIZER; |
64 g_callback = LAZY_INSTANCE_INITIALIZER; | 64 |
| 65 base::LazyInstance<FrameProxyCreationCallback>::Leaky |
| 66 g_frame_test_proxy_callback = LAZY_INSTANCE_INITIALIZER; |
65 | 67 |
66 RenderViewImpl* CreateWebTestProxy(CompositorDependencies* compositor_deps, | 68 RenderViewImpl* CreateWebTestProxy(CompositorDependencies* compositor_deps, |
67 const ViewMsg_New_Params& params) { | 69 const ViewMsg_New_Params& params) { |
68 typedef test_runner::WebTestProxy<RenderViewImpl, CompositorDependencies*, | 70 typedef test_runner::WebTestProxy<RenderViewImpl, CompositorDependencies*, |
69 const ViewMsg_New_Params&> ProxyType; | 71 const ViewMsg_New_Params&> ProxyType; |
70 ProxyType* render_view_proxy = new ProxyType(compositor_deps, params); | 72 ProxyType* render_view_proxy = new ProxyType(compositor_deps, params); |
71 if (g_callback == 0) | 73 if (g_view_test_proxy_callback == 0) |
72 return render_view_proxy; | 74 return render_view_proxy; |
73 g_callback.Get().Run(render_view_proxy, render_view_proxy); | 75 g_view_test_proxy_callback.Get().Run(render_view_proxy, render_view_proxy); |
74 return render_view_proxy; | 76 return render_view_proxy; |
75 } | 77 } |
76 | 78 |
77 test_runner::WebTestProxyBase* GetWebTestProxyBase( | |
78 RenderViewImpl* render_view) { | |
79 typedef test_runner::WebTestProxy<RenderViewImpl, const ViewMsg_New_Params&> | |
80 ViewProxy; | |
81 | |
82 ViewProxy* render_view_proxy = static_cast<ViewProxy*>(render_view); | |
83 return static_cast<test_runner::WebTestProxyBase*>(render_view_proxy); | |
84 } | |
85 | |
86 RenderFrameImpl* CreateWebFrameTestProxy( | 79 RenderFrameImpl* CreateWebFrameTestProxy( |
87 const RenderFrameImpl::CreateParams& params) { | 80 const RenderFrameImpl::CreateParams& params) { |
88 typedef test_runner::WebFrameTestProxy< | 81 typedef test_runner::WebFrameTestProxy< |
89 RenderFrameImpl, const RenderFrameImpl::CreateParams&> FrameProxy; | 82 RenderFrameImpl, const RenderFrameImpl::CreateParams&> FrameProxy; |
90 | 83 |
91 FrameProxy* render_frame_proxy = new FrameProxy(params); | 84 FrameProxy* render_frame_proxy = new FrameProxy(params); |
92 render_frame_proxy->set_base_proxy(GetWebTestProxyBase(params.render_view)); | 85 if (g_frame_test_proxy_callback == 0) |
93 | 86 return render_frame_proxy; |
| 87 g_frame_test_proxy_callback.Get().Run(render_frame_proxy, render_frame_proxy); |
94 return render_frame_proxy; | 88 return render_frame_proxy; |
95 } | 89 } |
96 | 90 |
97 #if defined(OS_WIN) | 91 #if defined(OS_WIN) |
98 // DirectWrite only has access to %WINDIR%\Fonts by default. For developer | 92 // DirectWrite only has access to %WINDIR%\Fonts by default. For developer |
99 // side-loading, support kRegisterFontFiles to allow access to additional fonts. | 93 // side-loading, support kRegisterFontFiles to allow access to additional fonts. |
100 void RegisterSideloadedTypefaces(SkFontMgr* fontmgr) { | 94 void RegisterSideloadedTypefaces(SkFontMgr* fontmgr) { |
101 std::vector<std::string> files = switches::GetSideloadFontFiles(); | 95 std::vector<std::string> files = switches::GetSideloadFontFiles(); |
102 for (std::vector<std::string>::const_iterator i(files.begin()); | 96 for (std::vector<std::string>::const_iterator i(files.begin()); |
103 i != files.end(); | 97 i != files.end(); |
104 ++i) { | 98 ++i) { |
105 SkTypeface* typeface = fontmgr->createFromFile(i->c_str()); | 99 SkTypeface* typeface = fontmgr->createFromFile(i->c_str()); |
106 if (!ShouldUseDirectWriteFontProxyFieldTrial()) | 100 if (!ShouldUseDirectWriteFontProxyFieldTrial()) |
107 DoPreSandboxWarmupForTypeface(typeface); | 101 DoPreSandboxWarmupForTypeface(typeface); |
108 blink::WebFontRendering::addSideloadedFontForTesting(typeface); | 102 blink::WebFontRendering::addSideloadedFontForTesting(typeface); |
109 } | 103 } |
110 } | 104 } |
111 #endif // OS_WIN | 105 #endif // OS_WIN |
112 | 106 |
113 } // namespace | 107 } // namespace |
114 | 108 |
115 void EnableWebTestProxyCreation( | 109 void EnableWebTestProxyCreation( |
116 const base::Callback<void(RenderView*, test_runner::WebTestProxyBase*)>& | 110 const ViewProxyCreationCallback& view_proxy_creation_callback, |
117 callback) { | 111 const FrameProxyCreationCallback& frame_proxy_creation_callback) { |
118 g_callback.Get() = callback; | 112 g_view_test_proxy_callback.Get() = view_proxy_creation_callback; |
| 113 g_frame_test_proxy_callback.Get() = frame_proxy_creation_callback; |
119 RenderViewImpl::InstallCreateHook(CreateWebTestProxy); | 114 RenderViewImpl::InstallCreateHook(CreateWebTestProxy); |
120 RenderFrameImpl::InstallCreateHook(CreateWebFrameTestProxy); | 115 RenderFrameImpl::InstallCreateHook(CreateWebFrameTestProxy); |
121 } | 116 } |
122 | 117 |
123 void FetchManifestDoneCallback( | 118 void FetchManifestDoneCallback( |
124 scoped_ptr<ManifestFetcher> fetcher, | 119 scoped_ptr<ManifestFetcher> fetcher, |
125 const FetchManifestCallback& callback, | 120 const FetchManifestCallback& callback, |
126 const blink::WebURLResponse& response, | 121 const blink::WebURLResponse& response, |
127 const std::string& data) { | 122 const std::string& data) { |
128 // |fetcher| will be autodeleted here as it is going out of scope. | 123 // |fetcher| will be autodeleted here as it is going out of scope. |
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
450 result.append( | 445 result.append( |
451 DumpHistoryItem(entry->root_history_node(), | 446 DumpHistoryItem(entry->root_history_node(), |
452 8, | 447 8, |
453 index == current_index)); | 448 index == current_index)); |
454 } | 449 } |
455 result.append("===============================================\n"); | 450 result.append("===============================================\n"); |
456 return result; | 451 return result; |
457 } | 452 } |
458 | 453 |
459 } // namespace content | 454 } // namespace content |
OLD | NEW |