| OLD | NEW |
| (Empty) |
| 1 /* | |
| 2 * Copyright (C) 2012 Google Inc. All rights reserved. | |
| 3 * | |
| 4 * Redistribution and use in source and binary forms, with or without | |
| 5 * modification, are permitted provided that the following conditions are | |
| 6 * met: | |
| 7 * | |
| 8 * * Redistributions of source code must retain the above copyright | |
| 9 * notice, this list of conditions and the following disclaimer. | |
| 10 * * Redistributions in binary form must reproduce the above | |
| 11 * copyright notice, this list of conditions and the following disclaimer | |
| 12 * in the documentation and/or other materials provided with the | |
| 13 * distribution. | |
| 14 * * Neither the name of Google Inc. nor the names of its | |
| 15 * contributors may be used to endorse or promote products derived from | |
| 16 * this software without specific prior written permission. | |
| 17 * | |
| 18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | |
| 19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | |
| 20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | |
| 21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | |
| 22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |
| 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |
| 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | |
| 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | |
| 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
| 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | |
| 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
| 29 */ | |
| 30 | |
| 31 #ifndef WebViewHost_h | |
| 32 #define WebViewHost_h | |
| 33 | |
| 34 #include "TestNavigationController.h" | |
| 35 #include "WebCursorInfo.h" | |
| 36 #include "WebFrameClient.h" | |
| 37 #include "WebPrerendererClient.h" | |
| 38 #include "WebTask.h" | |
| 39 #include "WebTestDelegate.h" | |
| 40 #include "WebTestProxy.h" | |
| 41 #include "WebViewClient.h" | |
| 42 #include "public/platform/WebFileSystemType.h" | |
| 43 #include <wtf/HashMap.h> | |
| 44 #include <wtf/HashSet.h> | |
| 45 #include <wtf/Vector.h> | |
| 46 #include <wtf/text/WTFString.h> | |
| 47 | |
| 48 class SkCanvas; | |
| 49 class TestShell; | |
| 50 | |
| 51 namespace WebKit { | |
| 52 class WebFrame; | |
| 53 class WebSerializedScriptValue; | |
| 54 class WebSharedWorkerClient; | |
| 55 class WebURL; | |
| 56 struct WebRect; | |
| 57 struct WebURLError; | |
| 58 struct WebWindowFeatures; | |
| 59 } | |
| 60 | |
| 61 namespace webkit_support { | |
| 62 class DRTLayerTreeViewClient; | |
| 63 class MediaStreamUtil; | |
| 64 class TestMediaStreamClient; | |
| 65 } | |
| 66 | |
| 67 namespace WebTestRunner { | |
| 68 class WebTestRunner; | |
| 69 } | |
| 70 | |
| 71 class WebViewHost : public WebKit::WebViewClient, public WebKit::WebFrameClient,
public NavigationHost, public WebKit::WebPrerendererClient, public WebTestRunne
r::WebTestDelegate { | |
| 72 public: | |
| 73 WebViewHost(TestShell*); | |
| 74 virtual ~WebViewHost(); | |
| 75 void shutdown(); | |
| 76 void setWebWidget(WebKit::WebWidget*); | |
| 77 WebKit::WebView* webView() const; | |
| 78 WebKit::WebWidget* webWidget() const; | |
| 79 WebTestRunner::WebTestProxyBase* proxy() const; | |
| 80 void setProxy(WebTestRunner::WebTestProxyBase*); | |
| 81 void reset(); | |
| 82 void setPendingExtraData(PassOwnPtr<TestShellExtraData>); | |
| 83 | |
| 84 TestNavigationController* navigationController() { return m_navigationContro
ller.get(); } | |
| 85 | |
| 86 void closeWidget(); | |
| 87 | |
| 88 // WebTestDelegate. | |
| 89 virtual void setEditCommand(const std::string& name, const std::string& valu
e) OVERRIDE; | |
| 90 virtual void clearEditCommand() OVERRIDE; | |
| 91 virtual void setGamepadData(const WebKit::WebGamepads&) OVERRIDE; | |
| 92 virtual void printMessage(const std::string& message) OVERRIDE; | |
| 93 virtual void postTask(WebTestRunner::WebTask*) OVERRIDE; | |
| 94 virtual void postDelayedTask(WebTestRunner::WebTask*, long long ms) OVERRIDE
; | |
| 95 virtual WebKit::WebString registerIsolatedFileSystem(const WebKit::WebVector
<WebKit::WebString>& absoluteFilenames) OVERRIDE; | |
| 96 virtual long long getCurrentTimeInMillisecond() OVERRIDE; | |
| 97 virtual WebKit::WebString getAbsoluteWebStringFromUTF8Path(const std::string
& path) OVERRIDE; | |
| 98 virtual WebKit::WebURL localFileToDataURL(const WebKit::WebURL&) OVERRIDE; | |
| 99 virtual WebKit::WebURL rewriteLayoutTestsURL(const std::string&) OVERRIDE; | |
| 100 virtual WebTestRunner::WebPreferences* preferences() OVERRIDE; | |
| 101 virtual void applyPreferences() OVERRIDE; | |
| 102 virtual std::string makeURLErrorDescription(const WebKit::WebURLError&) OVER
RIDE; | |
| 103 virtual void setClientWindowRect(const WebKit::WebRect&) OVERRIDE; | |
| 104 virtual void enableAutoResizeMode(const WebKit::WebSize&, const WebKit::WebS
ize&) OVERRIDE; | |
| 105 virtual void disableAutoResizeMode(const WebKit::WebSize&) OVERRIDE; | |
| 106 virtual void showDevTools() OVERRIDE; | |
| 107 virtual void closeDevTools() OVERRIDE; | |
| 108 virtual void evaluateInWebInspector(long, const std::string&) OVERRIDE; | |
| 109 virtual void clearAllDatabases() OVERRIDE; | |
| 110 virtual void setDatabaseQuota(int) OVERRIDE; | |
| 111 virtual void setDeviceScaleFactor(float) OVERRIDE; | |
| 112 virtual void setFocus(WebTestRunner::WebTestProxyBase*, bool) OVERRIDE; | |
| 113 virtual void setAcceptAllCookies(bool) OVERRIDE; | |
| 114 virtual std::string pathToLocalResource(const std::string& url) OVERRIDE; | |
| 115 virtual void setLocale(const std::string&) OVERRIDE; | |
| 116 virtual void testFinished() OVERRIDE; | |
| 117 virtual void closeRemainingWindows() OVERRIDE; | |
| 118 virtual int navigationEntryCount() OVERRIDE; | |
| 119 virtual void goToOffset(int) OVERRIDE; | |
| 120 virtual void reload() OVERRIDE; | |
| 121 virtual void loadURLForFrame(const WebKit::WebURL&, const std::string& frame
Name) OVERRIDE; | |
| 122 virtual bool allowExternalPages() OVERRIDE; | |
| 123 virtual void captureHistoryForWindow(WebTestRunner::WebTestProxyBase*, WebKi
t::WebVector<WebKit::WebHistoryItem>*, size_t* currentEntryIndex) OVERRIDE; | |
| 124 virtual WebKit::WebMediaPlayer* createWebMediaPlayer(WebKit::WebFrame*, cons
t WebKit::WebURL&, WebKit::WebMediaPlayerClient*) OVERRIDE; | |
| 125 | |
| 126 // NavigationHost | |
| 127 virtual bool navigate(const TestNavigationEntry&, bool reload); | |
| 128 | |
| 129 // WebKit::WebPrerendererClient | |
| 130 virtual void willAddPrerender(WebKit::WebPrerender*) OVERRIDE; | |
| 131 | |
| 132 // WebKit::WebViewClient | |
| 133 virtual WebKit::WebView* createView(WebKit::WebFrame*, const WebKit::WebURLR
equest&, const WebKit::WebWindowFeatures&, const WebKit::WebString&, WebKit::Web
NavigationPolicy); | |
| 134 virtual WebKit::WebWidget* createPopupMenu(WebKit::WebPopupType); | |
| 135 virtual WebKit::WebWidget* createPopupMenu(const WebKit::WebPopupMenuInfo&); | |
| 136 virtual WebKit::WebStorageNamespace* createSessionStorageNamespace(unsigned
quota); | |
| 137 | |
| 138 virtual void didAddMessageToConsole(const WebKit::WebConsoleMessage&, const
WebKit::WebString& sourceName, unsigned sourceLine); | |
| 139 virtual void didStartLoading(); | |
| 140 virtual void didStopLoading(); | |
| 141 virtual bool shouldBeginEditing(const WebKit::WebRange&); | |
| 142 virtual bool shouldEndEditing(const WebKit::WebRange&); | |
| 143 virtual bool shouldInsertNode(const WebKit::WebNode&, const WebKit::WebRange
&, WebKit::WebEditingAction); | |
| 144 virtual bool shouldInsertText(const WebKit::WebString&, const WebKit::WebRan
ge&, WebKit::WebEditingAction); | |
| 145 virtual bool shouldChangeSelectedRange(const WebKit::WebRange& from, const W
ebKit::WebRange& to, WebKit::WebTextAffinity, bool stillSelecting); | |
| 146 virtual bool shouldDeleteRange(const WebKit::WebRange&); | |
| 147 virtual bool shouldApplyStyle(const WebKit::WebString& style, const WebKit::
WebRange&); | |
| 148 virtual bool handleCurrentKeyboardEvent(); | |
| 149 virtual void runModalAlertDialog(WebKit::WebFrame*, const WebKit::WebString&
); | |
| 150 virtual bool runModalConfirmDialog(WebKit::WebFrame*, const WebKit::WebStrin
g&); | |
| 151 virtual bool runModalPromptDialog(WebKit::WebFrame*, const WebKit::WebString
& message, const WebKit::WebString& defaultValue, WebKit::WebString* actualValue
); | |
| 152 virtual void showContextMenu(WebKit::WebFrame*, const WebKit::WebContextMenu
Data&); | |
| 153 virtual void didUpdateLayout(); | |
| 154 virtual void navigateBackForwardSoon(int offset); | |
| 155 virtual int historyBackListCount(); | |
| 156 virtual int historyForwardListCount(); | |
| 157 | |
| 158 // WebKit::WebWidgetClient | |
| 159 virtual void didAutoResize(const WebKit::WebSize& newSize); | |
| 160 virtual void initializeLayerTreeView(); | |
| 161 virtual WebKit::WebLayerTreeView* layerTreeView(); | |
| 162 virtual void scheduleAnimation(); | |
| 163 virtual void didFocus(); | |
| 164 virtual void didBlur(); | |
| 165 virtual void didChangeCursor(const WebKit::WebCursorInfo&); | |
| 166 virtual void closeWidgetSoon(); | |
| 167 virtual void show(WebKit::WebNavigationPolicy); | |
| 168 virtual void runModal(); | |
| 169 virtual bool enterFullScreen(); | |
| 170 virtual void exitFullScreen(); | |
| 171 virtual WebKit::WebRect windowRect(); | |
| 172 virtual void setWindowRect(const WebKit::WebRect&); | |
| 173 virtual WebKit::WebRect rootWindowRect(); | |
| 174 virtual WebKit::WebRect windowResizerRect(); | |
| 175 virtual WebKit::WebScreenInfo screenInfo(); | |
| 176 | |
| 177 // WebKit::WebFrameClient | |
| 178 virtual WebKit::WebPlugin* createPlugin(WebKit::WebFrame*, const WebKit::Web
PluginParams&); | |
| 179 virtual WebKit::WebApplicationCacheHost* createApplicationCacheHost(WebKit::
WebFrame*, WebKit::WebApplicationCacheHostClient*); | |
| 180 virtual void loadURLExternally(WebKit::WebFrame*, const WebKit::WebURLReques
t&, WebKit::WebNavigationPolicy); | |
| 181 virtual void loadURLExternally(WebKit::WebFrame*, const WebKit::WebURLReques
t&, WebKit::WebNavigationPolicy, const WebKit::WebString& downloadName); | |
| 182 virtual WebKit::WebNavigationPolicy decidePolicyForNavigation( | |
| 183 WebKit::WebFrame*, const WebKit::WebURLRequest&, | |
| 184 WebKit::WebNavigationType, WebKit::WebNavigationPolicy, bool isRedirect)
; | |
| 185 virtual WebKit::WebURLError cancelledError(WebKit::WebFrame*, const WebKit::
WebURLRequest&); | |
| 186 virtual void unableToImplementPolicyWithError(WebKit::WebFrame*, const WebKi
t::WebURLError&); | |
| 187 virtual void didCreateDataSource(WebKit::WebFrame*, WebKit::WebDataSource*); | |
| 188 virtual void didCommitProvisionalLoad(WebKit::WebFrame*, bool isNewNavigatio
n); | |
| 189 virtual void didClearWindowObject(WebKit::WebFrame*); | |
| 190 virtual void didReceiveTitle(WebKit::WebFrame*, const WebKit::WebString&, We
bKit::WebTextDirection); | |
| 191 virtual void didChangeIcon(WebKit::WebFrame* , WebKit::WebIconURL::Type); | |
| 192 virtual void didNavigateWithinPage(WebKit::WebFrame*, bool isNewNavigation); | |
| 193 virtual void willSendRequest(WebKit::WebFrame*, unsigned identifier, WebKit:
:WebURLRequest&, const WebKit::WebURLResponse&); | |
| 194 virtual void openFileSystem(WebKit::WebFrame*, WebKit::WebFileSystemType, lo
ng long size, bool create, WebKit::WebFileSystemCallbacks*); | |
| 195 virtual void deleteFileSystem(WebKit::WebFrame*, WebKit::WebFileSystemType,
WebKit::WebFileSystemCallbacks*); | |
| 196 virtual bool willCheckAndDispatchMessageEvent( | |
| 197 WebKit::WebFrame* sourceFrame, WebKit::WebFrame* targetFrame, | |
| 198 WebKit::WebSecurityOrigin target, WebKit::WebDOMMessageEvent); | |
| 199 | |
| 200 // Pending task list, Note taht the method is referred from WebMethodTask cl
ass. | |
| 201 WebTestRunner::WebTaskList* taskList() { return &m_taskList; } | |
| 202 | |
| 203 // Exposed for WebTestProxy. | |
| 204 void scheduleComposite() { } | |
| 205 | |
| 206 static const int screenUnavailableBorder; | |
| 207 | |
| 208 private: | |
| 209 | |
| 210 class HostMethodTask : public WebTestRunner::WebMethodTask<WebViewHost> { | |
| 211 public: | |
| 212 typedef void (WebViewHost::*CallbackMethodType)(); | |
| 213 HostMethodTask(WebViewHost* object, CallbackMethodType callback) | |
| 214 : WebTestRunner::WebMethodTask<WebViewHost>(object) | |
| 215 , m_callback(callback) | |
| 216 { } | |
| 217 | |
| 218 virtual void runIfValid() { (m_object->*m_callback)(); } | |
| 219 | |
| 220 private: | |
| 221 CallbackMethodType m_callback; | |
| 222 }; | |
| 223 | |
| 224 // Called the title of the page changes. | |
| 225 // Can be used to update the title of the window. | |
| 226 void setPageTitle(const WebKit::WebString&); | |
| 227 | |
| 228 void animateNow(); | |
| 229 void enterFullScreenNow(); | |
| 230 void exitFullScreenNow(); | |
| 231 | |
| 232 void updateForCommittedLoad(WebKit::WebFrame*, bool isNewNavigation); | |
| 233 void updateURL(WebKit::WebFrame*); | |
| 234 void updateSessionHistory(WebKit::WebFrame*); | |
| 235 | |
| 236 // Dumping a frame to the console. | |
| 237 void printFrameDescription(WebKit::WebFrame*); | |
| 238 | |
| 239 bool hasWindow() const { return m_hasWindow; } | |
| 240 | |
| 241 void updateViewportSize(); | |
| 242 | |
| 243 webkit_support::TestMediaStreamClient* testMediaStreamClient(); | |
| 244 | |
| 245 // Non-owning pointer. The WebViewHost instance is owned by this TestShell i
nstance. | |
| 246 TestShell* m_shell; | |
| 247 | |
| 248 // Non-owning pointer. This class needs to be wrapped in a WebTestProxy. Thi
s is the pointer to the WebTestProxyBase. | |
| 249 WebTestRunner::WebTestProxyBase* m_proxy; | |
| 250 | |
| 251 // This delegate works for the following widget. | |
| 252 WebKit::WebWidget* m_webWidget; | |
| 253 | |
| 254 // For tracking session history. See RenderView. | |
| 255 int m_pageId; | |
| 256 int m_lastPageIdUpdated; | |
| 257 | |
| 258 OwnPtr<TestShellExtraData> m_pendingExtraData; | |
| 259 | |
| 260 WebKit::WebCursorInfo m_currentCursor; | |
| 261 | |
| 262 bool m_hasWindow; | |
| 263 bool m_inModalLoop; | |
| 264 | |
| 265 bool m_shutdownWasInvoked; | |
| 266 bool m_animateScheduled; | |
| 267 bool m_finished; | |
| 268 | |
| 269 WebKit::WebRect m_windowRect; | |
| 270 | |
| 271 // Edit command associated to the current keyboard event. | |
| 272 std::string m_editCommandName; | |
| 273 std::string m_editCommandValue; | |
| 274 | |
| 275 OwnPtr<WebKit::WebContextMenuData> m_lastContextMenuData; | |
| 276 | |
| 277 OwnPtr<webkit_support::TestMediaStreamClient> m_testMediaStreamClient; | |
| 278 | |
| 279 OwnPtr<TestNavigationController> m_navigationController; | |
| 280 | |
| 281 WebTestRunner::WebTaskList m_taskList; | |
| 282 Vector<WebKit::WebWidget*> m_popupmenus; | |
| 283 | |
| 284 OwnPtr<webkit_support::DRTLayerTreeViewClient> m_layerTreeViewClient; | |
| 285 OwnPtr<WebKit::WebLayerTreeView> m_layerTreeView; | |
| 286 }; | |
| 287 | |
| 288 #endif // WebViewHost_h | |
| OLD | NEW |