| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 // TestWebViewDelegate class: | 5 // TestWebViewDelegate class: |
| 6 // This class implements the WebViewDelegate methods for the test shell. One | 6 // This class implements the WebViewDelegate methods for the test shell. One |
| 7 // instance is owned by each TestShell. | 7 // instance is owned by each TestShell. |
| 8 | 8 |
| 9 #ifndef WEBKIT_TOOLS_TEST_SHELL_TEST_WEBVIEW_DELEGATE_H_ | 9 #ifndef WEBKIT_TOOLS_TEST_SHELL_TEST_WEBVIEW_DELEGATE_H_ |
| 10 #define WEBKIT_TOOLS_TEST_SHELL_TEST_WEBVIEW_DELEGATE_H_ | 10 #define WEBKIT_TOOLS_TEST_SHELL_TEST_WEBVIEW_DELEGATE_H_ |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 virtual void WillDestroyPluginWindow(gfx::PluginWindowHandle handle); | 104 virtual void WillDestroyPluginWindow(gfx::PluginWindowHandle handle); |
| 105 #endif | 105 #endif |
| 106 virtual WebKit::WebMediaPlayer* CreateWebMediaPlayer( | 106 virtual WebKit::WebMediaPlayer* CreateWebMediaPlayer( |
| 107 WebKit::WebMediaPlayerClient* client); | 107 WebKit::WebMediaPlayerClient* client); |
| 108 virtual WebKit::WebWorker* CreateWebWorker(WebKit::WebWorkerClient* client); | 108 virtual WebKit::WebWorker* CreateWebWorker(WebKit::WebWorkerClient* client); |
| 109 virtual void OpenURL(WebView* webview, | 109 virtual void OpenURL(WebView* webview, |
| 110 const GURL& url, | 110 const GURL& url, |
| 111 const GURL& referrer, | 111 const GURL& referrer, |
| 112 WebKit::WebNavigationPolicy policy); | 112 WebKit::WebNavigationPolicy policy); |
| 113 virtual void DidMovePlugin(const WebPluginGeometry& move); | 113 virtual void DidMovePlugin(const WebPluginGeometry& move); |
| 114 virtual void RunJavaScriptAlert(WebFrame* webframe, | 114 virtual void RunJavaScriptAlert(WebKit::WebFrame* webframe, |
| 115 const std::wstring& message); | 115 const std::wstring& message); |
| 116 virtual bool RunJavaScriptConfirm(WebFrame* webframe, | 116 virtual bool RunJavaScriptConfirm(WebKit::WebFrame* webframe, |
| 117 const std::wstring& message); | 117 const std::wstring& message); |
| 118 virtual bool RunJavaScriptPrompt(WebFrame* webframe, | 118 virtual bool RunJavaScriptPrompt(WebKit::WebFrame* webframe, |
| 119 const std::wstring& message, | 119 const std::wstring& message, |
| 120 const std::wstring& default_value, | 120 const std::wstring& default_value, |
| 121 std::wstring* result); | 121 std::wstring* result); |
| 122 | 122 |
| 123 virtual void SetStatusbarText(WebView* webview, | 123 virtual void SetStatusbarText(WebView* webview, |
| 124 const std::wstring& message); | 124 const std::wstring& message); |
| 125 | 125 |
| 126 virtual void AddMessageToConsole(WebView* webview, | 126 virtual void AddMessageToConsole(WebView* webview, |
| 127 const std::wstring& message, | 127 const std::wstring& message, |
| 128 unsigned int line_no, | 128 unsigned int line_no, |
| 129 const std::wstring& source_id); | 129 const std::wstring& source_id); |
| 130 virtual void StartDragging(WebView* webview, | 130 virtual void StartDragging(WebView* webview, |
| 131 const WebKit::WebDragData& drag_data); | 131 const WebKit::WebDragData& drag_data); |
| 132 virtual void ShowContextMenu(WebView* webview, | 132 virtual void ShowContextMenu(WebView* webview, |
| 133 ContextNodeType node_type, | 133 ContextNodeType node_type, |
| 134 int x, | 134 int x, |
| 135 int y, | 135 int y, |
| 136 const GURL& link_url, | 136 const GURL& link_url, |
| 137 const GURL& image_url, | 137 const GURL& image_url, |
| 138 const GURL& page_url, | 138 const GURL& page_url, |
| 139 const GURL& frame_url, | 139 const GURL& frame_url, |
| 140 const ContextMenuMediaParams& media_params, | 140 const ContextMenuMediaParams& media_params, |
| 141 const std::wstring& selection_text, | 141 const std::wstring& selection_text, |
| 142 const std::wstring& misspelled_word, | 142 const std::wstring& misspelled_word, |
| 143 int edit_flags, | 143 int edit_flags, |
| 144 const std::string& security_info, | 144 const std::string& security_info, |
| 145 const std::string& frame_charset); | 145 const std::string& frame_charset); |
| 146 virtual void DidCreateDataSource(WebFrame* frame, | 146 virtual void DidCreateDataSource(WebKit::WebFrame* frame, |
| 147 WebKit::WebDataSource* ds); | 147 WebKit::WebDataSource* ds); |
| 148 virtual void DidStartProvisionalLoadForFrame( | 148 virtual void DidStartProvisionalLoadForFrame( |
| 149 WebView* webview, | 149 WebView* webview, |
| 150 WebFrame* frame, | 150 WebKit::WebFrame* frame, |
| 151 NavigationGesture gesture); | 151 NavigationGesture gesture); |
| 152 virtual void DidReceiveProvisionalLoadServerRedirect( | 152 virtual void DidReceiveProvisionalLoadServerRedirect( |
| 153 WebView* webview, WebFrame* frame); | 153 WebView* webview, WebKit::WebFrame* frame); |
| 154 virtual void DidFailProvisionalLoadWithError( | 154 virtual void DidFailProvisionalLoadWithError( |
| 155 WebView* webview, | 155 WebView* webview, |
| 156 const WebKit::WebURLError& error, | 156 const WebKit::WebURLError& error, |
| 157 WebFrame* frame); | 157 WebKit::WebFrame* frame); |
| 158 virtual void DidCommitLoadForFrame(WebView* webview, WebFrame* frame, | 158 virtual void DidCommitLoadForFrame( |
| 159 bool is_new_navigation); | 159 WebView* webview, |
| 160 WebKit::WebFrame* frame, |
| 161 bool is_new_navigation); |
| 160 virtual void DidReceiveTitle(WebView* webview, | 162 virtual void DidReceiveTitle(WebView* webview, |
| 161 const std::wstring& title, | 163 const std::wstring& title, |
| 162 WebFrame* frame); | 164 WebKit::WebFrame* frame); |
| 163 virtual void DidFinishDocumentLoadForFrame(WebView* webview, | 165 virtual void DidFinishDocumentLoadForFrame(WebView* webview, |
| 164 WebFrame* frame); | 166 WebKit::WebFrame* frame); |
| 165 virtual void DidHandleOnloadEventsForFrame(WebView* webview, | 167 virtual void DidHandleOnloadEventsForFrame(WebView* webview, |
| 166 WebFrame* frame); | 168 WebKit::WebFrame* frame); |
| 167 virtual void DidChangeLocationWithinPageForFrame(WebView* webview, | 169 virtual void DidChangeLocationWithinPageForFrame(WebView* webview, |
| 168 WebFrame* frame, | 170 WebKit::WebFrame* frame, |
| 169 bool is_new_navigation); | 171 bool is_new_navigation); |
| 170 virtual void DidReceiveIconForFrame(WebView* webview, WebFrame* frame); | 172 virtual void DidReceiveIconForFrame(WebView* webview, WebKit::WebFrame* frame)
; |
| 171 | 173 |
| 172 virtual void WillPerformClientRedirect(WebView* webview, | 174 virtual void WillPerformClientRedirect(WebView* webview, |
| 173 WebFrame* frame, | 175 WebKit::WebFrame* frame, |
| 174 const GURL& src_url, | 176 const GURL& src_url, |
| 175 const GURL& dest_url, | 177 const GURL& dest_url, |
| 176 unsigned int delay_seconds, | 178 unsigned int delay_seconds, |
| 177 unsigned int fire_date); | 179 unsigned int fire_date); |
| 178 virtual void DidCancelClientRedirect(WebView* webview, | 180 virtual void DidCancelClientRedirect(WebView* webview, |
| 179 WebFrame* frame); | 181 WebKit::WebFrame* frame); |
| 180 | 182 |
| 181 virtual void DidFinishLoadForFrame(WebView* webview, WebFrame* frame); | 183 virtual void DidFinishLoadForFrame(WebView* webview, WebKit::WebFrame* frame); |
| 182 virtual void DidFailLoadWithError(WebView* webview, | 184 virtual void DidFailLoadWithError(WebView* webview, |
| 183 const WebKit::WebURLError& error, | 185 const WebKit::WebURLError& error, |
| 184 WebFrame* for_frame); | 186 WebKit::WebFrame* for_frame); |
| 185 | 187 |
| 186 virtual void AssignIdentifierToRequest(WebFrame* webframe, | 188 virtual void AssignIdentifierToRequest(WebKit::WebFrame* webframe, |
| 187 uint32 identifier, | 189 uint32 identifier, |
| 188 const WebKit::WebURLRequest& request); | 190 const WebKit::WebURLRequest& request); |
| 189 virtual void WillSendRequest(WebFrame* webframe, | 191 virtual void WillSendRequest(WebKit::WebFrame* webframe, |
| 190 uint32 identifier, | 192 uint32 identifier, |
| 191 WebKit::WebURLRequest* request, | 193 WebKit::WebURLRequest* request, |
| 192 const WebKit::WebURLResponse& redirect_response); | 194 const WebKit::WebURLResponse& redirect_response); |
| 193 virtual void DidReceiveResponse(WebFrame* webframe, | 195 virtual void DidReceiveResponse(WebKit::WebFrame* webframe, |
| 194 uint32 identifier, | 196 uint32 identifier, |
| 195 const WebKit::WebURLResponse& response); | 197 const WebKit::WebURLResponse& response); |
| 196 virtual void DidFinishLoading(WebFrame* webframe, uint32 identifier); | 198 virtual void DidFinishLoading(WebKit::WebFrame* webframe, uint32 identifier); |
| 197 virtual void DidFailLoadingWithError(WebFrame* webframe, | 199 virtual void DidFailLoadingWithError(WebKit::WebFrame* webframe, |
| 198 uint32 identifier, | 200 uint32 identifier, |
| 199 const WebKit::WebURLError& error); | 201 const WebKit::WebURLError& error); |
| 200 | 202 |
| 201 virtual bool ShouldBeginEditing(WebView* webview, std::wstring range); | 203 virtual bool ShouldBeginEditing(WebView* webview, std::wstring range); |
| 202 virtual bool ShouldEndEditing(WebView* webview, std::wstring range); | 204 virtual bool ShouldEndEditing(WebView* webview, std::wstring range); |
| 203 virtual bool ShouldInsertNode(WebView* webview, | 205 virtual bool ShouldInsertNode(WebView* webview, |
| 204 std::wstring node, | 206 std::wstring node, |
| 205 std::wstring range, | 207 std::wstring range, |
| 206 std::wstring action); | 208 std::wstring action); |
| 207 virtual bool ShouldInsertText(WebView* webview, | 209 virtual bool ShouldInsertText(WebView* webview, |
| (...skipping 12 matching lines...) Expand all Loading... |
| 220 virtual bool SmartInsertDeleteEnabled(); | 222 virtual bool SmartInsertDeleteEnabled(); |
| 221 virtual bool IsSelectTrailingWhitespaceEnabled(); | 223 virtual bool IsSelectTrailingWhitespaceEnabled(); |
| 222 virtual void DidBeginEditing(); | 224 virtual void DidBeginEditing(); |
| 223 virtual void DidChangeSelection(bool is_empty_selection); | 225 virtual void DidChangeSelection(bool is_empty_selection); |
| 224 virtual void DidChangeContents(); | 226 virtual void DidChangeContents(); |
| 225 virtual void DidEndEditing(); | 227 virtual void DidEndEditing(); |
| 226 | 228 |
| 227 virtual void DidStartLoading(WebView* webview); | 229 virtual void DidStartLoading(WebView* webview); |
| 228 virtual void DidStopLoading(WebView* webview); | 230 virtual void DidStopLoading(WebView* webview); |
| 229 | 231 |
| 230 virtual void WindowObjectCleared(WebFrame* webframe); | 232 virtual void WindowObjectCleared(WebKit::WebFrame* webframe); |
| 231 virtual WebKit::WebNavigationPolicy PolicyForNavigationAction( | 233 virtual WebKit::WebNavigationPolicy PolicyForNavigationAction( |
| 232 WebView* webview, | 234 WebView* webview, |
| 233 WebFrame* frame, | 235 WebKit::WebFrame* frame, |
| 234 const WebKit::WebURLRequest& request, | 236 const WebKit::WebURLRequest& request, |
| 235 WebKit::WebNavigationType type, | 237 WebKit::WebNavigationType type, |
| 236 WebKit::WebNavigationPolicy default_policy, | 238 WebKit::WebNavigationPolicy default_policy, |
| 237 bool is_redirect); | 239 bool is_redirect); |
| 238 virtual void NavigateBackForwardSoon(int offset); | 240 virtual void NavigateBackForwardSoon(int offset); |
| 239 virtual int GetHistoryBackListCount(); | 241 virtual int GetHistoryBackListCount(); |
| 240 virtual int GetHistoryForwardListCount(); | 242 virtual int GetHistoryForwardListCount(); |
| 241 | 243 |
| 242 // WebWidgetClient | 244 // WebWidgetClient |
| 243 virtual void didInvalidateRect(const WebKit::WebRect& rect); | 245 virtual void didInvalidateRect(const WebKit::WebRect& rect); |
| 244 virtual void didScrollRect(int dx, int dy, | 246 virtual void didScrollRect(int dx, int dy, |
| 245 const WebKit::WebRect& clip_rect); | 247 const WebKit::WebRect& clip_rect); |
| 246 virtual void didFocus(); | 248 virtual void didFocus(); |
| 247 virtual void didBlur(); | 249 virtual void didBlur(); |
| 248 virtual void didChangeCursor(const WebKit::WebCursorInfo& cursor); | 250 virtual void didChangeCursor(const WebKit::WebCursorInfo& cursor); |
| 249 virtual void closeWidgetSoon(); | 251 virtual void closeWidgetSoon(); |
| 250 virtual void show(WebKit::WebNavigationPolicy policy); | 252 virtual void show(WebKit::WebNavigationPolicy policy); |
| 251 virtual void runModal(); | 253 virtual void runModal(); |
| 252 virtual WebKit::WebRect windowRect(); | 254 virtual WebKit::WebRect windowRect(); |
| 253 virtual void setWindowRect(const WebKit::WebRect& rect); | 255 virtual void setWindowRect(const WebKit::WebRect& rect); |
| 254 virtual WebKit::WebRect rootWindowRect(); | 256 virtual WebKit::WebRect rootWindowRect(); |
| 255 virtual WebKit::WebRect windowResizerRect(); | 257 virtual WebKit::WebRect windowResizerRect(); |
| 256 virtual WebKit::WebScreenInfo screenInfo(); | 258 virtual WebKit::WebScreenInfo screenInfo(); |
| 257 | 259 |
| 258 void SetSmartInsertDeleteEnabled(bool enabled); | 260 void SetSmartInsertDeleteEnabled(bool enabled); |
| 259 void SetSelectTrailingWhitespaceEnabled(bool enabled); | 261 void SetSelectTrailingWhitespaceEnabled(bool enabled); |
| 260 | 262 |
| 261 // Additional accessors | 263 // Additional accessors |
| 262 WebFrame* top_loading_frame() { return top_loading_frame_; } | 264 WebKit::WebFrame* top_loading_frame() { return top_loading_frame_; } |
| 263 #if defined(OS_WIN) | 265 #if defined(OS_WIN) |
| 264 IDropTarget* drop_delegate() { return drop_delegate_.get(); } | 266 IDropTarget* drop_delegate() { return drop_delegate_.get(); } |
| 265 IDropSource* drag_delegate() { return drag_delegate_.get(); } | 267 IDropSource* drag_delegate() { return drag_delegate_.get(); } |
| 266 #endif | 268 #endif |
| 267 const CapturedContextMenuEvents& captured_context_menu_events() const { | 269 const CapturedContextMenuEvents& captured_context_menu_events() const { |
| 268 return captured_context_menu_events_; | 270 return captured_context_menu_events_; |
| 269 } | 271 } |
| 270 void clear_captured_context_menu_events() { | 272 void clear_captured_context_menu_events() { |
| 271 captured_context_menu_events_.clear(); | 273 captured_context_menu_events_.clear(); |
| 272 } | 274 } |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 306 void SetAddressBarURL(const GURL& url); | 308 void SetAddressBarURL(const GURL& url); |
| 307 | 309 |
| 308 // Show a JavaScript alert as a popup message. | 310 // Show a JavaScript alert as a popup message. |
| 309 // The caller should test whether we're in layout test mode and only | 311 // The caller should test whether we're in layout test mode and only |
| 310 // call this function when we really want a message to pop up. | 312 // call this function when we really want a message to pop up. |
| 311 void ShowJavaScriptAlert(const std::wstring& message); | 313 void ShowJavaScriptAlert(const std::wstring& message); |
| 312 | 314 |
| 313 // In the Mac code, this is called to trigger the end of a test after the | 315 // In the Mac code, this is called to trigger the end of a test after the |
| 314 // page has finished loading. From here, we can generate the dump for the | 316 // page has finished loading. From here, we can generate the dump for the |
| 315 // test. | 317 // test. |
| 316 void LocationChangeDone(WebFrame*); | 318 void LocationChangeDone(WebKit::WebFrame*); |
| 317 | 319 |
| 318 WebWidgetHost* GetWidgetHost(); | 320 WebWidgetHost* GetWidgetHost(); |
| 319 | 321 |
| 320 void UpdateForCommittedLoad(WebFrame* webframe, bool is_new_navigation); | 322 void UpdateForCommittedLoad(WebKit::WebFrame* webframe, bool is_new_navigation
); |
| 321 void UpdateURL(WebFrame* frame); | 323 void UpdateURL(WebKit::WebFrame* frame); |
| 322 void UpdateSessionHistory(WebFrame* frame); | 324 void UpdateSessionHistory(WebKit::WebFrame* frame); |
| 323 void UpdateSelectionClipboard(bool is_empty_selection); | 325 void UpdateSelectionClipboard(bool is_empty_selection); |
| 324 | 326 |
| 325 // Get a string suitable for dumping a frame to the console. | 327 // Get a string suitable for dumping a frame to the console. |
| 326 std::wstring GetFrameDescription(WebFrame* webframe); | 328 std::wstring GetFrameDescription(WebKit::WebFrame* webframe); |
| 327 | 329 |
| 328 private: | 330 private: |
| 329 // Causes navigation actions just printout the intended navigation instead | 331 // Causes navigation actions just printout the intended navigation instead |
| 330 // of taking you to the page. This is used for cases like mailto, where you | 332 // of taking you to the page. This is used for cases like mailto, where you |
| 331 // don't actually want to open the mail program. | 333 // don't actually want to open the mail program. |
| 332 bool policy_delegate_enabled_; | 334 bool policy_delegate_enabled_; |
| 333 | 335 |
| 334 // Toggles the behavior of the policy delegate. If true, then navigations | 336 // Toggles the behavior of the policy delegate. If true, then navigations |
| 335 // will be allowed. Otherwise, they will be ignored (dropped). | 337 // will be allowed. Otherwise, they will be ignored (dropped). |
| 336 bool policy_delegate_is_permissive_; | 338 bool policy_delegate_is_permissive_; |
| 337 | 339 |
| 338 // If true, the policy delegate will signal layout test completion. | 340 // If true, the policy delegate will signal layout test completion. |
| 339 bool policy_delegate_should_notify_done_; | 341 bool policy_delegate_should_notify_done_; |
| 340 | 342 |
| 341 // Non-owning pointer. The delegate is owned by the host. | 343 // Non-owning pointer. The delegate is owned by the host. |
| 342 TestShell* shell_; | 344 TestShell* shell_; |
| 343 | 345 |
| 344 // This is non-NULL IFF a load is in progress. | 346 // This is non-NULL IFF a load is in progress. |
| 345 WebFrame* top_loading_frame_; | 347 WebKit::WebFrame* top_loading_frame_; |
| 346 | 348 |
| 347 // For tracking session history. See RenderView. | 349 // For tracking session history. See RenderView. |
| 348 int page_id_; | 350 int page_id_; |
| 349 int last_page_id_updated_; | 351 int last_page_id_updated_; |
| 350 | 352 |
| 351 scoped_ptr<TestShellExtraData> pending_extra_data_; | 353 scoped_ptr<TestShellExtraData> pending_extra_data_; |
| 352 | 354 |
| 353 // Maps resource identifiers to a descriptive string. | 355 // Maps resource identifiers to a descriptive string. |
| 354 typedef std::map<uint32, std::string> ResourceMap; | 356 typedef std::map<uint32, std::string> ResourceMap; |
| 355 ResourceMap resource_identifier_map_; | 357 ResourceMap resource_identifier_map_; |
| (...skipping 27 matching lines...) Expand all Loading... |
| 383 // true if we want to enable selection of trailing whitespaces | 385 // true if we want to enable selection of trailing whitespaces |
| 384 bool select_trailing_whitespace_enabled_; | 386 bool select_trailing_whitespace_enabled_; |
| 385 | 387 |
| 386 // true if we should block any redirects | 388 // true if we should block any redirects |
| 387 bool block_redirects_; | 389 bool block_redirects_; |
| 388 | 390 |
| 389 DISALLOW_COPY_AND_ASSIGN(TestWebViewDelegate); | 391 DISALLOW_COPY_AND_ASSIGN(TestWebViewDelegate); |
| 390 }; | 392 }; |
| 391 | 393 |
| 392 #endif // WEBKIT_TOOLS_TEST_SHELL_TEST_WEBVIEW_DELEGATE_H_ | 394 #endif // WEBKIT_TOOLS_TEST_SHELL_TEST_WEBVIEW_DELEGATE_H_ |
| OLD | NEW |