OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "webkit/tools/test_shell/test_webview_delegate.h" | 9 #include "webkit/tools/test_shell/test_webview_delegate.h" |
10 | 10 |
(...skipping 12 matching lines...) Expand all Loading... |
23 #include "third_party/WebKit/WebKit/chromium/public/WebData.h" | 23 #include "third_party/WebKit/WebKit/chromium/public/WebData.h" |
24 #include "third_party/WebKit/WebKit/chromium/public/WebDataSource.h" | 24 #include "third_party/WebKit/WebKit/chromium/public/WebDataSource.h" |
25 #include "third_party/WebKit/WebKit/chromium/public/WebDragData.h" | 25 #include "third_party/WebKit/WebKit/chromium/public/WebDragData.h" |
26 #include "third_party/WebKit/WebKit/chromium/public/WebHistoryItem.h" | 26 #include "third_party/WebKit/WebKit/chromium/public/WebHistoryItem.h" |
27 #include "third_party/WebKit/WebKit/chromium/public/WebImage.h" | 27 #include "third_party/WebKit/WebKit/chromium/public/WebImage.h" |
28 #include "third_party/WebKit/WebKit/chromium/public/WebFrame.h" | 28 #include "third_party/WebKit/WebKit/chromium/public/WebFrame.h" |
29 #include "third_party/WebKit/WebKit/chromium/public/WebKit.h" | 29 #include "third_party/WebKit/WebKit/chromium/public/WebKit.h" |
30 #include "third_party/WebKit/WebKit/chromium/public/WebKitClient.h" | 30 #include "third_party/WebKit/WebKit/chromium/public/WebKitClient.h" |
31 #include "third_party/WebKit/WebKit/chromium/public/WebNode.h" | 31 #include "third_party/WebKit/WebKit/chromium/public/WebNode.h" |
32 #include "third_party/WebKit/WebKit/chromium/public/WebNotificationPresenter.h" | 32 #include "third_party/WebKit/WebKit/chromium/public/WebNotificationPresenter.h" |
| 33 #include "third_party/WebKit/WebKit/chromium/public/WebPluginParams.h" |
33 #include "third_party/WebKit/WebKit/chromium/public/WebPoint.h" | 34 #include "third_party/WebKit/WebKit/chromium/public/WebPoint.h" |
34 #include "third_party/WebKit/WebKit/chromium/public/WebPopupMenu.h" | 35 #include "third_party/WebKit/WebKit/chromium/public/WebPopupMenu.h" |
35 #include "third_party/WebKit/WebKit/chromium/public/WebRange.h" | 36 #include "third_party/WebKit/WebKit/chromium/public/WebRange.h" |
36 #include "third_party/WebKit/WebKit/chromium/public/WebScreenInfo.h" | 37 #include "third_party/WebKit/WebKit/chromium/public/WebScreenInfo.h" |
37 #include "third_party/WebKit/WebKit/chromium/public/WebStorageNamespace.h" | 38 #include "third_party/WebKit/WebKit/chromium/public/WebStorageNamespace.h" |
38 #include "third_party/WebKit/WebKit/chromium/public/WebString.h" | 39 #include "third_party/WebKit/WebKit/chromium/public/WebString.h" |
39 #include "third_party/WebKit/WebKit/chromium/public/WebURL.h" | 40 #include "third_party/WebKit/WebKit/chromium/public/WebURL.h" |
40 #include "third_party/WebKit/WebKit/chromium/public/WebURLError.h" | 41 #include "third_party/WebKit/WebKit/chromium/public/WebURLError.h" |
41 #include "third_party/WebKit/WebKit/chromium/public/WebURLRequest.h" | 42 #include "third_party/WebKit/WebKit/chromium/public/WebURLRequest.h" |
42 #include "third_party/WebKit/WebKit/chromium/public/WebURLResponse.h" | 43 #include "third_party/WebKit/WebKit/chromium/public/WebURLResponse.h" |
(...skipping 519 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
562 data.mousePosition.x, | 563 data.mousePosition.x, |
563 data.mousePosition.y); | 564 data.mousePosition.y); |
564 captured_context_menu_events_.push_back(context); | 565 captured_context_menu_events_.push_back(context); |
565 } | 566 } |
566 | 567 |
567 | 568 |
568 void TestWebViewDelegate::setStatusText(const WebString& text) { | 569 void TestWebViewDelegate::setStatusText(const WebString& text) { |
569 if (WebKit::layoutTestMode() && | 570 if (WebKit::layoutTestMode() && |
570 shell_->layout_test_controller()->ShouldDumpStatusCallbacks()) { | 571 shell_->layout_test_controller()->ShouldDumpStatusCallbacks()) { |
571 // When running tests, write to stdout. | 572 // When running tests, write to stdout. |
572 printf("UI DELEGATE STATUS CALLBACK: setStatusText:%s\n", text.utf8().data()
); | 573 printf("UI DELEGATE STATUS CALLBACK: setStatusText:%s\n", |
| 574 text.utf8().data()); |
573 } | 575 } |
574 } | 576 } |
575 | 577 |
576 void TestWebViewDelegate::startDragging( | 578 void TestWebViewDelegate::startDragging( |
577 const WebDragData& data, | 579 const WebDragData& data, |
578 WebDragOperationsMask mask, | 580 WebDragOperationsMask mask, |
579 const WebImage& image, | 581 const WebImage& image, |
580 const WebPoint& image_offset) { | 582 const WebPoint& image_offset) { |
581 if (WebKit::layoutTestMode()) { | 583 if (WebKit::layoutTestMode()) { |
582 WebDragData mutable_drag_data = data; | 584 WebDragData mutable_drag_data = data; |
583 if (shell_->layout_test_controller()->ShouldAddFileToPasteboard()) { | 585 if (shell_->layout_test_controller()->ShouldAddFileToPasteboard()) { |
584 // Add a file called DRTFakeFile to the drag&drop clipboard. | 586 // Add a file called DRTFakeFile to the drag&drop clipboard. |
585 AddDRTFakeFileToDataObject(&mutable_drag_data); | 587 AddDRTFakeFileToDataObject(&mutable_drag_data); |
586 } | 588 } |
587 | 589 |
588 // When running a test, we need to fake a drag drop operation otherwise | 590 // When running a test, we need to fake a drag drop operation otherwise |
589 // Windows waits for real mouse events to know when the drag is over. | 591 // Windows waits for real mouse events to know when the drag is over. |
590 shell_->event_sending_controller()->DoDragDrop( | 592 shell_->event_sending_controller()->DoDragDrop( |
591 mutable_drag_data, mask); | 593 mutable_drag_data, mask); |
592 } else { | 594 } else { |
593 // TODO(tc): Drag and drop is disabled in the test shell because we need | 595 // TODO(tc): Drag and drop is disabled in the test shell because we need |
594 // to be able to convert from WebDragData to an IDataObject. | 596 // to be able to convert from WebDragData to an IDataObject. |
595 //if (!drag_delegate_) | 597 //if (!drag_delegate_) |
596 // drag_delegate_ = new TestDragDelegate(shell_->webViewWnd(), | 598 // drag_delegate_ = new TestDragDelegate(shell_->webViewWnd(), |
597 // shell_->webView()); | 599 // shell_->webView()); |
598 //const DWORD ok_effect = DROPEFFECT_COPY | DROPEFFECT_LINK | DROPEFFECT_MOV
E; | 600 //const DWORD ok_effect = DROPEFFECT_COPY | DROPEFFECT_LINK | |
| 601 // DROPEFFECT_MOVE; |
599 //DWORD effect; | 602 //DWORD effect; |
600 //HRESULT res = DoDragDrop(drop_data.data_object, drag_delegate_.get(), | 603 //HRESULT res = DoDragDrop(drop_data.data_object, drag_delegate_.get(), |
601 // ok_effect, &effect); | 604 // ok_effect, &effect); |
602 //DCHECK(DRAGDROP_S_DROP == res || DRAGDROP_S_CANCEL == res); | 605 //DCHECK(DRAGDROP_S_DROP == res || DRAGDROP_S_CANCEL == res); |
603 } | 606 } |
604 } | 607 } |
605 | 608 |
606 void TestWebViewDelegate::navigateBackForwardSoon(int offset) { | 609 void TestWebViewDelegate::navigateBackForwardSoon(int offset) { |
607 shell_->navigation_controller()->GoToOffset(offset); | 610 shell_->navigation_controller()->GoToOffset(offset); |
608 } | 611 } |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
659 if (WebWidgetHost* host = GetWidgetHost()) | 662 if (WebWidgetHost* host = GetWidgetHost()) |
660 return host->GetScreenInfo(); | 663 return host->GetScreenInfo(); |
661 | 664 |
662 return WebScreenInfo(); | 665 return WebScreenInfo(); |
663 } | 666 } |
664 | 667 |
665 // WebFrameClient ------------------------------------------------------------ | 668 // WebFrameClient ------------------------------------------------------------ |
666 | 669 |
667 WebPlugin* TestWebViewDelegate::createPlugin( | 670 WebPlugin* TestWebViewDelegate::createPlugin( |
668 WebFrame* frame, const WebPluginParams& params) { | 671 WebFrame* frame, const WebPluginParams& params) { |
669 return new webkit_glue::WebPluginImpl(frame, params, AsWeakPtr()); | 672 bool allow_wildcard = true; |
| 673 WebPluginInfo info; |
| 674 std::string actual_mime_type; |
| 675 if (!NPAPI::PluginList::Singleton()->GetPluginInfo( |
| 676 params.url, params.mimeType.utf8(), allow_wildcard, &info, |
| 677 &actual_mime_type)) { |
| 678 return NULL; |
| 679 } |
| 680 |
| 681 if (actual_mime_type.empty()) |
| 682 actual_mime_type = params.mimeType.utf8(); |
| 683 |
| 684 return new webkit_glue::WebPluginImpl( |
| 685 frame, params, info.path, actual_mime_type, AsWeakPtr()); |
670 } | 686 } |
671 | 687 |
672 WebWorker* TestWebViewDelegate::createWorker( | 688 WebWorker* TestWebViewDelegate::createWorker( |
673 WebFrame* frame, WebWorkerClient* client) { | 689 WebFrame* frame, WebWorkerClient* client) { |
674 return new TestWebWorker(); | 690 return new TestWebWorker(); |
675 } | 691 } |
676 | 692 |
677 WebMediaPlayer* TestWebViewDelegate::createMediaPlayer( | 693 WebMediaPlayer* TestWebViewDelegate::createMediaPlayer( |
678 WebFrame* frame, WebMediaPlayerClient* client) { | 694 WebFrame* frame, WebMediaPlayerClient* client) { |
679 scoped_refptr<media::FilterFactoryCollection> factory = | 695 scoped_refptr<media::FilterFactoryCollection> factory = |
(...skipping 600 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1280 } | 1296 } |
1281 | 1297 |
1282 void TestWebViewDelegate::set_fake_window_rect(const WebRect& rect) { | 1298 void TestWebViewDelegate::set_fake_window_rect(const WebRect& rect) { |
1283 fake_rect_ = rect; | 1299 fake_rect_ = rect; |
1284 using_fake_rect_ = true; | 1300 using_fake_rect_ = true; |
1285 } | 1301 } |
1286 | 1302 |
1287 WebRect TestWebViewDelegate::fake_window_rect() { | 1303 WebRect TestWebViewDelegate::fake_window_rect() { |
1288 return fake_rect_; | 1304 return fake_rect_; |
1289 } | 1305 } |
OLD | NEW |