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