• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 "HTMLFormElement.h"
41 #include "HTMLFrameOwnerElement.h"
42 #include "NotImplemented.h"
43 #include "Page.h"
44 #include "PlatformString.h"
45 #include "ProgressTracker.h"
46 #include "RenderPart.h"
47 #include "ResourceError.h"
48 #include "ResourceResponse.h"
49 #include "ScriptController.h"
50 #include "ScriptString.h"
51 
52 #include <stdio.h>
53 
54 #include "WebFrame.h"
55 #include "WebView.h"
56 #include "WebViewPrivate.h"
57 
58 namespace WebCore {
59 
wxNavTypeFromWebNavType(NavigationType type)60 inline int wxNavTypeFromWebNavType(NavigationType type){
61     if (type == NavigationTypeLinkClicked)
62         return wxWEBVIEW_NAV_LINK_CLICKED;
63 
64     if (type == NavigationTypeFormSubmitted)
65         return wxWEBVIEW_NAV_FORM_SUBMITTED;
66 
67     if (type == NavigationTypeBackForward)
68         return wxWEBVIEW_NAV_BACK_NEXT;
69 
70     if (type == NavigationTypeReload)
71         return wxWEBVIEW_NAV_RELOAD;
72 
73     if (type == NavigationTypeFormResubmitted)
74         return wxWEBVIEW_NAV_FORM_RESUBMITTED;
75 
76     return wxWEBVIEW_NAV_OTHER;
77 }
78 
FrameLoaderClientWx()79 FrameLoaderClientWx::FrameLoaderClientWx()
80     : m_frame(0)
81 {
82 }
83 
84 
~FrameLoaderClientWx()85 FrameLoaderClientWx::~FrameLoaderClientWx()
86 {
87 }
88 
setFrame(Frame * frame)89 void FrameLoaderClientWx::setFrame(Frame *frame)
90 {
91     m_frame = frame;
92 }
93 
setWebView(wxWebView * webview)94 void FrameLoaderClientWx::setWebView(wxWebView *webview)
95 {
96     m_webView = webview;
97 }
98 
detachFrameLoader()99 void FrameLoaderClientWx::detachFrameLoader()
100 {
101     m_frame = 0;
102 }
103 
hasWebView() const104 bool FrameLoaderClientWx::hasWebView() const
105 {
106     return m_webView != NULL;
107 }
108 
hasBackForwardList() const109 bool FrameLoaderClientWx::hasBackForwardList() const
110 {
111     notImplemented();
112     return true;
113 }
114 
115 
resetBackForwardList()116 void FrameLoaderClientWx::resetBackForwardList()
117 {
118     notImplemented();
119 }
120 
121 
provisionalItemIsTarget() const122 bool FrameLoaderClientWx::provisionalItemIsTarget() const
123 {
124     notImplemented();
125     return false;
126 }
127 
makeRepresentation(DocumentLoader *)128 void FrameLoaderClientWx::makeRepresentation(DocumentLoader*)
129 {
130     notImplemented();
131 }
132 
133 
forceLayout()134 void FrameLoaderClientWx::forceLayout()
135 {
136     notImplemented();
137 }
138 
139 
forceLayoutForNonHTML()140 void FrameLoaderClientWx::forceLayoutForNonHTML()
141 {
142     notImplemented();
143 }
144 
145 
updateHistoryForCommit()146 void FrameLoaderClientWx::updateHistoryForCommit()
147 {
148     notImplemented();
149 }
150 
151 
updateHistoryForBackForwardNavigation()152 void FrameLoaderClientWx::updateHistoryForBackForwardNavigation()
153 {
154     notImplemented();
155 }
156 
157 
updateHistoryForReload()158 void FrameLoaderClientWx::updateHistoryForReload()
159 {
160     notImplemented();
161 }
162 
163 
updateHistoryForStandardLoad()164 void FrameLoaderClientWx::updateHistoryForStandardLoad()
165 {
166     notImplemented();
167 }
168 
169 
updateHistoryForInternalLoad()170 void FrameLoaderClientWx::updateHistoryForInternalLoad()
171 {
172     notImplemented();
173 }
174 
175 
updateHistoryAfterClientRedirect()176 void FrameLoaderClientWx::updateHistoryAfterClientRedirect()
177 {
178     notImplemented();
179 }
180 
181 
setCopiesOnScroll()182 void FrameLoaderClientWx::setCopiesOnScroll()
183 {
184     // apparently mac specific
185     notImplemented();
186 }
187 
188 
tokenForLoadErrorReset()189 LoadErrorResetToken* FrameLoaderClientWx::tokenForLoadErrorReset()
190 {
191     notImplemented();
192     return 0;
193 }
194 
195 
resetAfterLoadError(LoadErrorResetToken *)196 void FrameLoaderClientWx::resetAfterLoadError(LoadErrorResetToken*)
197 {
198     notImplemented();
199 }
200 
201 
doNotResetAfterLoadError(LoadErrorResetToken *)202 void FrameLoaderClientWx::doNotResetAfterLoadError(LoadErrorResetToken*)
203 {
204     notImplemented();
205 }
206 
207 
willCloseDocument()208 void FrameLoaderClientWx::willCloseDocument()
209 {
210     notImplemented();
211 }
212 
213 
detachedFromParent2()214 void FrameLoaderClientWx::detachedFromParent2()
215 {
216     notImplemented();
217 }
218 
219 
detachedFromParent3()220 void FrameLoaderClientWx::detachedFromParent3()
221 {
222     notImplemented();
223 }
224 
dispatchDidHandleOnloadEvents()225 void FrameLoaderClientWx::dispatchDidHandleOnloadEvents()
226 {
227     if (m_webView) {
228         wxWebViewLoadEvent wkEvent(m_webView);
229         wkEvent.SetState(wxWEBVIEW_LOAD_ONLOAD_HANDLED);
230         wkEvent.SetURL(m_frame->loader()->documentLoader()->request().url().string());
231         m_webView->GetEventHandler()->ProcessEvent(wkEvent);
232     }
233 }
234 
235 
dispatchDidReceiveServerRedirectForProvisionalLoad()236 void FrameLoaderClientWx::dispatchDidReceiveServerRedirectForProvisionalLoad()
237 {
238     notImplemented();
239 }
240 
241 
dispatchDidCancelClientRedirect()242 void FrameLoaderClientWx::dispatchDidCancelClientRedirect()
243 {
244     notImplemented();
245 }
246 
247 
dispatchWillPerformClientRedirect(const KURL &,double interval,double fireDate)248 void FrameLoaderClientWx::dispatchWillPerformClientRedirect(const KURL&,
249                                                             double interval,
250                                                             double fireDate)
251 {
252     notImplemented();
253 }
254 
255 
dispatchDidChangeLocationWithinPage()256 void FrameLoaderClientWx::dispatchDidChangeLocationWithinPage()
257 {
258     notImplemented();
259 }
260 
261 
dispatchWillClose()262 void FrameLoaderClientWx::dispatchWillClose()
263 {
264     notImplemented();
265 }
266 
267 
dispatchDidStartProvisionalLoad()268 void FrameLoaderClientWx::dispatchDidStartProvisionalLoad()
269 {
270     if (m_webView) {
271         wxWebViewLoadEvent wkEvent(m_webView);
272         wkEvent.SetState(wxWEBVIEW_LOAD_NEGOTIATING);
273         wkEvent.SetURL(m_frame->loader()->provisionalDocumentLoader()->request().url().string());
274         m_webView->GetEventHandler()->ProcessEvent(wkEvent);
275     }
276 }
277 
278 
dispatchDidReceiveTitle(const String & title)279 void FrameLoaderClientWx::dispatchDidReceiveTitle(const String& title)
280 {
281     if (m_webView) {
282         m_webView->SetPageTitle(title);
283         wxWebViewReceivedTitleEvent wkEvent(m_webView);
284         wkEvent.SetTitle(title);
285         m_webView->GetEventHandler()->ProcessEvent(wkEvent);
286     }
287 }
288 
289 
dispatchDidCommitLoad()290 void FrameLoaderClientWx::dispatchDidCommitLoad()
291 {
292     if (m_webView) {
293         wxWebViewLoadEvent wkEvent(m_webView);
294         wkEvent.SetState(wxWEBVIEW_LOAD_TRANSFERRING);
295         wkEvent.SetURL(m_frame->loader()->documentLoader()->request().url().string());
296         m_webView->GetEventHandler()->ProcessEvent(wkEvent);
297     }
298 }
299 
dispatchDidFinishDocumentLoad()300 void FrameLoaderClientWx::dispatchDidFinishDocumentLoad()
301 {
302     if (m_webView) {
303         wxWebViewLoadEvent wkEvent(m_webView);
304         wkEvent.SetState(wxWEBVIEW_LOAD_DOC_COMPLETED);
305         wkEvent.SetURL(m_frame->loader()->url().string());
306         m_webView->GetEventHandler()->ProcessEvent(wkEvent);
307     }
308 }
309 
dispatchDidFinishLoad()310 void FrameLoaderClientWx::dispatchDidFinishLoad()
311 {
312     notImplemented();
313 }
314 
315 
dispatchDidFirstLayout()316 void FrameLoaderClientWx::dispatchDidFirstLayout()
317 {
318     notImplemented();
319 }
320 
dispatchDidFirstVisuallyNonEmptyLayout()321 void FrameLoaderClientWx::dispatchDidFirstVisuallyNonEmptyLayout()
322 {
323     notImplemented();
324 }
325 
dispatchShow()326 void FrameLoaderClientWx::dispatchShow()
327 {
328     notImplemented();
329 }
330 
331 
cancelPolicyCheck()332 void FrameLoaderClientWx::cancelPolicyCheck()
333 {
334     notImplemented();
335 }
336 
337 
dispatchWillSubmitForm(FramePolicyFunction function,PassRefPtr<FormState>)338 void FrameLoaderClientWx::dispatchWillSubmitForm(FramePolicyFunction function,
339                                                  PassRefPtr<FormState>)
340 {
341     // FIXME: Send an event to allow for alerts and cancellation
342     if (!m_frame)
343         return;
344     (m_frame->loader()->*function)(PolicyUse);
345 }
346 
347 
dispatchDidLoadMainResource(DocumentLoader *)348 void FrameLoaderClientWx::dispatchDidLoadMainResource(DocumentLoader*)
349 {
350     notImplemented();
351 }
352 
353 
revertToProvisionalState(DocumentLoader *)354 void FrameLoaderClientWx::revertToProvisionalState(DocumentLoader*)
355 {
356     notImplemented();
357 }
358 
postProgressStartedNotification()359 void FrameLoaderClientWx::postProgressStartedNotification()
360 {
361     notImplemented();
362 }
363 
postProgressEstimateChangedNotification()364 void FrameLoaderClientWx::postProgressEstimateChangedNotification()
365 {
366     notImplemented();
367 }
368 
postProgressFinishedNotification()369 void FrameLoaderClientWx::postProgressFinishedNotification()
370 {
371     if (m_webView) {
372         wxWebViewLoadEvent wkEvent(m_webView);
373         wkEvent.SetState(wxWEBVIEW_LOAD_DL_COMPLETED);
374         wkEvent.SetURL(m_frame->loader()->url().string());
375         m_webView->GetEventHandler()->ProcessEvent(wkEvent);
376     }
377 }
378 
progressStarted()379 void FrameLoaderClientWx::progressStarted()
380 {
381     notImplemented();
382 }
383 
384 
progressCompleted()385 void FrameLoaderClientWx::progressCompleted()
386 {
387     notImplemented();
388 }
389 
390 
setMainFrameDocumentReady(bool b)391 void FrameLoaderClientWx::setMainFrameDocumentReady(bool b)
392 {
393     notImplemented();
394     // this is only interesting once we provide an external API for the DOM
395 }
396 
397 
willChangeTitle(DocumentLoader *)398 void FrameLoaderClientWx::willChangeTitle(DocumentLoader*)
399 {
400     notImplemented();
401 }
402 
403 
didChangeTitle(DocumentLoader * l)404 void FrameLoaderClientWx::didChangeTitle(DocumentLoader *l)
405 {
406     setTitle(l->title(), l->url());
407 }
408 
409 
finishedLoading(DocumentLoader *)410 void FrameLoaderClientWx::finishedLoading(DocumentLoader*)
411 {
412     notImplemented();
413 }
414 
415 
canShowMIMEType(const String & MIMEType) const416 bool FrameLoaderClientWx::canShowMIMEType(const String& MIMEType) const
417 {
418     notImplemented();
419     return true;
420 }
421 
422 
representationExistsForURLScheme(const String & URLScheme) const423 bool FrameLoaderClientWx::representationExistsForURLScheme(const String& URLScheme) const
424 {
425     notImplemented();
426     return false;
427 }
428 
429 
generatedMIMETypeForURLScheme(const String & URLScheme) const430 String FrameLoaderClientWx::generatedMIMETypeForURLScheme(const String& URLScheme) const
431 {
432     notImplemented();
433     return String();
434 }
435 
436 
frameLoadCompleted()437 void FrameLoaderClientWx::frameLoadCompleted()
438 {
439     notImplemented();
440 }
441 
saveViewStateToItem(HistoryItem *)442 void FrameLoaderClientWx::saveViewStateToItem(HistoryItem*)
443 {
444     notImplemented();
445 }
446 
restoreViewState()447 void FrameLoaderClientWx::restoreViewState()
448 {
449     notImplemented();
450 }
451 
restoreScrollPositionAndViewState()452 void FrameLoaderClientWx::restoreScrollPositionAndViewState()
453 {
454     notImplemented();
455 }
456 
457 
provisionalLoadStarted()458 void FrameLoaderClientWx::provisionalLoadStarted()
459 {
460     notImplemented();
461 }
462 
463 
shouldTreatURLAsSameAsCurrent(const KURL &) const464 bool FrameLoaderClientWx::shouldTreatURLAsSameAsCurrent(const KURL&) const
465 {
466     notImplemented();
467     return false;
468 }
469 
470 
addHistoryItemForFragmentScroll()471 void FrameLoaderClientWx::addHistoryItemForFragmentScroll()
472 {
473     notImplemented();
474 }
475 
476 
didFinishLoad()477 void FrameLoaderClientWx::didFinishLoad()
478 {
479     notImplemented();
480 }
481 
482 
prepareForDataSourceReplacement()483 void FrameLoaderClientWx::prepareForDataSourceReplacement()
484 {
485     notImplemented();
486 }
487 
488 
setTitle(const String & title,const KURL &)489 void FrameLoaderClientWx::setTitle(const String& title, const KURL&)
490 {
491     notImplemented();
492 }
493 
494 
userAgent(const KURL &)495 String FrameLoaderClientWx::userAgent(const KURL&)
496 {
497     // FIXME: Use the new APIs introduced by the GTK port to fill in these values.
498     return String("Mozilla/5.0 (Macintosh; U; Intel Mac OS X; en) AppleWebKit/418.9.1 (KHTML, like Gecko) Safari/419.3");
499 }
500 
dispatchDidReceiveIcon()501 void FrameLoaderClientWx::dispatchDidReceiveIcon()
502 {
503     notImplemented();
504 }
505 
frameLoaderDestroyed()506 void FrameLoaderClientWx::frameLoaderDestroyed()
507 {
508     m_frame = 0;
509     delete this;
510 }
511 
canHandleRequest(const WebCore::ResourceRequest &) const512 bool FrameLoaderClientWx::canHandleRequest(const WebCore::ResourceRequest&) const
513 {
514     notImplemented();
515     return true;
516 }
517 
partClearedInBegin()518 void FrameLoaderClientWx::partClearedInBegin()
519 {
520     notImplemented();
521 }
522 
updateGlobalHistory()523 void FrameLoaderClientWx::updateGlobalHistory()
524 {
525     notImplemented();
526 }
527 
updateGlobalHistoryRedirectLinks()528 void FrameLoaderClientWx::updateGlobalHistoryRedirectLinks()
529 {
530     notImplemented();
531 }
532 
shouldGoToHistoryItem(WebCore::HistoryItem *) const533 bool FrameLoaderClientWx::shouldGoToHistoryItem(WebCore::HistoryItem*) const
534 {
535     notImplemented();
536     return true;
537 }
538 
saveScrollPositionAndViewStateToItem(WebCore::HistoryItem *)539 void FrameLoaderClientWx::saveScrollPositionAndViewStateToItem(WebCore::HistoryItem*)
540 {
541     notImplemented();
542 }
543 
canCachePage() const544 bool FrameLoaderClientWx::canCachePage() const
545 {
546     return false;
547 }
548 
setMainDocumentError(WebCore::DocumentLoader *,const WebCore::ResourceError &)549 void FrameLoaderClientWx::setMainDocumentError(WebCore::DocumentLoader*, const WebCore::ResourceError&)
550 {
551     notImplemented();
552 }
553 
committedLoad(WebCore::DocumentLoader * loader,const char * data,int length)554 void FrameLoaderClientWx::committedLoad(WebCore::DocumentLoader* loader, const char* data, int length)
555 {
556     if (!m_frame)
557         return;
558     FrameLoader* fl = loader->frameLoader();
559     fl->setEncoding(m_response.textEncodingName(), false);
560     fl->addData(data, length);
561 }
562 
cancelledError(const WebCore::ResourceRequest & request)563 WebCore::ResourceError FrameLoaderClientWx::cancelledError(const WebCore::ResourceRequest& request)
564 {
565     notImplemented();
566     return ResourceError(String(), WebKitErrorCannotShowURL, request.url().string(), String());
567 }
568 
blockedError(const ResourceRequest & request)569 WebCore::ResourceError FrameLoaderClientWx::blockedError(const ResourceRequest& request)
570 {
571     notImplemented();
572     return ResourceError(String(), WebKitErrorCannotShowURL, request.url().string(), String());
573 }
574 
cannotShowURLError(const WebCore::ResourceRequest & request)575 WebCore::ResourceError FrameLoaderClientWx::cannotShowURLError(const WebCore::ResourceRequest& request)
576 {
577     return ResourceError(String(), WebKitErrorCannotShowURL, request.url().string(), String());
578 }
579 
interruptForPolicyChangeError(const WebCore::ResourceRequest & request)580 WebCore::ResourceError FrameLoaderClientWx::interruptForPolicyChangeError(const WebCore::ResourceRequest& request)
581 {
582     notImplemented();
583     return ResourceError(String(), WebKitErrorFrameLoadInterruptedByPolicyChange, request.url().string(), String());
584 }
585 
cannotShowMIMETypeError(const WebCore::ResourceResponse & response)586 WebCore::ResourceError FrameLoaderClientWx::cannotShowMIMETypeError(const WebCore::ResourceResponse& response)
587 {
588     notImplemented();
589     return ResourceError(String(), WebKitErrorCannotShowMIMEType, response.url().string(), String());
590 }
591 
fileDoesNotExistError(const WebCore::ResourceResponse & response)592 WebCore::ResourceError FrameLoaderClientWx::fileDoesNotExistError(const WebCore::ResourceResponse& response)
593 {
594     notImplemented();
595     return ResourceError(String(), WebKitErrorCannotShowURL, response.url().string(), String());
596 }
597 
shouldFallBack(const WebCore::ResourceError & error)598 bool FrameLoaderClientWx::shouldFallBack(const WebCore::ResourceError& error)
599 {
600     notImplemented();
601     return false;
602 }
603 
createDocumentLoader(const ResourceRequest & request,const SubstituteData & substituteData)604 WTF::PassRefPtr<DocumentLoader> FrameLoaderClientWx::createDocumentLoader(const ResourceRequest& request, const SubstituteData& substituteData)
605 {
606     return DocumentLoader::create(request, substituteData);
607 }
608 
download(ResourceHandle *,const ResourceRequest &,const ResourceRequest &,const ResourceResponse &)609 void FrameLoaderClientWx::download(ResourceHandle*, const ResourceRequest&, const ResourceRequest&, const ResourceResponse&)
610 {
611     notImplemented();
612 }
613 
assignIdentifierToInitialRequest(unsigned long identifier,DocumentLoader *,const ResourceRequest &)614 void FrameLoaderClientWx::assignIdentifierToInitialRequest(unsigned long identifier, DocumentLoader*, const ResourceRequest&)
615 {
616     notImplemented();
617 }
618 
dispatchWillSendRequest(DocumentLoader *,unsigned long,ResourceRequest & request,const ResourceResponse & response)619 void FrameLoaderClientWx::dispatchWillSendRequest(DocumentLoader*, unsigned long, ResourceRequest& request, const ResourceResponse& response)
620 {
621     notImplemented();
622 }
623 
shouldUseCredentialStorage(DocumentLoader *,unsigned long)624 bool FrameLoaderClientWx::shouldUseCredentialStorage(DocumentLoader*, unsigned long)
625 {
626     notImplemented();
627     return false;
628 }
629 
dispatchDidReceiveAuthenticationChallenge(DocumentLoader *,unsigned long,const AuthenticationChallenge &)630 void FrameLoaderClientWx::dispatchDidReceiveAuthenticationChallenge(DocumentLoader*, unsigned long, const AuthenticationChallenge&)
631 {
632     notImplemented();
633 }
634 
dispatchDidCancelAuthenticationChallenge(DocumentLoader *,unsigned long,const AuthenticationChallenge &)635 void FrameLoaderClientWx::dispatchDidCancelAuthenticationChallenge(DocumentLoader*, unsigned long, const AuthenticationChallenge&)
636 {
637     notImplemented();
638 }
639 
dispatchDidReceiveResponse(DocumentLoader * loader,unsigned long id,const ResourceResponse & response)640 void FrameLoaderClientWx::dispatchDidReceiveResponse(DocumentLoader* loader, unsigned long id, const ResourceResponse& response)
641 {
642     notImplemented();
643     m_response = response;
644     m_firstData = true;
645 }
646 
dispatchDidReceiveContentLength(DocumentLoader * loader,unsigned long id,int length)647 void FrameLoaderClientWx::dispatchDidReceiveContentLength(DocumentLoader* loader, unsigned long id, int length)
648 {
649     notImplemented();
650 }
651 
dispatchDidFinishLoading(DocumentLoader *,unsigned long)652 void FrameLoaderClientWx::dispatchDidFinishLoading(DocumentLoader*, unsigned long)
653 {
654     notImplemented();
655 }
656 
dispatchDidFailLoading(DocumentLoader *,unsigned long,const ResourceError &)657 void FrameLoaderClientWx::dispatchDidFailLoading(DocumentLoader*, unsigned long, const ResourceError&)
658 {
659     if (m_webView) {
660         wxWebViewLoadEvent wkEvent(m_webView);
661         wkEvent.SetState(wxWEBVIEW_LOAD_FAILED);
662         wkEvent.SetURL(m_frame->loader()->documentLoader()->request().url().string());
663         m_webView->GetEventHandler()->ProcessEvent(wkEvent);
664     }
665 }
666 
dispatchDidLoadResourceFromMemoryCache(DocumentLoader *,const ResourceRequest &,const ResourceResponse &,int)667 bool FrameLoaderClientWx::dispatchDidLoadResourceFromMemoryCache(DocumentLoader*, const ResourceRequest&, const ResourceResponse&, int)
668 {
669     notImplemented();
670     return false;
671 }
672 
dispatchDidLoadResourceByXMLHttpRequest(unsigned long,const ScriptString &)673 void FrameLoaderClientWx::dispatchDidLoadResourceByXMLHttpRequest(unsigned long, const ScriptString&)
674 {
675   notImplemented();
676 }
677 
dispatchDidFailProvisionalLoad(const ResourceError &)678 void FrameLoaderClientWx::dispatchDidFailProvisionalLoad(const ResourceError&)
679 {
680     notImplemented();
681 }
682 
dispatchDidFailLoad(const ResourceError &)683 void FrameLoaderClientWx::dispatchDidFailLoad(const ResourceError&)
684 {
685     notImplemented();
686 }
687 
dispatchCreatePage()688 Frame* FrameLoaderClientWx::dispatchCreatePage()
689 {
690     notImplemented();
691     return false;
692 }
693 
dispatchDecidePolicyForMIMEType(FramePolicyFunction function,const String & mimetype,const ResourceRequest & request)694 void FrameLoaderClientWx::dispatchDecidePolicyForMIMEType(FramePolicyFunction function, const String& mimetype, const ResourceRequest& request)
695 {
696     if (!m_frame)
697         return;
698 
699     notImplemented();
700     (m_frame->loader()->*function)(PolicyUse);
701 }
702 
dispatchDecidePolicyForNewWindowAction(FramePolicyFunction function,const NavigationAction &,const ResourceRequest & request,PassRefPtr<FormState>,const String & targetName)703 void FrameLoaderClientWx::dispatchDecidePolicyForNewWindowAction(FramePolicyFunction function, const NavigationAction&, const ResourceRequest& request, PassRefPtr<FormState>, const String& targetName)
704 {
705     if (!m_frame)
706         return;
707 
708     if (m_webView) {
709         wxWebViewNewWindowEvent wkEvent(m_webView);
710         wkEvent.SetURL(request.url().string());
711         wkEvent.SetTargetName(targetName);
712         if (m_webView->GetEventHandler()->ProcessEvent(wkEvent)) {
713             // if the app handles and doesn't skip the event,
714             // from WebKit's perspective treat it as blocked / ignored
715             (m_frame->loader()->*function)(PolicyIgnore);
716             return;
717         }
718     }
719 
720     (m_frame->loader()->*function)(PolicyUse);
721 }
722 
dispatchDecidePolicyForNavigationAction(FramePolicyFunction function,const NavigationAction & action,const ResourceRequest & request,PassRefPtr<FormState>)723 void FrameLoaderClientWx::dispatchDecidePolicyForNavigationAction(FramePolicyFunction function, const NavigationAction& action, const ResourceRequest& request, PassRefPtr<FormState>)
724 {
725     if (!m_frame)
726         return;
727 
728     if (m_webView) {
729         wxWebViewBeforeLoadEvent wkEvent(m_webView);
730         wkEvent.SetNavigationType(wxNavTypeFromWebNavType(action.type()));
731         wkEvent.SetURL(request.url().string());
732 
733         m_webView->GetEventHandler()->ProcessEvent(wkEvent);
734         if (wkEvent.IsCancelled())
735             (m_frame->loader()->*function)(PolicyIgnore);
736         else
737             (m_frame->loader()->*function)(PolicyUse);
738 
739     }
740 }
741 
dispatchUnableToImplementPolicy(const ResourceError &)742 void FrameLoaderClientWx::dispatchUnableToImplementPolicy(const ResourceError&)
743 {
744     notImplemented();
745 }
746 
startDownload(const ResourceRequest &)747 void FrameLoaderClientWx::startDownload(const ResourceRequest&)
748 {
749     notImplemented();
750 }
751 
createFrame(const KURL & url,const String & name,HTMLFrameOwnerElement * ownerElement,const String & referrer,bool allowsScrolling,int marginWidth,int marginHeight)752 PassRefPtr<Frame> FrameLoaderClientWx::createFrame(const KURL& url, const String& name, HTMLFrameOwnerElement* ownerElement,
753                                    const String& referrer, bool allowsScrolling, int marginWidth, int marginHeight)
754 {
755 /*
756     FIXME: Temporarily disabling code for loading subframes. While most
757     (i)frames load and are destroyed properly, the iframe created by
758     google.com in its new homepage does not get destroyed when
759     document()->detach() is called, as other (i)frames do. It is destroyed on
760     app shutdown, but until that point, this 'in limbo' frame will do things
761     like steal keyboard focus and crash when clicked on. (On some platforms,
762     it is actually a visible object, even though it's not in a valid state.)
763 
764     Since just about every user is probably going to test against Google at
765     some point, I'm disabling this functionality until I have time to track down
766     why it is not being destroyed.
767 */
768 
769 /*
770     wxWindow* parent = m_webView;
771 
772     WebViewFrameData* data = new WebViewFrameData();
773     data->name = name;
774     data->ownerElement = ownerElement;
775     data->url = url;
776     data->referrer = referrer;
777     data->marginWidth = marginWidth;
778     data->marginHeight = marginHeight;
779 
780     wxWebView* newWin = new wxWebView(parent, -1, wxDefaultPosition, wxDefaultSize, data);
781 
782     RefPtr<Frame> childFrame = newWin->m_impl->frame;
783 
784     // FIXME: All of the below should probably be moved over into WebCore
785     childFrame->tree()->setName(name);
786     m_frame->tree()->appendChild(childFrame);
787     // ### set override encoding if we have one
788 
789     FrameLoadType loadType = m_frame->loader()->loadType();
790     FrameLoadType childLoadType = FrameLoadTypeInternal;
791 
792     childFrame->loader()->load(url, referrer, childLoadType,
793                             String(), 0, 0);
794 
795     // The frame's onload handler may have removed it from the document.
796     if (!childFrame->tree()->parent())
797         return 0;
798 
799     delete data;
800 
801     return childFrame.get();
802 */
803     notImplemented();
804     return 0;
805 }
806 
objectContentType(const KURL & url,const String & mimeType)807 ObjectContentType FrameLoaderClientWx::objectContentType(const KURL& url, const String& mimeType)
808 {
809     notImplemented();
810     return ObjectContentType();
811 }
812 
createPlugin(const IntSize &,HTMLPlugInElement *,const KURL &,const Vector<String> &,const Vector<String> &,const String &,bool loadManually)813 PassRefPtr<Widget> FrameLoaderClientWx::createPlugin(const IntSize&, HTMLPlugInElement*, const KURL&, const Vector<String>&, const Vector<String>&, const String&, bool loadManually)
814 {
815     notImplemented();
816     return 0;
817 }
818 
redirectDataToPlugin(Widget * pluginWidget)819 void FrameLoaderClientWx::redirectDataToPlugin(Widget* pluginWidget)
820 {
821     notImplemented();
822     return;
823 }
824 
pluginWillHandleLoadError(const ResourceResponse & response)825 ResourceError FrameLoaderClientWx::pluginWillHandleLoadError(const ResourceResponse& response)
826 {
827     notImplemented();
828     return ResourceError(String(), WebKitErrorCannotLoadPlugIn, response.url().string(), String());
829 }
830 
createJavaAppletWidget(const IntSize &,HTMLAppletElement *,const KURL & baseURL,const Vector<String> & paramNames,const Vector<String> & paramValues)831 PassRefPtr<Widget> FrameLoaderClientWx::createJavaAppletWidget(const IntSize&, HTMLAppletElement*, const KURL& baseURL,
832                                                     const Vector<String>& paramNames, const Vector<String>& paramValues)
833 {
834     notImplemented();
835     return 0;
836 }
837 
overrideMediaType() const838 String FrameLoaderClientWx::overrideMediaType() const
839 {
840     notImplemented();
841     return String();
842 }
843 
windowObjectCleared()844 void FrameLoaderClientWx::windowObjectCleared()
845 {
846     if (m_webView) {
847         wxWebViewWindowObjectClearedEvent wkEvent(m_webView);
848         Frame* coreFrame = m_webView->GetMainFrame()->GetFrame();
849         JSGlobalContextRef context = toGlobalRef(coreFrame->script()->globalObject()->globalExec());
850         JSObjectRef windowObject = toRef(coreFrame->script()->globalObject());
851         wkEvent.SetJSContext(context);
852         wkEvent.SetWindowObject(windowObject);
853         m_webView->GetEventHandler()->ProcessEvent(wkEvent);
854     }
855 }
856 
documentElementAvailable()857 void FrameLoaderClientWx::documentElementAvailable()
858 {
859 }
860 
didPerformFirstNavigation() const861 void FrameLoaderClientWx::didPerformFirstNavigation() const
862 {
863     notImplemented();
864 }
865 
registerForIconNotification(bool listen)866 void FrameLoaderClientWx::registerForIconNotification(bool listen)
867 {
868     notImplemented();
869 }
870 
savePlatformDataToCachedFrame(CachedFrame *)871 void FrameLoaderClientWx::savePlatformDataToCachedFrame(CachedFrame*)
872 {
873     notImplemented();
874 }
875 
transitionToCommittedFromCachedFrame(CachedFrame *)876 void FrameLoaderClientWx::transitionToCommittedFromCachedFrame(CachedFrame*)
877 {
878     notImplemented();
879 }
880 
transitionToCommittedForNewPage()881 void FrameLoaderClientWx::transitionToCommittedForNewPage()
882 {
883     ASSERT(m_frame);
884     ASSERT(m_webView);
885 
886     Page* page = m_frame->page();
887     ASSERT(page);
888 
889     bool isMainFrame = m_frame == page->mainFrame();
890 
891     m_frame->setView(0);
892 
893     RefPtr<FrameView> frameView;
894     if (isMainFrame)
895         frameView = FrameView::create(m_frame, IntRect(m_webView->GetRect()).size());
896     else
897         frameView = FrameView::create(m_frame);
898 
899     ASSERT(frameView);
900     m_frame->setView(frameView);
901 
902     frameView->setPlatformWidget(m_webView);
903 
904     if (HTMLFrameOwnerElement* owner = m_frame->ownerElement())
905         m_frame->view()->setScrollbarModes(owner->scrollingMode(), owner->scrollingMode());
906 }
907 
908 }
909