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 #include "webkit/tools/test_shell/test_webview_delegate.h" | 11 #include "webkit/tools/test_shell/test_webview_delegate.h" |
12 | 12 |
13 #include "base/file_util.h" | 13 #include "base/file_util.h" |
14 #include "base/gfx/point.h" | 14 #include "base/gfx/point.h" |
15 #include "base/gfx/native_widget_types.h" | 15 #include "base/gfx/native_widget_types.h" |
16 #include "base/message_loop.h" | 16 #include "base/message_loop.h" |
17 #include "base/process_util.h" | 17 #include "base/process_util.h" |
18 #include "base/string_util.h" | 18 #include "base/string_util.h" |
19 #include "base/trace_event.h" | 19 #include "base/trace_event.h" |
20 #include "net/base/net_errors.h" | 20 #include "net/base/net_errors.h" |
| 21 #include "webkit/api/public/WebData.h" |
21 #include "webkit/api/public/WebDataSource.h" | 22 #include "webkit/api/public/WebDataSource.h" |
22 #include "webkit/api/public/WebDragData.h" | 23 #include "webkit/api/public/WebDragData.h" |
23 #include "webkit/api/public/WebHistoryItem.h" | 24 #include "webkit/api/public/WebHistoryItem.h" |
24 #include "webkit/api/public/WebKit.h" | 25 #include "webkit/api/public/WebKit.h" |
25 #include "webkit/api/public/WebScreenInfo.h" | 26 #include "webkit/api/public/WebScreenInfo.h" |
26 #include "webkit/api/public/WebString.h" | 27 #include "webkit/api/public/WebString.h" |
27 #include "webkit/api/public/WebURL.h" | 28 #include "webkit/api/public/WebURL.h" |
28 #include "webkit/api/public/WebURLError.h" | 29 #include "webkit/api/public/WebURLError.h" |
29 #include "webkit/api/public/WebURLRequest.h" | 30 #include "webkit/api/public/WebURLRequest.h" |
30 #include "webkit/glue/glue_serialize.h" | 31 #include "webkit/glue/glue_serialize.h" |
(...skipping 12 matching lines...) Expand all Loading... |
43 #include "webkit/tools/test_shell/test_navigation_controller.h" | 44 #include "webkit/tools/test_shell/test_navigation_controller.h" |
44 #include "webkit/tools/test_shell/test_shell.h" | 45 #include "webkit/tools/test_shell/test_shell.h" |
45 #include "webkit/tools/test_shell/test_webworker_helper.h" | 46 #include "webkit/tools/test_shell/test_webworker_helper.h" |
46 | 47 |
47 #if defined(OS_WIN) | 48 #if defined(OS_WIN) |
48 // TODO(port): make these files work everywhere. | 49 // TODO(port): make these files work everywhere. |
49 #include "webkit/tools/test_shell/drag_delegate.h" | 50 #include "webkit/tools/test_shell/drag_delegate.h" |
50 #include "webkit/tools/test_shell/drop_delegate.h" | 51 #include "webkit/tools/test_shell/drop_delegate.h" |
51 #endif | 52 #endif |
52 | 53 |
| 54 using WebKit::WebData; |
53 using WebKit::WebDataSource; | 55 using WebKit::WebDataSource; |
54 using WebKit::WebDragData; | 56 using WebKit::WebDragData; |
55 using WebKit::WebHistoryItem; | 57 using WebKit::WebHistoryItem; |
56 using WebKit::WebNavigationType; | 58 using WebKit::WebNavigationType; |
57 using WebKit::WebRect; | 59 using WebKit::WebRect; |
58 using WebKit::WebScreenInfo; | 60 using WebKit::WebScreenInfo; |
59 using WebKit::WebSize; | 61 using WebKit::WebSize; |
60 using WebKit::WebString; | 62 using WebKit::WebString; |
61 using WebKit::WebURL; | 63 using WebKit::WebURL; |
62 using WebKit::WebURLError; | 64 using WebKit::WebURLError; |
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
335 // from being dumb, WebCore doesn't expect it and it will cause a crash. | 337 // from being dumb, WebCore doesn't expect it and it will cause a crash. |
336 if (error.reason == net::ERR_ABORTED) | 338 if (error.reason == net::ERR_ABORTED) |
337 return; | 339 return; |
338 | 340 |
339 const WebDataSource* failed_ds = frame->GetProvisionalDataSource(); | 341 const WebDataSource* failed_ds = frame->GetProvisionalDataSource(); |
340 | 342 |
341 TestShellExtraData* extra_data = | 343 TestShellExtraData* extra_data = |
342 static_cast<TestShellExtraData*>(failed_ds->extraData()); | 344 static_cast<TestShellExtraData*>(failed_ds->extraData()); |
343 bool replace = extra_data && extra_data->pending_page_id != -1; | 345 bool replace = extra_data && extra_data->pending_page_id != -1; |
344 | 346 |
345 WebURLRequest request = failed_ds->request(); | 347 const std::string& error_text = |
346 | |
347 std::string error_text = | |
348 StringPrintf("Error %d when loading url %s", error.reason, | 348 StringPrintf("Error %d when loading url %s", error.reason, |
349 request.url().spec().data()); | 349 failed_ds->request().url().spec().data()); |
350 request.setURL(GURL("testshell-error:")); | |
351 | 350 |
352 // Make sure we never show errors in view source mode. | 351 // Make sure we never show errors in view source mode. |
353 frame->SetInViewSourceMode(false); | 352 frame->SetInViewSourceMode(false); |
354 | 353 |
355 frame->LoadAlternateHTMLString( | 354 frame->LoadHTMLString( |
356 request, error_text, error.unreachableURL, replace); | 355 error_text, GURL("testshell-error:"), error.unreachableURL, replace); |
357 } | 356 } |
358 | 357 |
359 void TestWebViewDelegate::DidCommitLoadForFrame(WebView* webview, | 358 void TestWebViewDelegate::DidCommitLoadForFrame(WebView* webview, |
360 WebFrame* frame, | 359 WebFrame* frame, |
361 bool is_new_navigation) { | 360 bool is_new_navigation) { |
362 if (shell_->ShouldDumpFrameLoadCallbacks()) { | 361 if (shell_->ShouldDumpFrameLoadCallbacks()) { |
363 printf("%S - didCommitLoadForFrame\n", | 362 printf("%S - didCommitLoadForFrame\n", |
364 GetFrameDescription(frame).c_str()); | 363 GetFrameDescription(frame).c_str()); |
365 } | 364 } |
366 | 365 |
(...skipping 565 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
932 return L"main frame \"" + name + L"\""; | 931 return L"main frame \"" + name + L"\""; |
933 else | 932 else |
934 return L"main frame"; | 933 return L"main frame"; |
935 } else { | 934 } else { |
936 if (name.length()) | 935 if (name.length()) |
937 return L"frame \"" + name + L"\""; | 936 return L"frame \"" + name + L"\""; |
938 else | 937 else |
939 return L"frame (anonymous)"; | 938 return L"frame (anonymous)"; |
940 } | 939 } |
941 } | 940 } |
OLD | NEW |