OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 #ifndef CONTENT_SHELL_RENDERER_TEST_RUNNER_WEB_FRAME_TEST_PROXY_H_ | 5 #ifndef CONTENT_SHELL_RENDERER_TEST_RUNNER_WEB_FRAME_TEST_PROXY_H_ |
6 #define CONTENT_SHELL_RENDERER_TEST_RUNNER_WEB_FRAME_TEST_PROXY_H_ | 6 #define CONTENT_SHELL_RENDERER_TEST_RUNNER_WEB_FRAME_TEST_PROXY_H_ |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "content/shell/renderer/test_runner/TestInterfaces.h" | 9 #include "content/shell/renderer/test_runner/TestInterfaces.h" |
10 #include "content/shell/renderer/test_runner/WebTestDelegate.h" | 10 #include "content/shell/renderer/test_runner/WebTestDelegate.h" |
(...skipping 13 matching lines...) Expand all Loading... |
24 WebFrameTestProxy(P p, R r) : Base(p, r), base_proxy_(NULL) {} | 24 WebFrameTestProxy(P p, R r) : Base(p, r), base_proxy_(NULL) {} |
25 | 25 |
26 virtual ~WebFrameTestProxy() {} | 26 virtual ~WebFrameTestProxy() {} |
27 | 27 |
28 void set_base_proxy(WebTestProxyBase* proxy) { base_proxy_ = proxy; } | 28 void set_base_proxy(WebTestProxyBase* proxy) { base_proxy_ = proxy; } |
29 | 29 |
30 // WebFrameClient implementation. | 30 // WebFrameClient implementation. |
31 virtual blink::WebPlugin* createPlugin(blink::WebLocalFrame* frame, | 31 virtual blink::WebPlugin* createPlugin(blink::WebLocalFrame* frame, |
32 const blink::WebPluginParams& params) { | 32 const blink::WebPluginParams& params) { |
33 blink::WebPlugin* plugin = base_proxy_->CreatePlugin(frame, params); | 33 blink::WebPlugin* plugin = base_proxy_->CreatePlugin(frame, params); |
34 if (plugin) return plugin; | 34 if (plugin) |
| 35 return plugin; |
35 return Base::createPlugin(frame, params); | 36 return Base::createPlugin(frame, params); |
36 } | 37 } |
37 | 38 |
38 virtual blink::WebScreenOrientationClient* webScreenOrientationClient() { | 39 virtual blink::WebScreenOrientationClient* webScreenOrientationClient() { |
39 return base_proxy_->GetScreenOrientationClientMock(); | 40 return base_proxy_->GetScreenOrientationClientMock(); |
40 } | 41 } |
41 | 42 |
42 virtual void didAddMessageToConsole(const blink::WebConsoleMessage& message, | 43 virtual void didAddMessageToConsole(const blink::WebConsoleMessage& message, |
43 const blink::WebString& sourceName, | 44 const blink::WebString& source_name, |
44 unsigned sourceLine, | 45 unsigned source_line, |
45 const blink::WebString& stackTrace) { | 46 const blink::WebString& stack_trace) { |
46 base_proxy_->DidAddMessageToConsole(message, sourceName, sourceLine); | 47 base_proxy_->DidAddMessageToConsole(message, source_name, source_line); |
47 Base::didAddMessageToConsole(message, sourceName, sourceLine, stackTrace); | 48 Base::didAddMessageToConsole( |
| 49 message, source_name, source_line, stack_trace); |
48 } | 50 } |
49 | 51 |
50 virtual bool canCreatePluginWithoutRenderer( | 52 virtual bool canCreatePluginWithoutRenderer( |
51 const blink::WebString& mimeType) { | 53 const blink::WebString& mime_type) { |
52 using blink::WebString; | 54 using blink::WebString; |
53 | 55 |
54 const CR_DEFINE_STATIC_LOCAL(WebString, suffix, | 56 const CR_DEFINE_STATIC_LOCAL( |
55 ("-can-create-without-renderer")); | 57 WebString, suffix, ("-can-create-without-renderer")); |
56 return mimeType.utf8().find(suffix.utf8()) != std::string::npos; | 58 return mime_type.utf8().find(suffix.utf8()) != std::string::npos; |
57 } | 59 } |
58 | 60 |
59 virtual void loadURLExternally(blink::WebLocalFrame* frame, | 61 virtual void loadURLExternally(blink::WebLocalFrame* frame, |
60 const blink::WebURLRequest& request, | 62 const blink::WebURLRequest& request, |
61 blink::WebNavigationPolicy policy, | 63 blink::WebNavigationPolicy policy, |
62 const blink::WebString& suggested_name) { | 64 const blink::WebString& suggested_name) { |
63 base_proxy_->LoadURLExternally(frame, request, policy, suggested_name); | 65 base_proxy_->LoadURLExternally(frame, request, policy, suggested_name); |
64 Base::loadURLExternally(frame, request, policy, suggested_name); | 66 Base::loadURLExternally(frame, request, policy, suggested_name); |
65 } | 67 } |
66 | 68 |
67 virtual void didStartProvisionalLoad(blink::WebLocalFrame* frame) { | 69 virtual void didStartProvisionalLoad(blink::WebLocalFrame* frame) { |
68 base_proxy_->DidStartProvisionalLoad(frame); | 70 base_proxy_->DidStartProvisionalLoad(frame); |
69 Base::didStartProvisionalLoad(frame); | 71 Base::didStartProvisionalLoad(frame); |
70 } | 72 } |
71 | 73 |
72 virtual void didReceiveServerRedirectForProvisionalLoad( | 74 virtual void didReceiveServerRedirectForProvisionalLoad( |
73 blink::WebLocalFrame* frame) { | 75 blink::WebLocalFrame* frame) { |
74 base_proxy_->DidReceiveServerRedirectForProvisionalLoad(frame); | 76 base_proxy_->DidReceiveServerRedirectForProvisionalLoad(frame); |
75 Base::didReceiveServerRedirectForProvisionalLoad(frame); | 77 Base::didReceiveServerRedirectForProvisionalLoad(frame); |
76 } | 78 } |
77 | 79 |
78 virtual void didFailProvisionalLoad(blink::WebLocalFrame* frame, | 80 virtual void didFailProvisionalLoad(blink::WebLocalFrame* frame, |
79 const blink::WebURLError& error) { | 81 const blink::WebURLError& error) { |
80 // If the test finished, don't notify the embedder of the failed load, | 82 // If the test finished, don't notify the embedder of the failed load, |
81 // as we already destroyed the document loader. | 83 // as we already destroyed the document loader. |
82 if (base_proxy_->DidFailProvisionalLoad(frame, error)) return; | 84 if (base_proxy_->DidFailProvisionalLoad(frame, error)) |
| 85 return; |
83 Base::didFailProvisionalLoad(frame, error); | 86 Base::didFailProvisionalLoad(frame, error); |
84 } | 87 } |
85 | 88 |
86 virtual void didCommitProvisionalLoad( | 89 virtual void didCommitProvisionalLoad( |
87 blink::WebLocalFrame* frame, const blink::WebHistoryItem& item, | 90 blink::WebLocalFrame* frame, |
| 91 const blink::WebHistoryItem& item, |
88 blink::WebHistoryCommitType commit_type) { | 92 blink::WebHistoryCommitType commit_type) { |
89 base_proxy_->DidCommitProvisionalLoad(frame, item, commit_type); | 93 base_proxy_->DidCommitProvisionalLoad(frame, item, commit_type); |
90 Base::didCommitProvisionalLoad(frame, item, commit_type); | 94 Base::didCommitProvisionalLoad(frame, item, commit_type); |
91 } | 95 } |
92 | 96 |
93 virtual void didReceiveTitle(blink::WebLocalFrame* frame, | 97 virtual void didReceiveTitle(blink::WebLocalFrame* frame, |
94 const blink::WebString& title, | 98 const blink::WebString& title, |
95 blink::WebTextDirection direction) { | 99 blink::WebTextDirection direction) { |
96 base_proxy_->DidReceiveTitle(frame, title, direction); | 100 base_proxy_->DidReceiveTitle(frame, title, direction); |
97 Base::didReceiveTitle(frame, title, direction); | 101 Base::didReceiveTitle(frame, title, direction); |
98 } | 102 } |
99 | 103 |
100 virtual void didChangeIcon(blink::WebLocalFrame* frame, | 104 virtual void didChangeIcon(blink::WebLocalFrame* frame, |
101 blink::WebIconURL::Type iconType) { | 105 blink::WebIconURL::Type icon_type) { |
102 base_proxy_->DidChangeIcon(frame, iconType); | 106 base_proxy_->DidChangeIcon(frame, icon_type); |
103 Base::didChangeIcon(frame, iconType); | 107 Base::didChangeIcon(frame, icon_type); |
104 } | 108 } |
105 | 109 |
106 virtual void didFinishDocumentLoad(blink::WebLocalFrame* frame) { | 110 virtual void didFinishDocumentLoad(blink::WebLocalFrame* frame) { |
107 base_proxy_->DidFinishDocumentLoad(frame); | 111 base_proxy_->DidFinishDocumentLoad(frame); |
108 Base::didFinishDocumentLoad(frame); | 112 Base::didFinishDocumentLoad(frame); |
109 } | 113 } |
110 | 114 |
111 virtual void didHandleOnloadEvents(blink::WebLocalFrame* frame) { | 115 virtual void didHandleOnloadEvents(blink::WebLocalFrame* frame) { |
112 base_proxy_->DidHandleOnloadEvents(frame); | 116 base_proxy_->DidHandleOnloadEvents(frame); |
113 Base::didHandleOnloadEvents(frame); | 117 Base::didHandleOnloadEvents(frame); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
145 message.utf8().data() + "\n"); | 149 message.utf8().data() + "\n"); |
146 } | 150 } |
147 | 151 |
148 virtual bool runModalConfirmDialog(const blink::WebString& message) { | 152 virtual bool runModalConfirmDialog(const blink::WebString& message) { |
149 base_proxy_->delegate_->printMessage(std::string("CONFIRM: ") + | 153 base_proxy_->delegate_->printMessage(std::string("CONFIRM: ") + |
150 message.utf8().data() + "\n"); | 154 message.utf8().data() + "\n"); |
151 return true; | 155 return true; |
152 } | 156 } |
153 | 157 |
154 virtual bool runModalPromptDialog(const blink::WebString& message, | 158 virtual bool runModalPromptDialog(const blink::WebString& message, |
155 const blink::WebString& defaultValue, | 159 const blink::WebString& default_value, |
156 blink::WebString*) { | 160 blink::WebString*) { |
157 base_proxy_->delegate_->printMessage( | 161 base_proxy_->delegate_->printMessage( |
158 std::string("PROMPT: ") + message.utf8().data() + ", default text: " + | 162 std::string("PROMPT: ") + message.utf8().data() + ", default text: " + |
159 defaultValue.utf8().data() + "\n"); | 163 default_value.utf8().data() + "\n"); |
160 return true; | 164 return true; |
161 } | 165 } |
162 | 166 |
163 virtual bool runModalBeforeUnloadDialog(bool is_reload, | 167 virtual bool runModalBeforeUnloadDialog(bool is_reload, |
164 const blink::WebString& message) { | 168 const blink::WebString& message) { |
165 base_proxy_->delegate_->printMessage(std::string("CONFIRM NAVIGATION: ") + | 169 base_proxy_->delegate_->printMessage(std::string("CONFIRM NAVIGATION: ") + |
166 message.utf8().data() + "\n"); | 170 message.utf8().data() + "\n"); |
167 return !base_proxy_->test_interfaces_->testRunner() | 171 return !base_proxy_->test_interfaces_->testRunner() |
168 ->shouldStayOnPageAfterHandlingBeforeUnload(); | 172 ->shouldStayOnPageAfterHandlingBeforeUnload(); |
169 } | 173 } |
170 | 174 |
171 virtual void showContextMenu( | 175 virtual void showContextMenu( |
172 const blink::WebContextMenuData& contextMenuData) { | 176 const blink::WebContextMenuData& context_menu_data) { |
173 base_proxy_->ShowContextMenu(Base::GetWebFrame()->toWebLocalFrame(), | 177 base_proxy_->ShowContextMenu(Base::GetWebFrame()->toWebLocalFrame(), |
174 contextMenuData); | 178 context_menu_data); |
175 Base::showContextMenu(contextMenuData); | 179 Base::showContextMenu(context_menu_data); |
176 } | 180 } |
177 | 181 |
178 virtual void didDetectXSS(blink::WebLocalFrame* frame, | 182 virtual void didDetectXSS(blink::WebLocalFrame* frame, |
179 const blink::WebURL& insecureURL, | 183 const blink::WebURL& insecure_url, |
180 bool didBlockEntirePage) { | 184 bool did_block_entire_page) { |
181 // This is not implemented in RenderFrameImpl, so need to explicitly call | 185 // This is not implemented in RenderFrameImpl, so need to explicitly call |
182 // into the base proxy. | 186 // into the base proxy. |
183 base_proxy_->DidDetectXSS(frame, insecureURL, didBlockEntirePage); | 187 base_proxy_->DidDetectXSS(frame, insecure_url, did_block_entire_page); |
184 Base::didDetectXSS(frame, insecureURL, didBlockEntirePage); | 188 Base::didDetectXSS(frame, insecure_url, did_block_entire_page); |
185 } | 189 } |
186 | 190 |
187 virtual void didDispatchPingLoader(blink::WebLocalFrame* frame, | 191 virtual void didDispatchPingLoader(blink::WebLocalFrame* frame, |
188 const blink::WebURL& url) { | 192 const blink::WebURL& url) { |
189 // This is not implemented in RenderFrameImpl, so need to explicitly call | 193 // This is not implemented in RenderFrameImpl, so need to explicitly call |
190 // into the base proxy. | 194 // into the base proxy. |
191 base_proxy_->DidDispatchPingLoader(frame, url); | 195 base_proxy_->DidDispatchPingLoader(frame, url); |
192 Base::didDispatchPingLoader(frame, url); | 196 Base::didDispatchPingLoader(frame, url); |
193 } | 197 } |
194 | 198 |
195 virtual void willRequestResource(blink::WebLocalFrame* frame, | 199 virtual void willRequestResource(blink::WebLocalFrame* frame, |
196 const blink::WebCachedURLRequest& request) { | 200 const blink::WebCachedURLRequest& request) { |
197 // This is not implemented in RenderFrameImpl, so need to explicitly call | 201 // This is not implemented in RenderFrameImpl, so need to explicitly call |
198 // into the base proxy. | 202 // into the base proxy. |
199 base_proxy_->WillRequestResource(frame, request); | 203 base_proxy_->WillRequestResource(frame, request); |
200 Base::willRequestResource(frame, request); | 204 Base::willRequestResource(frame, request); |
201 } | 205 } |
202 | 206 |
203 virtual void didCreateDataSource(blink::WebLocalFrame* frame, | 207 virtual void didCreateDataSource(blink::WebLocalFrame* frame, |
204 blink::WebDataSource* ds) { | 208 blink::WebDataSource* ds) { |
205 Base::didCreateDataSource(frame, ds); | 209 Base::didCreateDataSource(frame, ds); |
206 } | 210 } |
207 | 211 |
208 virtual void willSendRequest(blink::WebLocalFrame* frame, unsigned identifier, | 212 virtual void willSendRequest(blink::WebLocalFrame* frame, |
| 213 unsigned identifier, |
209 blink::WebURLRequest& request, | 214 blink::WebURLRequest& request, |
210 const blink::WebURLResponse& redirectResponse) { | 215 const blink::WebURLResponse& redirect_response) { |
211 Base::willSendRequest(frame, identifier, request, redirectResponse); | 216 Base::willSendRequest(frame, identifier, request, redirect_response); |
212 base_proxy_->WillSendRequest(frame, identifier, request, redirectResponse); | 217 base_proxy_->WillSendRequest(frame, identifier, request, redirect_response); |
213 } | 218 } |
214 | 219 |
215 virtual void didReceiveResponse(blink::WebLocalFrame* frame, | 220 virtual void didReceiveResponse(blink::WebLocalFrame* frame, |
216 unsigned identifier, | 221 unsigned identifier, |
217 const blink::WebURLResponse& response) { | 222 const blink::WebURLResponse& response) { |
218 base_proxy_->DidReceiveResponse(frame, identifier, response); | 223 base_proxy_->DidReceiveResponse(frame, identifier, response); |
219 Base::didReceiveResponse(frame, identifier, response); | 224 Base::didReceiveResponse(frame, identifier, response); |
220 } | 225 } |
221 | 226 |
222 virtual void didChangeResourcePriority( | 227 virtual void didChangeResourcePriority( |
223 blink::WebLocalFrame* frame, unsigned identifier, | 228 blink::WebLocalFrame* frame, |
| 229 unsigned identifier, |
224 const blink::WebURLRequest::Priority& priority, | 230 const blink::WebURLRequest::Priority& priority, |
225 int intra_priority_value) { | 231 int intra_priority_value) { |
226 // This is not implemented in RenderFrameImpl, so need to explicitly call | 232 // This is not implemented in RenderFrameImpl, so need to explicitly call |
227 // into the base proxy. | 233 // into the base proxy. |
228 base_proxy_->DidChangeResourcePriority(frame, identifier, priority, | 234 base_proxy_->DidChangeResourcePriority( |
229 intra_priority_value); | 235 frame, identifier, priority, intra_priority_value); |
230 Base::didChangeResourcePriority(frame, identifier, priority, | 236 Base::didChangeResourcePriority( |
231 intra_priority_value); | 237 frame, identifier, priority, intra_priority_value); |
232 } | 238 } |
233 | 239 |
234 virtual void didFinishResourceLoad(blink::WebLocalFrame* frame, | 240 virtual void didFinishResourceLoad(blink::WebLocalFrame* frame, |
235 unsigned identifier) { | 241 unsigned identifier) { |
236 base_proxy_->DidFinishResourceLoad(frame, identifier); | 242 base_proxy_->DidFinishResourceLoad(frame, identifier); |
237 Base::didFinishResourceLoad(frame, identifier); | 243 Base::didFinishResourceLoad(frame, identifier); |
238 } | 244 } |
239 | 245 |
240 virtual blink::WebNavigationPolicy decidePolicyForNavigation( | 246 virtual blink::WebNavigationPolicy decidePolicyForNavigation( |
241 blink::WebLocalFrame* frame, blink::WebDataSource::ExtraData* extraData, | 247 blink::WebLocalFrame* frame, |
242 const blink::WebURLRequest& request, blink::WebNavigationType type, | 248 blink::WebDataSource::ExtraData* extra_data, |
243 blink::WebNavigationPolicy defaultPolicy, bool isRedirect) { | 249 const blink::WebURLRequest& request, |
| 250 blink::WebNavigationType type, |
| 251 blink::WebNavigationPolicy default_policy, |
| 252 bool is_redirect) { |
244 blink::WebNavigationPolicy policy = base_proxy_->DecidePolicyForNavigation( | 253 blink::WebNavigationPolicy policy = base_proxy_->DecidePolicyForNavigation( |
245 frame, extraData, request, type, defaultPolicy, isRedirect); | 254 frame, extra_data, request, type, default_policy, is_redirect); |
246 if (policy == blink::WebNavigationPolicyIgnore) return policy; | 255 if (policy == blink::WebNavigationPolicyIgnore) |
| 256 return policy; |
247 | 257 |
248 return Base::decidePolicyForNavigation(frame, extraData, request, type, | 258 return Base::decidePolicyForNavigation( |
249 defaultPolicy, isRedirect); | 259 frame, extra_data, request, type, default_policy, is_redirect); |
250 } | 260 } |
251 | 261 |
252 virtual void willStartUsingPeerConnectionHandler( | 262 virtual void willStartUsingPeerConnectionHandler( |
253 blink::WebLocalFrame* frame, | 263 blink::WebLocalFrame* frame, |
254 blink::WebRTCPeerConnectionHandler* handler) { | 264 blink::WebRTCPeerConnectionHandler* handler) { |
255 // RenderFrameImpl::willStartUsingPeerConnectionHandler can not be mocked. | 265 // RenderFrameImpl::willStartUsingPeerConnectionHandler can not be mocked. |
256 // See http://crbug/363285. | 266 // See http://crbug/363285. |
257 } | 267 } |
258 | 268 |
259 virtual blink::WebUserMediaClient* userMediaClient() { | 269 virtual blink::WebUserMediaClient* userMediaClient() { |
260 return base_proxy_->GetUserMediaClient(); | 270 return base_proxy_->GetUserMediaClient(); |
261 } | 271 } |
262 | 272 |
263 | |
264 virtual blink::WebMIDIClient* webMIDIClient() { | 273 virtual blink::WebMIDIClient* webMIDIClient() { |
265 return base_proxy_->GetWebMIDIClient(); | 274 return base_proxy_->GetWebMIDIClient(); |
266 } | 275 } |
267 | 276 |
268 virtual bool willCheckAndDispatchMessageEvent( | 277 virtual bool willCheckAndDispatchMessageEvent( |
269 blink::WebLocalFrame* sourceFrame, blink::WebFrame* targetFrame, | 278 blink::WebLocalFrame* source_frame, |
270 blink::WebSecurityOrigin target, blink::WebDOMMessageEvent event) { | 279 blink::WebFrame* target_frame, |
271 if (base_proxy_->WillCheckAndDispatchMessageEvent(sourceFrame, targetFrame, | 280 blink::WebSecurityOrigin target, |
272 target, event)) | 281 blink::WebDOMMessageEvent event) { |
| 282 if (base_proxy_->WillCheckAndDispatchMessageEvent( |
| 283 source_frame, target_frame, target, event)) |
273 return true; | 284 return true; |
274 return Base::willCheckAndDispatchMessageEvent(sourceFrame, targetFrame, | 285 return Base::willCheckAndDispatchMessageEvent( |
275 target, event); | 286 source_frame, target_frame, target, event); |
276 } | 287 } |
277 | 288 |
278 virtual void didStopLoading() { | 289 virtual void didStopLoading() { |
279 base_proxy_->DidStopLoading(); | 290 base_proxy_->DidStopLoading(); |
280 Base::didStopLoading(); | 291 Base::didStopLoading(); |
281 } | 292 } |
282 | 293 |
283 private: | 294 private: |
284 #if defined(ENABLE_WEBRTC) | 295 #if defined(ENABLE_WEBRTC) |
285 virtual scoped_ptr<MediaStreamRendererFactory> | 296 virtual scoped_ptr<MediaStreamRendererFactory> CreateRendererFactory() |
286 CreateRendererFactory() OVERRIDE { | 297 OVERRIDE { |
287 return scoped_ptr<MediaStreamRendererFactory>( | 298 return scoped_ptr<MediaStreamRendererFactory>( |
288 new TestMediaStreamRendererFactory()); | 299 new TestMediaStreamRendererFactory()); |
289 } | 300 } |
290 #endif | 301 #endif |
291 | 302 |
292 WebTestProxyBase* base_proxy_; | 303 WebTestProxyBase* base_proxy_; |
293 | 304 |
294 DISALLOW_COPY_AND_ASSIGN(WebFrameTestProxy); | 305 DISALLOW_COPY_AND_ASSIGN(WebFrameTestProxy); |
295 }; | 306 }; |
296 | 307 |
297 } // namespace content | 308 } // namespace content |
298 | 309 |
299 #endif // CONTENT_SHELL_RENDERER_TEST_RUNNER_WEB_FRAME_TEST_PROXY_H_ | 310 #endif // CONTENT_SHELL_RENDERER_TEST_RUNNER_WEB_FRAME_TEST_PROXY_H_ |
OLD | NEW |