1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef CONTENT_SHELL_RENDERER_TEST_RUNNER_WEBFRAMETESTPROXY_H_
6 #define CONTENT_SHELL_RENDERER_TEST_RUNNER_WEBFRAMETESTPROXY_H_
8 #include "base/basictypes.h"
9 #include "content/shell/renderer/test_runner/WebTestProxy.h"
10 #include "third_party/WebKit/public/platform/WebString.h"
12 namespace WebTestRunner {
14 // Templetized wrapper around RenderFrameImpl objects, which implement
15 // the WebFrameClient interface.
16 template<class Base, typename P, typename R>
17 class WebFrameTestProxy : public Base {
19 WebFrameTestProxy(P p, R r)
24 virtual ~WebFrameTestProxy() { }
26 void setBaseProxy(WebTestProxyBase* proxy)
31 void setVersion(int version)
36 blink::WebPlugin* createPlugin(blink::WebFrame* frame, const blink::WebPluginParams& params)
38 blink::WebPlugin* plugin = m_baseProxy->createPlugin(frame, params);
41 return Base::createPlugin(frame, params);
44 // WebFrameClient implementation.
45 virtual bool canCreatePluginWithoutRenderer(const blink::WebString& mimeType)
47 using blink::WebString;
49 const CR_DEFINE_STATIC_LOCAL(WebString, suffix, ("-can-create-without-renderer"));
50 return mimeType.utf8().find(suffix.utf8()) != std::string::npos;
52 virtual void didStartProvisionalLoad(blink::WebFrame* frame)
55 m_baseProxy->didStartProvisionalLoad(frame);
56 Base::didStartProvisionalLoad(frame);
58 virtual void didReceiveServerRedirectForProvisionalLoad(blink::WebFrame* frame)
60 m_baseProxy->didReceiveServerRedirectForProvisionalLoad(frame);
61 Base::didReceiveServerRedirectForProvisionalLoad(frame);
63 virtual void didFailProvisionalLoad(blink::WebFrame* frame, const blink::WebURLError& error)
65 Base::didFailProvisionalLoad(frame, error);
67 virtual void didCommitProvisionalLoad(blink::WebFrame* frame, bool isNewNavigation)
69 Base::didCommitProvisionalLoad(frame, isNewNavigation);
71 virtual void didReceiveTitle(blink::WebFrame* frame, const blink::WebString& title, blink::WebTextDirection direction)
73 Base::didReceiveTitle(frame, title, direction);
75 virtual void didChangeIcon(blink::WebFrame* frame, blink::WebIconURL::Type iconType)
77 Base::didChangeIcon(frame, iconType);
79 virtual void didFinishDocumentLoad(blink::WebFrame* frame)
81 Base::didFinishDocumentLoad(frame);
83 virtual void didHandleOnloadEvents(blink::WebFrame* frame)
85 Base::didHandleOnloadEvents(frame);
87 virtual void didFailLoad(blink::WebFrame* frame, const blink::WebURLError& error)
89 Base::didFailLoad(frame, error);
91 virtual void didFinishLoad(blink::WebFrame* frame)
93 Base::didFinishLoad(frame);
95 virtual void didChangeSelection(bool is_selection_empty) {
96 m_baseProxy->didChangeSelection(is_selection_empty);
97 Base::didChangeSelection(is_selection_empty);
99 virtual void showContextMenu(const blink::WebContextMenuData& contextMenuData) {
100 m_baseProxy->showContextMenu(Base::GetWebFrame(), contextMenuData);
101 Base::showContextMenu(contextMenuData);
103 virtual void didDetectXSS(blink::WebFrame* frame, const blink::WebURL& insecureURL, bool didBlockEntirePage)
105 // This is not implemented in RenderFrameImpl, so need to explicitly call
106 // into the base proxy.
107 m_baseProxy->didDetectXSS(frame, insecureURL, didBlockEntirePage);
108 Base::didDetectXSS(frame, insecureURL, didBlockEntirePage);
110 virtual void didDispatchPingLoader(blink::WebFrame* frame, const blink::WebURL& url)
112 // This is not implemented in RenderFrameImpl, so need to explicitly call
113 // into the base proxy.
114 m_baseProxy->didDispatchPingLoader(frame, url);
115 Base::didDispatchPingLoader(frame, url);
117 virtual void willRequestResource(blink::WebFrame* frame, const blink::WebCachedURLRequest& request)
119 // This is not implemented in RenderFrameImpl, so need to explicitly call
120 // into the base proxy.
121 m_baseProxy->willRequestResource(frame, request);
122 Base::willRequestResource(frame, request);
124 virtual void didCreateDataSource(blink::WebFrame* frame, blink::WebDataSource* ds)
126 Base::didCreateDataSource(frame, ds);
128 virtual void willSendRequest(blink::WebFrame* frame, unsigned identifier, blink::WebURLRequest& request, const blink::WebURLResponse& redirectResponse)
130 m_baseProxy->willSendRequest(frame, identifier, request, redirectResponse);
131 Base::willSendRequest(frame, identifier, request, redirectResponse);
133 virtual void didReceiveResponse(blink::WebFrame* frame, unsigned identifier, const blink::WebURLResponse& response)
135 m_baseProxy->didReceiveResponse(frame, identifier, response);
136 Base::didReceiveResponse(frame, identifier, response);
138 virtual void didChangeResourcePriority(blink::WebFrame* frame, unsigned identifier, const blink::WebURLRequest::Priority& priority)
140 // This is not implemented in RenderFrameImpl, so need to explicitly call
141 // into the base proxy.
142 m_baseProxy->didChangeResourcePriority(frame, identifier, priority);
143 Base::didChangeResourcePriority(frame, identifier, priority);
145 virtual void didFinishResourceLoad(blink::WebFrame* frame, unsigned identifier)
147 Base::didFinishResourceLoad(frame, identifier);
149 virtual blink::WebNavigationPolicy decidePolicyForNavigation(blink::WebFrame* frame, blink::WebDataSource::ExtraData* extraData, const blink::WebURLRequest& request, blink::WebNavigationType type, blink::WebNavigationPolicy defaultPolicy, bool isRedirect)
151 blink::WebNavigationPolicy policy = m_baseProxy->decidePolicyForNavigation(frame, extraData, request, type, defaultPolicy, isRedirect);
152 if (policy == blink::WebNavigationPolicyIgnore)
155 return Base::decidePolicyForNavigation(frame, extraData, request, type, defaultPolicy, isRedirect);
157 virtual bool willCheckAndDispatchMessageEvent(blink::WebFrame* sourceFrame, blink::WebFrame* targetFrame, blink::WebSecurityOrigin target, blink::WebDOMMessageEvent event)
159 if (m_baseProxy->willCheckAndDispatchMessageEvent(sourceFrame, targetFrame, target, event))
161 return Base::willCheckAndDispatchMessageEvent(sourceFrame, targetFrame, target, event);
163 virtual void didStopLoading()
165 m_baseProxy->didStopLoading();
166 Base::didStopLoading();
170 WebTestProxyBase* m_baseProxy;
172 // This is used to incrementally change code between Blink and Chromium.
173 // It is used instead of a #define and is set by layouttest_support when
174 // creating this object.
177 DISALLOW_COPY_AND_ASSIGN(WebFrameTestProxy);
182 #endif // WebTestProxy_h