4bcc0488ea4a9e6bb049b3576ffdc6c1a2323f86
[WebKit.git] / WebKit2 / WebProcess / WebCoreSupport / WebFrameLoaderClient.cpp
1 /*
2  * Copyright (C) 2010 Apple Inc. All rights reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
7  * 1. Redistributions of source code must retain the above copyright
8  *    notice, this list of conditions and the following disclaimer.
9  * 2. Redistributions in binary form must reproduce the above copyright
10  *    notice, this list of conditions and the following disclaimer in the
11  *    documentation and/or other materials provided with the distribution.
12  *
13  * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
14  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
15  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
17  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
23  * THE POSSIBILITY OF SUCH DAMAGE.
24  */
25
26 #include "WebFrameLoaderClient.h"
27
28 #include "NotImplemented.h"
29 #include "PluginView.h"
30 #include "WebCoreArgumentCoders.h"
31 #include "WebErrors.h"
32 #include "WebFrame.h"
33 #include "WebNavigationDataStore.h"
34 #include "WebPage.h"
35 #include "WebPageProxyMessageKinds.h"
36 #include "WebProcess.h"
37 #include <JavaScriptCore/APICast.h>
38 #include <JavaScriptCore/JSObject.h>
39 #include <WebCore/Chrome.h>
40 #include <WebCore/DOMWrapperWorld.h>
41 #include <WebCore/DocumentLoader.h>
42 #include <WebCore/FormState.h>
43 #include <WebCore/Frame.h>
44 #include <WebCore/FrameLoadRequest.h>
45 #include <WebCore/FrameView.h>
46 #include <WebCore/HTMLFormElement.h>
47 #include <WebCore/MIMETypeRegistry.h>
48 #include <WebCore/Page.h>
49 #include <WebCore/PluginData.h>
50 #include <WebCore/ProgressTracker.h>
51 #include <WebCore/ResourceError.h>
52 #include <WebCore/Widget.h>
53 #include <WebCore/WindowFeatures.h>
54
55 using namespace WebCore;
56
57 namespace WebKit {
58
59 void WebFrameLoaderClient::frameLoaderDestroyed()
60 {
61     m_frame->invalidate();
62
63     // Balances explicit ref() in WebFrame::createMainFrame and WebFrame::createSubframe.
64     m_frame->deref();
65 }
66
67 bool WebFrameLoaderClient::hasHTMLView() const
68 {
69     return true;
70 }
71
72 bool WebFrameLoaderClient::hasWebView() const
73 {
74     return m_frame->page();
75 }
76
77 void WebFrameLoaderClient::makeRepresentation(DocumentLoader*)
78 {
79     notImplemented();
80 }
81
82 void WebFrameLoaderClient::forceLayout()
83 {
84     notImplemented();
85 }
86
87 void WebFrameLoaderClient::forceLayoutForNonHTML()
88 {
89     notImplemented();
90 }
91
92 void WebFrameLoaderClient::setCopiesOnScroll()
93 {
94     notImplemented();
95 }
96
97 void WebFrameLoaderClient::detachedFromParent2()
98 {
99     notImplemented();
100 }
101
102 void WebFrameLoaderClient::detachedFromParent3()
103 {
104     notImplemented();
105 }
106
107 void WebFrameLoaderClient::assignIdentifierToInitialRequest(unsigned long identifier, DocumentLoader*, const ResourceRequest&)
108 {
109     notImplemented();
110 }
111
112
113 void WebFrameLoaderClient::dispatchWillSendRequest(DocumentLoader*, unsigned long identifier, ResourceRequest&, const ResourceResponse& redirectResponse)
114 {
115     notImplemented();
116 }
117
118 bool WebFrameLoaderClient::shouldUseCredentialStorage(DocumentLoader*, unsigned long identifier)
119 {
120     notImplemented();
121     return false;
122 }
123
124 void WebFrameLoaderClient::dispatchDidReceiveAuthenticationChallenge(DocumentLoader*, unsigned long identifier, const AuthenticationChallenge&)
125 {
126     notImplemented();
127 }
128
129 void WebFrameLoaderClient::dispatchDidCancelAuthenticationChallenge(DocumentLoader*, unsigned long identifier, const AuthenticationChallenge&)    
130 {
131     notImplemented();
132 }
133
134 #if USE(PROTECTION_SPACE_AUTH_CALLBACK)
135 bool WebFrameLoaderClient::canAuthenticateAgainstProtectionSpace(DocumentLoader*, unsigned long identifier, const ProtectionSpace&)
136 {
137     notImplemented();
138     return false;
139 }
140 #endif
141
142 void WebFrameLoaderClient::dispatchDidReceiveResponse(DocumentLoader*, unsigned long identifier, const ResourceResponse&)
143 {
144     notImplemented();
145 }
146
147 void WebFrameLoaderClient::dispatchDidReceiveContentLength(DocumentLoader*, unsigned long identifier, int lengthReceived)
148 {
149     notImplemented();
150 }
151
152 void WebFrameLoaderClient::dispatchDidFinishLoading(DocumentLoader*, unsigned long identifier)
153 {
154     notImplemented();
155 }
156
157 void WebFrameLoaderClient::dispatchDidFailLoading(DocumentLoader*, unsigned long identifier, const ResourceError&)
158 {
159     notImplemented();
160 }
161
162 bool WebFrameLoaderClient::dispatchDidLoadResourceFromMemoryCache(DocumentLoader*, const ResourceRequest&, const ResourceResponse&, int length)
163 {
164     notImplemented();
165     return false;
166 }
167
168 void WebFrameLoaderClient::dispatchDidLoadResourceByXMLHttpRequest(unsigned long identifier, const ScriptString&)
169 {
170     notImplemented();
171 }
172
173 void WebFrameLoaderClient::dispatchDidHandleOnloadEvents()
174 {
175     notImplemented();
176 }
177
178 void WebFrameLoaderClient::dispatchDidReceiveServerRedirectForProvisionalLoad()
179 {
180     WebPage* webPage = m_frame->page();
181     if (!webPage)
182         return;
183
184     // Notify the bundle client.
185     webPage->injectedBundleLoaderClient().didReceiveServerRedirectForProvisionalLoadForFrame(webPage, m_frame);
186
187     // Notify the UIProcess.
188     WebProcess::shared().connection()->send(WebPageProxyMessage::DidReceiveServerRedirectForProvisionalLoadForFrame, webPage->pageID(), CoreIPC::In(m_frame->frameID()));
189 }
190
191 void WebFrameLoaderClient::dispatchDidCancelClientRedirect()
192 {
193     notImplemented();
194 }
195
196 void WebFrameLoaderClient::dispatchWillPerformClientRedirect(const KURL&, double interval, double fireDate)
197 {
198     notImplemented();
199 }
200
201 void WebFrameLoaderClient::dispatchDidChangeLocationWithinPage()
202 {
203     notImplemented();
204 }
205
206 void WebFrameLoaderClient::dispatchDidPushStateWithinPage()
207 {
208     notImplemented();
209 }
210
211 void WebFrameLoaderClient::dispatchDidReplaceStateWithinPage()
212 {
213     notImplemented();
214 }
215
216 void WebFrameLoaderClient::dispatchDidPopStateWithinPage()
217 {
218     notImplemented();
219 }
220
221 void WebFrameLoaderClient::dispatchWillClose()
222 {
223     notImplemented();
224 }
225
226 void WebFrameLoaderClient::dispatchDidReceiveIcon()
227 {
228     notImplemented();
229 }
230
231 void WebFrameLoaderClient::dispatchDidStartProvisionalLoad()
232 {
233     WebPage* webPage = m_frame->page();
234     if (!webPage)
235         return;
236
237     DocumentLoader* provisionalLoader = m_frame->coreFrame()->loader()->provisionalDocumentLoader();
238     const String& url = provisionalLoader->url().string();
239
240     // Notify the bundle client.
241     webPage->injectedBundleLoaderClient().didStartProvisionalLoadForFrame(webPage, m_frame);
242
243     // Notify the UIProcess.
244     WebProcess::shared().connection()->send(WebPageProxyMessage::DidStartProvisionalLoadForFrame, webPage->pageID(), CoreIPC::In(m_frame->frameID(), url));
245 }
246
247 void WebFrameLoaderClient::dispatchDidReceiveTitle(const String& title)
248 {
249     WebPage* webPage = m_frame->page();
250     if (!webPage)
251         return;
252
253     // Notify the bundle client.
254     webPage->injectedBundleLoaderClient().didReceiveTitleForFrame(webPage, title, m_frame);
255
256     // Notify the UIProcess.
257     WebProcess::shared().connection()->send(WebPageProxyMessage::DidReceiveTitleForFrame, webPage->pageID(), CoreIPC::In(m_frame->frameID(), title));
258 }
259
260 void WebFrameLoaderClient::dispatchDidChangeIcons()
261 {
262     notImplemented();
263 }
264
265 void WebFrameLoaderClient::dispatchDidCommitLoad()
266 {
267     WebPage* webPage = m_frame->page();
268     if (!webPage)
269         return;
270
271     // Notify the bundle client.
272     webPage->injectedBundleLoaderClient().didCommitLoadForFrame(webPage, m_frame);
273
274     // Notify the UIProcess.
275     WebProcess::shared().connection()->send(WebPageProxyMessage::DidCommitLoadForFrame, webPage->pageID(), CoreIPC::In(m_frame->frameID()));
276 }
277
278 void WebFrameLoaderClient::dispatchDidFailProvisionalLoad(const ResourceError&)
279 {
280     WebPage* webPage = m_frame->page();
281     if (!webPage)
282         return;
283
284     // Notify the bundle client.
285     webPage->injectedBundleLoaderClient().didFailProvisionalLoadWithErrorForFrame(webPage, m_frame);
286
287     // Notify the UIProcess.
288     WebProcess::shared().connection()->send(WebPageProxyMessage::DidFailProvisionalLoadForFrame, webPage->pageID(), CoreIPC::In(m_frame->frameID()));
289 }
290
291 void WebFrameLoaderClient::dispatchDidFailLoad(const ResourceError&)
292 {
293     WebPage* webPage = m_frame->page();
294     if (!webPage)
295         return;
296
297     // Notify the bundle client.
298     webPage->injectedBundleLoaderClient().didFailLoadWithErrorForFrame(webPage, m_frame);
299
300     // Notify the UIProcess.
301     WebProcess::shared().connection()->send(WebPageProxyMessage::DidFailLoadForFrame, webPage->pageID(), CoreIPC::In(m_frame->frameID()));
302 }
303
304 void WebFrameLoaderClient::dispatchDidFinishDocumentLoad()
305 {
306     notImplemented();
307 }
308
309 void WebFrameLoaderClient::dispatchDidFinishLoad()
310 {
311     WebPage* webPage = m_frame->page();
312     if (!webPage)
313         return;
314
315     // Notify the bundle client.
316     webPage->injectedBundleLoaderClient().didFinishLoadForFrame(webPage, m_frame);
317
318     // Notify the UIProcess.
319     WebProcess::shared().connection()->send(WebPageProxyMessage::DidFinishLoadForFrame, webPage->pageID(), CoreIPC::In(m_frame->frameID()));
320 }
321
322 void WebFrameLoaderClient::dispatchDidFirstLayout()
323 {
324     WebPage* webPage = m_frame->page();
325     if (!webPage)
326         return;
327
328     WebProcess::shared().connection()->send(WebPageProxyMessage::DidFirstLayoutForFrame, webPage->pageID(), CoreIPC::In(m_frame->frameID()));
329 }
330
331 void WebFrameLoaderClient::dispatchDidFirstVisuallyNonEmptyLayout()
332 {
333     WebPage* webPage = m_frame->page();
334     if (!webPage)
335         return;
336
337     WebProcess::shared().connection()->send(WebPageProxyMessage::DidFirstVisuallyNonEmptyLayoutForFrame, webPage->pageID(), CoreIPC::In(m_frame->frameID()));
338 }
339
340 Frame* WebFrameLoaderClient::dispatchCreatePage()
341 {
342     WebPage* webPage = m_frame->page();
343     if (!webPage)
344         return 0;
345
346     // Just call through to the chrome client.
347     Page* newPage = webPage->corePage()->chrome()->createWindow(m_frame->coreFrame(), FrameLoadRequest(), WindowFeatures());
348     if (!newPage)
349         return 0;
350     
351     return newPage->mainFrame();
352 }
353
354 void WebFrameLoaderClient::dispatchShow()
355 {
356     WebPage* webPage = m_frame->page();
357     if (!webPage)
358         return;
359
360     webPage->show();
361 }
362
363 void WebFrameLoaderClient::dispatchDecidePolicyForMIMEType(FramePolicyFunction function, const String& MIMEType, const ResourceRequest& request)
364 {
365     WebPage* webPage = m_frame->page();
366     if (!webPage)
367         return;
368
369     uint64_t listenerID = m_frame->setUpPolicyListener(function);
370     const String& url = request.url().string(); // FIXME: Pass entire request.
371
372     WebProcess::shared().connection()->send(WebPageProxyMessage::DecidePolicyForMIMEType, webPage->pageID(),
373                                             CoreIPC::In(m_frame->frameID(), MIMEType, url, listenerID));
374 }
375
376 void WebFrameLoaderClient::dispatchDecidePolicyForNewWindowAction(FramePolicyFunction function, const NavigationAction& navigationAction, const ResourceRequest& request, PassRefPtr<FormState>, const String& frameName)
377 {
378     WebPage* webPage = m_frame->page();
379     if (!webPage)
380         return;
381
382     uint64_t listenerID = m_frame->setUpPolicyListener(function);
383
384     // FIXME: Pass more than just the navigation action type.
385     // FIXME: Pass the frame name.
386     const String& url = request.url().string(); // FIXME: Pass entire request.
387
388     WebProcess::shared().connection()->send(WebPageProxyMessage::DecidePolicyForNewWindowAction, webPage->pageID(),
389                                             CoreIPC::In(m_frame->frameID(), (uint32_t)navigationAction.type(), url, listenerID));
390 }
391
392 void WebFrameLoaderClient::dispatchDecidePolicyForNavigationAction(FramePolicyFunction function, const NavigationAction& navigationAction, const ResourceRequest& request, PassRefPtr<FormState>)
393 {
394     WebPage* webPage = m_frame->page();
395     if (!webPage)
396         return;
397
398     uint64_t listenerID = m_frame->setUpPolicyListener(function);
399
400     // FIXME: Pass more than just the navigation action type.
401     const String& url = request.url().string(); // FIXME: Pass entire request.
402
403     WebProcess::shared().connection()->send(WebPageProxyMessage::DecidePolicyForNavigationAction, webPage->pageID(),
404                                             CoreIPC::In(m_frame->frameID(), (uint32_t)navigationAction.type(), url, listenerID));
405 }
406
407 void WebFrameLoaderClient::cancelPolicyCheck()
408 {
409     m_frame->invalidatePolicyListener();
410 }
411
412 void WebFrameLoaderClient::dispatchUnableToImplementPolicy(const ResourceError&)
413 {
414     notImplemented();
415 }
416
417 void WebFrameLoaderClient::dispatchWillSubmitForm(FramePolicyFunction function, PassRefPtr<FormState>)
418 {
419     notImplemented();
420
421     Frame* coreFrame = m_frame->coreFrame();
422     (coreFrame->loader()->policyChecker()->*function)(PolicyUse);
423 }
424
425 void WebFrameLoaderClient::dispatchDidLoadMainResource(DocumentLoader*)
426 {
427     notImplemented();
428 }
429
430 void WebFrameLoaderClient::revertToProvisionalState(DocumentLoader*)
431 {
432     notImplemented();
433 }
434
435 void WebFrameLoaderClient::setMainDocumentError(DocumentLoader*, const ResourceError&)
436 {
437     notImplemented();
438 }
439
440 void WebFrameLoaderClient::willChangeEstimatedProgress()
441 {
442     notImplemented();
443 }
444
445 void WebFrameLoaderClient::didChangeEstimatedProgress()
446 {
447     notImplemented();
448 }
449
450 void WebFrameLoaderClient::postProgressStartedNotification()
451 {
452     if (WebPage* webPage = m_frame->page())
453         WebProcess::shared().connection()->send(WebPageProxyMessage::DidStartProgress, webPage->pageID(), CoreIPC::In());
454 }
455
456 void WebFrameLoaderClient::postProgressEstimateChangedNotification()
457 {
458     if (WebPage* webPage = m_frame->page()) {
459         double progress = webPage->corePage()->progress()->estimatedProgress();
460         WebProcess::shared().connection()->send(WebPageProxyMessage::DidChangeProgress, webPage->pageID(), CoreIPC::In(progress));
461     }
462 }
463
464 void WebFrameLoaderClient::postProgressFinishedNotification()
465 {
466     if (WebPage* webPage = m_frame->page())
467         WebProcess::shared().connection()->send(WebPageProxyMessage::DidFinishProgress, webPage->pageID(), CoreIPC::In());
468 }
469
470 void WebFrameLoaderClient::setMainFrameDocumentReady(bool)
471 {
472     notImplemented();
473 }
474
475 void WebFrameLoaderClient::startDownload(const ResourceRequest&)
476 {
477     notImplemented();
478 }
479
480 void WebFrameLoaderClient::willChangeTitle(DocumentLoader*)
481 {
482     notImplemented();
483 }
484
485 void WebFrameLoaderClient::didChangeTitle(DocumentLoader*)
486 {
487     notImplemented();
488 }
489
490 void WebFrameLoaderClient::committedLoad(DocumentLoader* loader, const char* data, int length)
491 {
492     const String& textEncoding = loader->response().textEncodingName();
493     
494     receivedData(data, length, textEncoding);
495 }
496
497 void WebFrameLoaderClient::receivedData(const char* data, int length, const String& textEncoding)
498 {
499     Frame* coreFrame = m_frame->coreFrame();
500     if (!coreFrame)
501         return;
502     
503     // Set the encoding. This only needs to be done once, but it's harmless to do it again later.
504     String encoding = coreFrame->loader()->documentLoader()->overrideEncoding();
505     bool userChosen = !encoding.isNull();
506     if (encoding.isNull())
507         encoding = textEncoding;
508     coreFrame->loader()->writer()->setEncoding(encoding, userChosen);
509     
510     coreFrame->loader()->addData(data, length);
511 }
512
513 void WebFrameLoaderClient::finishedLoading(DocumentLoader* loader)
514 {
515     committedLoad(loader, 0, 0);
516 }
517
518 void WebFrameLoaderClient::updateGlobalHistory()
519 {
520     WebPage* webPage = m_frame->page();
521     if (!webPage)
522         return;
523
524     DocumentLoader* loader = m_frame->coreFrame()->loader()->documentLoader();
525
526     WebNavigationDataStore data;
527     data.url = loader->urlForHistory().string();
528     data.title = loader->title();
529
530     WebProcess::shared().connection()->send(WebPageProxyMessage::DidNavigateWithNavigationData,
531                                             webPage->pageID(),
532                                             CoreIPC::In(data, m_frame->frameID()));
533 }
534
535 void WebFrameLoaderClient::updateGlobalHistoryRedirectLinks()
536 {
537     WebPage* webPage = m_frame->page();
538     if (!webPage)
539         return;
540
541     DocumentLoader* loader = m_frame->coreFrame()->loader()->documentLoader();
542     ASSERT(loader->unreachableURL().isEmpty());
543
544     // Client redirect
545     if (!loader->clientRedirectSourceForHistory().isNull()) {
546         WebProcess::shared().connection()->send(WebPageProxyMessage::DidPerformClientRedirect,
547                                                 webPage->pageID(),
548                                                 CoreIPC::In(loader->clientRedirectSourceForHistory(), 
549                                                             loader->clientRedirectDestinationForHistory(),
550                                                             m_frame->frameID()));
551     }
552
553     // Server redirect
554     if (!loader->serverRedirectSourceForHistory().isNull()) {
555         WebProcess::shared().connection()->send(WebPageProxyMessage::DidPerformServerRedirect,
556                                                 webPage->pageID(),
557                                                 CoreIPC::In(loader->serverRedirectSourceForHistory(),
558                                                             loader->serverRedirectDestinationForHistory(),
559                                                             m_frame->frameID()));
560     }
561 }
562
563 bool WebFrameLoaderClient::shouldGoToHistoryItem(HistoryItem*) const
564 {
565     notImplemented();
566     return true;
567 }
568
569 void WebFrameLoaderClient::dispatchDidAddBackForwardItem(HistoryItem*) const
570 {
571     if (WebPage* webPage = m_frame->page())
572         webPage->backForwardListDidChange();
573 }
574
575 void WebFrameLoaderClient::dispatchDidRemoveBackForwardItem(HistoryItem*) const
576 {
577     if (WebPage* webPage = m_frame->page())
578         webPage->backForwardListDidChange();
579 }
580
581 void WebFrameLoaderClient::dispatchDidChangeBackForwardIndex() const
582 {
583     if (WebPage* webPage = m_frame->page())
584         webPage->backForwardListDidChange();
585 }
586
587 void WebFrameLoaderClient::didDisplayInsecureContent()
588 {
589     notImplemented();
590 }
591
592 void WebFrameLoaderClient::didRunInsecureContent(SecurityOrigin*)
593 {
594     notImplemented();
595 }
596
597 ResourceError WebFrameLoaderClient::cancelledError(const ResourceRequest& request)
598 {
599     return WebKit::cancelledError(request);
600 }
601
602 ResourceError WebFrameLoaderClient::blockedError(const ResourceRequest& request)
603 {
604     return WebKit::blockedError(request);
605 }
606
607 ResourceError WebFrameLoaderClient::cannotShowURLError(const ResourceRequest& request)
608 {
609     return WebKit::cannotShowURLError(request);
610 }
611
612 ResourceError WebFrameLoaderClient::interruptForPolicyChangeError(const ResourceRequest& request)
613 {
614     return WebKit::interruptForPolicyChangeError(request);
615 }
616
617 ResourceError WebFrameLoaderClient::cannotShowMIMETypeError(const ResourceResponse& response)
618 {
619     return WebKit::cannotShowMIMETypeError(response);
620 }
621
622 ResourceError WebFrameLoaderClient::fileDoesNotExistError(const ResourceResponse& response)
623 {
624     return WebKit::fileDoesNotExistError(response);
625 }
626
627 ResourceError WebFrameLoaderClient::pluginWillHandleLoadError(const ResourceResponse&)
628 {
629     notImplemented();
630     return ResourceError();
631 }
632
633 bool WebFrameLoaderClient::shouldFallBack(const ResourceError&)
634 {
635     notImplemented();
636     return false;
637 }
638
639 bool WebFrameLoaderClient::canHandleRequest(const ResourceRequest&) const
640 {
641     notImplemented();
642     return true;
643 }
644
645 bool WebFrameLoaderClient::canShowMIMEType(const String& MIMEType) const
646 {
647     notImplemented();
648     return true;
649 }
650
651 bool WebFrameLoaderClient::representationExistsForURLScheme(const String& URLScheme) const
652 {
653     notImplemented();
654     return false;
655 }
656
657 String WebFrameLoaderClient::generatedMIMETypeForURLScheme(const String& URLScheme) const
658 {
659     notImplemented();
660     return String();
661 }
662
663 void WebFrameLoaderClient::frameLoadCompleted()
664 {
665     notImplemented();
666 }
667
668 void WebFrameLoaderClient::saveViewStateToItem(HistoryItem*)
669 {
670     notImplemented();
671 }
672
673 void WebFrameLoaderClient::restoreViewState()
674 {
675     notImplemented();
676 }
677
678 void WebFrameLoaderClient::provisionalLoadStarted()
679 {
680     notImplemented();
681 }
682
683 void WebFrameLoaderClient::didFinishLoad()
684 {
685     notImplemented();
686 }
687
688 void WebFrameLoaderClient::prepareForDataSourceReplacement()
689 {
690     notImplemented();
691 }
692
693 PassRefPtr<DocumentLoader> WebFrameLoaderClient::createDocumentLoader(const ResourceRequest& request, const SubstituteData& data)
694 {
695     return DocumentLoader::create(request, data);
696 }
697
698 void WebFrameLoaderClient::setTitle(const String& title, const KURL& url)
699 {
700     WebPage* webPage = m_frame->page();
701     if (!webPage)
702         return;
703
704     WebProcess::shared().connection()->send(WebPageProxyMessage::DidUpdateHistoryTitle, webPage->pageID(), CoreIPC::In(title, url.string(), m_frame->frameID()));
705 }
706
707 String WebFrameLoaderClient::userAgent(const KURL&)
708 {
709     notImplemented();
710     return "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6; en-us) AppleWebKit/531.4 (KHTML, like Gecko) Version/4.0.3 Safari/531.4";
711 }
712
713 void WebFrameLoaderClient::savePlatformDataToCachedFrame(CachedFrame*)
714 {
715     notImplemented();
716 }
717
718 void WebFrameLoaderClient::transitionToCommittedFromCachedFrame(CachedFrame*)
719 {
720     notImplemented();
721 }
722
723 void WebFrameLoaderClient::transitionToCommittedForNewPage()
724 {
725     m_frame->coreFrame()->createView(m_frame->page()->size(), Color::white, false, IntSize(), false);
726 }
727
728 bool WebFrameLoaderClient::canCachePage() const
729 {
730     notImplemented();
731     return false;
732 }
733
734 void WebFrameLoaderClient::download(ResourceHandle*, const ResourceRequest&, const ResourceRequest&, const ResourceResponse&)
735 {
736     notImplemented();
737 }
738
739 PassRefPtr<Frame> WebFrameLoaderClient::createFrame(const KURL& url, const String& name, HTMLFrameOwnerElement* ownerElement,
740                                                     const String& referrer, bool allowsScrolling, int marginWidth, int marginHeight)
741 {
742     WebPage* webPage = m_frame->page();
743
744     RefPtr<WebFrame> subframe = WebFrame::createSubframe(webPage, name, ownerElement);
745
746     // Notify the UI process that subframe has been added.
747     WebProcess::shared().connection()->send(WebPageProxyMessage::DidCreateSubFrame, webPage->pageID(), CoreIPC::In(subframe->frameID()));
748
749     Frame* coreSubframe = subframe->coreFrame();
750
751      // The creation of the frame may have run arbitrary JavaScript that removed it from the page already.
752     m_frame->coreFrame()->loader()->loadURLIntoChildFrame(url, referrer, coreSubframe);
753
754     // The frame's onload handler may have removed it from the document.
755     if (!coreSubframe->tree()->parent())
756         return 0;
757
758     return coreSubframe;
759 }
760
761 void WebFrameLoaderClient::didTransferChildFrameToNewDocument()
762 {
763     notImplemented();
764 }    
765
766 PassRefPtr<Widget> WebFrameLoaderClient::createPlugin(const IntSize&, HTMLPlugInElement*, const KURL&, const Vector<String>&, const Vector<String>&, const String&, bool loadManually)
767 {
768     notImplemented();
769     return PluginView::create();
770 }
771
772 void WebFrameLoaderClient::redirectDataToPlugin(Widget* pluginWidget)
773 {
774     notImplemented();
775 }
776
777 PassRefPtr<Widget> WebFrameLoaderClient::createJavaAppletWidget(const IntSize&, HTMLAppletElement*, const KURL& baseURL, const Vector<String>& paramNames, const Vector<String>& paramValues)
778 {
779     notImplemented();
780     return 0;
781 }
782
783 ObjectContentType WebFrameLoaderClient::objectContentType(const KURL& url, const String& mimeType)
784 {
785     if (mimeType.isEmpty()) {
786         // FIXME: Try to find the MIME type based on the extension of the URL.
787         return ObjectContentNone;
788     }
789
790     if (WebPage* webPage = m_frame->page()) {
791         if (PluginData* pluginData = webPage->corePage()->pluginData()) {
792             if (pluginData->supportsMimeType(mimeType))
793                 return ObjectContentNetscapePlugin;
794         }
795     }
796
797     if (MIMETypeRegistry::isSupportedImageMIMEType(mimeType))
798         return ObjectContentImage;
799
800     notImplemented();
801     return ObjectContentNone;
802 }
803
804 String WebFrameLoaderClient::overrideMediaType() const
805 {
806     notImplemented();
807     return String();
808 }
809
810 void WebFrameLoaderClient::dispatchDidClearWindowObjectInWorld(DOMWrapperWorld* world)
811 {
812     WebPage* webPage = m_frame->page();
813     if (!webPage)
814         return;
815
816     if (world != mainThreadNormalWorld())
817         return;
818
819     JSContextRef context = toRef(m_frame->coreFrame()->script()->globalObject(world)->globalExec());
820     JSObjectRef windowObject = toRef(m_frame->coreFrame()->script()->globalObject(world));
821
822     webPage->injectedBundleLoaderClient().didClearWindowObjectForFrame(webPage, m_frame, context, windowObject);
823 }
824
825 void WebFrameLoaderClient::documentElementAvailable()
826 {
827     notImplemented();
828 }
829
830 void WebFrameLoaderClient::didPerformFirstNavigation() const
831 {
832     notImplemented();
833 }
834
835 void WebFrameLoaderClient::registerForIconNotification(bool listen)
836 {
837     notImplemented();
838 }
839
840 #if PLATFORM(MAC)
841 #if ENABLE(MAC_JAVA_BRIDGE)
842 jobject WebFrameLoaderClient::javaApplet(NSView*) { return 0; }
843 #endif
844 NSCachedURLResponse* WebFrameLoaderClient::willCacheResponse(DocumentLoader*, unsigned long identifier, NSCachedURLResponse*) const
845 {
846     notImplemented();
847     return 0;
848 }
849
850 #endif
851 #if USE(CFNETWORK)
852 bool WebFrameLoaderClient::shouldCacheResponse(DocumentLoader*, unsigned long identifier, const ResourceResponse&, const unsigned char* data, unsigned long long length)
853 {
854     notImplemented();
855     return false;
856 }
857
858 #endif
859
860 bool WebFrameLoaderClient::shouldUsePluginDocument(const String& /*mimeType*/) const
861 {
862     notImplemented();
863     return false;
864 }
865
866 } // namespace WebKit