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