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 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 | 114 |
115 void EnableWebTestProxyCreation( | 115 void EnableWebTestProxyCreation( |
116 const ViewProxyCreationCallback& view_proxy_creation_callback, | 116 const ViewProxyCreationCallback& view_proxy_creation_callback, |
117 const FrameProxyCreationCallback& frame_proxy_creation_callback) { | 117 const FrameProxyCreationCallback& frame_proxy_creation_callback) { |
118 g_view_test_proxy_callback.Get() = view_proxy_creation_callback; | 118 g_view_test_proxy_callback.Get() = view_proxy_creation_callback; |
119 g_frame_test_proxy_callback.Get() = frame_proxy_creation_callback; | 119 g_frame_test_proxy_callback.Get() = frame_proxy_creation_callback; |
120 RenderViewImpl::InstallCreateHook(CreateWebTestProxy); | 120 RenderViewImpl::InstallCreateHook(CreateWebTestProxy); |
121 RenderFrameImpl::InstallCreateHook(CreateWebFrameTestProxy); | 121 RenderFrameImpl::InstallCreateHook(CreateWebFrameTestProxy); |
122 } | 122 } |
123 | 123 |
124 void FetchManifestDoneCallback( | 124 void FetchManifestDoneCallback(std::unique_ptr<ManifestFetcher> fetcher, |
125 scoped_ptr<ManifestFetcher> fetcher, | 125 const FetchManifestCallback& callback, |
126 const FetchManifestCallback& callback, | 126 const blink::WebURLResponse& response, |
127 const blink::WebURLResponse& response, | 127 const std::string& data) { |
128 const std::string& data) { | |
129 // |fetcher| will be autodeleted here as it is going out of scope. | 128 // |fetcher| will be autodeleted here as it is going out of scope. |
130 callback.Run(response, data); | 129 callback.Run(response, data); |
131 } | 130 } |
132 | 131 |
133 void FetchManifest(blink::WebView* view, const GURL& url, | 132 void FetchManifest(blink::WebView* view, const GURL& url, |
134 const FetchManifestCallback& callback) { | 133 const FetchManifestCallback& callback) { |
135 ManifestFetcher* fetcher = new ManifestFetcher(url); | 134 ManifestFetcher* fetcher = new ManifestFetcher(url); |
136 scoped_ptr<ManifestFetcher> autodeleter(fetcher); | 135 std::unique_ptr<ManifestFetcher> autodeleter(fetcher); |
137 | 136 |
138 // Start is called on fetcher which is also bound to the callback. | 137 // Start is called on fetcher which is also bound to the callback. |
139 // A raw pointer is used instead of a scoped_ptr as base::Passes passes | 138 // A raw pointer is used instead of a scoped_ptr as base::Passes passes |
140 // ownership and thus nulls the scoped_ptr. On MSVS this happens before | 139 // ownership and thus nulls the scoped_ptr. On MSVS this happens before |
141 // the call to Start, resulting in a crash. | 140 // the call to Start, resulting in a crash. |
142 fetcher->Start(view->mainFrame(), | 141 fetcher->Start(view->mainFrame(), |
143 false, | 142 false, |
144 base::Bind(&FetchManifestDoneCallback, | 143 base::Bind(&FetchManifestDoneCallback, |
145 base::Passed(&autodeleter), | 144 base::Passed(&autodeleter), |
146 callback)); | 145 callback)); |
147 } | 146 } |
148 | 147 |
149 void SetMockGamepadProvider(scoped_ptr<RendererGamepadProvider> provider) { | 148 void SetMockGamepadProvider(std::unique_ptr<RendererGamepadProvider> provider) { |
150 RenderThreadImpl::current() | 149 RenderThreadImpl::current() |
151 ->blink_platform_impl() | 150 ->blink_platform_impl() |
152 ->SetPlatformEventObserverForTesting(blink::WebPlatformEventTypeGamepad, | 151 ->SetPlatformEventObserverForTesting(blink::WebPlatformEventTypeGamepad, |
153 std::move(provider)); | 152 std::move(provider)); |
154 } | 153 } |
155 | 154 |
156 void SetMockDeviceLightData(const double data) { | 155 void SetMockDeviceLightData(const double data) { |
157 RendererBlinkPlatformImpl::SetMockDeviceLightDataForTesting(data); | 156 RendererBlinkPlatformImpl::SetMockDeviceLightDataForTesting(data); |
158 } | 157 } |
159 | 158 |
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
436 } | 435 } |
437 | 436 |
438 return result; | 437 return result; |
439 } | 438 } |
440 | 439 |
441 std::string DumpBackForwardList(std::vector<PageState>& page_state, | 440 std::string DumpBackForwardList(std::vector<PageState>& page_state, |
442 size_t current_index) { | 441 size_t current_index) { |
443 std::string result; | 442 std::string result; |
444 result.append("\n============== Back Forward List ==============\n"); | 443 result.append("\n============== Back Forward List ==============\n"); |
445 for (size_t index = 0; index < page_state.size(); ++index) { | 444 for (size_t index = 0; index < page_state.size(); ++index) { |
446 scoped_ptr<HistoryEntry> entry( | 445 std::unique_ptr<HistoryEntry> entry( |
447 PageStateToHistoryEntry(page_state[index])); | 446 PageStateToHistoryEntry(page_state[index])); |
448 result.append( | 447 result.append( |
449 DumpHistoryItem(entry->root_history_node(), | 448 DumpHistoryItem(entry->root_history_node(), |
450 8, | 449 8, |
451 index == current_index)); | 450 index == current_index)); |
452 } | 451 } |
453 result.append("===============================================\n"); | 452 result.append("===============================================\n"); |
454 return result; | 453 return result; |
455 } | 454 } |
456 | 455 |
457 } // namespace content | 456 } // namespace content |
OLD | NEW |