| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 436 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 447 // Returns an empty string as Mac WebKit ('WebKitSupport/WebEditorClient.mm') | 447 // Returns an empty string as Mac WebKit ('WebKitSupport/WebEditorClient.mm') |
| 448 // does. (If this function returns a non-empty string, WebKit replaces the | 448 // does. (If this function returns a non-empty string, WebKit replaces the |
| 449 // given misspelled string with the result one. This process executes some | 449 // given misspelled string with the result one. This process executes some |
| 450 // editor commands and causes layout-test failures.) | 450 // editor commands and causes layout-test failures.) |
| 451 return WebString(); | 451 return WebString(); |
| 452 } | 452 } |
| 453 | 453 |
| 454 void TestWebViewDelegate::runModalAlertDialog( | 454 void TestWebViewDelegate::runModalAlertDialog( |
| 455 WebFrame* frame, const WebString& message) { | 455 WebFrame* frame, const WebString& message) { |
| 456 if (!shell_->layout_test_mode()) { | 456 if (!shell_->layout_test_mode()) { |
| 457 ShowJavaScriptAlert(UTF16ToWideHack(message)); | 457 ShowJavaScriptAlert(message); |
| 458 } else { | 458 } else { |
| 459 printf("ALERT: %s\n", message.utf8().data()); | 459 printf("ALERT: %s\n", message.utf8().data()); |
| 460 } | 460 } |
| 461 } | 461 } |
| 462 | 462 |
| 463 bool TestWebViewDelegate::runModalConfirmDialog( | 463 bool TestWebViewDelegate::runModalConfirmDialog( |
| 464 WebFrame* frame, const WebString& message) { | 464 WebFrame* frame, const WebString& message) { |
| 465 if (shell_->layout_test_mode()) { | 465 if (shell_->layout_test_mode()) { |
| 466 // When running tests, write to stdout. | 466 // When running tests, write to stdout. |
| 467 printf("CONFIRM: %s\n", message.utf8().data()); | 467 printf("CONFIRM: %s\n", message.utf8().data()); |
| (...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 761 WebFrame* frame, WebDataSource* ds) { | 761 WebFrame* frame, WebDataSource* ds) { |
| 762 ds->setExtraData(pending_extra_data_.release()); | 762 ds->setExtraData(pending_extra_data_.release()); |
| 763 } | 763 } |
| 764 | 764 |
| 765 void TestWebViewDelegate::didStartProvisionalLoad(WebFrame* frame) { | 765 void TestWebViewDelegate::didStartProvisionalLoad(WebFrame* frame) { |
| 766 if (!top_loading_frame_) { | 766 if (!top_loading_frame_) { |
| 767 top_loading_frame_ = frame; | 767 top_loading_frame_ = frame; |
| 768 } | 768 } |
| 769 | 769 |
| 770 if (shell_->layout_test_controller()->StopProvisionalFrameLoads()) { | 770 if (shell_->layout_test_controller()->StopProvisionalFrameLoads()) { |
| 771 printf("%S - stopping load in didStartProvisionalLoadForFrame callback\n", | 771 printf("%s - stopping load in didStartProvisionalLoadForFrame callback\n", |
| 772 GetFrameDescription(frame).c_str()); | 772 UTF16ToUTF8(GetFrameDescription(frame)).c_str()); |
| 773 frame->stopLoading(); | 773 frame->stopLoading(); |
| 774 } | 774 } |
| 775 UpdateAddressBar(frame->view()); | 775 UpdateAddressBar(frame->view()); |
| 776 } | 776 } |
| 777 | 777 |
| 778 void TestWebViewDelegate::didReceiveServerRedirectForProvisionalLoad( | 778 void TestWebViewDelegate::didReceiveServerRedirectForProvisionalLoad( |
| 779 WebFrame* frame) { | 779 WebFrame* frame) { |
| 780 UpdateAddressBar(frame->view()); | 780 UpdateAddressBar(frame->view()); |
| 781 } | 781 } |
| 782 | 782 |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 829 } | 829 } |
| 830 | 830 |
| 831 void TestWebViewDelegate::didReceiveTitle( | 831 void TestWebViewDelegate::didReceiveTitle( |
| 832 WebFrame* frame, const WebString& title, WebTextDirection direction) { | 832 WebFrame* frame, const WebString& title, WebTextDirection direction) { |
| 833 SetPageTitle(title); | 833 SetPageTitle(title); |
| 834 } | 834 } |
| 835 | 835 |
| 836 void TestWebViewDelegate::didFinishDocumentLoad(WebFrame* frame) { | 836 void TestWebViewDelegate::didFinishDocumentLoad(WebFrame* frame) { |
| 837 unsigned pending_unload_events = frame->unloadListenerCount(); | 837 unsigned pending_unload_events = frame->unloadListenerCount(); |
| 838 if (pending_unload_events) { | 838 if (pending_unload_events) { |
| 839 printf("%S - has %u onunload handler(s)\n", | 839 printf("%s - has %u onunload handler(s)\n", |
| 840 GetFrameDescription(frame).c_str(), pending_unload_events); | 840 UTF16ToUTF8(GetFrameDescription(frame)).c_str(), pending_unload_events); |
| 841 } | 841 } |
| 842 } | 842 } |
| 843 | 843 |
| 844 void TestWebViewDelegate::didHandleOnloadEvents(WebFrame* frame) { | 844 void TestWebViewDelegate::didHandleOnloadEvents(WebFrame* frame) { |
| 845 } | 845 } |
| 846 | 846 |
| 847 void TestWebViewDelegate::didFailLoad( | 847 void TestWebViewDelegate::didFailLoad( |
| 848 WebFrame* frame, const WebURLError& error) { | 848 WebFrame* frame, const WebURLError& error) { |
| 849 LocationChangeDone(frame); | 849 LocationChangeDone(frame); |
| 850 } | 850 } |
| (...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1130 return; | 1130 return; |
| 1131 | 1131 |
| 1132 const WebHistoryItem& history_item = | 1132 const WebHistoryItem& history_item = |
| 1133 shell_->webView()->mainFrame()->previousHistoryItem(); | 1133 shell_->webView()->mainFrame()->previousHistoryItem(); |
| 1134 if (history_item.isNull()) | 1134 if (history_item.isNull()) |
| 1135 return; | 1135 return; |
| 1136 | 1136 |
| 1137 entry->SetContentState(webkit_glue::HistoryItemToString(history_item)); | 1137 entry->SetContentState(webkit_glue::HistoryItemToString(history_item)); |
| 1138 } | 1138 } |
| 1139 | 1139 |
| 1140 std::wstring TestWebViewDelegate::GetFrameDescription(WebFrame* webframe) { | 1140 string16 TestWebViewDelegate::GetFrameDescription(WebFrame* webframe) { |
| 1141 std::wstring name = UTF16ToWideHack(webframe->name()); | 1141 std::string name = UTF16ToUTF8(webframe->name()); |
| 1142 | 1142 |
| 1143 if (webframe == shell_->webView()->mainFrame()) { | 1143 if (webframe == shell_->webView()->mainFrame()) { |
| 1144 if (name.length()) | 1144 if (name.length()) |
| 1145 return L"main frame \"" + name + L"\""; | 1145 name = "main frame \"" + name + "\""; |
| 1146 else | 1146 else |
| 1147 return L"main frame"; | 1147 name = "main frame"; |
| 1148 } else { | 1148 } else { |
| 1149 if (name.length()) | 1149 if (name.length()) |
| 1150 return L"frame \"" + name + L"\""; | 1150 name = "frame \"" + name + "\""; |
| 1151 else | 1151 else |
| 1152 return L"frame (anonymous)"; | 1152 name = "frame (anonymous)"; |
| 1153 } | 1153 } |
| 1154 return UTF8ToUTF16(name); |
| 1154 } | 1155 } |
| 1155 | 1156 |
| 1156 void TestWebViewDelegate::set_fake_window_rect(const WebRect& rect) { | 1157 void TestWebViewDelegate::set_fake_window_rect(const WebRect& rect) { |
| 1157 fake_rect_ = rect; | 1158 fake_rect_ = rect; |
| 1158 using_fake_rect_ = true; | 1159 using_fake_rect_ = true; |
| 1159 } | 1160 } |
| 1160 | 1161 |
| 1161 WebRect TestWebViewDelegate::fake_window_rect() { | 1162 WebRect TestWebViewDelegate::fake_window_rect() { |
| 1162 return fake_rect_; | 1163 return fake_rect_; |
| 1163 } | 1164 } |
| OLD | NEW |