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 loadURLExternally(blink::WebFrame* frame, const blink::WebURLRequest& request, blink::WebNavigationPolicy policy, const blink::WebString& suggested_name)
54 m_baseProxy->loadURLExternally(frame, request, policy, suggested_name);
55 Base::loadURLExternally(frame, request, policy, suggested_name);
57 virtual void didStartProvisionalLoad(blink::WebFrame* frame)
60 m_baseProxy->didStartProvisionalLoad(frame);
61 Base::didStartProvisionalLoad(frame);
63 virtual void didReceiveServerRedirectForProvisionalLoad(blink::WebFrame* frame)
65 m_baseProxy->didReceiveServerRedirectForProvisionalLoad(frame);
66 Base::didReceiveServerRedirectForProvisionalLoad(frame);
68 virtual void didFailProvisionalLoad(blink::WebFrame* frame, const blink::WebURLError& error)
70 Base::didFailProvisionalLoad(frame, error);
72 virtual void didCommitProvisionalLoad(blink::WebFrame* frame, bool isNewNavigation)
74 Base::didCommitProvisionalLoad(frame, isNewNavigation);
76 virtual void didReceiveTitle(blink::WebFrame* frame, const blink::WebString& title, blink::WebTextDirection direction)
78 Base::didReceiveTitle(frame, title, direction);
80 virtual void didChangeIcon(blink::WebFrame* frame, blink::WebIconURL::Type iconType)
82 Base::didChangeIcon(frame, iconType);
84 virtual void didFinishDocumentLoad(blink::WebFrame* frame)
86 Base::didFinishDocumentLoad(frame);
88 virtual void didHandleOnloadEvents(blink::WebFrame* frame)
90 Base::didHandleOnloadEvents(frame);
92 virtual void didFailLoad(blink::WebFrame* frame, const blink::WebURLError& error)
94 Base::didFailLoad(frame, error);
96 virtual void didFinishLoad(blink::WebFrame* frame)
98 Base::didFinishLoad(frame);
100 virtual void didChangeSelection(bool is_selection_empty) {
101 m_baseProxy->didChangeSelection(is_selection_empty);
102 Base::didChangeSelection(is_selection_empty);
104 virtual void showContextMenu(const blink::WebContextMenuData& contextMenuData) {
105 m_baseProxy->showContextMenu(Base::GetWebFrame(), contextMenuData);
106 Base::showContextMenu(contextMenuData);
108 virtual void didDetectXSS(blink::WebFrame* frame, const blink::WebURL& insecureURL, bool didBlockEntirePage)
110 // This is not implemented in RenderFrameImpl, so need to explicitly call
111 // into the base proxy.
112 m_baseProxy->didDetectXSS(frame, insecureURL, didBlockEntirePage);
113 Base::didDetectXSS(frame, insecureURL, didBlockEntirePage);
115 virtual void didDispatchPingLoader(blink::WebFrame* frame, const blink::WebURL& url)
117 // This is not implemented in RenderFrameImpl, so need to explicitly call
118 // into the base proxy.
119 m_baseProxy->didDispatchPingLoader(frame, url);
120 Base::didDispatchPingLoader(frame, url);
122 virtual void willRequestResource(blink::WebFrame* frame, const blink::WebCachedURLRequest& request)
124 // This is not implemented in RenderFrameImpl, so need to explicitly call
125 // into the base proxy.
126 m_baseProxy->willRequestResource(frame, request);
127 Base::willRequestResource(frame, request);
129 virtual void didCreateDataSource(blink::WebFrame* frame, blink::WebDataSource* ds)
131 Base::didCreateDataSource(frame, ds);
133 virtual void willSendRequest(blink::WebFrame* frame, unsigned identifier, blink::WebURLRequest& request, const blink::WebURLResponse& redirectResponse)
135 m_baseProxy->willSendRequest(frame, identifier, request, redirectResponse);
136 Base::willSendRequest(frame, identifier, request, redirectResponse);
138 virtual void didReceiveResponse(blink::WebFrame* frame, unsigned identifier, const blink::WebURLResponse& response)
140 m_baseProxy->didReceiveResponse(frame, identifier, response);
141 Base::didReceiveResponse(frame, identifier, response);
143 virtual void didChangeResourcePriority(blink::WebFrame* frame, unsigned identifier, const blink::WebURLRequest::Priority& priority)
145 // This is not implemented in RenderFrameImpl, so need to explicitly call
146 // into the base proxy.
147 m_baseProxy->didChangeResourcePriority(frame, identifier, priority);
148 Base::didChangeResourcePriority(frame, identifier, priority);
150 virtual void didFinishResourceLoad(blink::WebFrame* frame, unsigned identifier)
152 Base::didFinishResourceLoad(frame, identifier);
154 virtual blink::WebNavigationPolicy decidePolicyForNavigation(blink::WebFrame* frame, blink::WebDataSource::ExtraData* extraData, const blink::WebURLRequest& request, blink::WebNavigationType type, blink::WebNavigationPolicy defaultPolicy, bool isRedirect)
156 blink::WebNavigationPolicy policy = m_baseProxy->decidePolicyForNavigation(frame, extraData, request, type, defaultPolicy, isRedirect);
157 if (policy == blink::WebNavigationPolicyIgnore)
160 return Base::decidePolicyForNavigation(frame, extraData, request, type, defaultPolicy, isRedirect);
162 virtual bool willCheckAndDispatchMessageEvent(blink::WebFrame* sourceFrame, blink::WebFrame* targetFrame, blink::WebSecurityOrigin target, blink::WebDOMMessageEvent event)
164 if (m_baseProxy->willCheckAndDispatchMessageEvent(sourceFrame, targetFrame, target, event))
166 return Base::willCheckAndDispatchMessageEvent(sourceFrame, targetFrame, target, event);
168 virtual void didStopLoading()
170 m_baseProxy->didStopLoading();
171 Base::didStopLoading();
175 WebTestProxyBase* m_baseProxy;
177 // This is used to incrementally change code between Blink and Chromium.
178 // It is used instead of a #define and is set by layouttest_support when
179 // creating this object.
182 DISALLOW_COPY_AND_ASSIGN(WebFrameTestProxy);
187 #endif // WebTestProxy_h