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