WK2: Support Accessibility
[WebKit-https.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 #define DISABLE_NOT_IMPLEMENTED_WARNINGS 1
29 #include "NotImplemented.h"
30
31 #include "AuthenticationManager.h"
32 #include "DataReference.h"
33 #include "InjectedBundleUserMessageCoders.h"
34 #include "PlatformCertificateInfo.h"
35 #include "PluginView.h"
36 #include "StringPairVector.h"
37 #include "WebContextMessages.h"
38 #include "WebCoreArgumentCoders.h"
39 #include "WebErrors.h"
40 #include "WebEvent.h"
41 #include "WebFrame.h"
42 #include "WebFrameNetworkingContext.h"
43 #include "WebNavigationDataStore.h"
44 #include "WebPage.h"
45 #include "WebPageProxyMessages.h"
46 #include "WebProcess.h"
47 #include "WebProcessProxyMessageKinds.h"
48 #include "WebProcessProxyMessages.h"
49 #include <JavaScriptCore/APICast.h>
50 #include <JavaScriptCore/JSObject.h>
51 #include <WebCore/Chrome.h>
52 #include <WebCore/DOMWrapperWorld.h>
53 #include <WebCore/DocumentLoader.h>
54 #include <WebCore/FormState.h>
55 #include <WebCore/Frame.h>
56 #include <WebCore/FrameLoadRequest.h>
57 #include <WebCore/FrameView.h>
58 #include <WebCore/HTMLAppletElement.h>
59 #include <WebCore/HTMLFormElement.h>
60 #include <WebCore/MIMETypeRegistry.h>
61 #include <WebCore/MouseEvent.h>
62 #include <WebCore/Page.h>
63 #include <WebCore/PluginData.h>
64 #include <WebCore/ProgressTracker.h>
65 #include <WebCore/ResourceError.h>
66 #include <WebCore/UIEventWithKeyState.h>
67 #include <WebCore/Widget.h>
68 #include <WebCore/WindowFeatures.h>
69
70 using namespace WebCore;
71
72 namespace WebKit {
73
74 WebFrameLoaderClient::WebFrameLoaderClient(WebFrame* frame)
75     : m_frame(frame)
76     , m_hasSentResponseToPluginView(false)
77     , m_frameHasCustomRepresentation(false)
78 {
79 }
80
81 WebFrameLoaderClient::~WebFrameLoaderClient()
82 {
83 }
84     
85 void WebFrameLoaderClient::frameLoaderDestroyed()
86 {
87     m_frame->invalidate();
88
89     // Balances explicit ref() in WebFrame::createMainFrame and WebFrame::createSubframe.
90     m_frame->deref();
91 }
92
93 bool WebFrameLoaderClient::hasHTMLView() const
94 {
95     return !m_frameHasCustomRepresentation;
96 }
97
98 bool WebFrameLoaderClient::hasWebView() const
99 {
100     return m_frame->page();
101 }
102
103 void WebFrameLoaderClient::makeRepresentation(DocumentLoader*)
104 {
105     notImplemented();
106 }
107
108 void WebFrameLoaderClient::forceLayout()
109 {
110     notImplemented();
111 }
112
113 void WebFrameLoaderClient::forceLayoutForNonHTML()
114 {
115     notImplemented();
116 }
117
118 void WebFrameLoaderClient::setCopiesOnScroll()
119 {
120     notImplemented();
121 }
122
123 void WebFrameLoaderClient::detachedFromParent2()
124 {
125     WebPage* webPage = m_frame->page();
126     if (!webPage)
127         return;
128
129     RefPtr<APIObject> userData;
130
131     // Notify the bundle client.
132     webPage->injectedBundleLoaderClient().didRemoveFrameFromHierarchy(webPage, m_frame, userData);
133
134     // Notify the UIProcess.
135     webPage->send(Messages::WebPageProxy::DidRemoveFrameFromHierarchy(m_frame->frameID(), InjectedBundleUserMessageEncoder(userData.get())));
136
137 }
138
139 void WebFrameLoaderClient::detachedFromParent3()
140 {
141     notImplemented();
142 }
143
144 void WebFrameLoaderClient::assignIdentifierToInitialRequest(unsigned long identifier, DocumentLoader*, const ResourceRequest& request)
145 {
146     WebPage* webPage = m_frame->page();
147     if (!webPage)
148         return;
149
150     webPage->send(Messages::WebPageProxy::DidInitiateLoadForResource(m_frame->frameID(), identifier, request));
151 }
152
153 void WebFrameLoaderClient::dispatchWillSendRequest(DocumentLoader*, unsigned long identifier, ResourceRequest& request, const ResourceResponse& redirectResponse)
154 {
155     WebPage* webPage = m_frame->page();
156     if (!webPage)
157         return;
158
159     webPage->send(Messages::WebPageProxy::DidSendRequestForResource(m_frame->frameID(), identifier, request, redirectResponse));
160 }
161
162 bool WebFrameLoaderClient::shouldUseCredentialStorage(DocumentLoader*, unsigned long identifier)
163 {
164     return true;
165 }
166
167 void WebFrameLoaderClient::dispatchDidReceiveAuthenticationChallenge(DocumentLoader*, unsigned long, const AuthenticationChallenge& challenge)
168 {
169     // FIXME: Authentication is a per-resource concept, but we don't do per-resource handling in the UIProcess at the API level quite yet.
170     // Once we do, we might need to make sure authentication fits with our solution.
171
172     WebPage* webPage = m_frame->page();
173     if (!webPage)
174         return;
175
176     AuthenticationManager::shared().didReceiveAuthenticationChallenge(m_frame, challenge);
177 }
178
179 void WebFrameLoaderClient::dispatchDidCancelAuthenticationChallenge(DocumentLoader*, unsigned long identifier, const AuthenticationChallenge&)    
180 {
181     notImplemented();
182 }
183
184 #if USE(PROTECTION_SPACE_AUTH_CALLBACK)
185 bool WebFrameLoaderClient::canAuthenticateAgainstProtectionSpace(DocumentLoader*, unsigned long, const ProtectionSpace& protectionSpace)
186 {
187     // FIXME: Authentication is a per-resource concept, but we don't do per-resource handling in the UIProcess at the API level quite yet.
188     // Once we do, we might need to make sure authentication fits with our solution.
189     
190     WebPage* webPage = m_frame->page();
191     if (!webPage)
192         return false;
193         
194     bool canAuthenticate;
195     if (!webPage->sendSync(Messages::WebPageProxy::CanAuthenticateAgainstProtectionSpaceInFrame(m_frame->frameID(), protectionSpace), Messages::WebPageProxy::CanAuthenticateAgainstProtectionSpaceInFrame::Reply(canAuthenticate)))
196         return false;
197     
198     return canAuthenticate;
199 }
200 #endif
201
202 void WebFrameLoaderClient::dispatchDidReceiveResponse(DocumentLoader*, unsigned long identifier, const ResourceResponse& response)
203 {
204     WebPage* webPage = m_frame->page();
205     if (!webPage)
206         return;
207
208     webPage->send(Messages::WebPageProxy::DidReceiveResponseForResource(m_frame->frameID(), identifier, response));
209 }
210
211 void WebFrameLoaderClient::dispatchDidReceiveContentLength(DocumentLoader*, unsigned long identifier, int lengthReceived)
212 {
213     WebPage* webPage = m_frame->page();
214     if (!webPage)
215         return;
216
217     webPage->send(Messages::WebPageProxy::DidReceiveContentLengthForResource(m_frame->frameID(), identifier, lengthReceived));
218 }
219
220 void WebFrameLoaderClient::dispatchDidFinishLoading(DocumentLoader*, unsigned long identifier)
221 {
222     WebPage* webPage = m_frame->page();
223     if (!webPage)
224         return;
225
226     webPage->send(Messages::WebPageProxy::DidFinishLoadForResource(m_frame->frameID(), identifier));
227 }
228
229 void WebFrameLoaderClient::dispatchDidFailLoading(DocumentLoader*, unsigned long identifier, const ResourceError& error)
230 {
231     WebPage* webPage = m_frame->page();
232     if (!webPage)
233         return;
234
235     webPage->send(Messages::WebPageProxy::DidFailLoadForResource(m_frame->frameID(), identifier, error));
236 }
237
238 bool WebFrameLoaderClient::dispatchDidLoadResourceFromMemoryCache(DocumentLoader*, const ResourceRequest&, const ResourceResponse&, int length)
239 {
240     notImplemented();
241     return false;
242 }
243
244 void WebFrameLoaderClient::dispatchDidLoadResourceByXMLHttpRequest(unsigned long identifier, const String&)
245 {
246     notImplemented();
247 }
248
249 void WebFrameLoaderClient::dispatchDidHandleOnloadEvents()
250 {
251     WebPage* webPage = m_frame->page();
252     if (!webPage)
253         return;
254
255     // Notify the bundle client.
256     webPage->injectedBundleLoaderClient().didHandleOnloadEventsForFrame(webPage, m_frame);
257 }
258
259 void WebFrameLoaderClient::dispatchDidReceiveServerRedirectForProvisionalLoad()
260 {
261     WebPage* webPage = m_frame->page();
262     if (!webPage)
263         return;
264
265     DocumentLoader* provisionalLoader = m_frame->coreFrame()->loader()->provisionalDocumentLoader();
266     const String& url = provisionalLoader->url().string();
267     RefPtr<APIObject> userData;
268
269     // Notify the bundle client.
270     webPage->injectedBundleLoaderClient().didReceiveServerRedirectForProvisionalLoadForFrame(webPage, m_frame, userData);
271
272     // Notify the UIProcess.
273     webPage->send(Messages::WebPageProxy::DidReceiveServerRedirectForProvisionalLoadForFrame(m_frame->frameID(), url, InjectedBundleUserMessageEncoder(userData.get())));
274 }
275
276 void WebFrameLoaderClient::dispatchDidCancelClientRedirect()
277 {
278     WebPage* webPage = m_frame->page();
279     if (!webPage)
280         return;
281
282     // Notify the bundle client.
283     webPage->injectedBundleLoaderClient().didCancelClientRedirectForFrame(webPage, m_frame);
284 }
285
286 void WebFrameLoaderClient::dispatchWillPerformClientRedirect(const KURL& url, double interval, double fireDate)
287 {
288     WebPage* webPage = m_frame->page();
289     if (!webPage)
290         return;
291
292     // Notify the bundle client.
293     webPage->injectedBundleLoaderClient().willPerformClientRedirectForFrame(webPage, m_frame, url.string(), interval, fireDate);
294 }
295
296 void WebFrameLoaderClient::dispatchDidChangeLocationWithinPage()
297 {
298     WebPage* webPage = m_frame->page();
299     if (!webPage)
300         return;
301
302     RefPtr<APIObject> userData;
303
304     // Notify the bundle client.
305     webPage->injectedBundleLoaderClient().didSameDocumentNavigationForFrame(webPage, m_frame, SameDocumentNavigationAnchorNavigation, userData);
306
307     // Notify the UIProcess.
308     webPage->send(Messages::WebPageProxy::DidSameDocumentNavigationForFrame(m_frame->frameID(), SameDocumentNavigationAnchorNavigation, m_frame->coreFrame()->loader()->url().string(), InjectedBundleUserMessageEncoder(userData.get())));
309 }
310
311 void WebFrameLoaderClient::dispatchDidPushStateWithinPage()
312 {
313     WebPage* webPage = m_frame->page();
314     if (!webPage)
315         return;
316
317     RefPtr<APIObject> userData;
318
319     // Notify the bundle client.
320     webPage->injectedBundleLoaderClient().didSameDocumentNavigationForFrame(webPage, m_frame, SameDocumentNavigationSessionStatePush, userData);
321
322     // Notify the UIProcess.
323     webPage->send(Messages::WebPageProxy::DidSameDocumentNavigationForFrame(m_frame->frameID(), SameDocumentNavigationSessionStatePush, m_frame->coreFrame()->loader()->url().string(), InjectedBundleUserMessageEncoder(userData.get())));
324 }
325
326 void WebFrameLoaderClient::dispatchDidReplaceStateWithinPage()
327 {
328     WebPage* webPage = m_frame->page();
329     if (!webPage)
330         return;
331
332     RefPtr<APIObject> userData;
333
334     // Notify the bundle client.
335     webPage->injectedBundleLoaderClient().didSameDocumentNavigationForFrame(webPage, m_frame, SameDocumentNavigationSessionStateReplace, userData);
336
337     // Notify the UIProcess.
338     webPage->send(Messages::WebPageProxy::DidSameDocumentNavigationForFrame(m_frame->frameID(), SameDocumentNavigationSessionStateReplace, m_frame->coreFrame()->loader()->url().string(), InjectedBundleUserMessageEncoder(userData.get())));
339 }
340
341 void WebFrameLoaderClient::dispatchDidPopStateWithinPage()
342 {
343     WebPage* webPage = m_frame->page();
344     if (!webPage)
345         return;
346
347     RefPtr<APIObject> userData;
348
349     // Notify the bundle client.
350     webPage->injectedBundleLoaderClient().didSameDocumentNavigationForFrame(webPage, m_frame, SameDocumentNavigationSessionStatePop, userData);
351
352     // Notify the UIProcess.
353     webPage->send(Messages::WebPageProxy::DidSameDocumentNavigationForFrame(m_frame->frameID(), SameDocumentNavigationSessionStatePop, m_frame->coreFrame()->loader()->url().string(), InjectedBundleUserMessageEncoder(userData.get())));
354 }
355
356 void WebFrameLoaderClient::dispatchWillClose()
357 {
358     notImplemented();
359 }
360
361 void WebFrameLoaderClient::dispatchDidReceiveIcon()
362 {
363     notImplemented();
364 }
365
366 void WebFrameLoaderClient::dispatchDidStartProvisionalLoad()
367 {
368     WebPage* webPage = m_frame->page();
369     if (!webPage)
370         return;
371     webPage->findController().hideFindUI();
372     
373     DocumentLoader* provisionalLoader = m_frame->coreFrame()->loader()->provisionalDocumentLoader();
374     const String& url = provisionalLoader->url().string();
375     RefPtr<APIObject> userData;
376
377     // Notify the bundle client.
378     webPage->injectedBundleLoaderClient().didStartProvisionalLoadForFrame(webPage, m_frame, userData);
379
380     bool loadingSubstituteDataForUnreachableURL = !provisionalLoader->unreachableURL().isNull();
381
382     webPage->sandboxExtensionTracker().didStartProvisionalLoad(m_frame);
383
384     // Notify the UIProcess.
385     webPage->send(Messages::WebPageProxy::DidStartProvisionalLoadForFrame(m_frame->frameID(), url, loadingSubstituteDataForUnreachableURL, InjectedBundleUserMessageEncoder(userData.get())));
386 }
387
388 void WebFrameLoaderClient::dispatchDidReceiveTitle(const String& title)
389 {
390     WebPage* webPage = m_frame->page();
391     if (!webPage)
392         return;
393
394     RefPtr<APIObject> userData;
395
396     // Notify the bundle client.
397     webPage->injectedBundleLoaderClient().didReceiveTitleForFrame(webPage, title, m_frame, userData);
398
399     // Notify the UIProcess.
400     webPage->send(Messages::WebPageProxy::DidReceiveTitleForFrame(m_frame->frameID(), title, InjectedBundleUserMessageEncoder(userData.get())));
401 }
402
403 void WebFrameLoaderClient::dispatchDidChangeIcons()
404 {
405     notImplemented();
406 }
407
408 void WebFrameLoaderClient::dispatchDidCommitLoad()
409 {
410     WebPage* webPage = m_frame->page();
411     if (!webPage)
412         return;
413
414     const ResourceResponse& response = m_frame->coreFrame()->loader()->documentLoader()->response();
415     RefPtr<APIObject> userData;
416
417     // Notify the bundle client.
418     webPage->injectedBundleLoaderClient().didCommitLoadForFrame(webPage, m_frame, userData);
419
420     webPage->sandboxExtensionTracker().didCommitProvisionalLoad(m_frame);
421
422     // Notify the UIProcess.
423     webPage->send(Messages::WebPageProxy::DidCommitLoadForFrame(m_frame->frameID(), response.mimeType(), m_frameHasCustomRepresentation, PlatformCertificateInfo(response), InjectedBundleUserMessageEncoder(userData.get())));
424 }
425
426 void WebFrameLoaderClient::dispatchDidFailProvisionalLoad(const ResourceError& error)
427 {
428     WebPage* webPage = m_frame->page();
429     if (!webPage)
430         return;
431
432     RefPtr<APIObject> userData;
433
434     // Notify the bundle client.
435     webPage->injectedBundleLoaderClient().didFailProvisionalLoadWithErrorForFrame(webPage, m_frame, error, userData);
436
437     webPage->sandboxExtensionTracker().didFailProvisionalLoad(m_frame);
438
439     // Notify the UIProcess.
440     webPage->send(Messages::WebPageProxy::DidFailProvisionalLoadForFrame(m_frame->frameID(), error, InjectedBundleUserMessageEncoder(userData.get())));
441     
442     // If we have a load listener, notify it.
443     if (WebFrame::LoadListener* loadListener = m_frame->loadListener())
444         loadListener->didFailLoad(m_frame, error.isCancellation());
445 }
446
447 void WebFrameLoaderClient::dispatchDidFailLoad(const ResourceError& error)
448 {
449     WebPage* webPage = m_frame->page();
450     if (!webPage)
451         return;
452
453     RefPtr<APIObject> userData;
454
455     // Notify the bundle client.
456     webPage->injectedBundleLoaderClient().didFailLoadWithErrorForFrame(webPage, m_frame, error, userData);
457
458     // Notify the UIProcess.
459     webPage->send(Messages::WebPageProxy::DidFailLoadForFrame(m_frame->frameID(), error, InjectedBundleUserMessageEncoder(userData.get())));
460
461     // If we have a load listener, notify it.
462     if (WebFrame::LoadListener* loadListener = m_frame->loadListener())
463         loadListener->didFailLoad(m_frame, error.isCancellation());
464 }
465
466 void WebFrameLoaderClient::dispatchDidFinishDocumentLoad()
467 {
468     WebPage* webPage = m_frame->page();
469     if (!webPage)
470         return;
471
472     RefPtr<APIObject> userData;
473
474     // Notify the bundle client.
475     webPage->injectedBundleLoaderClient().didFinishDocumentLoadForFrame(webPage, m_frame, userData);
476
477     // Notify the UIProcess.
478     webPage->send(Messages::WebPageProxy::DidFinishDocumentLoadForFrame(m_frame->frameID(), InjectedBundleUserMessageEncoder(userData.get())));
479 }
480
481 void WebFrameLoaderClient::dispatchDidFinishLoad()
482 {
483     WebPage* webPage = m_frame->page();
484     if (!webPage)
485         return;
486
487     RefPtr<APIObject> userData;
488
489     // Notify the bundle client.
490     webPage->injectedBundleLoaderClient().didFinishLoadForFrame(webPage, m_frame, userData);
491
492     // Notify the UIProcess.
493     webPage->send(Messages::WebPageProxy::DidFinishLoadForFrame(m_frame->frameID(), InjectedBundleUserMessageEncoder(userData.get())));
494
495     // If we have a load listener, notify it.
496     if (WebFrame::LoadListener* loadListener = m_frame->loadListener())
497         loadListener->didFinishLoad(m_frame);
498 }
499
500 void WebFrameLoaderClient::dispatchDidFirstLayout()
501 {
502     WebPage* webPage = m_frame->page();
503     if (!webPage)
504         return;
505
506     RefPtr<APIObject> userData;
507
508     // Notify the bundle client.
509     webPage->injectedBundleLoaderClient().didFirstLayoutForFrame(webPage, m_frame, userData);
510
511     // Notify the UIProcess.
512     webPage->send(Messages::WebPageProxy::DidFirstLayoutForFrame(m_frame->frameID(), InjectedBundleUserMessageEncoder(userData.get())));
513 }
514
515 void WebFrameLoaderClient::dispatchDidFirstVisuallyNonEmptyLayout()
516 {
517     WebPage* webPage = m_frame->page();
518     if (!webPage)
519         return;
520
521     RefPtr<APIObject> userData;
522
523     // Notify the bundle client.
524     webPage->injectedBundleLoaderClient().didFirstVisuallyNonEmptyLayoutForFrame(webPage, m_frame, userData);
525
526     // Notify the UIProcess.
527     webPage->send(Messages::WebPageProxy::DidFirstVisuallyNonEmptyLayoutForFrame(m_frame->frameID(), InjectedBundleUserMessageEncoder(userData.get())));
528 }
529
530 Frame* WebFrameLoaderClient::dispatchCreatePage(const NavigationAction& navigationAction)
531 {
532     WebPage* webPage = m_frame->page();
533     if (!webPage)
534         return 0;
535
536     // Just call through to the chrome client.
537     Page* newPage = webPage->corePage()->chrome()->createWindow(m_frame->coreFrame(), FrameLoadRequest(m_frame->coreFrame()->document()->securityOrigin()), WindowFeatures(), navigationAction);
538     if (!newPage)
539         return 0;
540     
541     return newPage->mainFrame();
542 }
543
544 void WebFrameLoaderClient::dispatchShow()
545 {
546     WebPage* webPage = m_frame->page();
547     if (!webPage)
548         return;
549
550     webPage->show();
551 }
552
553 uint32_t modifiersForNavigationAction(const NavigationAction& navigationAction)
554 {
555     uint32_t modifiers = 0;
556     if (const UIEventWithKeyState* keyStateEvent = findEventWithKeyState(const_cast<Event*>(navigationAction.event()))) {
557         if (keyStateEvent->shiftKey())
558             modifiers |= WebEvent::ShiftKey;
559         if (keyStateEvent->ctrlKey())
560             modifiers |= WebEvent::ControlKey;
561         if (keyStateEvent->altKey())
562             modifiers |= WebEvent::AltKey;
563         if (keyStateEvent->metaKey())
564             modifiers |= WebEvent::MetaKey;
565     }
566
567     return modifiers;
568 }
569
570 static const MouseEvent* findMouseEvent(const Event* event)
571 {
572     for (const Event* e = event; e; e = e->underlyingEvent()) {
573         if (e->isMouseEvent())
574             return static_cast<const MouseEvent*>(e);
575     }
576     return 0;
577 }
578
579 int32_t mouseButtonForNavigationAction(const NavigationAction& navigationAction)
580 {
581     const MouseEvent* mouseEvent = findMouseEvent(navigationAction.event());
582     if (!mouseEvent)
583         return -1;
584
585     if (!mouseEvent->buttonDown())
586         return -1;
587
588     return mouseEvent->button();
589 }
590
591 void WebFrameLoaderClient::dispatchDecidePolicyForMIMEType(FramePolicyFunction function, const String& MIMEType, const ResourceRequest& request)
592 {
593     if (m_frame->coreFrame()->loader()->documentLoader()->url().isEmpty() && request.url() == blankURL()) {
594         // WebKit2 loads initial about:blank documents synchronously, without consulting the policy delegate
595         ASSERT(m_frame->coreFrame()->loader()->stateMachine()->committingFirstRealLoad());
596         (m_frame->coreFrame()->loader()->policyChecker()->*function)(PolicyUse);
597         return;
598     }
599     
600     WebPage* webPage = m_frame->page();
601     if (!webPage)
602         return;
603
604     uint64_t listenerID = m_frame->setUpPolicyListener(function);
605     const String& url = request.url().string(); // FIXME: Pass entire request.
606
607     bool receivedPolicyAction;
608     uint64_t policyAction;
609     uint64_t downloadID;
610     if (!webPage->sendSync(Messages::WebPageProxy::DecidePolicyForMIMEType(m_frame->frameID(), MIMEType, url, listenerID), Messages::WebPageProxy::DecidePolicyForMIMEType::Reply(receivedPolicyAction, policyAction, downloadID)))
611         return;
612
613     // We call this synchronously because CFNetwork can only convert a loading connection to a download from its didReceiveResponse callback.
614     if (receivedPolicyAction)
615         m_frame->didReceivePolicyDecision(listenerID, static_cast<PolicyAction>(policyAction), downloadID);
616 }
617
618 void WebFrameLoaderClient::dispatchDecidePolicyForNewWindowAction(FramePolicyFunction function, const NavigationAction& navigationAction, const ResourceRequest& request, PassRefPtr<FormState>, const String& frameName)
619 {
620     WebPage* webPage = m_frame->page();
621     if (!webPage)
622         return;
623
624     uint64_t listenerID = m_frame->setUpPolicyListener(function);
625
626     // FIXME: Pass more than just the navigation action type.
627     // FIXME: Pass the frame name.
628     const String& url = request.url().string(); // FIXME: Pass entire request.
629
630     uint32_t navigationType = static_cast<uint32_t>(navigationAction.type());
631     uint32_t modifiers = modifiersForNavigationAction(navigationAction);
632     int32_t mouseButton = mouseButtonForNavigationAction(navigationAction);
633
634     webPage->send(Messages::WebPageProxy::DecidePolicyForNewWindowAction(m_frame->frameID(), navigationType, modifiers, mouseButton, url, listenerID));
635 }
636
637 void WebFrameLoaderClient::dispatchDecidePolicyForNavigationAction(FramePolicyFunction function, const NavigationAction& navigationAction, const ResourceRequest& request, PassRefPtr<FormState>)
638 {
639     if (m_frame->coreFrame()->loader()->documentLoader()->url().isEmpty() && request.url() == blankURL()) {
640         // WebKit2 loads initial about:blank documents synchronously, without consulting the policy delegate
641         ASSERT(m_frame->coreFrame()->loader()->stateMachine()->committingFirstRealLoad());
642         (m_frame->coreFrame()->loader()->policyChecker()->*function)(PolicyUse);
643         return;
644     }
645
646     // Always ignore requests with empty URLs.
647     if (request.isEmpty()) {
648         (m_frame->coreFrame()->loader()->policyChecker()->*function)(PolicyIgnore);
649         return;
650     }
651     
652     WebPage* webPage = m_frame->page();
653     if (!webPage)
654         return;
655
656     uint64_t listenerID = m_frame->setUpPolicyListener(function);
657
658     // FIXME: Pass more than just the navigation action type.
659     const String& url = request.url().string(); // FIXME: Pass entire request.
660
661     uint32_t navigationType = static_cast<uint32_t>(navigationAction.type());
662     uint32_t modifiers = modifiersForNavigationAction(navigationAction);
663     int32_t mouseButton = mouseButtonForNavigationAction(navigationAction);
664
665     webPage->send(Messages::WebPageProxy::DecidePolicyForNavigationAction(m_frame->frameID(), navigationType, modifiers, mouseButton, url, listenerID));
666 }
667
668 void WebFrameLoaderClient::cancelPolicyCheck()
669 {
670     m_frame->invalidatePolicyListener();
671 }
672
673 void WebFrameLoaderClient::dispatchUnableToImplementPolicy(const ResourceError&)
674 {
675     notImplemented();
676 }
677
678 void WebFrameLoaderClient::dispatchWillSubmitForm(FramePolicyFunction function, PassRefPtr<FormState> prpFormState)
679 {
680     WebPage* webPage = m_frame->page();
681     if (!webPage)
682         return;
683
684     // FIXME: Pass more of the form state.
685     RefPtr<FormState> formState = prpFormState;
686     
687     HTMLFormElement* form = formState->form();
688     WebFrame* sourceFrame = static_cast<WebFrameLoaderClient*>(formState->sourceFrame()->loader()->client())->webFrame();    
689     const Vector<std::pair<String, String> >& values = formState->textFieldValues();
690
691     RefPtr<APIObject> userData;
692     webPage->injectedBundleFormClient().willSubmitForm(webPage, form, m_frame, sourceFrame, values, userData);
693
694
695     uint64_t listenerID = m_frame->setUpPolicyListener(function);
696     StringPairVector valuesVector(values);
697
698     webPage->send(Messages::WebPageProxy::WillSubmitForm(m_frame->frameID(), sourceFrame->frameID(), valuesVector, listenerID, InjectedBundleUserMessageEncoder(userData.get())));
699 }
700
701 void WebFrameLoaderClient::dispatchDidLoadMainResource(DocumentLoader*)
702 {
703     notImplemented();
704 }
705
706 void WebFrameLoaderClient::revertToProvisionalState(DocumentLoader*)
707 {
708     notImplemented();
709 }
710
711 void WebFrameLoaderClient::setMainDocumentError(DocumentLoader*, const ResourceError& error)
712 {
713     if (!m_pluginView)
714         return;
715     
716     m_pluginView->manualLoadDidFail(error);
717     m_pluginView = 0;
718     m_hasSentResponseToPluginView = false;
719 }
720
721 void WebFrameLoaderClient::willChangeEstimatedProgress()
722 {
723     notImplemented();
724 }
725
726 void WebFrameLoaderClient::didChangeEstimatedProgress()
727 {
728     notImplemented();
729 }
730
731 void WebFrameLoaderClient::postProgressStartedNotification()
732 {
733     if (WebPage* webPage = m_frame->page())
734         webPage->send(Messages::WebPageProxy::DidStartProgress());
735 }
736
737 void WebFrameLoaderClient::postProgressEstimateChangedNotification()
738 {
739     if (WebPage* webPage = m_frame->page()) {
740         double progress = webPage->corePage()->progress()->estimatedProgress();
741         webPage->send(Messages::WebPageProxy::DidChangeProgress(progress));
742
743     }
744 }
745
746 void WebFrameLoaderClient::postProgressFinishedNotification()
747 {
748     if (WebPage* webPage = m_frame->page())
749         webPage->send(Messages::WebPageProxy::DidFinishProgress());
750 }
751
752 void WebFrameLoaderClient::setMainFrameDocumentReady(bool)
753 {
754     notImplemented();
755 }
756
757 void WebFrameLoaderClient::startDownload(const ResourceRequest& request)
758 {
759     m_frame->startDownload(request);
760 }
761
762 void WebFrameLoaderClient::willChangeTitle(DocumentLoader*)
763 {
764     notImplemented();
765 }
766
767 void WebFrameLoaderClient::didChangeTitle(DocumentLoader*)
768 {
769     notImplemented();
770 }
771
772 void WebFrameLoaderClient::committedLoad(DocumentLoader* loader, const char* data, int length)
773 {
774     // If we're loading a custom representation, we don't want to hand off the data to WebCore.
775     if (m_frameHasCustomRepresentation)
776         return;
777
778     if (!m_pluginView)
779         loader->commitData(data, length);
780
781     // If the document is a stand-alone media document, now is the right time to cancel the WebKit load.
782     // FIXME: This code should be shared across all ports. <http://webkit.org/b/48762>.
783     if (m_frame->coreFrame()->document()->isMediaDocument())
784         loader->cancelMainResourceLoad(pluginWillHandleLoadError(loader->response()));
785
786     // Calling commitData did not create the plug-in view.
787     if (!m_pluginView)
788         return;
789
790     if (!m_hasSentResponseToPluginView) {
791         m_pluginView->manualLoadDidReceiveResponse(loader->response());
792         // manualLoadDidReceiveResponse sets up a new stream to the plug-in. on a full-page plug-in, a failure in
793         // setting up this stream can cause the main document load to be cancelled, setting m_pluginView
794         // to null
795         if (!m_pluginView)
796             return;
797         m_hasSentResponseToPluginView = true;
798     }
799     m_pluginView->manualLoadDidReceiveData(data, length);
800 }
801
802 void WebFrameLoaderClient::finishedLoading(DocumentLoader* loader)
803 {
804     if (!m_pluginView) {
805         committedLoad(loader, 0, 0);
806
807         if (m_frameHasCustomRepresentation) {
808             WebPage* webPage = m_frame->page();
809             if (!webPage)
810                 return;
811
812             RefPtr<SharedBuffer> mainResourceData = loader->mainResourceData();
813             CoreIPC::DataReference dataReference(reinterpret_cast<const uint8_t*>(mainResourceData ? mainResourceData->data() : 0), mainResourceData ? mainResourceData->size() : 0);
814             
815             webPage->send(Messages::WebPageProxy::DidFinishLoadingDataForCustomRepresentation(dataReference));
816         }
817
818         return;
819     }
820
821     m_pluginView->manualLoadDidFinishLoading();
822     m_pluginView = 0;
823     m_hasSentResponseToPluginView = false;
824 }
825
826 void WebFrameLoaderClient::updateGlobalHistory()
827 {
828     WebPage* webPage = m_frame->page();
829     if (!webPage)
830         return;
831
832     DocumentLoader* loader = m_frame->coreFrame()->loader()->documentLoader();
833
834     WebNavigationDataStore data;
835     data.url = loader->urlForHistory().string();
836     data.title = loader->title();
837
838     WebProcess::shared().connection()->send(Messages::WebContext::DidNavigateWithNavigationData(webPage->pageID(), data, m_frame->frameID()), 0);
839 }
840
841 void WebFrameLoaderClient::updateGlobalHistoryRedirectLinks()
842 {
843     WebPage* webPage = m_frame->page();
844     if (!webPage)
845         return;
846
847     DocumentLoader* loader = m_frame->coreFrame()->loader()->documentLoader();
848     ASSERT(loader->unreachableURL().isEmpty());
849
850     // Client redirect
851     if (!loader->clientRedirectSourceForHistory().isNull()) {
852         WebProcess::shared().connection()->send(Messages::WebContext::DidPerformClientRedirect(webPage->pageID(),
853             loader->clientRedirectSourceForHistory(), loader->clientRedirectDestinationForHistory(), m_frame->frameID()), 0);
854     }
855
856     // Server redirect
857     if (!loader->serverRedirectSourceForHistory().isNull()) {
858         WebProcess::shared().connection()->send(Messages::WebContext::DidPerformServerRedirect(webPage->pageID(),
859             loader->serverRedirectSourceForHistory(), loader->serverRedirectDestinationForHistory(), m_frame->frameID()), 0);
860     }
861 }
862
863 bool WebFrameLoaderClient::shouldGoToHistoryItem(HistoryItem*) const
864 {
865     notImplemented();
866     return true;
867 }
868
869 void WebFrameLoaderClient::dispatchDidAddBackForwardItem(HistoryItem*) const
870 {
871     notImplemented();
872 }
873
874 void WebFrameLoaderClient::dispatchDidRemoveBackForwardItem(HistoryItem*) const
875 {
876     notImplemented();
877 }
878
879 void WebFrameLoaderClient::dispatchDidChangeBackForwardIndex() const
880 {
881     notImplemented();
882 }
883
884 void WebFrameLoaderClient::didDisplayInsecureContent()
885 {
886     WebPage* webPage = m_frame->page();
887     if (!webPage)
888         return;
889
890     RefPtr<APIObject> userData;
891
892     webPage->injectedBundleLoaderClient().didDisplayInsecureContentForFrame(webPage, m_frame, userData);
893
894     webPage->send(Messages::WebPageProxy::DidDisplayInsecureContentForFrame(m_frame->frameID(), InjectedBundleUserMessageEncoder(userData.get())));
895 }
896
897 void WebFrameLoaderClient::didRunInsecureContent(SecurityOrigin*)
898 {
899     WebPage* webPage = m_frame->page();
900     if (!webPage)
901         return;
902
903     RefPtr<APIObject> userData;
904
905     webPage->injectedBundleLoaderClient().didRunInsecureContentForFrame(webPage, m_frame, userData);
906
907     webPage->send(Messages::WebPageProxy::DidRunInsecureContentForFrame(m_frame->frameID(), InjectedBundleUserMessageEncoder(userData.get())));
908 }
909
910 ResourceError WebFrameLoaderClient::cancelledError(const ResourceRequest& request)
911 {
912     return WebKit::cancelledError(request);
913 }
914
915 ResourceError WebFrameLoaderClient::blockedError(const ResourceRequest& request)
916 {
917     return WebKit::blockedError(request);
918 }
919
920 ResourceError WebFrameLoaderClient::cannotShowURLError(const ResourceRequest& request)
921 {
922     return WebKit::cannotShowURLError(request);
923 }
924
925 ResourceError WebFrameLoaderClient::interruptForPolicyChangeError(const ResourceRequest& request)
926 {
927     return WebKit::interruptForPolicyChangeError(request);
928 }
929
930 ResourceError WebFrameLoaderClient::cannotShowMIMETypeError(const ResourceResponse& response)
931 {
932     return WebKit::cannotShowMIMETypeError(response);
933 }
934
935 ResourceError WebFrameLoaderClient::fileDoesNotExistError(const ResourceResponse& response)
936 {
937     return WebKit::fileDoesNotExistError(response);
938 }
939
940 ResourceError WebFrameLoaderClient::pluginWillHandleLoadError(const ResourceResponse& response)
941 {
942     return WebKit::pluginWillHandleLoadError(response);
943 }
944
945 bool WebFrameLoaderClient::shouldFallBack(const ResourceError& error)
946 {
947     DEFINE_STATIC_LOCAL(const ResourceError, cancelledError, (this->cancelledError(ResourceRequest())));
948     DEFINE_STATIC_LOCAL(const ResourceError, pluginWillHandleLoadError, (this->pluginWillHandleLoadError(ResourceResponse())));
949
950     if (error.errorCode() == cancelledError.errorCode() && error.domain() == cancelledError.domain())
951         return false;
952
953     if (error.errorCode() == pluginWillHandleLoadError.errorCode() && error.domain() == pluginWillHandleLoadError.domain())
954         return false;
955
956     return true;
957 }
958
959 bool WebFrameLoaderClient::canHandleRequest(const ResourceRequest&) const
960 {
961     notImplemented();
962     return true;
963 }
964
965 bool WebFrameLoaderClient::canShowMIMEType(const String& MIMEType) const
966 {
967     notImplemented();
968     return true;
969 }
970
971 bool WebFrameLoaderClient::canShowMIMETypeAsHTML(const String& MIMEType) const
972 {
973     return true;
974 }
975
976 bool WebFrameLoaderClient::representationExistsForURLScheme(const String& URLScheme) const
977 {
978     notImplemented();
979     return false;
980 }
981
982 String WebFrameLoaderClient::generatedMIMETypeForURLScheme(const String& URLScheme) const
983 {
984     notImplemented();
985     return String();
986 }
987
988 void WebFrameLoaderClient::frameLoadCompleted()
989 {
990     notImplemented();
991 }
992
993 void WebFrameLoaderClient::saveViewStateToItem(HistoryItem*)
994 {
995     notImplemented();
996 }
997
998 void WebFrameLoaderClient::restoreViewState()
999 {
1000     notImplemented();
1001 }
1002
1003 void WebFrameLoaderClient::provisionalLoadStarted()
1004 {
1005     notImplemented();
1006 }
1007
1008 void WebFrameLoaderClient::didFinishLoad()
1009 {
1010     // If we have a load listener, notify it.
1011     if (WebFrame::LoadListener* loadListener = m_frame->loadListener())
1012         loadListener->didFinishLoad(m_frame);
1013 }
1014
1015 void WebFrameLoaderClient::prepareForDataSourceReplacement()
1016 {
1017     notImplemented();
1018 }
1019
1020 PassRefPtr<DocumentLoader> WebFrameLoaderClient::createDocumentLoader(const ResourceRequest& request, const SubstituteData& data)
1021 {
1022     return DocumentLoader::create(request, data);
1023 }
1024
1025 void WebFrameLoaderClient::setTitle(const String& title, const KURL& url)
1026 {
1027     WebPage* webPage = m_frame->page();
1028     if (!webPage)
1029         return;
1030
1031     WebProcess::shared().connection()->send(Messages::WebContext::DidUpdateHistoryTitle(webPage->pageID(),
1032         title, url.string(), m_frame->frameID()), 0);
1033 }
1034
1035 String WebFrameLoaderClient::userAgent(const KURL&)
1036 {
1037     WebPage* webPage = m_frame->page();
1038     if (!webPage)
1039         return String();
1040
1041     return webPage->userAgent();
1042 }
1043
1044 void WebFrameLoaderClient::savePlatformDataToCachedFrame(CachedFrame*)
1045 {
1046 }
1047
1048 void WebFrameLoaderClient::transitionToCommittedFromCachedFrame(CachedFrame*)
1049 {
1050 }
1051
1052 void WebFrameLoaderClient::transitionToCommittedForNewPage()
1053 {
1054     WebPage* webPage = m_frame->page();
1055     Color backgroundColor = webPage->drawsTransparentBackground() ? Color::transparent : Color::white;
1056
1057     bool isMainFrame = webPage->mainFrame() == m_frame;
1058
1059 #if ENABLE(TILED_BACKING_STORE)
1060     IntSize currentVisibleContentSize = m_frame->coreFrame()->view() ? m_frame->coreFrame()->view()->actualVisibleContentRect().size() : IntSize();
1061     m_frame->coreFrame()->createView(webPage->size(), backgroundColor, false, webPage->resizesToContentsLayoutSize(), isMainFrame && webPage->resizesToContentsEnabled());
1062
1063     if (isMainFrame && webPage->resizesToContentsEnabled()) {
1064         m_frame->coreFrame()->view()->setDelegatesScrolling(true);
1065         m_frame->coreFrame()->view()->setPaintsEntireContents(true);
1066     }
1067
1068     // The HistoryController will update the scroll position later if needed.
1069     m_frame->coreFrame()->view()->setActualVisibleContentRect(IntRect(IntPoint::zero(), currentVisibleContentSize));
1070 #else
1071     const String& mimeType = m_frame->coreFrame()->loader()->documentLoader()->response().mimeType();
1072     m_frameHasCustomRepresentation = isMainFrame && WebProcess::shared().shouldUseCustomRepresentationForMIMEType(mimeType);
1073
1074     m_frame->coreFrame()->createView(webPage->size(), backgroundColor, false, IntSize(), false);
1075 #endif
1076
1077     m_frame->coreFrame()->view()->setTransparent(!webPage->drawsBackground());
1078 }
1079
1080 void WebFrameLoaderClient::didSaveToPageCache()
1081 {
1082     WebPage* webPage = m_frame->page();
1083     if (!webPage)
1084         return;
1085
1086     if (m_frame->isMainFrame())
1087         return;
1088
1089     webPage->send(Messages::WebPageProxy::DidSaveFrameToPageCache(m_frame->frameID()));
1090 }
1091
1092 void WebFrameLoaderClient::didRestoreFromPageCache()
1093 {
1094     WebPage* webPage = m_frame->page();
1095     if (!webPage)
1096         return;
1097
1098     if (m_frame->isMainFrame())
1099         return;
1100
1101     WebFrame* parentFrame = static_cast<WebFrameLoaderClient*>(m_frame->coreFrame()->tree()->parent()->loader()->client())->webFrame();
1102     webPage->send(Messages::WebPageProxy::DidRestoreFrameFromPageCache(m_frame->frameID(), parentFrame->frameID()));
1103 }
1104
1105 void WebFrameLoaderClient::dispatchDidBecomeFrameset(bool value)
1106 {
1107     WebPage* webPage = m_frame->page();
1108     if (!webPage)
1109         return;
1110
1111     webPage->send(Messages::WebPageProxy::FrameDidBecomeFrameSet(m_frame->frameID(), value));
1112 }
1113
1114 bool WebFrameLoaderClient::canCachePage() const
1115 {
1116     // We cannot cache frames that have custom representations because they are
1117     // rendered in the UIProcess. 
1118     return !m_frameHasCustomRepresentation;
1119 }
1120
1121 void WebFrameLoaderClient::download(ResourceHandle* handle, const ResourceRequest& request, const ResourceRequest& initialRequest, const ResourceResponse& response)
1122 {
1123     m_frame->convertHandleToDownload(handle, request, initialRequest, response);
1124 }
1125
1126 PassRefPtr<Frame> WebFrameLoaderClient::createFrame(const KURL& url, const String& name, HTMLFrameOwnerElement* ownerElement,
1127                                                     const String& referrer, bool allowsScrolling, int marginWidth, int marginHeight)
1128 {
1129     WebPage* webPage = m_frame->page();
1130
1131     RefPtr<WebFrame> subframe = WebFrame::createSubframe(webPage, name, ownerElement);
1132
1133     Frame* coreSubframe = subframe->coreFrame();
1134
1135      // The creation of the frame may have run arbitrary JavaScript that removed it from the page already.
1136     m_frame->coreFrame()->loader()->loadURLIntoChildFrame(url, referrer, coreSubframe);
1137
1138     // The frame's onload handler may have removed it from the document.
1139     if (!coreSubframe->tree()->parent())
1140         return 0;
1141
1142     return coreSubframe;
1143 }
1144
1145 void WebFrameLoaderClient::didTransferChildFrameToNewDocument(Page*)
1146 {
1147     notImplemented();
1148 }
1149
1150 void WebFrameLoaderClient::transferLoadingResourceFromPage(unsigned long, DocumentLoader*, const ResourceRequest&, Page*)
1151 {
1152     notImplemented();
1153 }
1154
1155 PassRefPtr<Widget> WebFrameLoaderClient::createPlugin(const IntSize&, HTMLPlugInElement* pluginElement, const KURL& url, const Vector<String>& paramNames, const Vector<String>& paramValues, const String& mimeType, bool loadManually)
1156 {
1157     ASSERT(paramNames.size() == paramValues.size());
1158     
1159     WebPage* webPage = m_frame->page();
1160     ASSERT(webPage);
1161     
1162     Plugin::Parameters parameters;
1163     parameters.url = url;
1164     parameters.names = paramNames;
1165     parameters.values = paramValues;
1166     parameters.mimeType = mimeType;
1167     parameters.loadManually = loadManually;
1168
1169     // <rdar://problem/8440903>: AppleConnect has a bug where it does not
1170     // understand the parameter names specified in the <object> element that
1171     // embeds its plug-in. This hack works around the issue by converting the
1172     // parameter names to lowercase before passing them to the plug-in.
1173     // FIXME: This workaround should be dependent on site-specific quirks being
1174     // enabled. This requires adding this setting to WebKit2's WebPreferences
1175     // implementation. See <https://bugs.webkit.org/show_bug.cgi?id=46076>.
1176     if (equalIgnoringCase(mimeType, "application/x-snkp")) {
1177         for (size_t i = 0; i < paramNames.size(); ++i)
1178             parameters.names[i] = paramNames[i].lower();
1179     }
1180
1181     RefPtr<Plugin> plugin = webPage->createPlugin(parameters);
1182     if (!plugin)
1183         return 0;
1184     
1185     return PluginView::create(pluginElement, plugin.release(), parameters);
1186 }
1187
1188 void WebFrameLoaderClient::redirectDataToPlugin(Widget* pluginWidget)
1189 {
1190     ASSERT(!m_pluginView);
1191     ASSERT(pluginWidget);
1192     
1193     m_pluginView = static_cast<PluginView*>(pluginWidget);
1194 }
1195
1196 PassRefPtr<Widget> WebFrameLoaderClient::createJavaAppletWidget(const IntSize& pluginSize, HTMLAppletElement* appletElement, const KURL& baseURL, const Vector<String>& paramNames, const Vector<String>& paramValues)
1197 {
1198     return createPlugin(pluginSize, appletElement, KURL(), paramNames, paramValues, "application/x-java-applet", false);
1199 }
1200
1201 ObjectContentType WebFrameLoaderClient::objectContentType(const KURL& url, const String& mimeTypeIn)
1202 {
1203     // FIXME: This should be merged with WebCore::FrameLoader::defaultObjectContentType when the plugin code
1204     // is consolidated.
1205
1206     String mimeType = mimeTypeIn;
1207     if (mimeType.isEmpty())
1208         mimeType = MIMETypeRegistry::getMIMETypeForExtension(url.path().substring(url.path().reverseFind('.') + 1));
1209
1210     if (mimeType.isEmpty())
1211         return ObjectContentFrame;
1212
1213     if (MIMETypeRegistry::isSupportedImageMIMEType(mimeType))
1214         return WebCore::ObjectContentImage;
1215
1216     if (WebPage* webPage = m_frame->page()) {
1217         if (PluginData* pluginData = webPage->corePage()->pluginData()) {
1218             if (pluginData->supportsMimeType(mimeType))
1219                 return ObjectContentNetscapePlugin;
1220         }
1221     }
1222
1223     if (MIMETypeRegistry::isSupportedNonImageMIMEType(mimeType))
1224         return ObjectContentFrame;
1225
1226     return ObjectContentNone;
1227 }
1228
1229 String WebFrameLoaderClient::overrideMediaType() const
1230 {
1231     notImplemented();
1232     return String();
1233 }
1234
1235 void WebFrameLoaderClient::dispatchDidClearWindowObjectInWorld(DOMWrapperWorld* world)
1236 {
1237     WebPage* webPage = m_frame->page();
1238     if (!webPage)
1239         return;
1240
1241     webPage->injectedBundleLoaderClient().didClearWindowObjectForFrame(webPage, m_frame, world);
1242 }
1243
1244 void WebFrameLoaderClient::documentElementAvailable()
1245 {
1246     notImplemented();
1247 }
1248
1249 void WebFrameLoaderClient::didPerformFirstNavigation() const
1250 {
1251     notImplemented();
1252 }
1253
1254 void WebFrameLoaderClient::registerForIconNotification(bool listen)
1255 {
1256     notImplemented();
1257 }
1258
1259 #if PLATFORM(MAC)
1260     
1261 RemoteAXObjectRef WebFrameLoaderClient::accessibilityRemoteObject() 
1262 {
1263     return m_frame->page()->accessibilityRemoteObject();
1264 }
1265     
1266 #if ENABLE(MAC_JAVA_BRIDGE)
1267 jobject WebFrameLoaderClient::javaApplet(NSView*) { return 0; }
1268 #endif
1269 NSCachedURLResponse* WebFrameLoaderClient::willCacheResponse(DocumentLoader*, unsigned long identifier, NSCachedURLResponse* response) const
1270 {
1271     return response;
1272 }
1273
1274 #endif
1275 #if USE(CFNETWORK)
1276 bool WebFrameLoaderClient::shouldCacheResponse(DocumentLoader*, unsigned long identifier, const ResourceResponse&, const unsigned char* data, unsigned long long length)
1277 {
1278     return true;
1279 }
1280
1281 #endif
1282
1283 bool WebFrameLoaderClient::shouldUsePluginDocument(const String& /*mimeType*/) const
1284 {
1285     notImplemented();
1286     return false;
1287 }
1288
1289 PassRefPtr<FrameNetworkingContext> WebFrameLoaderClient::createNetworkingContext()
1290 {
1291     return WebFrameNetworkingContext::create(m_frame->coreFrame());
1292 }
1293
1294 } // namespace WebKit