1 /*
2 * Copyright (C) 2007 Kevin Ollivier <kevino@theolliviers.com>
3 * Copyright (C) 2011 Apple Inc. All rights reserved.
4 *
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 *
16 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
19 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
20 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
21 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
22 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
23 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
24 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28
29 #include "config.h"
30 #include "FrameLoaderClientWx.h"
31
32 #include <JavaScriptCore/JavaScript.h>
33 #include <JavaScriptCore/APICast.h>
34
35 #include "DocumentLoader.h"
36 #include "FormState.h"
37 #include "Frame.h"
38 #include "FrameLoaderTypes.h"
39 #include "FrameView.h"
40 #include "FrameTree.h"
41 #include "PluginView.h"
42 #include "HTMLFormElement.h"
43 #include "HTMLFrameOwnerElement.h"
44 #include "NotImplemented.h"
45 #include "Page.h"
46 #include "PlatformString.h"
47 #include "PluginView.h"
48 #include "ProgressTracker.h"
49 #include "RenderPart.h"
50 #include "ResourceError.h"
51 #include "ResourceResponse.h"
52 #include "ScriptController.h"
53 #include <wtf/PassRefPtr.h>
54 #include <wtf/RefPtr.h>
55
56 #include <stdio.h>
57
58 #include "FrameNetworkingContextWx.h"
59 #include "WebFrame.h"
60 #include "WebFramePrivate.h"
61 #include "WebView.h"
62 #include "WebViewPrivate.h"
63
64 namespace WebCore {
65
wxNavTypeFromWebNavType(NavigationType type)66 inline int wxNavTypeFromWebNavType(NavigationType type){
67 if (type == NavigationTypeLinkClicked)
68 return wxWEBVIEW_NAV_LINK_CLICKED;
69
70 if (type == NavigationTypeFormSubmitted)
71 return wxWEBVIEW_NAV_FORM_SUBMITTED;
72
73 if (type == NavigationTypeBackForward)
74 return wxWEBVIEW_NAV_BACK_NEXT;
75
76 if (type == NavigationTypeReload)
77 return wxWEBVIEW_NAV_RELOAD;
78
79 if (type == NavigationTypeFormResubmitted)
80 return wxWEBVIEW_NAV_FORM_RESUBMITTED;
81
82 return wxWEBVIEW_NAV_OTHER;
83 }
84
FrameLoaderClientWx()85 FrameLoaderClientWx::FrameLoaderClientWx()
86 : m_frame(0)
87 , m_pluginView(0)
88 , m_hasSentResponseToPlugin(false)
89 , m_webFrame(0)
90 {
91 }
92
93
~FrameLoaderClientWx()94 FrameLoaderClientWx::~FrameLoaderClientWx()
95 {
96 }
97
setFrame(wxWebFrame * frame)98 void FrameLoaderClientWx::setFrame(wxWebFrame *frame)
99 {
100 m_webFrame = frame;
101 m_frame = m_webFrame->m_impl->frame;
102 }
103
setWebView(wxWebView * webview)104 void FrameLoaderClientWx::setWebView(wxWebView *webview)
105 {
106 m_webView = webview;
107 }
108
hasWebView() const109 bool FrameLoaderClientWx::hasWebView() const
110 {
111 return m_webView != NULL;
112 }
113
hasBackForwardList() const114 bool FrameLoaderClientWx::hasBackForwardList() const
115 {
116 notImplemented();
117 return true;
118 }
119
120
resetBackForwardList()121 void FrameLoaderClientWx::resetBackForwardList()
122 {
123 notImplemented();
124 }
125
126
provisionalItemIsTarget() const127 bool FrameLoaderClientWx::provisionalItemIsTarget() const
128 {
129 notImplemented();
130 return false;
131 }
132
makeRepresentation(DocumentLoader *)133 void FrameLoaderClientWx::makeRepresentation(DocumentLoader*)
134 {
135 notImplemented();
136 }
137
138
forceLayout()139 void FrameLoaderClientWx::forceLayout()
140 {
141 notImplemented();
142 }
143
144
forceLayoutForNonHTML()145 void FrameLoaderClientWx::forceLayoutForNonHTML()
146 {
147 notImplemented();
148 }
149
150
updateHistoryForCommit()151 void FrameLoaderClientWx::updateHistoryForCommit()
152 {
153 notImplemented();
154 }
155
156
updateHistoryForBackForwardNavigation()157 void FrameLoaderClientWx::updateHistoryForBackForwardNavigation()
158 {
159 notImplemented();
160 }
161
162
updateHistoryForReload()163 void FrameLoaderClientWx::updateHistoryForReload()
164 {
165 notImplemented();
166 }
167
168
updateHistoryForStandardLoad()169 void FrameLoaderClientWx::updateHistoryForStandardLoad()
170 {
171 notImplemented();
172 }
173
174
updateHistoryForInternalLoad()175 void FrameLoaderClientWx::updateHistoryForInternalLoad()
176 {
177 notImplemented();
178 }
179
180
updateHistoryAfterClientRedirect()181 void FrameLoaderClientWx::updateHistoryAfterClientRedirect()
182 {
183 notImplemented();
184 }
185
186
setCopiesOnScroll()187 void FrameLoaderClientWx::setCopiesOnScroll()
188 {
189 // apparently mac specific
190 notImplemented();
191 }
192
193
tokenForLoadErrorReset()194 LoadErrorResetToken* FrameLoaderClientWx::tokenForLoadErrorReset()
195 {
196 notImplemented();
197 return 0;
198 }
199
200
resetAfterLoadError(LoadErrorResetToken *)201 void FrameLoaderClientWx::resetAfterLoadError(LoadErrorResetToken*)
202 {
203 notImplemented();
204 }
205
206
doNotResetAfterLoadError(LoadErrorResetToken *)207 void FrameLoaderClientWx::doNotResetAfterLoadError(LoadErrorResetToken*)
208 {
209 notImplemented();
210 }
211
212
willCloseDocument()213 void FrameLoaderClientWx::willCloseDocument()
214 {
215 notImplemented();
216 }
217
218
detachedFromParent2()219 void FrameLoaderClientWx::detachedFromParent2()
220 {
221 notImplemented();
222 }
223
224
detachedFromParent3()225 void FrameLoaderClientWx::detachedFromParent3()
226 {
227 notImplemented();
228 }
229
dispatchDidHandleOnloadEvents()230 void FrameLoaderClientWx::dispatchDidHandleOnloadEvents()
231 {
232 if (m_webView) {
233 wxWebViewLoadEvent wkEvent(m_webView);
234 wkEvent.SetState(wxWEBVIEW_LOAD_ONLOAD_HANDLED);
235 wkEvent.SetURL(m_frame->loader()->documentLoader()->request().url().string());
236 m_webView->GetEventHandler()->ProcessEvent(wkEvent);
237 }
238 }
239
240
dispatchDidReceiveServerRedirectForProvisionalLoad()241 void FrameLoaderClientWx::dispatchDidReceiveServerRedirectForProvisionalLoad()
242 {
243 notImplemented();
244 }
245
246
dispatchDidCancelClientRedirect()247 void FrameLoaderClientWx::dispatchDidCancelClientRedirect()
248 {
249 notImplemented();
250 }
251
252
dispatchWillPerformClientRedirect(const KURL &,double interval,double fireDate)253 void FrameLoaderClientWx::dispatchWillPerformClientRedirect(const KURL&,
254 double interval,
255 double fireDate)
256 {
257 notImplemented();
258 }
259
260
dispatchDidChangeLocationWithinPage()261 void FrameLoaderClientWx::dispatchDidChangeLocationWithinPage()
262 {
263 notImplemented();
264 }
265
dispatchDidPushStateWithinPage()266 void FrameLoaderClientWx::dispatchDidPushStateWithinPage()
267 {
268 notImplemented();
269 }
270
dispatchDidReplaceStateWithinPage()271 void FrameLoaderClientWx::dispatchDidReplaceStateWithinPage()
272 {
273 notImplemented();
274 }
275
dispatchDidPopStateWithinPage()276 void FrameLoaderClientWx::dispatchDidPopStateWithinPage()
277 {
278 notImplemented();
279 }
280
dispatchWillClose()281 void FrameLoaderClientWx::dispatchWillClose()
282 {
283 notImplemented();
284 }
285
286
dispatchDidStartProvisionalLoad()287 void FrameLoaderClientWx::dispatchDidStartProvisionalLoad()
288 {
289 if (m_webView) {
290 wxWebViewLoadEvent wkEvent(m_webView);
291 wkEvent.SetState(wxWEBVIEW_LOAD_NEGOTIATING);
292 wkEvent.SetURL(m_frame->loader()->provisionalDocumentLoader()->request().url().string());
293 m_webView->GetEventHandler()->ProcessEvent(wkEvent);
294 }
295 }
296
297
dispatchDidReceiveTitle(const StringWithDirection & title)298 void FrameLoaderClientWx::dispatchDidReceiveTitle(const StringWithDirection& title)
299 {
300 if (m_webView) {
301 // FIXME: use direction of title.
302 m_webView->SetPageTitle(title.string());
303 wxWebViewReceivedTitleEvent wkEvent(m_webView);
304 wkEvent.SetTitle(title.string());
305 m_webView->GetEventHandler()->ProcessEvent(wkEvent);
306 }
307 }
308
309
dispatchDidCommitLoad()310 void FrameLoaderClientWx::dispatchDidCommitLoad()
311 {
312 if (m_webView) {
313 wxWebViewLoadEvent wkEvent(m_webView);
314 wkEvent.SetState(wxWEBVIEW_LOAD_TRANSFERRING);
315 wkEvent.SetURL(m_frame->loader()->documentLoader()->request().url().string());
316 m_webView->GetEventHandler()->ProcessEvent(wkEvent);
317 }
318 }
319
dispatchDidFinishDocumentLoad()320 void FrameLoaderClientWx::dispatchDidFinishDocumentLoad()
321 {
322 if (m_webView) {
323 wxWebViewLoadEvent wkEvent(m_webView);
324 wkEvent.SetState(wxWEBVIEW_LOAD_DOC_COMPLETED);
325 wkEvent.SetURL(m_frame->document()->url().string());
326 m_webView->GetEventHandler()->ProcessEvent(wkEvent);
327 }
328 }
329
dispatchDidChangeIcons()330 void FrameLoaderClientWx::dispatchDidChangeIcons()
331 {
332 notImplemented();
333 }
334
dispatchDidFinishLoad()335 void FrameLoaderClientWx::dispatchDidFinishLoad()
336 {
337 notImplemented();
338 }
339
340
dispatchDidFirstLayout()341 void FrameLoaderClientWx::dispatchDidFirstLayout()
342 {
343 notImplemented();
344 }
345
dispatchDidFirstVisuallyNonEmptyLayout()346 void FrameLoaderClientWx::dispatchDidFirstVisuallyNonEmptyLayout()
347 {
348 notImplemented();
349 }
350
dispatchShow()351 void FrameLoaderClientWx::dispatchShow()
352 {
353 notImplemented();
354 }
355
356
cancelPolicyCheck()357 void FrameLoaderClientWx::cancelPolicyCheck()
358 {
359 notImplemented();
360 }
361
362
dispatchWillSubmitForm(FramePolicyFunction function,PassRefPtr<FormState>)363 void FrameLoaderClientWx::dispatchWillSubmitForm(FramePolicyFunction function,
364 PassRefPtr<FormState>)
365 {
366 // FIXME: Send an event to allow for alerts and cancellation
367 if (!m_webFrame)
368 return;
369 (m_frame->loader()->policyChecker()->*function)(PolicyUse);
370 }
371
372
dispatchDidLoadMainResource(DocumentLoader *)373 void FrameLoaderClientWx::dispatchDidLoadMainResource(DocumentLoader*)
374 {
375 notImplemented();
376 }
377
378
revertToProvisionalState(DocumentLoader *)379 void FrameLoaderClientWx::revertToProvisionalState(DocumentLoader*)
380 {
381 notImplemented();
382 }
383
postProgressStartedNotification()384 void FrameLoaderClientWx::postProgressStartedNotification()
385 {
386 notImplemented();
387 }
388
postProgressEstimateChangedNotification()389 void FrameLoaderClientWx::postProgressEstimateChangedNotification()
390 {
391 notImplemented();
392 }
393
postProgressFinishedNotification()394 void FrameLoaderClientWx::postProgressFinishedNotification()
395 {
396 if (m_webView) {
397 wxWebViewLoadEvent wkEvent(m_webView);
398 wkEvent.SetState(wxWEBVIEW_LOAD_DL_COMPLETED);
399 wkEvent.SetURL(m_frame->document()->url().string());
400 m_webView->GetEventHandler()->ProcessEvent(wkEvent);
401 }
402 }
403
progressStarted()404 void FrameLoaderClientWx::progressStarted()
405 {
406 notImplemented();
407 }
408
409
progressCompleted()410 void FrameLoaderClientWx::progressCompleted()
411 {
412 notImplemented();
413 }
414
415
setMainFrameDocumentReady(bool b)416 void FrameLoaderClientWx::setMainFrameDocumentReady(bool b)
417 {
418 notImplemented();
419 // this is only interesting once we provide an external API for the DOM
420 }
421
422
willChangeTitle(DocumentLoader *)423 void FrameLoaderClientWx::willChangeTitle(DocumentLoader*)
424 {
425 notImplemented();
426 }
427
428
didChangeTitle(DocumentLoader * l)429 void FrameLoaderClientWx::didChangeTitle(DocumentLoader *l)
430 {
431 setTitle(l->title(), l->url());
432 }
433
434
finishedLoading(DocumentLoader * loader)435 void FrameLoaderClientWx::finishedLoading(DocumentLoader* loader)
436 {
437 if (!m_pluginView) {
438 if (m_firstData) {
439 loader->writer()->setEncoding(m_response.textEncodingName(), false);
440 m_firstData = false;
441 }
442 } else {
443 m_pluginView->didFinishLoading();
444 m_pluginView = 0;
445 m_hasSentResponseToPlugin = false;
446 }
447 }
448
canShowMIMETypeAsHTML(const String & MIMEType) const449 bool FrameLoaderClientWx::canShowMIMETypeAsHTML(const String& MIMEType) const
450 {
451 notImplemented();
452 return true;
453 }
454
455
canShowMIMEType(const String & MIMEType) const456 bool FrameLoaderClientWx::canShowMIMEType(const String& MIMEType) const
457 {
458 notImplemented();
459 return true;
460 }
461
462
representationExistsForURLScheme(const String & URLScheme) const463 bool FrameLoaderClientWx::representationExistsForURLScheme(const String& URLScheme) const
464 {
465 notImplemented();
466 return false;
467 }
468
469
generatedMIMETypeForURLScheme(const String & URLScheme) const470 String FrameLoaderClientWx::generatedMIMETypeForURLScheme(const String& URLScheme) const
471 {
472 notImplemented();
473 return String();
474 }
475
476
frameLoadCompleted()477 void FrameLoaderClientWx::frameLoadCompleted()
478 {
479 notImplemented();
480 }
481
saveViewStateToItem(HistoryItem *)482 void FrameLoaderClientWx::saveViewStateToItem(HistoryItem*)
483 {
484 notImplemented();
485 }
486
restoreViewState()487 void FrameLoaderClientWx::restoreViewState()
488 {
489 notImplemented();
490 }
491
restoreScrollPositionAndViewState()492 void FrameLoaderClientWx::restoreScrollPositionAndViewState()
493 {
494 notImplemented();
495 }
496
497
provisionalLoadStarted()498 void FrameLoaderClientWx::provisionalLoadStarted()
499 {
500 notImplemented();
501 }
502
503
shouldTreatURLAsSameAsCurrent(const KURL &) const504 bool FrameLoaderClientWx::shouldTreatURLAsSameAsCurrent(const KURL&) const
505 {
506 notImplemented();
507 return false;
508 }
509
510
addHistoryItemForFragmentScroll()511 void FrameLoaderClientWx::addHistoryItemForFragmentScroll()
512 {
513 notImplemented();
514 }
515
516
didFinishLoad()517 void FrameLoaderClientWx::didFinishLoad()
518 {
519 notImplemented();
520 }
521
522
prepareForDataSourceReplacement()523 void FrameLoaderClientWx::prepareForDataSourceReplacement()
524 {
525 notImplemented();
526 }
527
528
setTitle(const StringWithDirection & title,const KURL &)529 void FrameLoaderClientWx::setTitle(const StringWithDirection& title, const KURL&)
530 {
531 notImplemented();
532 }
533
534
userAgent(const KURL &)535 String FrameLoaderClientWx::userAgent(const KURL&)
536 {
537 // FIXME: Use the new APIs introduced by the GTK port to fill in these values.
538 return String("Mozilla/5.0 (Macintosh; Intel Mac OS X) AppleWebKit/418.9.1 (KHTML, like Gecko) Safari/419.3");
539 }
540
dispatchDidReceiveIcon()541 void FrameLoaderClientWx::dispatchDidReceiveIcon()
542 {
543 notImplemented();
544 }
545
frameLoaderDestroyed()546 void FrameLoaderClientWx::frameLoaderDestroyed()
547 {
548 if (m_webFrame)
549 delete m_webFrame;
550 m_webFrame = 0;
551 m_frame = 0;
552 delete this;
553 }
554
canHandleRequest(const WebCore::ResourceRequest &) const555 bool FrameLoaderClientWx::canHandleRequest(const WebCore::ResourceRequest&) const
556 {
557 notImplemented();
558 return true;
559 }
560
partClearedInBegin()561 void FrameLoaderClientWx::partClearedInBegin()
562 {
563 notImplemented();
564 }
565
updateGlobalHistory()566 void FrameLoaderClientWx::updateGlobalHistory()
567 {
568 notImplemented();
569 }
570
updateGlobalHistoryRedirectLinks()571 void FrameLoaderClientWx::updateGlobalHistoryRedirectLinks()
572 {
573 notImplemented();
574 }
575
shouldGoToHistoryItem(WebCore::HistoryItem *) const576 bool FrameLoaderClientWx::shouldGoToHistoryItem(WebCore::HistoryItem*) const
577 {
578 notImplemented();
579 return true;
580 }
581
shouldStopLoadingForHistoryItem(WebCore::HistoryItem *) const582 bool FrameLoaderClientWx::shouldStopLoadingForHistoryItem(WebCore::HistoryItem*) const
583 {
584 return true;
585 }
586
dispatchDidAddBackForwardItem(WebCore::HistoryItem *) const587 void FrameLoaderClientWx::dispatchDidAddBackForwardItem(WebCore::HistoryItem*) const
588 {
589 }
590
dispatchDidRemoveBackForwardItem(WebCore::HistoryItem *) const591 void FrameLoaderClientWx::dispatchDidRemoveBackForwardItem(WebCore::HistoryItem*) const
592 {
593 }
594
dispatchDidChangeBackForwardIndex() const595 void FrameLoaderClientWx::dispatchDidChangeBackForwardIndex() const
596 {
597 }
598
didDisplayInsecureContent()599 void FrameLoaderClientWx::didDisplayInsecureContent()
600 {
601 notImplemented();
602 }
603
didRunInsecureContent(WebCore::SecurityOrigin *,const KURL &)604 void FrameLoaderClientWx::didRunInsecureContent(WebCore::SecurityOrigin*, const KURL&)
605 {
606 notImplemented();
607 }
608
saveScrollPositionAndViewStateToItem(WebCore::HistoryItem *)609 void FrameLoaderClientWx::saveScrollPositionAndViewStateToItem(WebCore::HistoryItem*)
610 {
611 notImplemented();
612 }
613
canCachePage() const614 bool FrameLoaderClientWx::canCachePage() const
615 {
616 return false;
617 }
618
setMainDocumentError(WebCore::DocumentLoader * loader,const WebCore::ResourceError &)619 void FrameLoaderClientWx::setMainDocumentError(WebCore::DocumentLoader* loader, const WebCore::ResourceError&)
620 {
621 if (m_firstData) {
622 loader->writer()->setEncoding(m_response.textEncodingName(), false);
623 m_firstData = false;
624 }
625 }
626
627 // FIXME: This function should be moved into WebCore.
committedLoad(WebCore::DocumentLoader * loader,const char * data,int length)628 void FrameLoaderClientWx::committedLoad(WebCore::DocumentLoader* loader, const char* data, int length)
629 {
630 if (!m_webFrame)
631 return;
632 if (!m_pluginView)
633 loader->commitData(data, length);
634
635 // We re-check here as the plugin can have been created
636 if (m_pluginView) {
637 if (!m_hasSentResponseToPlugin) {
638 m_pluginView->didReceiveResponse(loader->response());
639 // didReceiveResponse sets up a new stream to the plug-in. on a full-page plug-in, a failure in
640 // setting up this stream can cause the main document load to be cancelled, setting m_pluginView
641 // to null
642 if (!m_pluginView)
643 return;
644 m_hasSentResponseToPlugin = true;
645 }
646 m_pluginView->didReceiveData(data, length);
647 }
648 }
649
cancelledError(const WebCore::ResourceRequest & request)650 WebCore::ResourceError FrameLoaderClientWx::cancelledError(const WebCore::ResourceRequest& request)
651 {
652 notImplemented();
653 return ResourceError(String(), WebKitErrorCannotShowURL, request.url().string(), String());
654 }
655
blockedError(const ResourceRequest & request)656 WebCore::ResourceError FrameLoaderClientWx::blockedError(const ResourceRequest& request)
657 {
658 notImplemented();
659 return ResourceError(String(), WebKitErrorCannotShowURL, request.url().string(), String());
660 }
661
cannotShowURLError(const WebCore::ResourceRequest & request)662 WebCore::ResourceError FrameLoaderClientWx::cannotShowURLError(const WebCore::ResourceRequest& request)
663 {
664 return ResourceError(String(), WebKitErrorCannotShowURL, request.url().string(), String());
665 }
666
interruptForPolicyChangeError(const WebCore::ResourceRequest & request)667 WebCore::ResourceError FrameLoaderClientWx::interruptForPolicyChangeError(const WebCore::ResourceRequest& request)
668 {
669 notImplemented();
670 return ResourceError(String(), WebKitErrorFrameLoadInterruptedByPolicyChange, request.url().string(), String());
671 }
672
cannotShowMIMETypeError(const WebCore::ResourceResponse & response)673 WebCore::ResourceError FrameLoaderClientWx::cannotShowMIMETypeError(const WebCore::ResourceResponse& response)
674 {
675 notImplemented();
676 return ResourceError(String(), WebKitErrorCannotShowMIMEType, response.url().string(), String());
677 }
678
fileDoesNotExistError(const WebCore::ResourceResponse & response)679 WebCore::ResourceError FrameLoaderClientWx::fileDoesNotExistError(const WebCore::ResourceResponse& response)
680 {
681 notImplemented();
682 return ResourceError(String(), WebKitErrorCannotShowURL, response.url().string(), String());
683 }
684
shouldFallBack(const WebCore::ResourceError & error)685 bool FrameLoaderClientWx::shouldFallBack(const WebCore::ResourceError& error)
686 {
687 notImplemented();
688 return false;
689 }
690
createDocumentLoader(const ResourceRequest & request,const SubstituteData & substituteData)691 WTF::PassRefPtr<DocumentLoader> FrameLoaderClientWx::createDocumentLoader(const ResourceRequest& request, const SubstituteData& substituteData)
692 {
693 return DocumentLoader::create(request, substituteData);
694 }
695
download(ResourceHandle *,const ResourceRequest &,const ResourceRequest &,const ResourceResponse &)696 void FrameLoaderClientWx::download(ResourceHandle*, const ResourceRequest&, const ResourceRequest&, const ResourceResponse&)
697 {
698 notImplemented();
699 }
700
assignIdentifierToInitialRequest(unsigned long identifier,DocumentLoader *,const ResourceRequest &)701 void FrameLoaderClientWx::assignIdentifierToInitialRequest(unsigned long identifier, DocumentLoader*, const ResourceRequest&)
702 {
703 notImplemented();
704 }
705
dispatchWillSendRequest(DocumentLoader *,unsigned long,ResourceRequest & request,const ResourceResponse & response)706 void FrameLoaderClientWx::dispatchWillSendRequest(DocumentLoader*, unsigned long, ResourceRequest& request, const ResourceResponse& response)
707 {
708 notImplemented();
709 }
710
shouldUseCredentialStorage(DocumentLoader *,unsigned long)711 bool FrameLoaderClientWx::shouldUseCredentialStorage(DocumentLoader*, unsigned long)
712 {
713 notImplemented();
714 return false;
715 }
716
dispatchDidReceiveAuthenticationChallenge(DocumentLoader *,unsigned long,const AuthenticationChallenge &)717 void FrameLoaderClientWx::dispatchDidReceiveAuthenticationChallenge(DocumentLoader*, unsigned long, const AuthenticationChallenge&)
718 {
719 notImplemented();
720 }
721
dispatchDidCancelAuthenticationChallenge(DocumentLoader *,unsigned long,const AuthenticationChallenge &)722 void FrameLoaderClientWx::dispatchDidCancelAuthenticationChallenge(DocumentLoader*, unsigned long, const AuthenticationChallenge&)
723 {
724 notImplemented();
725 }
726
dispatchDidReceiveResponse(DocumentLoader * loader,unsigned long id,const ResourceResponse & response)727 void FrameLoaderClientWx::dispatchDidReceiveResponse(DocumentLoader* loader, unsigned long id, const ResourceResponse& response)
728 {
729 notImplemented();
730 m_response = response;
731 m_firstData = true;
732 }
733
dispatchDidReceiveContentLength(DocumentLoader * loader,unsigned long id,int length)734 void FrameLoaderClientWx::dispatchDidReceiveContentLength(DocumentLoader* loader, unsigned long id, int length)
735 {
736 notImplemented();
737 }
738
dispatchDidFinishLoading(DocumentLoader *,unsigned long)739 void FrameLoaderClientWx::dispatchDidFinishLoading(DocumentLoader*, unsigned long)
740 {
741 notImplemented();
742 }
743
dispatchDidFailLoading(DocumentLoader * loader,unsigned long,const ResourceError &)744 void FrameLoaderClientWx::dispatchDidFailLoading(DocumentLoader* loader, unsigned long, const ResourceError&)
745 {
746 if (m_firstData) {
747 loader->writer()->setEncoding(m_response.textEncodingName(), false);
748 m_firstData = false;
749 }
750 if (m_webView) {
751 wxWebViewLoadEvent wkEvent(m_webView);
752 wkEvent.SetState(wxWEBVIEW_LOAD_FAILED);
753 wkEvent.SetURL(m_frame->loader()->documentLoader()->request().url().string());
754 m_webView->GetEventHandler()->ProcessEvent(wkEvent);
755 }
756 }
757
dispatchDidLoadResourceFromMemoryCache(DocumentLoader *,const ResourceRequest &,const ResourceResponse &,int)758 bool FrameLoaderClientWx::dispatchDidLoadResourceFromMemoryCache(DocumentLoader*, const ResourceRequest&, const ResourceResponse&, int)
759 {
760 notImplemented();
761 return false;
762 }
763
dispatchDidFailProvisionalLoad(const ResourceError &)764 void FrameLoaderClientWx::dispatchDidFailProvisionalLoad(const ResourceError&)
765 {
766 notImplemented();
767 }
768
dispatchDidFailLoad(const ResourceError &)769 void FrameLoaderClientWx::dispatchDidFailLoad(const ResourceError&)
770 {
771 notImplemented();
772 }
773
dispatchCreatePage(const NavigationAction &)774 Frame* FrameLoaderClientWx::dispatchCreatePage(const NavigationAction&)
775 {
776 notImplemented();
777 return false;
778 }
779
dispatchDecidePolicyForResponse(FramePolicyFunction function,const ResourceResponse & response,const ResourceRequest & request)780 void FrameLoaderClientWx::dispatchDecidePolicyForResponse(FramePolicyFunction function, const ResourceResponse& response, const ResourceRequest& request)
781 {
782 if (!m_webFrame)
783 return;
784
785 notImplemented();
786 (m_frame->loader()->policyChecker()->*function)(PolicyUse);
787 }
788
dispatchDecidePolicyForNewWindowAction(FramePolicyFunction function,const NavigationAction &,const ResourceRequest & request,PassRefPtr<FormState>,const String & targetName)789 void FrameLoaderClientWx::dispatchDecidePolicyForNewWindowAction(FramePolicyFunction function, const NavigationAction&, const ResourceRequest& request, PassRefPtr<FormState>, const String& targetName)
790 {
791 if (!m_webFrame)
792 return;
793
794 if (m_webView) {
795 wxWebViewNewWindowEvent wkEvent(m_webView);
796 wkEvent.SetURL(request.url().string());
797 wkEvent.SetTargetName(targetName);
798 if (m_webView->GetEventHandler()->ProcessEvent(wkEvent)) {
799 // if the app handles and doesn't skip the event,
800 // from WebKit's perspective treat it as blocked / ignored
801 (m_frame->loader()->policyChecker()->*function)(PolicyIgnore);
802 return;
803 }
804 }
805
806 (m_frame->loader()->policyChecker()->*function)(PolicyUse);
807 }
808
dispatchDecidePolicyForNavigationAction(FramePolicyFunction function,const NavigationAction & action,const ResourceRequest & request,PassRefPtr<FormState>)809 void FrameLoaderClientWx::dispatchDecidePolicyForNavigationAction(FramePolicyFunction function, const NavigationAction& action, const ResourceRequest& request, PassRefPtr<FormState>)
810 {
811 if (!m_webFrame)
812 return;
813
814 if (m_webView) {
815 wxWebViewBeforeLoadEvent wkEvent(m_webView);
816 wkEvent.SetNavigationType(wxNavTypeFromWebNavType(action.type()));
817 wkEvent.SetURL(request.url().string());
818
819 m_webView->GetEventHandler()->ProcessEvent(wkEvent);
820 if (wkEvent.IsCancelled())
821 (m_frame->loader()->policyChecker()->*function)(PolicyIgnore);
822 else
823 (m_frame->loader()->policyChecker()->*function)(PolicyUse);
824
825 }
826 }
827
dispatchUnableToImplementPolicy(const ResourceError &)828 void FrameLoaderClientWx::dispatchUnableToImplementPolicy(const ResourceError&)
829 {
830 notImplemented();
831 }
832
startDownload(const ResourceRequest &)833 void FrameLoaderClientWx::startDownload(const ResourceRequest&)
834 {
835 notImplemented();
836 }
837
createFrame(const KURL & url,const String & name,HTMLFrameOwnerElement * ownerElement,const String & referrer,bool allowsScrolling,int marginWidth,int marginHeight)838 PassRefPtr<Frame> FrameLoaderClientWx::createFrame(const KURL& url, const String& name, HTMLFrameOwnerElement* ownerElement,
839 const String& referrer, bool allowsScrolling, int marginWidth, int marginHeight)
840 {
841 WebViewFrameData* data = new WebViewFrameData();
842 data->name = name;
843 data->ownerElement = ownerElement;
844 data->url = url;
845 data->referrer = referrer;
846 data->allowsScrolling = allowsScrolling;
847 data->marginWidth = marginWidth;
848 data->marginHeight = marginHeight;
849
850 wxWebFrame* newFrame = new wxWebFrame(m_webView, m_webFrame, data);
851
852 RefPtr<Frame> childFrame = adoptRef(newFrame->m_impl->frame);
853
854 // The creation of the frame may have run arbitrary JavaScript that removed it from the page already.
855 if (!childFrame->page())
856 return 0;
857
858 m_frame->loader()->loadURLIntoChildFrame(url, referrer, childFrame.get());
859
860 // The frame's onload handler may have removed it from the document.
861 if (!childFrame->tree()->parent())
862 return 0;
863
864 return childFrame.release();
865 }
866
didTransferChildFrameToNewDocument(Page *)867 void FrameLoaderClientWx::didTransferChildFrameToNewDocument(Page*)
868 {
869 }
870
transferLoadingResourceFromPage(unsigned long,DocumentLoader *,const ResourceRequest &,Page *)871 void FrameLoaderClientWx::transferLoadingResourceFromPage(unsigned long, DocumentLoader*, const ResourceRequest&, Page*)
872 {
873 }
874
objectContentType(const KURL & url,const String & mimeType,bool shouldPreferPlugInsForImages)875 ObjectContentType FrameLoaderClientWx::objectContentType(const KURL& url, const String& mimeType, bool shouldPreferPlugInsForImages)
876 {
877 notImplemented();
878 return ObjectContentType();
879 }
880
createPlugin(const IntSize & size,HTMLPlugInElement * element,const KURL & url,const Vector<String> & paramNames,const Vector<String> & paramValues,const String & mimeType,bool loadManually)881 PassRefPtr<Widget> FrameLoaderClientWx::createPlugin(const IntSize& size, HTMLPlugInElement* element, const KURL& url, const Vector<String>& paramNames, const Vector<String>& paramValues, const String& mimeType, bool loadManually)
882 {
883 #if __WXMSW__ || __WXMAC__
884 RefPtr<PluginView> pv = PluginView::create(m_frame, size, element, url, paramNames, paramValues, mimeType, loadManually);
885 if (pv->status() == PluginStatusLoadedSuccessfully)
886 return pv;
887 #endif
888 return 0;
889 }
890
redirectDataToPlugin(Widget * pluginWidget)891 void FrameLoaderClientWx::redirectDataToPlugin(Widget* pluginWidget)
892 {
893 ASSERT(!m_pluginView);
894 m_pluginView = static_cast<PluginView*>(pluginWidget);
895 m_hasSentResponseToPlugin = false;
896 }
897
pluginWillHandleLoadError(const ResourceResponse & response)898 ResourceError FrameLoaderClientWx::pluginWillHandleLoadError(const ResourceResponse& response)
899 {
900 notImplemented();
901 return ResourceError(String(), WebKitErrorCannotLoadPlugIn, response.url().string(), String());
902 }
903
createJavaAppletWidget(const IntSize &,HTMLAppletElement *,const KURL & baseURL,const Vector<String> & paramNames,const Vector<String> & paramValues)904 PassRefPtr<Widget> FrameLoaderClientWx::createJavaAppletWidget(const IntSize&, HTMLAppletElement*, const KURL& baseURL,
905 const Vector<String>& paramNames, const Vector<String>& paramValues)
906 {
907 notImplemented();
908 return 0;
909 }
910
overrideMediaType() const911 String FrameLoaderClientWx::overrideMediaType() const
912 {
913 notImplemented();
914 return String();
915 }
916
dispatchDidClearWindowObjectInWorld(DOMWrapperWorld * world)917 void FrameLoaderClientWx::dispatchDidClearWindowObjectInWorld(DOMWrapperWorld* world)
918 {
919 if (world != mainThreadNormalWorld())
920 return;
921
922 if (m_webView) {
923 wxWebViewWindowObjectClearedEvent wkEvent(m_webView);
924 Frame* coreFrame = m_webView->GetMainFrame()->GetFrame();
925 JSGlobalContextRef context = toGlobalRef(coreFrame->script()->globalObject(mainThreadNormalWorld())->globalExec());
926 JSObjectRef windowObject = toRef(coreFrame->script()->globalObject(mainThreadNormalWorld()));
927 wkEvent.SetJSContext(context);
928 wkEvent.SetWindowObject(windowObject);
929 m_webView->GetEventHandler()->ProcessEvent(wkEvent);
930 }
931 }
932
documentElementAvailable()933 void FrameLoaderClientWx::documentElementAvailable()
934 {
935 }
936
didPerformFirstNavigation() const937 void FrameLoaderClientWx::didPerformFirstNavigation() const
938 {
939 notImplemented();
940 }
941
registerForIconNotification(bool listen)942 void FrameLoaderClientWx::registerForIconNotification(bool listen)
943 {
944 notImplemented();
945 }
946
savePlatformDataToCachedFrame(CachedFrame *)947 void FrameLoaderClientWx::savePlatformDataToCachedFrame(CachedFrame*)
948 {
949 notImplemented();
950 }
951
transitionToCommittedFromCachedFrame(CachedFrame *)952 void FrameLoaderClientWx::transitionToCommittedFromCachedFrame(CachedFrame*)
953 {
954 notImplemented();
955 }
956
transitionToCommittedForNewPage()957 void FrameLoaderClientWx::transitionToCommittedForNewPage()
958 {
959 ASSERT(m_webFrame);
960 ASSERT(m_frame);
961 ASSERT(m_webView);
962
963 IntSize size = IntRect(m_webView->GetRect()).size();
964 // FIXME: This value should be gotten from m_webView->IsTransparent();
965 // but transitionToCommittedForNewPage() can be called while m_webView is
966 // still being initialized.
967 bool transparent = false;
968 Color backgroundColor = transparent ? WebCore::Color::transparent : WebCore::Color::white;
969
970 if (m_frame)
971 m_frame->createView(size, backgroundColor, transparent, IntSize(), false);
972 }
973
didSaveToPageCache()974 void FrameLoaderClientWx::didSaveToPageCache()
975 {
976 }
977
didRestoreFromPageCache()978 void FrameLoaderClientWx::didRestoreFromPageCache()
979 {
980 }
981
dispatchDidBecomeFrameset(bool)982 void FrameLoaderClientWx::dispatchDidBecomeFrameset(bool)
983 {
984 }
985
shouldUsePluginDocument(const String & mimeType) const986 bool FrameLoaderClientWx::shouldUsePluginDocument(const String &mimeType) const
987 {
988 // NOTE: Plugin Documents are used for viewing PDFs, etc. inline, and should
989 // not be used for pages with plugins in them.
990 return false;
991 }
992
createNetworkingContext()993 PassRefPtr<FrameNetworkingContext> FrameLoaderClientWx::createNetworkingContext()
994 {
995 return FrameNetworkingContextWx::create(m_frame);
996 }
997
998 }
999