| 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 // This file contains the implementation of TestWebViewDelegate, which serves | 5 // This file contains the implementation of TestWebViewDelegate, which serves |
| 6 // as the WebViewDelegate for the TestShellWebHost. The host is expected to | 6 // as the WebViewDelegate for the TestShellWebHost. The host is expected to |
| 7 // have initialized a MessageLoop before these methods are called. | 7 // have initialized a MessageLoop before these methods are called. |
| 8 | 8 |
| 9 #include "config.h" | 9 #include "config.h" |
| 10 | 10 |
| 11 #undef LOG | 11 #undef LOG |
| 12 | 12 |
| 13 #include "webkit/tools/test_shell/test_webview_delegate.h" | 13 #include "webkit/tools/test_shell/test_webview_delegate.h" |
| 14 | 14 |
| 15 #include "base/file_util.h" | 15 #include "base/file_util.h" |
| 16 #include "base/gfx/point.h" | 16 #include "base/gfx/point.h" |
| 17 #include "base/gfx/native_widget_types.h" | 17 #include "base/gfx/native_widget_types.h" |
| 18 #include "base/message_loop.h" | 18 #include "base/message_loop.h" |
| 19 #include "base/process_util.h" | 19 #include "base/process_util.h" |
| 20 #include "base/string_util.h" | 20 #include "base/string_util.h" |
| 21 #include "base/trace_event.h" | 21 #include "base/trace_event.h" |
| 22 #include "net/base/net_errors.h" | 22 #include "net/base/net_errors.h" |
| 23 #include "webkit/api/public/WebConsoleMessage.h" |
| 23 #include "webkit/api/public/WebCString.h" | 24 #include "webkit/api/public/WebCString.h" |
| 24 #include "webkit/api/public/WebData.h" | 25 #include "webkit/api/public/WebData.h" |
| 25 #include "webkit/api/public/WebDataSource.h" | 26 #include "webkit/api/public/WebDataSource.h" |
| 26 #include "webkit/api/public/WebDragData.h" | 27 #include "webkit/api/public/WebDragData.h" |
| 27 #include "webkit/api/public/WebHistoryItem.h" | 28 #include "webkit/api/public/WebHistoryItem.h" |
| 28 #include "webkit/api/public/WebFrame.h" | 29 #include "webkit/api/public/WebFrame.h" |
| 29 #include "webkit/api/public/WebKit.h" | 30 #include "webkit/api/public/WebKit.h" |
| 30 #include "webkit/api/public/WebNode.h" | 31 #include "webkit/api/public/WebNode.h" |
| 31 #include "webkit/api/public/WebPoint.h" | 32 #include "webkit/api/public/WebPoint.h" |
| 33 #include "webkit/api/public/WebPopupMenu.h" |
| 32 #include "webkit/api/public/WebRange.h" | 34 #include "webkit/api/public/WebRange.h" |
| 33 #include "webkit/api/public/WebScreenInfo.h" | 35 #include "webkit/api/public/WebScreenInfo.h" |
| 34 #include "webkit/api/public/WebString.h" | 36 #include "webkit/api/public/WebString.h" |
| 35 #include "webkit/api/public/WebURL.h" | 37 #include "webkit/api/public/WebURL.h" |
| 36 #include "webkit/api/public/WebURLError.h" | 38 #include "webkit/api/public/WebURLError.h" |
| 37 #include "webkit/api/public/WebURLRequest.h" | 39 #include "webkit/api/public/WebURLRequest.h" |
| 38 #include "webkit/api/public/WebURLResponse.h" | 40 #include "webkit/api/public/WebURLResponse.h" |
| 39 #include "webkit/appcache/appcache_interfaces.h" | 41 #include "webkit/appcache/appcache_interfaces.h" |
| 40 #include "webkit/glue/glue_serialize.h" | 42 #include "webkit/glue/glue_serialize.h" |
| 41 #include "webkit/glue/media/buffered_data_source.h" | 43 #include "webkit/glue/media/buffered_data_source.h" |
| (...skipping 11 matching lines...) Expand all Loading... |
| 53 #include "webkit/tools/test_shell/test_navigation_controller.h" | 55 #include "webkit/tools/test_shell/test_navigation_controller.h" |
| 54 #include "webkit/tools/test_shell/test_shell.h" | 56 #include "webkit/tools/test_shell/test_shell.h" |
| 55 #include "webkit/tools/test_shell/test_web_worker.h" | 57 #include "webkit/tools/test_shell/test_web_worker.h" |
| 56 | 58 |
| 57 #if defined(OS_WIN) | 59 #if defined(OS_WIN) |
| 58 // TODO(port): make these files work everywhere. | 60 // TODO(port): make these files work everywhere. |
| 59 #include "webkit/tools/test_shell/drag_delegate.h" | 61 #include "webkit/tools/test_shell/drag_delegate.h" |
| 60 #include "webkit/tools/test_shell/drop_delegate.h" | 62 #include "webkit/tools/test_shell/drop_delegate.h" |
| 61 #endif | 63 #endif |
| 62 | 64 |
| 65 using WebKit::WebConsoleMessage; |
| 63 using WebKit::WebData; | 66 using WebKit::WebData; |
| 64 using WebKit::WebDataSource; | 67 using WebKit::WebDataSource; |
| 65 using WebKit::WebDragData; | 68 using WebKit::WebDragData; |
| 66 using WebKit::WebDragOperationsMask; | 69 using WebKit::WebDragOperationsMask; |
| 67 using WebKit::WebEditingAction; | 70 using WebKit::WebEditingAction; |
| 68 using WebKit::WebForm; | 71 using WebKit::WebForm; |
| 69 using WebKit::WebFrame; | 72 using WebKit::WebFrame; |
| 70 using WebKit::WebHistoryItem; | 73 using WebKit::WebHistoryItem; |
| 71 using WebKit::WebMediaPlayer; | 74 using WebKit::WebMediaPlayer; |
| 72 using WebKit::WebMediaPlayerClient; | 75 using WebKit::WebMediaPlayerClient; |
| 73 using WebKit::WebNavigationType; | 76 using WebKit::WebNavigationType; |
| 74 using WebKit::WebNavigationPolicy; | 77 using WebKit::WebNavigationPolicy; |
| 75 using WebKit::WebNode; | 78 using WebKit::WebNode; |
| 76 using WebKit::WebPlugin; | 79 using WebKit::WebPlugin; |
| 77 using WebKit::WebPluginParams; | 80 using WebKit::WebPluginParams; |
| 78 using WebKit::WebPoint; | 81 using WebKit::WebPoint; |
| 82 using WebKit::WebPopupMenu; |
| 79 using WebKit::WebRange; | 83 using WebKit::WebRange; |
| 80 using WebKit::WebRect; | 84 using WebKit::WebRect; |
| 81 using WebKit::WebScreenInfo; | 85 using WebKit::WebScreenInfo; |
| 82 using WebKit::WebSize; | 86 using WebKit::WebSize; |
| 83 using WebKit::WebString; | 87 using WebKit::WebString; |
| 84 using WebKit::WebTextAffinity; | 88 using WebKit::WebTextAffinity; |
| 89 using WebKit::WebTextDirection; |
| 85 using WebKit::WebURL; | 90 using WebKit::WebURL; |
| 86 using WebKit::WebURLError; | 91 using WebKit::WebURLError; |
| 87 using WebKit::WebURLRequest; | 92 using WebKit::WebURLRequest; |
| 88 using WebKit::WebURLResponse; | 93 using WebKit::WebURLResponse; |
| 89 using WebKit::WebWidget; | 94 using WebKit::WebWidget; |
| 90 using WebKit::WebWorker; | 95 using WebKit::WebWorker; |
| 91 using WebKit::WebWorkerClient; | 96 using WebKit::WebWorkerClient; |
| 92 | 97 |
| 93 namespace { | 98 namespace { |
| 94 | 99 |
| 95 // WebNavigationType debugging strings taken from PolicyDelegate.mm. | 100 // WebNavigationType debugging strings taken from PolicyDelegate.mm. |
| 96 const char* kLinkClickedString = "link clicked"; | 101 const char* kLinkClickedString = "link clicked"; |
| 97 const char* kFormSubmittedString = "form submitted"; | 102 const char* kFormSubmittedString = "form submitted"; |
| 98 const char* kBackForwardString = "back/forward"; | 103 const char* kBackForwardString = "back/forward"; |
| 99 const char* kReloadString = "reload"; | 104 const char* kReloadString = "reload"; |
| 100 const char* kFormResubmittedString = "form resubmitted"; | 105 const char* kFormResubmittedString = "form resubmitted"; |
| 101 const char* kOtherString = "other"; | 106 const char* kOtherString = "other"; |
| 102 const char* kIllegalString = "illegal value"; | 107 const char* kIllegalString = "illegal value"; |
| 103 | 108 |
| 104 int next_page_id_ = 1; | 109 int next_page_id_ = 1; |
| 105 | 110 |
| 106 // Used to write a platform neutral file:/// URL by only taking the filename | 111 // Used to write a platform neutral file:/// URL by only taking the filename |
| 107 // (e.g., converts "file:///tmp/foo.txt" to just "foo.txt"). | 112 // (e.g., converts "file:///tmp/foo.txt" to just "foo.txt"). |
| 108 std::wstring UrlSuitableForTestResult(const std::wstring& url) { | 113 std::string UrlSuitableForTestResult(const std::string& url) { |
| 109 if (url.empty() || std::wstring::npos == url.find(L"file://")) | 114 if (url.empty() || std::string::npos == url.find("file://")) |
| 110 return url; | 115 return url; |
| 111 | 116 |
| 112 std::wstring filename = file_util::GetFilenameFromPath(url); | 117 std::string filename = |
| 118 WideToUTF8(file_util::GetFilenameFromPath(UTF8ToWide(url))); |
| 113 if (filename.empty()) | 119 if (filename.empty()) |
| 114 return L"file:"; // A WebKit test has this in its expected output. | 120 return "file:"; // A WebKit test has this in its expected output. |
| 115 return filename; | 121 return filename; |
| 116 } | 122 } |
| 117 | 123 |
| 118 // Adds a file called "DRTFakeFile" to |data_object| (CF_HDROP). Use to fake | 124 // Adds a file called "DRTFakeFile" to |data_object| (CF_HDROP). Use to fake |
| 119 // dragging a file. | 125 // dragging a file. |
| 120 void AddDRTFakeFileToDataObject(WebDragData* drag_data) { | 126 void AddDRTFakeFileToDataObject(WebDragData* drag_data) { |
| 121 drag_data->appendToFileNames(WebString::fromUTF8("DRTFakeFile")); | 127 drag_data->appendToFileNames(WebString::fromUTF8("DRTFakeFile")); |
| 122 } | 128 } |
| 123 | 129 |
| 124 // Get a debugging string from a WebNavigationType. | 130 // Get a debugging string from a WebNavigationType. |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 237 case WebKit::WebTextAffinityDownstream: | 243 case WebKit::WebTextAffinityDownstream: |
| 238 return "NSSelectionAffinityDownstream"; | 244 return "NSSelectionAffinityDownstream"; |
| 239 } | 245 } |
| 240 return "(UNKNOWN AFFINITY)"; | 246 return "(UNKNOWN AFFINITY)"; |
| 241 } | 247 } |
| 242 | 248 |
| 243 } // namespace | 249 } // namespace |
| 244 | 250 |
| 245 // WebViewDelegate ----------------------------------------------------------- | 251 // WebViewDelegate ----------------------------------------------------------- |
| 246 | 252 |
| 247 WebView* TestWebViewDelegate::CreateWebView(WebView* webview, | |
| 248 bool user_gesture, | |
| 249 const GURL& creator_url) { | |
| 250 return shell_->CreateWebView(webview); | |
| 251 } | |
| 252 | |
| 253 WebWidget* TestWebViewDelegate::CreatePopupWidget(WebView* webview, | |
| 254 bool activatable) { | |
| 255 return shell_->CreatePopupWidget(webview); | |
| 256 } | |
| 257 | |
| 258 std::string TestWebViewDelegate::GetResourceDescription(uint32 identifier) { | 253 std::string TestWebViewDelegate::GetResourceDescription(uint32 identifier) { |
| 259 ResourceMap::iterator it = resource_identifier_map_.find(identifier); | 254 ResourceMap::iterator it = resource_identifier_map_.find(identifier); |
| 260 return it != resource_identifier_map_.end() ? it->second : "<unknown>"; | 255 return it != resource_identifier_map_.end() ? it->second : "<unknown>"; |
| 261 } | 256 } |
| 262 | 257 |
| 263 void TestWebViewDelegate::AddMessageToConsole(WebView* webview, | 258 void TestWebViewDelegate::ShowContextMenu( |
| 264 const std::wstring& message, | 259 WebView* webview, |
| 265 unsigned int line_no, | 260 ContextNodeType node_type, |
| 266 const std::wstring& source_id) { | 261 int x, |
| 262 int y, |
| 263 const GURL& link_url, |
| 264 const GURL& image_url, |
| 265 const GURL& page_url, |
| 266 const GURL& frame_url, |
| 267 const ContextMenuMediaParams& media_params, |
| 268 const std::wstring& selection_text, |
| 269 const std::wstring& misspelled_word, |
| 270 int edit_flags, |
| 271 const std::string& security_info, |
| 272 const std::string& frame_charset) { |
| 273 CapturedContextMenuEvent context(node_type, x, y); |
| 274 captured_context_menu_events_.push_back(context); |
| 275 } |
| 276 |
| 277 void TestWebViewDelegate::SetUserStyleSheetEnabled(bool is_enabled) { |
| 278 WebPreferences* prefs = shell_->GetWebPreferences(); |
| 279 prefs->user_style_sheet_enabled = is_enabled; |
| 280 prefs->Apply(shell_->webView()); |
| 281 } |
| 282 |
| 283 void TestWebViewDelegate::SetUserStyleSheetLocation(const GURL& location) { |
| 284 WebPreferences* prefs = shell_->GetWebPreferences(); |
| 285 prefs->user_style_sheet_enabled = true; |
| 286 prefs->user_style_sheet_location = location; |
| 287 prefs->Apply(shell_->webView()); |
| 288 } |
| 289 |
| 290 // WebViewClient ------------------------------------------------------------- |
| 291 |
| 292 WebView* TestWebViewDelegate::createView(WebFrame* creator) { |
| 293 return shell_->CreateWebView(); |
| 294 } |
| 295 |
| 296 WebWidget* TestWebViewDelegate::createPopupMenu( |
| 297 bool activatable) { |
| 298 // TODO(darin): Should we honor activatable? |
| 299 return shell_->CreatePopupWidget(); |
| 300 } |
| 301 |
| 302 void TestWebViewDelegate::didAddMessageToConsole( |
| 303 const WebConsoleMessage& message, const WebString& source_name, |
| 304 unsigned source_line) { |
| 267 if (!shell_->layout_test_mode()) { | 305 if (!shell_->layout_test_mode()) { |
| 268 logging::LogMessage("CONSOLE", 0).stream() << "\"" | 306 logging::LogMessage("CONSOLE", 0).stream() << "\"" |
| 269 << message.c_str() | 307 << message.text.utf8().data() |
| 270 << ",\" source: " | 308 << ",\" source: " |
| 271 << source_id.c_str() | 309 << source_name.utf8().data() |
| 272 << "(" | 310 << "(" |
| 273 << line_no | 311 << source_line |
| 274 << ")"; | 312 << ")"; |
| 275 } else { | 313 } else { |
| 276 // This matches win DumpRenderTree's UIDelegate.cpp. | 314 // This matches win DumpRenderTree's UIDelegate.cpp. |
| 277 std::wstring new_message = message; | 315 std::string new_message; |
| 278 if (!message.empty()) { | 316 if (!message.text.isEmpty()) { |
| 279 new_message = message; | 317 new_message = message.text.utf8(); |
| 280 size_t file_protocol = new_message.find(L"file://"); | 318 size_t file_protocol = new_message.find("file://"); |
| 281 if (file_protocol != std::wstring::npos) { | 319 if (file_protocol != std::string::npos) { |
| 282 new_message = new_message.substr(0, file_protocol) + | 320 new_message = new_message.substr(0, file_protocol) + |
| 283 UrlSuitableForTestResult(new_message.substr(file_protocol)); | 321 UrlSuitableForTestResult(new_message.substr(file_protocol)); |
| 284 } | 322 } |
| 285 } | 323 } |
| 286 | 324 |
| 287 std::string utf8 = WideToUTF8(new_message); | 325 printf("CONSOLE MESSAGE: line %d: %s\n", source_line, new_message.data()); |
| 288 printf("CONSOLE MESSAGE: line %d: %s\n", line_no, utf8.c_str()); | |
| 289 } | 326 } |
| 290 } | 327 } |
| 291 | 328 |
| 292 void TestWebViewDelegate::RunJavaScriptAlert(WebFrame* webframe, | 329 void TestWebViewDelegate::printPage(WebFrame* frame) { |
| 293 const std::wstring& message) { | 330 } |
| 331 |
| 332 void TestWebViewDelegate::didStartLoading() { |
| 333 } |
| 334 |
| 335 void TestWebViewDelegate::didStopLoading() { |
| 336 } |
| 337 |
| 338 void TestWebViewDelegate::runModalAlertDialog( |
| 339 WebFrame* frame, const WebString& message) { |
| 294 if (!shell_->layout_test_mode()) { | 340 if (!shell_->layout_test_mode()) { |
| 295 ShowJavaScriptAlert(message); | 341 ShowJavaScriptAlert(UTF16ToWideHack(message)); |
| 296 } else { | 342 } else { |
| 297 std::string utf8 = WideToUTF8(message); | 343 printf("ALERT: %s\n", message.utf8().data()); |
| 298 printf("ALERT: %s\n", utf8.c_str()); | |
| 299 } | 344 } |
| 300 } | 345 } |
| 301 | 346 |
| 302 bool TestWebViewDelegate::RunJavaScriptConfirm(WebFrame* webframe, | 347 bool TestWebViewDelegate::runModalConfirmDialog( |
| 303 const std::wstring& message) { | 348 WebFrame* frame, const WebString& message) { |
| 304 if (shell_->layout_test_mode()) { | 349 if (shell_->layout_test_mode()) { |
| 305 // When running tests, write to stdout. | 350 // When running tests, write to stdout. |
| 306 std::string utf8 = WideToUTF8(message); | 351 printf("CONFIRM: %s\n", message.utf8().data()); |
| 307 printf("CONFIRM: %s\n", utf8.c_str()); | |
| 308 return true; | 352 return true; |
| 309 } | 353 } |
| 310 return false; | 354 return false; |
| 311 } | 355 } |
| 312 | 356 |
| 313 bool TestWebViewDelegate::RunJavaScriptPrompt(WebFrame* webframe, | 357 bool TestWebViewDelegate::runModalPromptDialog( |
| 314 const std::wstring& message, | 358 WebFrame* frame, const WebString& message, const WebString& default_value, |
| 315 const std::wstring& default_value, | 359 WebString* actual_value) { |
| 316 std::wstring* result) { | |
| 317 if (shell_->layout_test_mode()) { | 360 if (shell_->layout_test_mode()) { |
| 318 // When running tests, write to stdout. | 361 // When running tests, write to stdout. |
| 319 std::string utf8_message = WideToUTF8(message); | 362 printf("PROMPT: %s, default text: %s\n", |
| 320 std::string utf8_default_value = WideToUTF8(default_value); | 363 message.utf8().data(), |
| 321 printf("PROMPT: %s, default text: %s\n", utf8_message.c_str(), | 364 default_value.utf8().data()); |
| 322 utf8_default_value.c_str()); | |
| 323 return true; | 365 return true; |
| 324 } | 366 } |
| 325 return false; | 367 return false; |
| 326 } | 368 } |
| 327 | 369 |
| 328 void TestWebViewDelegate::SetStatusbarText(WebView* webview, | 370 bool TestWebViewDelegate::runModalBeforeUnloadDialog( |
| 329 const std::wstring& message) { | 371 WebFrame* frame, const WebString& message) { |
| 372 return true; // Allow window closure. |
| 373 } |
| 374 |
| 375 void TestWebViewDelegate::setStatusText(const WebString& text) { |
| 330 if (WebKit::layoutTestMode() && | 376 if (WebKit::layoutTestMode() && |
| 331 shell_->layout_test_controller()->ShouldDumpStatusCallbacks()) { | 377 shell_->layout_test_controller()->ShouldDumpStatusCallbacks()) { |
| 332 // When running tests, write to stdout. | 378 // When running tests, write to stdout. |
| 333 printf("UI DELEGATE STATUS CALLBACK: setStatusText:%S\n", message.c_str()); | 379 printf("UI DELEGATE STATUS CALLBACK: setStatusText:%s\n", text.utf8().data()
); |
| 334 } | 380 } |
| 335 } | 381 } |
| 336 | 382 |
| 337 void TestWebViewDelegate::StartDragging(WebView* webview, | 383 void TestWebViewDelegate::setMouseOverURL(const WebURL& url) { |
| 338 const WebPoint &mouse_coords, | 384 } |
| 339 const WebDragData& drag_data, | 385 |
| 340 WebDragOperationsMask mask) { | 386 void TestWebViewDelegate::setToolTipText( |
| 387 const WebString& text, WebTextDirection hint) { |
| 388 } |
| 389 |
| 390 void TestWebViewDelegate::startDragging( |
| 391 const WebPoint& mouse_coords, const WebDragData& data, |
| 392 WebDragOperationsMask mask) { |
| 341 if (WebKit::layoutTestMode()) { | 393 if (WebKit::layoutTestMode()) { |
| 342 WebDragData mutable_drag_data = drag_data; | 394 WebDragData mutable_drag_data = data; |
| 343 if (shell_->layout_test_controller()->ShouldAddFileToPasteboard()) { | 395 if (shell_->layout_test_controller()->ShouldAddFileToPasteboard()) { |
| 344 // Add a file called DRTFakeFile to the drag&drop clipboard. | 396 // Add a file called DRTFakeFile to the drag&drop clipboard. |
| 345 AddDRTFakeFileToDataObject(&mutable_drag_data); | 397 AddDRTFakeFileToDataObject(&mutable_drag_data); |
| 346 } | 398 } |
| 347 | 399 |
| 348 // When running a test, we need to fake a drag drop operation otherwise | 400 // When running a test, we need to fake a drag drop operation otherwise |
| 349 // Windows waits for real mouse events to know when the drag is over. | 401 // Windows waits for real mouse events to know when the drag is over. |
| 350 EventSendingController::DoDragDrop(mouse_coords, mutable_drag_data, mask); | 402 EventSendingController::DoDragDrop(mouse_coords, mutable_drag_data, mask); |
| 351 } else { | 403 } else { |
| 352 // TODO(tc): Drag and drop is disabled in the test shell because we need | 404 // TODO(tc): Drag and drop is disabled in the test shell because we need |
| 353 // to be able to convert from WebDragData to an IDataObject. | 405 // to be able to convert from WebDragData to an IDataObject. |
| 354 //if (!drag_delegate_) | 406 //if (!drag_delegate_) |
| 355 // drag_delegate_ = new TestDragDelegate(shell_->webViewWnd(), | 407 // drag_delegate_ = new TestDragDelegate(shell_->webViewWnd(), |
| 356 // shell_->webView()); | 408 // shell_->webView()); |
| 357 //const DWORD ok_effect = DROPEFFECT_COPY | DROPEFFECT_LINK | DROPEFFECT_MOV
E; | 409 //const DWORD ok_effect = DROPEFFECT_COPY | DROPEFFECT_LINK | DROPEFFECT_MOV
E; |
| 358 //DWORD effect; | 410 //DWORD effect; |
| 359 //HRESULT res = DoDragDrop(drop_data.data_object, drag_delegate_.get(), | 411 //HRESULT res = DoDragDrop(drop_data.data_object, drag_delegate_.get(), |
| 360 // ok_effect, &effect); | 412 // ok_effect, &effect); |
| 361 //DCHECK(DRAGDROP_S_DROP == res || DRAGDROP_S_CANCEL == res); | 413 //DCHECK(DRAGDROP_S_DROP == res || DRAGDROP_S_CANCEL == res); |
| 362 } | 414 } |
| 363 webview->DragSourceSystemDragEnded(); | 415 shell_->webView()->DragSourceSystemDragEnded(); |
| 364 } | 416 } |
| 365 | 417 |
| 366 void TestWebViewDelegate::ShowContextMenu( | 418 void TestWebViewDelegate::focusNext() { |
| 367 WebView* webview, | |
| 368 ContextNodeType node_type, | |
| 369 int x, | |
| 370 int y, | |
| 371 const GURL& link_url, | |
| 372 const GURL& image_url, | |
| 373 const GURL& page_url, | |
| 374 const GURL& frame_url, | |
| 375 const ContextMenuMediaParams& media_params, | |
| 376 const std::wstring& selection_text, | |
| 377 const std::wstring& misspelled_word, | |
| 378 int edit_flags, | |
| 379 const std::string& security_info, | |
| 380 const std::string& frame_charset) { | |
| 381 CapturedContextMenuEvent context(node_type, x, y); | |
| 382 captured_context_menu_events_.push_back(context); | |
| 383 } | 419 } |
| 384 | 420 |
| 385 void TestWebViewDelegate::NavigateBackForwardSoon(int offset) { | 421 void TestWebViewDelegate::focusPrevious() { |
| 422 } |
| 423 |
| 424 void TestWebViewDelegate::navigateBackForwardSoon(int offset) { |
| 386 shell_->navigation_controller()->GoToOffset(offset); | 425 shell_->navigation_controller()->GoToOffset(offset); |
| 387 } | 426 } |
| 388 | 427 |
| 389 int TestWebViewDelegate::GetHistoryBackListCount() { | 428 int TestWebViewDelegate::historyBackListCount() { |
| 390 int current_index = | 429 int current_index = |
| 391 shell_->navigation_controller()->GetLastCommittedEntryIndex(); | 430 shell_->navigation_controller()->GetLastCommittedEntryIndex(); |
| 392 return current_index; | 431 return current_index; |
| 393 } | 432 } |
| 394 | 433 |
| 395 int TestWebViewDelegate::GetHistoryForwardListCount() { | 434 int TestWebViewDelegate::historyForwardListCount() { |
| 396 int current_index = | 435 int current_index = |
| 397 shell_->navigation_controller()->GetLastCommittedEntryIndex(); | 436 shell_->navigation_controller()->GetLastCommittedEntryIndex(); |
| 398 return shell_->navigation_controller()->GetEntryCount() - current_index - 1; | 437 return shell_->navigation_controller()->GetEntryCount() - current_index - 1; |
| 399 } | 438 } |
| 400 | 439 |
| 401 void TestWebViewDelegate::SetUserStyleSheetEnabled(bool is_enabled) { | 440 void TestWebViewDelegate::didAddHistoryItem() { |
| 402 WebPreferences* prefs = shell_->GetWebPreferences(); | |
| 403 prefs->user_style_sheet_enabled = is_enabled; | |
| 404 prefs->Apply(shell_->webView()); | |
| 405 } | |
| 406 | |
| 407 void TestWebViewDelegate::SetUserStyleSheetLocation(const GURL& location) { | |
| 408 WebPreferences* prefs = shell_->GetWebPreferences(); | |
| 409 prefs->user_style_sheet_enabled = true; | |
| 410 prefs->user_style_sheet_location = location; | |
| 411 prefs->Apply(shell_->webView()); | |
| 412 } | 441 } |
| 413 | 442 |
| 414 // WebWidgetClient ----------------------------------------------------------- | 443 // WebWidgetClient ----------------------------------------------------------- |
| 415 | 444 |
| 416 void TestWebViewDelegate::didInvalidateRect(const WebRect& rect) { | 445 void TestWebViewDelegate::didInvalidateRect(const WebRect& rect) { |
| 417 if (WebWidgetHost* host = GetWidgetHost()) | 446 if (WebWidgetHost* host = GetWidgetHost()) |
| 418 host->DidInvalidateRect(rect); | 447 host->DidInvalidateRect(rect); |
| 419 } | 448 } |
| 420 | 449 |
| 421 void TestWebViewDelegate::didScrollRect(int dx, int dy, | 450 void TestWebViewDelegate::didScrollRect(int dx, int dy, |
| (...skipping 675 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1097 return L"main frame \"" + name + L"\""; | 1126 return L"main frame \"" + name + L"\""; |
| 1098 else | 1127 else |
| 1099 return L"main frame"; | 1128 return L"main frame"; |
| 1100 } else { | 1129 } else { |
| 1101 if (name.length()) | 1130 if (name.length()) |
| 1102 return L"frame \"" + name + L"\""; | 1131 return L"frame \"" + name + L"\""; |
| 1103 else | 1132 else |
| 1104 return L"frame (anonymous)"; | 1133 return L"frame (anonymous)"; |
| 1105 } | 1134 } |
| 1106 } | 1135 } |
| OLD | NEW |