Cancel composition when focused node was changed
[framework/web/webkit-efl.git] / Source / WebKit2 / WebProcess / WebCoreSupport / WebFrameLoaderClient.cpp
1 /*
2  * Copyright (C) 2010, 2011 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 "config.h"
27 #include "WebFrameLoaderClient.h"
28
29 #if ENABLE(TIZEN_WEBKIT2_ABOUT_MEMORY)
30 #include "AboutDataTizen.h"
31 #endif
32 #include "AuthenticationManager.h"
33 #include "DataReference.h"
34 #include "InjectedBundle.h"
35 #include "InjectedBundleBackForwardListItem.h"
36 #include "InjectedBundleDOMWindowExtension.h"
37 #include "InjectedBundleNavigationAction.h"
38 #include "InjectedBundleUserMessageCoders.h"
39 #include "PlatformCertificateInfo.h"
40 #include "PluginView.h"
41 #include "StringPairVector.h"
42 #include "WebBackForwardListProxy.h"
43 #include "WebContextMessages.h"
44 #include "WebCoreArgumentCoders.h"
45 #include "WebErrors.h"
46 #include "WebEvent.h"
47 #include "WebFrame.h"
48 #include "WebFrameNetworkingContext.h"
49 #include "WebFullScreenManager.h"
50 #include "WebIconDatabaseMessages.h"
51 #include "WebNavigationDataStore.h"
52 #include "WebPage.h"
53 #include "WebPageProxyMessages.h"
54 #include "WebProcess.h"
55 #include "WebProcessProxyMessages.h"
56 #include <JavaScriptCore/APICast.h>
57 #include <JavaScriptCore/JSObject.h>
58 #include <WebCore/Chrome.h>
59 #include <WebCore/DOMWrapperWorld.h>
60 #include <WebCore/DocumentLoader.h>
61 #include <WebCore/FormState.h>
62 #include <WebCore/Frame.h>
63 #include <WebCore/FrameLoadRequest.h>
64 #include <WebCore/FrameView.h>
65 #include <WebCore/HTMLAppletElement.h>
66 #include <WebCore/HTMLFormElement.h>
67 #include <WebCore/HistoryItem.h>
68 #include <WebCore/MIMETypeRegistry.h>
69 #include <WebCore/MouseEvent.h>
70 #include <WebCore/NotImplemented.h>
71 #include <WebCore/Page.h>
72 #include <WebCore/PluginData.h>
73 #include <WebCore/ProgressTracker.h>
74 #include <WebCore/ResourceError.h>
75 #include <WebCore/Settings.h>
76 #include <WebCore/UIEventWithKeyState.h>
77 #include <WebCore/Widget.h>
78 #include <WebCore/WindowFeatures.h>
79
80 #if ENABLE(WEB_INTENTS)
81 #include "InjectedBundleIntentRequest.h"
82 #include "IntentData.h"
83 #include <WebCore/IntentRequest.h>
84 #endif
85
86 #if ENABLE(WEB_INTENTS_TAG)
87 #include "IntentServiceInfo.h"
88 #include "WebIntentServiceInfo.h"
89 #endif
90
91 using namespace WebCore;
92
93 namespace WebKit {
94
95 WebFrameLoaderClient::WebFrameLoaderClient(WebFrame* frame)
96     : m_frame(frame)
97     , m_hasSentResponseToPluginView(false)
98     , m_frameHasCustomRepresentation(false)
99     , m_frameCameFromPageCache(false)
100 {
101 }
102
103 WebFrameLoaderClient::~WebFrameLoaderClient()
104 {
105 }
106     
107 void WebFrameLoaderClient::frameLoaderDestroyed()
108 {
109     m_frame->invalidate();
110
111     // Balances explicit ref() in WebFrame::createMainFrame and WebFrame::createSubframe.
112     m_frame->deref();
113 }
114
115 bool WebFrameLoaderClient::hasHTMLView() const
116 {
117     return !m_frameHasCustomRepresentation;
118 }
119
120 bool WebFrameLoaderClient::hasWebView() const
121 {
122     return m_frame->page();
123 }
124
125 void WebFrameLoaderClient::makeRepresentation(DocumentLoader*)
126 {
127     notImplemented();
128 }
129
130 void WebFrameLoaderClient::forceLayout()
131 {
132     notImplemented();
133 }
134
135 void WebFrameLoaderClient::forceLayoutForNonHTML()
136 {
137     notImplemented();
138 }
139
140 void WebFrameLoaderClient::setCopiesOnScroll()
141 {
142     notImplemented();
143 }
144
145 void WebFrameLoaderClient::detachedFromParent2()
146 {
147     WebPage* webPage = m_frame->page();
148     if (!webPage)
149         return;
150
151     RefPtr<APIObject> userData;
152
153     // Notify the bundle client.
154     webPage->injectedBundleLoaderClient().didRemoveFrameFromHierarchy(webPage, m_frame, userData);
155
156     // Notify the UIProcess.
157     webPage->send(Messages::WebPageProxy::DidRemoveFrameFromHierarchy(m_frame->frameID(), InjectedBundleUserMessageEncoder(userData.get())));
158
159 }
160
161 void WebFrameLoaderClient::detachedFromParent3()
162 {
163     notImplemented();
164 }
165
166 void WebFrameLoaderClient::assignIdentifierToInitialRequest(unsigned long identifier, DocumentLoader* loader, const ResourceRequest& request)
167 {
168     WebPage* webPage = m_frame->page();
169     if (!webPage)
170         return;
171
172     bool pageIsProvisionallyLoading = false;
173     if (FrameLoader* frameLoader = loader->frameLoader())
174         pageIsProvisionallyLoading = frameLoader->provisionalDocumentLoader() == loader;
175
176     webPage->injectedBundleResourceLoadClient().didInitiateLoadForResource(webPage, m_frame, identifier, request, pageIsProvisionallyLoading);
177     webPage->send(Messages::WebPageProxy::DidInitiateLoadForResource(m_frame->frameID(), identifier, request, pageIsProvisionallyLoading));
178 }
179
180 void WebFrameLoaderClient::dispatchWillSendRequest(DocumentLoader*, unsigned long identifier, ResourceRequest& request, const ResourceResponse& redirectResponse)
181 {
182     WebPage* webPage = m_frame->page();
183     if (!webPage)
184         return;
185
186 #if ENABLE(TIZEN_WRT_APP_URI_SCHEME)
187     // After willSendRequestForFrame() from injectedBundleResourceLoadClient, request url can be changded to data:// protocol or others by it.
188     // But the original request url should be kept until it is passed to http library to avoid any side-effecs by forced changing.
189     // So we need to have the backup original request url and restore after willSendRequestForFrame().
190     KURL originalUrl = request.url();
191     webPage->injectedBundleResourceLoadClient().willSendRequestForFrame(webPage, m_frame, identifier, request, redirectResponse);
192     if (m_frame->coreFrame()->loader()->documentLoader()->isChangedURLProtocolForWebAppOrigin(originalUrl, request.url())) {
193         request.setAlternativeURL(request.url());
194         request.setURL(originalUrl);
195     }
196 #else
197     webPage->injectedBundleResourceLoadClient().willSendRequestForFrame(webPage, m_frame, identifier, request, redirectResponse);
198 #endif
199
200     if (request.isNull()) {
201         // FIXME: We should probably send a message saying we cancelled the request for the resource.
202         return;
203     }
204
205     webPage->send(Messages::WebPageProxy::DidSendRequestForResource(m_frame->frameID(), identifier, request, redirectResponse));
206 }
207
208 bool WebFrameLoaderClient::shouldUseCredentialStorage(DocumentLoader*, unsigned long identifier)
209 {
210     WebPage* webPage = m_frame->page();
211     if (!webPage)
212         return true;
213
214     return webPage->injectedBundleResourceLoadClient().shouldUseCredentialStorage(webPage, m_frame, identifier);
215 }
216
217 void WebFrameLoaderClient::dispatchDidReceiveAuthenticationChallenge(DocumentLoader*, unsigned long, const AuthenticationChallenge& challenge)
218 {
219     // FIXME: Authentication is a per-resource concept, but we don't do per-resource handling in the UIProcess at the API level quite yet.
220     // Once we do, we might need to make sure authentication fits with our solution.
221
222     WebPage* webPage = m_frame->page();
223     if (!webPage)
224         return;
225
226     AuthenticationManager::shared().didReceiveAuthenticationChallenge(m_frame, challenge);
227 }
228
229 void WebFrameLoaderClient::dispatchDidCancelAuthenticationChallenge(DocumentLoader*, unsigned long identifier, const AuthenticationChallenge&)    
230 {
231     notImplemented();
232 }
233
234 #if USE(PROTECTION_SPACE_AUTH_CALLBACK)
235 bool WebFrameLoaderClient::canAuthenticateAgainstProtectionSpace(DocumentLoader*, unsigned long, const ProtectionSpace& protectionSpace)
236 {
237     // FIXME: Authentication is a per-resource concept, but we don't do per-resource handling in the UIProcess at the API level quite yet.
238     // Once we do, we might need to make sure authentication fits with our solution.
239     
240     WebPage* webPage = m_frame->page();
241     if (!webPage)
242         return false;
243         
244     bool canAuthenticate;
245     if (!webPage->sendSync(Messages::WebPageProxy::CanAuthenticateAgainstProtectionSpaceInFrame(m_frame->frameID(), protectionSpace), Messages::WebPageProxy::CanAuthenticateAgainstProtectionSpaceInFrame::Reply(canAuthenticate)))
246         return false;
247     
248     return canAuthenticate;
249 }
250 #endif
251
252 void WebFrameLoaderClient::dispatchDidReceiveResponse(DocumentLoader*, unsigned long identifier, const ResourceResponse& response)
253 {
254     WebPage* webPage = m_frame->page();
255     if (!webPage)
256         return;
257
258     webPage->injectedBundleResourceLoadClient().didReceiveResponseForResource(webPage, m_frame, identifier, response);
259     webPage->send(Messages::WebPageProxy::DidReceiveResponseForResource(m_frame->frameID(), identifier, response));
260 }
261
262 void WebFrameLoaderClient::dispatchDidReceiveContentLength(DocumentLoader*, unsigned long identifier, int dataLength)
263 {
264     WebPage* webPage = m_frame->page();
265     if (!webPage)
266         return;
267
268     webPage->injectedBundleResourceLoadClient().didReceiveContentLengthForResource(webPage, m_frame, identifier, dataLength);
269     webPage->send(Messages::WebPageProxy::DidReceiveContentLengthForResource(m_frame->frameID(), identifier, dataLength));
270 }
271
272 void WebFrameLoaderClient::dispatchDidFinishLoading(DocumentLoader*, unsigned long identifier)
273 {
274     WebPage* webPage = m_frame->page();
275     if (!webPage)
276         return;
277
278     webPage->injectedBundleResourceLoadClient().didFinishLoadForResource(webPage, m_frame, identifier);
279     webPage->send(Messages::WebPageProxy::DidFinishLoadForResource(m_frame->frameID(), identifier));
280 }
281
282 void WebFrameLoaderClient::dispatchDidFailLoading(DocumentLoader*, unsigned long identifier, const ResourceError& error)
283 {
284     WebPage* webPage = m_frame->page();
285     if (!webPage)
286         return;
287
288     webPage->injectedBundleResourceLoadClient().didFailLoadForResource(webPage, m_frame, identifier, error);
289     webPage->send(Messages::WebPageProxy::DidFailLoadForResource(m_frame->frameID(), identifier, error));
290 }
291
292 bool WebFrameLoaderClient::dispatchDidLoadResourceFromMemoryCache(DocumentLoader*, const ResourceRequest&, const ResourceResponse&, int length)
293 {
294     notImplemented();
295     return false;
296 }
297
298 void WebFrameLoaderClient::dispatchDidHandleOnloadEvents()
299 {
300     WebPage* webPage = m_frame->page();
301     if (!webPage)
302         return;
303
304     // Notify the bundle client.
305     webPage->injectedBundleLoaderClient().didHandleOnloadEventsForFrame(webPage, m_frame);
306 }
307
308 void WebFrameLoaderClient::dispatchDidReceiveServerRedirectForProvisionalLoad()
309 {
310     WebPage* webPage = m_frame->page();
311     if (!webPage)
312         return;
313
314     DocumentLoader* provisionalLoader = m_frame->coreFrame()->loader()->provisionalDocumentLoader();
315     const String& url = provisionalLoader->url().string();
316     RefPtr<APIObject> userData;
317
318     // Notify the bundle client.
319     webPage->injectedBundleLoaderClient().didReceiveServerRedirectForProvisionalLoadForFrame(webPage, m_frame, userData);
320
321     // Notify the UIProcess.
322     webPage->send(Messages::WebPageProxy::DidReceiveServerRedirectForProvisionalLoadForFrame(m_frame->frameID(), url, InjectedBundleUserMessageEncoder(userData.get())));
323 }
324
325 void WebFrameLoaderClient::dispatchDidCancelClientRedirect()
326 {
327     WebPage* webPage = m_frame->page();
328     if (!webPage)
329         return;
330
331     // Notify the bundle client.
332     webPage->injectedBundleLoaderClient().didCancelClientRedirectForFrame(webPage, m_frame);
333 }
334
335 void WebFrameLoaderClient::dispatchWillPerformClientRedirect(const KURL& url, double interval, double fireDate)
336 {
337     WebPage* webPage = m_frame->page();
338     if (!webPage)
339         return;
340
341     // Notify the bundle client.
342     webPage->injectedBundleLoaderClient().willPerformClientRedirectForFrame(webPage, m_frame, url.string(), interval, fireDate);
343 }
344
345 void WebFrameLoaderClient::dispatchDidChangeLocationWithinPage()
346 {
347     WebPage* webPage = m_frame->page();
348     if (!webPage)
349         return;
350
351     RefPtr<APIObject> userData;
352
353     // Notify the bundle client.
354     webPage->injectedBundleLoaderClient().didSameDocumentNavigationForFrame(webPage, m_frame, SameDocumentNavigationAnchorNavigation, userData);
355
356     // Notify the UIProcess.
357     webPage->send(Messages::WebPageProxy::DidSameDocumentNavigationForFrame(m_frame->frameID(), SameDocumentNavigationAnchorNavigation, m_frame->coreFrame()->document()->url().string(), InjectedBundleUserMessageEncoder(userData.get())));
358 }
359
360 void WebFrameLoaderClient::dispatchDidPushStateWithinPage()
361 {
362     WebPage* webPage = m_frame->page();
363     if (!webPage)
364         return;
365
366     RefPtr<APIObject> userData;
367
368     // Notify the bundle client.
369     webPage->injectedBundleLoaderClient().didSameDocumentNavigationForFrame(webPage, m_frame, SameDocumentNavigationSessionStatePush, userData);
370
371     // Notify the UIProcess.
372     webPage->send(Messages::WebPageProxy::DidSameDocumentNavigationForFrame(m_frame->frameID(), SameDocumentNavigationSessionStatePush, m_frame->coreFrame()->document()->url().string(), InjectedBundleUserMessageEncoder(userData.get())));
373 }
374
375 void WebFrameLoaderClient::dispatchDidReplaceStateWithinPage()
376 {
377     WebPage* webPage = m_frame->page();
378     if (!webPage)
379         return;
380
381     RefPtr<APIObject> userData;
382
383     // Notify the bundle client.
384     webPage->injectedBundleLoaderClient().didSameDocumentNavigationForFrame(webPage, m_frame, SameDocumentNavigationSessionStateReplace, userData);
385
386     // Notify the UIProcess.
387     webPage->send(Messages::WebPageProxy::DidSameDocumentNavigationForFrame(m_frame->frameID(), SameDocumentNavigationSessionStateReplace, m_frame->coreFrame()->document()->url().string(), InjectedBundleUserMessageEncoder(userData.get())));
388 }
389
390 void WebFrameLoaderClient::dispatchDidPopStateWithinPage()
391 {
392     WebPage* webPage = m_frame->page();
393     if (!webPage)
394         return;
395
396     RefPtr<APIObject> userData;
397
398     // Notify the bundle client.
399     webPage->injectedBundleLoaderClient().didSameDocumentNavigationForFrame(webPage, m_frame, SameDocumentNavigationSessionStatePop, userData);
400
401     // Notify the UIProcess.
402     webPage->send(Messages::WebPageProxy::DidSameDocumentNavigationForFrame(m_frame->frameID(), SameDocumentNavigationSessionStatePop, m_frame->coreFrame()->document()->url().string(), InjectedBundleUserMessageEncoder(userData.get())));
403 }
404
405 void WebFrameLoaderClient::dispatchWillClose()
406 {
407     notImplemented();
408 }
409
410 void WebFrameLoaderClient::dispatchDidReceiveIcon()
411 {
412 #if ENABLE(TIZEN_ICON_DATABASE)
413     WebPage* webPage = m_frame->page();
414     if (!webPage)
415         return;
416     // Notify the UIProcess.
417     webPage->send(Messages::WebPageProxy::DidReceiveIcon());
418     return;
419 #endif
420
421     WebProcess::shared().connection()->send(Messages::WebIconDatabase::DidReceiveIconForPageURL(m_frame->url()), 0);
422 }
423
424 void WebFrameLoaderClient::dispatchDidStartProvisionalLoad()
425 {
426     WebPage* webPage = m_frame->page();
427     if (!webPage)
428         return;
429
430 #if ENABLE(FULLSCREEN_API)
431     if (m_frame->coreFrame()->document()->webkitIsFullScreen())
432         webPage->fullScreenManager()->close();
433 #endif
434
435     webPage->findController().hideFindUI();
436     webPage->sandboxExtensionTracker().didStartProvisionalLoad(m_frame);
437
438     DocumentLoader* provisionalLoader = m_frame->coreFrame()->loader()->provisionalDocumentLoader();
439     const String& url = provisionalLoader->url().string();
440     RefPtr<APIObject> userData;
441
442     // Notify the bundle client.
443     webPage->injectedBundleLoaderClient().didStartProvisionalLoadForFrame(webPage, m_frame, userData);
444
445     String unreachableURL = provisionalLoader->unreachableURL().string();
446
447     // Notify the UIProcess.
448     webPage->send(Messages::WebPageProxy::DidStartProvisionalLoadForFrame(m_frame->frameID(), url, unreachableURL, InjectedBundleUserMessageEncoder(userData.get())));
449 }
450
451 void WebFrameLoaderClient::dispatchDidReceiveTitle(const StringWithDirection& title)
452 {
453     WebPage* webPage = m_frame->page();
454     if (!webPage)
455         return;
456
457     RefPtr<APIObject> userData;
458
459     // Notify the bundle client.
460     // FIXME: use direction of title.
461     webPage->injectedBundleLoaderClient().didReceiveTitleForFrame(webPage, title.string(), m_frame, userData);
462
463     // Notify the UIProcess.
464     webPage->send(Messages::WebPageProxy::DidReceiveTitleForFrame(m_frame->frameID(), title.string(), InjectedBundleUserMessageEncoder(userData.get())));
465 }
466
467 void WebFrameLoaderClient::dispatchDidChangeIcons(WebCore::IconType)
468 {
469     notImplemented();
470 }
471
472 void WebFrameLoaderClient::dispatchDidCommitLoad()
473 {
474     WebPage* webPage = m_frame->page();
475     if (!webPage)
476         return;
477
478     const ResourceResponse& response = m_frame->coreFrame()->loader()->documentLoader()->response();
479     RefPtr<APIObject> userData;
480
481     // Notify the bundle client.
482     webPage->injectedBundleLoaderClient().didCommitLoadForFrame(webPage, m_frame, userData);
483
484     webPage->sandboxExtensionTracker().didCommitProvisionalLoad(m_frame);
485
486     // Notify the UIProcess.
487
488     webPage->send(Messages::WebPageProxy::DidCommitLoadForFrame(m_frame->frameID(), response.mimeType(), m_frameHasCustomRepresentation, PlatformCertificateInfo(response), InjectedBundleUserMessageEncoder(userData.get())));
489
490     // Only restore the scale factor for standard frame loads (of the main frame).
491     if (m_frame->isMainFrame() && m_frame->coreFrame()->loader()->loadType() == FrameLoadTypeStandard) {
492         Page* page = m_frame->coreFrame()->page();
493         if (page && page->pageScaleFactor() != 1)
494             webPage->scalePage(1, IntPoint());
495     }
496
497 #if ENABLE(TIZEN_SCREEN_READER)
498     webPage->updateScreenReaderFocus(0);
499 #endif
500 }
501
502 void WebFrameLoaderClient::dispatchDidFailProvisionalLoad(const ResourceError& error)
503 {
504     WebPage* webPage = m_frame->page();
505     if (!webPage)
506         return;
507
508     RefPtr<APIObject> userData;
509
510     // Notify the bundle client.
511     webPage->injectedBundleLoaderClient().didFailProvisionalLoadWithErrorForFrame(webPage, m_frame, error, userData);
512
513     webPage->sandboxExtensionTracker().didFailProvisionalLoad(m_frame);
514
515     // Notify the UIProcess.
516     webPage->send(Messages::WebPageProxy::DidFailProvisionalLoadForFrame(m_frame->frameID(), error, InjectedBundleUserMessageEncoder(userData.get())));
517     
518     // If we have a load listener, notify it.
519     if (WebFrame::LoadListener* loadListener = m_frame->loadListener())
520         loadListener->didFailLoad(m_frame, error.isCancellation());
521 }
522
523 void WebFrameLoaderClient::dispatchDidFailLoad(const ResourceError& error)
524 {
525     WebPage* webPage = m_frame->page();
526     if (!webPage)
527         return;
528
529     RefPtr<APIObject> userData;
530
531     // Notify the bundle client.
532     webPage->injectedBundleLoaderClient().didFailLoadWithErrorForFrame(webPage, m_frame, error, userData);
533
534     // Notify the UIProcess.
535     webPage->send(Messages::WebPageProxy::DidFailLoadForFrame(m_frame->frameID(), error, InjectedBundleUserMessageEncoder(userData.get())));
536
537     // If we have a load listener, notify it.
538     if (WebFrame::LoadListener* loadListener = m_frame->loadListener())
539         loadListener->didFailLoad(m_frame, error.isCancellation());
540 }
541
542 void WebFrameLoaderClient::dispatchDidFinishDocumentLoad()
543 {
544     WebPage* webPage = m_frame->page();
545     if (!webPage)
546         return;
547
548     RefPtr<APIObject> userData;
549
550     // Notify the bundle client.
551     webPage->injectedBundleLoaderClient().didFinishDocumentLoadForFrame(webPage, m_frame, userData);
552
553     // Notify the UIProcess.
554     webPage->send(Messages::WebPageProxy::DidFinishDocumentLoadForFrame(m_frame->frameID(), InjectedBundleUserMessageEncoder(userData.get())));
555 }
556
557 void WebFrameLoaderClient::dispatchDidFinishLoad()
558 {
559     WebPage* webPage = m_frame->page();
560     if (!webPage)
561         return;
562
563     RefPtr<APIObject> userData;
564
565     // Notify the bundle client.
566     webPage->injectedBundleLoaderClient().didFinishLoadForFrame(webPage, m_frame, userData);
567
568     // Notify the UIProcess.
569     webPage->send(Messages::WebPageProxy::DidFinishLoadForFrame(m_frame->frameID(), InjectedBundleUserMessageEncoder(userData.get())));
570
571     // If we have a load listener, notify it.
572     if (WebFrame::LoadListener* loadListener = m_frame->loadListener())
573         loadListener->didFinishLoad(m_frame);
574 }
575
576 void WebFrameLoaderClient::dispatchDidFirstLayout()
577 {
578     WebPage* webPage = m_frame->page();
579     if (!webPage)
580         return;
581
582     RefPtr<APIObject> userData;
583
584     // Notify the bundle client.
585     webPage->injectedBundleLoaderClient().didFirstLayoutForFrame(webPage, m_frame, userData);
586
587     // Notify the UIProcess.
588     webPage->send(Messages::WebPageProxy::DidFirstLayoutForFrame(m_frame->frameID(), InjectedBundleUserMessageEncoder(userData.get())));
589
590     if (m_frame == m_frame->page()->mainWebFrame() && !webPage->corePage()->settings()->suppressesIncrementalRendering())
591         webPage->drawingArea()->setLayerTreeStateIsFrozen(false);
592
593 #if USE(TILED_BACKING_STORE)
594     // Make sure viewport properties are dispatched on the main frame by the time the first layout happens.
595     ASSERT(!webPage->useFixedLayout() || m_frame != m_frame->page()->mainWebFrame() || m_frame->coreFrame()->document()->didDispatchViewportPropertiesChanged());
596 #endif
597 }
598
599 void WebFrameLoaderClient::dispatchDidFirstVisuallyNonEmptyLayout()
600 {
601     WebPage* webPage = m_frame->page();
602     if (!webPage)
603         return;
604
605     RefPtr<APIObject> userData;
606
607     // Notify the bundle client.
608     webPage->injectedBundleLoaderClient().didFirstVisuallyNonEmptyLayoutForFrame(webPage, m_frame, userData);
609
610     // Notify the UIProcess.
611     webPage->send(Messages::WebPageProxy::DidFirstVisuallyNonEmptyLayoutForFrame(m_frame->frameID(), InjectedBundleUserMessageEncoder(userData.get())));
612 }
613
614 void WebFrameLoaderClient::dispatchDidNewFirstVisuallyNonEmptyLayout()
615 {
616     WebPage* webPage = m_frame->page();
617     if (!webPage)
618         return;
619
620     RefPtr<APIObject> userData;
621
622     // Notify the bundle client.
623     webPage->injectedBundleLoaderClient().didNewFirstVisuallyNonEmptyLayout(webPage, userData);
624     
625     // Notify the UIProcess.
626     webPage->send(Messages::WebPageProxy::DidNewFirstVisuallyNonEmptyLayout(InjectedBundleUserMessageEncoder(userData.get())));
627 }
628
629 void WebFrameLoaderClient::dispatchDidLayout()
630 {
631     WebPage* webPage = m_frame->page();
632     if (!webPage)
633         return;
634
635     // Notify the bundle client.
636     webPage->injectedBundleLoaderClient().didLayoutForFrame(webPage, m_frame);
637
638     webPage->recomputeShortCircuitHorizontalWheelEventsState();
639
640     // NOTE: Unlike the other layout notifications, this does not notify the
641     // the UIProcess for every call.
642
643     if (m_frame == m_frame->page()->mainWebFrame()) {
644         // FIXME: Remove at the soonest possible time.
645         webPage->send(Messages::WebPageProxy::SetRenderTreeSize(webPage->renderTreeSize()));
646         webPage->mainFrameDidLayout();
647     }
648 }
649
650 Frame* WebFrameLoaderClient::dispatchCreatePage(const NavigationAction& navigationAction)
651 {
652     WebPage* webPage = m_frame->page();
653     if (!webPage)
654         return 0;
655
656     // Just call through to the chrome client.
657     Page* newPage = webPage->corePage()->chrome()->createWindow(m_frame->coreFrame(), FrameLoadRequest(m_frame->coreFrame()->document()->securityOrigin()), WindowFeatures(), navigationAction);
658     if (!newPage)
659         return 0;
660     
661     return newPage->mainFrame();
662 }
663
664 void WebFrameLoaderClient::dispatchShow()
665 {
666     WebPage* webPage = m_frame->page();
667     if (!webPage)
668         return;
669
670     webPage->show();
671 }
672
673 void WebFrameLoaderClient::dispatchDecidePolicyForResponse(FramePolicyFunction function, const ResourceResponse& response, const ResourceRequest& request)
674 {
675     WebPage* webPage = m_frame->page();
676     if (!webPage)
677         return;
678
679     if (!request.url().string()) {
680         (m_frame->coreFrame()->loader()->policyChecker()->*function)(PolicyUse);
681         return;
682     }
683
684     RefPtr<APIObject> userData;
685
686     // Notify the bundle client.
687     WKBundlePagePolicyAction policy = webPage->injectedBundlePolicyClient().decidePolicyForResponse(webPage, m_frame, response, request, userData);
688     if (policy == WKBundlePagePolicyActionUse) {
689         (m_frame->coreFrame()->loader()->policyChecker()->*function)(PolicyUse);
690         return;
691     }
692
693     uint64_t listenerID = m_frame->setUpPolicyListener(function);
694     bool receivedPolicyAction = false;
695     uint64_t policyAction;
696     uint64_t downloadID;
697
698     // Notify the UIProcess.
699     if (!webPage->sendSync(Messages::WebPageProxy::DecidePolicyForResponse(m_frame->frameID(), response, request, listenerID, InjectedBundleUserMessageEncoder(userData.get())), Messages::WebPageProxy::DecidePolicyForResponse::Reply(receivedPolicyAction, policyAction, downloadID)))
700         return;
701
702     // We call this synchronously because CFNetwork can only convert a loading connection to a download from its didReceiveResponse callback.
703     if (receivedPolicyAction)
704         m_frame->didReceivePolicyDecision(listenerID, static_cast<PolicyAction>(policyAction), downloadID);
705 }
706
707 void WebFrameLoaderClient::dispatchDecidePolicyForNewWindowAction(FramePolicyFunction function, const NavigationAction& navigationAction, const ResourceRequest& request, PassRefPtr<FormState> formState, const String& frameName)
708 {
709     WebPage* webPage = m_frame->page();
710     if (!webPage)
711         return;
712
713     RefPtr<APIObject> userData;
714
715     RefPtr<InjectedBundleNavigationAction> action = InjectedBundleNavigationAction::create(m_frame, navigationAction, formState);
716
717     // Notify the bundle client.
718     WKBundlePagePolicyAction policy = webPage->injectedBundlePolicyClient().decidePolicyForNewWindowAction(webPage, m_frame, action.get(), request, frameName, userData);
719     if (policy == WKBundlePagePolicyActionUse) {
720         (m_frame->coreFrame()->loader()->policyChecker()->*function)(PolicyUse);
721         return;
722     }
723
724
725     uint64_t listenerID = m_frame->setUpPolicyListener(function);
726
727     // Notify the UIProcess.
728     webPage->send(Messages::WebPageProxy::DecidePolicyForNewWindowAction(m_frame->frameID(), action->navigationType(), action->modifiers(), action->mouseButton(), request, frameName, listenerID, InjectedBundleUserMessageEncoder(userData.get())));
729 }
730
731 void WebFrameLoaderClient::dispatchDecidePolicyForNavigationAction(FramePolicyFunction function, const NavigationAction& navigationAction, const ResourceRequest& request, PassRefPtr<FormState> formState)
732 {
733     WebPage* webPage = m_frame->page();
734     if (!webPage)
735         return;
736
737     // Always ignore requests with empty URLs. 
738     if (request.isEmpty()) { 
739         (m_frame->coreFrame()->loader()->policyChecker()->*function)(PolicyIgnore); 
740         return; 
741     }
742
743     RefPtr<APIObject> userData;
744
745     RefPtr<InjectedBundleNavigationAction> action = InjectedBundleNavigationAction::create(m_frame, navigationAction, formState);
746
747     // Notify the bundle client.
748     WKBundlePagePolicyAction policy = webPage->injectedBundlePolicyClient().decidePolicyForNavigationAction(webPage, m_frame, action.get(), request, userData);
749     if (policy == WKBundlePagePolicyActionUse) {
750         (m_frame->coreFrame()->loader()->policyChecker()->*function)(PolicyUse);
751         return;
752     }
753     
754     uint64_t listenerID = m_frame->setUpPolicyListener(function);
755     bool receivedPolicyAction = false;
756     uint64_t policyAction;
757     uint64_t downloadID;
758
759     // Notify the UIProcess.
760     if (!webPage->sendSync(Messages::WebPageProxy::DecidePolicyForNavigationAction(m_frame->frameID(), action->navigationType(), action->modifiers(), action->mouseButton(), request, listenerID, InjectedBundleUserMessageEncoder(userData.get())), Messages::WebPageProxy::DecidePolicyForNavigationAction::Reply(receivedPolicyAction, policyAction, downloadID)))
761         return;
762
763     // We call this synchronously because WebCore cannot gracefully handle a frame load without a synchronous navigation policy reply.
764     if (receivedPolicyAction)
765         m_frame->didReceivePolicyDecision(listenerID, static_cast<PolicyAction>(policyAction), downloadID);
766 }
767
768 void WebFrameLoaderClient::cancelPolicyCheck()
769 {
770     m_frame->invalidatePolicyListener();
771 }
772
773 void WebFrameLoaderClient::dispatchUnableToImplementPolicy(const ResourceError& error)
774 {
775     WebPage* webPage = m_frame->page();
776     if (!webPage)
777         return;
778
779     RefPtr<APIObject> userData;
780
781     // Notify the bundle client.
782     webPage->injectedBundlePolicyClient().unableToImplementPolicy(webPage, m_frame, error, userData);
783
784     // Notify the UIProcess.
785     webPage->send(Messages::WebPageProxy::UnableToImplementPolicy(m_frame->frameID(), error, InjectedBundleUserMessageEncoder(userData.get())));
786 }
787
788 void WebFrameLoaderClient::dispatchWillSendSubmitEvent(PassRefPtr<FormState> prpFormState)
789 {
790     WebPage* webPage = m_frame->page();
791     if (!webPage)
792         return;
793
794     RefPtr<FormState> formState = prpFormState;
795     HTMLFormElement* form = formState->form();
796     WebFrame* sourceFrame = static_cast<WebFrameLoaderClient*>(formState->sourceDocument()->frame()->loader()->client())->webFrame();
797
798     webPage->injectedBundleFormClient().willSendSubmitEvent(webPage, form, m_frame, sourceFrame, formState->textFieldValues());
799 }
800
801 void WebFrameLoaderClient::dispatchWillSubmitForm(FramePolicyFunction function, PassRefPtr<FormState> prpFormState)
802 {
803     WebPage* webPage = m_frame->page();
804     if (!webPage)
805         return;
806
807     // FIXME: Pass more of the form state.
808     RefPtr<FormState> formState = prpFormState;
809     
810     HTMLFormElement* form = formState->form();
811     WebFrame* sourceFrame = static_cast<WebFrameLoaderClient*>(formState->sourceDocument()->frame()->loader()->client())->webFrame();
812     const Vector<std::pair<String, String> >& values = formState->textFieldValues();
813
814     RefPtr<APIObject> userData;
815     webPage->injectedBundleFormClient().willSubmitForm(webPage, form, m_frame, sourceFrame, values, userData);
816
817
818     uint64_t listenerID = m_frame->setUpPolicyListener(function);
819     StringPairVector valuesVector(values);
820
821 #if ENABLE(TIZEN_WEBKIT2_FORM_DATABASE)
822     webPage->send(Messages::WebPageProxy::WillSubmitForm(m_frame->frameID(), sourceFrame->frameID(), valuesVector, formState->containsPasswordData(), listenerID, InjectedBundleUserMessageEncoder(userData.get())));
823 #else
824     webPage->send(Messages::WebPageProxy::WillSubmitForm(m_frame->frameID(), sourceFrame->frameID(), valuesVector, listenerID, InjectedBundleUserMessageEncoder(userData.get())));
825 #endif
826 }
827
828 void WebFrameLoaderClient::revertToProvisionalState(DocumentLoader*)
829 {
830     notImplemented();
831 }
832
833 void WebFrameLoaderClient::setMainDocumentError(DocumentLoader*, const ResourceError& error)
834 {
835     if (!m_pluginView)
836         return;
837     
838     m_pluginView->manualLoadDidFail(error);
839     m_pluginView = 0;
840     m_hasSentResponseToPluginView = false;
841 }
842
843 void WebFrameLoaderClient::willChangeEstimatedProgress()
844 {
845     notImplemented();
846 }
847
848 void WebFrameLoaderClient::didChangeEstimatedProgress()
849 {
850     notImplemented();
851 }
852
853 void WebFrameLoaderClient::postProgressStartedNotification()
854 {
855     if (WebPage* webPage = m_frame->page()) {
856 #if ENABLE(TIZEN_LAYER_FLUSH_THROTTLING)
857         if (m_frame->isMainFrame()) {
858             webPage->send(Messages::WebPageProxy::DidStartProgress());
859
860             webPage->drawingArea()->didStartProgress();
861         }
862 #else
863         if (m_frame->isMainFrame())
864             webPage->send(Messages::WebPageProxy::DidStartProgress());
865 #endif
866     }
867 }
868
869 void WebFrameLoaderClient::postProgressEstimateChangedNotification()
870 {
871     if (WebPage* webPage = m_frame->page()) {
872         if (m_frame->isMainFrame()) {
873             double progress = webPage->corePage()->progress()->estimatedProgress();
874             webPage->send(Messages::WebPageProxy::DidChangeProgress(progress));
875         }
876     }
877 }
878
879 void WebFrameLoaderClient::postProgressFinishedNotification()
880 {
881     if (WebPage* webPage = m_frame->page()) {
882         if (m_frame->isMainFrame()) {
883             // Notify the bundle client.
884             webPage->injectedBundleLoaderClient().didFinishProgress(webPage);
885
886             webPage->send(Messages::WebPageProxy::DidFinishProgress());
887 #if ENABLE(TIZEN_LAYER_FLUSH_THROTTLING)
888             webPage->drawingArea()->didFinishProgress();
889 #endif
890         }
891     }
892 }
893
894 void WebFrameLoaderClient::setMainFrameDocumentReady(bool)
895 {
896     notImplemented();
897 }
898
899 #if ENABLE(TIZEN_DOWNLOAD_ATTRIBUTE)
900 void WebFrameLoaderClient::startDownload(const ResourceRequest& request, const String& suggestedName)
901 {
902     m_frame->startDownload(request, suggestedName);
903 }
904 #else
905 void WebFrameLoaderClient::startDownload(const ResourceRequest& request, const String& /* suggestedName */)
906 {
907     m_frame->startDownload(request);
908 }
909 #endif
910
911 void WebFrameLoaderClient::willChangeTitle(DocumentLoader*)
912 {
913     notImplemented();
914 }
915
916 void WebFrameLoaderClient::didChangeTitle(DocumentLoader*)
917 {
918     notImplemented();
919 }
920
921 void WebFrameLoaderClient::committedLoad(DocumentLoader* loader, const char* data, int length)
922 {
923     // If we're loading a custom representation, we don't want to hand off the data to WebCore.
924     if (m_frameHasCustomRepresentation)
925         return;
926
927     if (!m_pluginView)
928         loader->commitData(data, length);
929
930     // If the document is a stand-alone media document, now is the right time to cancel the WebKit load.
931     // FIXME: This code should be shared across all ports. <http://webkit.org/b/48762>.
932     if (m_frame->coreFrame()->document()->isMediaDocument())
933         loader->cancelMainResourceLoad(pluginWillHandleLoadError(loader->response()));
934
935     // Calling commitData did not create the plug-in view.
936     if (!m_pluginView)
937         return;
938
939     if (!m_hasSentResponseToPluginView) {
940         m_pluginView->manualLoadDidReceiveResponse(loader->response());
941         // manualLoadDidReceiveResponse sets up a new stream to the plug-in. on a full-page plug-in, a failure in
942         // setting up this stream can cause the main document load to be cancelled, setting m_pluginView
943         // to null
944         if (!m_pluginView)
945             return;
946         m_hasSentResponseToPluginView = true;
947     }
948     m_pluginView->manualLoadDidReceiveData(data, length);
949 }
950
951 void WebFrameLoaderClient::finishedLoading(DocumentLoader* loader)
952 {
953     if (!m_pluginView) {
954         if (m_frameHasCustomRepresentation) {
955             WebPage* webPage = m_frame->page();
956             if (!webPage)
957                 return;
958
959             RefPtr<SharedBuffer> mainResourceData = loader->mainResourceData();
960             CoreIPC::DataReference dataReference(reinterpret_cast<const uint8_t*>(mainResourceData ? mainResourceData->data() : 0), mainResourceData ? mainResourceData->size() : 0);
961             
962             webPage->send(Messages::WebPageProxy::DidFinishLoadingDataForCustomRepresentation(loader->response().suggestedFilename(), dataReference));
963         }
964     }
965
966     if (m_pluginView) {
967         // If we just received an empty response without any data, we won't have sent a response to the plug-in view.
968         // Make sure to do this before calling manualLoadDidFinishLoading.
969         if (!m_hasSentResponseToPluginView) {
970             m_pluginView->manualLoadDidReceiveResponse(loader->response());
971
972             // Protect against the above call nulling out the plug-in (by trying to cancel the load for example).
973             if (!m_pluginView)
974                 return;
975         }
976
977         m_pluginView->manualLoadDidFinishLoading();
978         m_pluginView = 0;
979         m_hasSentResponseToPluginView = false;
980     }
981 }
982
983 void WebFrameLoaderClient::updateGlobalHistory()
984 {
985     WebPage* webPage = m_frame->page();
986     if (!webPage || !webPage->pageGroup()->isVisibleToHistoryClient())
987         return;
988
989     DocumentLoader* loader = m_frame->coreFrame()->loader()->documentLoader();
990
991     WebNavigationDataStore data;
992     data.url = loader->urlForHistory().string();
993     // FIXME: use direction of title.
994     data.title = loader->title().string();
995     data.originalRequest = loader->originalRequestCopy();
996
997     WebProcess::shared().connection()->send(Messages::WebContext::DidNavigateWithNavigationData(webPage->pageID(), data, m_frame->frameID()), 0);
998 }
999
1000 void WebFrameLoaderClient::updateGlobalHistoryRedirectLinks()
1001 {
1002     WebPage* webPage = m_frame->page();
1003     if (!webPage || !webPage->pageGroup()->isVisibleToHistoryClient())
1004         return;
1005
1006     DocumentLoader* loader = m_frame->coreFrame()->loader()->documentLoader();
1007     ASSERT(loader->unreachableURL().isEmpty());
1008
1009     // Client redirect
1010     if (!loader->clientRedirectSourceForHistory().isNull()) {
1011         WebProcess::shared().connection()->send(Messages::WebContext::DidPerformClientRedirect(webPage->pageID(),
1012             loader->clientRedirectSourceForHistory(), loader->clientRedirectDestinationForHistory(), m_frame->frameID()), 0);
1013     }
1014
1015     // Server redirect
1016     if (!loader->serverRedirectSourceForHistory().isNull()) {
1017         WebProcess::shared().connection()->send(Messages::WebContext::DidPerformServerRedirect(webPage->pageID(),
1018             loader->serverRedirectSourceForHistory(), loader->serverRedirectDestinationForHistory(), m_frame->frameID()), 0);
1019     }
1020 }
1021
1022 bool WebFrameLoaderClient::shouldGoToHistoryItem(HistoryItem* item) const
1023 {
1024     WebPage* webPage = m_frame->page();
1025     if (!webPage)
1026         return false;
1027     
1028     uint64_t itemID = WebBackForwardListProxy::idForItem(item);
1029     if (!itemID) {
1030         // We should never be considering navigating to an item that is not actually in the back/forward list.
1031         ASSERT_NOT_REACHED();
1032         return false;
1033     }
1034
1035     RefPtr<InjectedBundleBackForwardListItem> bundleItem = InjectedBundleBackForwardListItem::create(item);
1036     RefPtr<APIObject> userData;
1037
1038     // Ask the bundle client first
1039     bool shouldGoToBackForwardListItem = webPage->injectedBundleLoaderClient().shouldGoToBackForwardListItem(webPage, bundleItem.get(), userData);
1040     if (!shouldGoToBackForwardListItem)
1041         return false;
1042     
1043     if (webPage->willGoToBackForwardItemCallbackEnabled()) {
1044         webPage->send(Messages::WebPageProxy::WillGoToBackForwardListItem(itemID, InjectedBundleUserMessageEncoder(userData.get())));
1045         return true;
1046     }
1047     
1048     if (!webPage->sendSync(Messages::WebPageProxy::ShouldGoToBackForwardListItem(itemID), Messages::WebPageProxy::ShouldGoToBackForwardListItem::Reply(shouldGoToBackForwardListItem)))
1049         return false;
1050     
1051     return shouldGoToBackForwardListItem;
1052 }
1053
1054 bool WebFrameLoaderClient::shouldStopLoadingForHistoryItem(HistoryItem* item) const
1055 {
1056     return true;
1057 }
1058
1059 void WebFrameLoaderClient::didDisplayInsecureContent()
1060 {
1061     WebPage* webPage = m_frame->page();
1062     if (!webPage)
1063         return;
1064
1065     RefPtr<APIObject> userData;
1066
1067     webPage->injectedBundleLoaderClient().didDisplayInsecureContentForFrame(webPage, m_frame, userData);
1068
1069     webPage->send(Messages::WebPageProxy::DidDisplayInsecureContentForFrame(m_frame->frameID(), InjectedBundleUserMessageEncoder(userData.get())));
1070 }
1071
1072 void WebFrameLoaderClient::didRunInsecureContent(SecurityOrigin*, const KURL&)
1073 {
1074     WebPage* webPage = m_frame->page();
1075     if (!webPage)
1076         return;
1077
1078     RefPtr<APIObject> userData;
1079
1080     webPage->injectedBundleLoaderClient().didRunInsecureContentForFrame(webPage, m_frame, userData);
1081
1082     webPage->send(Messages::WebPageProxy::DidRunInsecureContentForFrame(m_frame->frameID(), InjectedBundleUserMessageEncoder(userData.get())));
1083 }
1084
1085 void WebFrameLoaderClient::didDetectXSS(const KURL&, bool)
1086 {
1087     WebPage* webPage = m_frame->page();
1088     if (!webPage)
1089         return;
1090
1091     RefPtr<APIObject> userData;
1092
1093     webPage->injectedBundleLoaderClient().didDetectXSSForFrame(webPage, m_frame, userData);
1094
1095     webPage->send(Messages::WebPageProxy::DidDetectXSSForFrame(m_frame->frameID(), InjectedBundleUserMessageEncoder(userData.get())));
1096 }
1097
1098 ResourceError WebFrameLoaderClient::cancelledError(const ResourceRequest& request)
1099 {
1100     return WebKit::cancelledError(request);
1101 }
1102
1103 ResourceError WebFrameLoaderClient::blockedError(const ResourceRequest& request)
1104 {
1105     return WebKit::blockedError(request);
1106 }
1107
1108 ResourceError WebFrameLoaderClient::cannotShowURLError(const ResourceRequest& request)
1109 {
1110     return WebKit::cannotShowURLError(request);
1111 }
1112
1113 ResourceError WebFrameLoaderClient::interruptedForPolicyChangeError(const ResourceRequest& request)
1114 {
1115     return WebKit::interruptedForPolicyChangeError(request);
1116 }
1117
1118 ResourceError WebFrameLoaderClient::cannotShowMIMETypeError(const ResourceResponse& response)
1119 {
1120     return WebKit::cannotShowMIMETypeError(response);
1121 }
1122
1123 ResourceError WebFrameLoaderClient::fileDoesNotExistError(const ResourceResponse& response)
1124 {
1125     return WebKit::fileDoesNotExistError(response);
1126 }
1127
1128 ResourceError WebFrameLoaderClient::pluginWillHandleLoadError(const ResourceResponse& response)
1129 {
1130     return WebKit::pluginWillHandleLoadError(response);
1131 }
1132
1133 bool WebFrameLoaderClient::shouldFallBack(const ResourceError& error)
1134 {
1135     DEFINE_STATIC_LOCAL(const ResourceError, cancelledError, (this->cancelledError(ResourceRequest())));
1136     DEFINE_STATIC_LOCAL(const ResourceError, pluginWillHandleLoadError, (this->pluginWillHandleLoadError(ResourceResponse())));
1137
1138     if (error.errorCode() == cancelledError.errorCode() && error.domain() == cancelledError.domain())
1139         return false;
1140
1141     if (error.errorCode() == pluginWillHandleLoadError.errorCode() && error.domain() == pluginWillHandleLoadError.domain())
1142         return false;
1143
1144 #if PLATFORM(QT)
1145     DEFINE_STATIC_LOCAL(const ResourceError, errorInterruptedForPolicyChange, (this->interruptedForPolicyChangeError(ResourceRequest())));
1146
1147     if (error.errorCode() == errorInterruptedForPolicyChange.errorCode() && error.domain() == errorInterruptedForPolicyChange.domain())
1148         return false;
1149 #endif
1150
1151     return true;
1152 }
1153
1154 bool WebFrameLoaderClient::canHandleRequest(const ResourceRequest&) const
1155 {
1156     notImplemented();
1157     return true;
1158 }
1159
1160 bool WebFrameLoaderClient::canShowMIMEType(const String& MIMEType) const
1161 {
1162     notImplemented();
1163     return true;
1164 }
1165
1166 bool WebFrameLoaderClient::canShowMIMETypeAsHTML(const String& MIMEType) const
1167 {
1168     return true;
1169 }
1170
1171 bool WebFrameLoaderClient::representationExistsForURLScheme(const String& URLScheme) const
1172 {
1173     notImplemented();
1174     return false;
1175 }
1176
1177 String WebFrameLoaderClient::generatedMIMETypeForURLScheme(const String& URLScheme) const
1178 {
1179     notImplemented();
1180     return String();
1181 }
1182
1183 void WebFrameLoaderClient::frameLoadCompleted()
1184 {
1185     WebPage* webPage = m_frame->page();
1186     if (!webPage)
1187         return;
1188
1189     if (m_frame == m_frame->page()->mainWebFrame())
1190         webPage->drawingArea()->setLayerTreeStateIsFrozen(false);
1191 }
1192
1193 void WebFrameLoaderClient::saveViewStateToItem(HistoryItem*)
1194 {
1195     notImplemented();
1196 }
1197
1198 void WebFrameLoaderClient::restoreViewState()
1199 {
1200     // Inform the UI process of the scale factor.
1201     double scaleFactor = m_frame->coreFrame()->loader()->history()->currentItem()->pageScaleFactor();
1202
1203     // A scale factor of 0.0 means the history item actually has the "default scale factor" of 1.0.
1204     if (!scaleFactor)
1205         scaleFactor = 1.0;
1206     m_frame->page()->send(Messages::WebPageProxy::PageScaleFactorDidChange(scaleFactor));
1207
1208     // FIXME: This should not be necessary. WebCore should be correctly invalidating
1209     // the view on restores from the back/forward cache.
1210     if (m_frame == m_frame->page()->mainWebFrame())
1211         m_frame->page()->drawingArea()->setNeedsDisplay(m_frame->page()->bounds());
1212 }
1213
1214 void WebFrameLoaderClient::provisionalLoadStarted()
1215 {
1216     WebPage* webPage = m_frame->page();
1217     if (!webPage)
1218         return;
1219
1220     if (m_frame == m_frame->page()->mainWebFrame())
1221         webPage->drawingArea()->setLayerTreeStateIsFrozen(true);
1222 }
1223
1224 void WebFrameLoaderClient::didFinishLoad()
1225 {
1226     // If we have a load listener, notify it.
1227     if (WebFrame::LoadListener* loadListener = m_frame->loadListener())
1228         loadListener->didFinishLoad(m_frame);
1229 }
1230
1231 void WebFrameLoaderClient::prepareForDataSourceReplacement()
1232 {
1233     notImplemented();
1234 }
1235
1236 PassRefPtr<DocumentLoader> WebFrameLoaderClient::createDocumentLoader(const ResourceRequest& request, const SubstituteData& data)
1237 {
1238  #if ENABLE(TIZEN_WEBKIT2_ABOUT_MEMORY)
1239     SubstituteData substituteDataLocal;
1240     String aboutWhat = request.url().string().substring(7);
1241     if (m_frame->isMainFrame() && aboutWhat.contains(String("about:"), false)) {
1242         String source = aboutData(aboutWhat);
1243         if (!source.isEmpty()) {
1244             // Always ignore existing substitute data if any.
1245             WTF::RefPtr<SharedBuffer> buffer = SharedBuffer::create(source.is8Bit() ? reinterpret_cast<const char*>(source.characters8()) : source.latin1().data(), source.length());
1246             substituteDataLocal = SubstituteData(buffer, "text/html", "latin1", KURL());
1247         }
1248     }
1249     else
1250         substituteDataLocal = data;
1251
1252     return DocumentLoader::create(request, substituteDataLocal);
1253 #else
1254     return DocumentLoader::create(request, data);
1255 #endif
1256 }
1257
1258 void WebFrameLoaderClient::setTitle(const StringWithDirection& title, const KURL& url)
1259 {
1260     WebPage* webPage = m_frame->page();
1261     if (!webPage || !webPage->pageGroup()->isVisibleToHistoryClient())
1262         return;
1263
1264     // FIXME: use direction of title.
1265     WebProcess::shared().connection()->send(Messages::WebContext::DidUpdateHistoryTitle(webPage->pageID(),
1266         title.string(), url.string(), m_frame->frameID()), 0);
1267 }
1268
1269 String WebFrameLoaderClient::userAgent(const KURL&)
1270 {
1271     WebPage* webPage = m_frame->page();
1272     if (!webPage)
1273         return String();
1274
1275     return webPage->userAgent();
1276 }
1277
1278 #if ENABLE(TIZEN_CUSTOM_HEADERS)
1279 WebCore::HTTPHeaderMap WebFrameLoaderClient::customHeaders(const KURL&)
1280 {
1281     WebPage* webPage = m_frame->page();
1282     if (!webPage)
1283         return WebCore::HTTPHeaderMap();
1284
1285     return webPage->customHeaders();
1286 }
1287 #endif
1288
1289 void WebFrameLoaderClient::savePlatformDataToCachedFrame(CachedFrame*)
1290 {
1291 }
1292
1293 void WebFrameLoaderClient::transitionToCommittedFromCachedFrame(CachedFrame*)
1294 {
1295     WebPage* webPage = m_frame->page();
1296     bool isMainFrame = webPage->mainWebFrame() == m_frame;
1297     
1298     const ResourceResponse& response = m_frame->coreFrame()->loader()->documentLoader()->response();
1299     m_frameHasCustomRepresentation = isMainFrame && WebProcess::shared().shouldUseCustomRepresentationForResponse(response);
1300     m_frameCameFromPageCache = true;
1301
1302 #if ENABLE(TIZEN_WEBKIT2_POPUP_INTERNAL)
1303     TIZEN_LOGI(" isMainFrame:%d", isMainFrame);
1304     if (isMainFrame)
1305         webPage->notifyTransitionToCommitted(false);
1306 #endif
1307 }
1308
1309 void WebFrameLoaderClient::transitionToCommittedForNewPage()
1310 {
1311     WebPage* webPage = m_frame->page();
1312
1313     Color backgroundColor = webPage->drawsTransparentBackground() ? Color::transparent : Color::white;
1314     bool isMainFrame = webPage->mainWebFrame() == m_frame;
1315     bool shouldUseFixedLayout = isMainFrame && webPage->useFixedLayout();
1316 #if ENABLE(TIZEN_WEBKIT2_FIX_INVAlID_SCROLL_FOR_NEW_PAGE)
1317      IntRect currentFixedVisibleContentRect = m_frame->coreFrame()->view() ? IntRect(IntPoint::zero(), m_frame->coreFrame()->view()->fixedVisibleContentRect().size()) : IntRect();
1318 #else
1319     IntRect currentFixedVisibleContentRect = m_frame->coreFrame()->view() ? m_frame->coreFrame()->view()->fixedVisibleContentRect() : IntRect();
1320 #endif
1321
1322     const ResourceResponse& response = m_frame->coreFrame()->loader()->documentLoader()->response();
1323     m_frameHasCustomRepresentation = isMainFrame && WebProcess::shared().shouldUseCustomRepresentationForResponse(response);
1324     m_frameCameFromPageCache = false;
1325
1326     m_frame->coreFrame()->createView(webPage->size(), backgroundColor, /* transparent */ false, IntSize(), currentFixedVisibleContentRect, shouldUseFixedLayout);
1327     m_frame->coreFrame()->view()->setTransparent(!webPage->drawsBackground());
1328
1329 #if ENABLE(TIZEN_WEBKIT2_POPUP_INTERNAL)
1330     TIZEN_LOGI(" isMainFrame:%d", isMainFrame);
1331     if (isMainFrame)
1332         webPage->notifyTransitionToCommitted(true);
1333 #endif
1334 }
1335
1336 void WebFrameLoaderClient::didSaveToPageCache()
1337 {
1338     WebPage* webPage = m_frame->page();
1339     if (!webPage)
1340         return;
1341
1342     if (m_frame->isMainFrame())
1343         return;
1344
1345     webPage->send(Messages::WebPageProxy::DidSaveFrameToPageCache(m_frame->frameID()));
1346 }
1347
1348 void WebFrameLoaderClient::didRestoreFromPageCache()
1349 {
1350     WebPage* webPage = m_frame->page();
1351     if (!webPage)
1352         return;
1353
1354     if (m_frame->isMainFrame())
1355         return;
1356
1357     WebFrame* parentFrame = static_cast<WebFrameLoaderClient*>(m_frame->coreFrame()->tree()->parent()->loader()->client())->webFrame();
1358     webPage->send(Messages::WebPageProxy::DidRestoreFrameFromPageCache(m_frame->frameID(), parentFrame->frameID()));
1359 }
1360
1361 void WebFrameLoaderClient::dispatchDidBecomeFrameset(bool value)
1362 {
1363     WebPage* webPage = m_frame->page();
1364     if (!webPage)
1365         return;
1366
1367     webPage->send(Messages::WebPageProxy::FrameDidBecomeFrameSet(m_frame->frameID(), value));
1368 }
1369
1370 bool WebFrameLoaderClient::canCachePage() const
1371 {
1372     // We cannot cache frames that have custom representations because they are
1373     // rendered in the UIProcess. 
1374     return !m_frameHasCustomRepresentation;
1375 }
1376
1377 void WebFrameLoaderClient::download(ResourceHandle* handle, const ResourceRequest& request, const ResourceResponse& response)
1378 {
1379     m_frame->convertHandleToDownload(handle, request, response);
1380 }
1381
1382 PassRefPtr<Frame> WebFrameLoaderClient::createFrame(const KURL& url, const String& name, HTMLFrameOwnerElement* ownerElement,
1383                                                     const String& referrer, bool allowsScrolling, int marginWidth, int marginHeight)
1384 {
1385     WebPage* webPage = m_frame->page();
1386
1387     RefPtr<WebFrame> subframe = WebFrame::createSubframe(webPage, name, ownerElement);
1388
1389     Frame* coreSubframe = subframe->coreFrame();
1390     if (!coreSubframe)
1391         return 0;
1392
1393     // The creation of the frame may have run arbitrary JavaScript that removed it from the page already.
1394     if (!coreSubframe->page())
1395         return 0;
1396
1397     m_frame->coreFrame()->loader()->loadURLIntoChildFrame(url, referrer, coreSubframe);
1398
1399     // The frame's onload handler may have removed it from the document.
1400     if (!subframe->coreFrame())
1401         return 0;
1402     ASSERT(subframe->coreFrame() == coreSubframe);
1403     if (!coreSubframe->tree()->parent())
1404         return 0;
1405
1406     return coreSubframe;
1407 }
1408
1409 PassRefPtr<Widget> WebFrameLoaderClient::createPlugin(const IntSize&, HTMLPlugInElement* pluginElement, const KURL& url, const Vector<String>& paramNames, const Vector<String>& paramValues, const String& mimeType, bool loadManually)
1410 {
1411     ASSERT(paramNames.size() == paramValues.size());
1412     
1413     WebPage* webPage = m_frame->page();
1414     ASSERT(webPage);
1415     
1416     Plugin::Parameters parameters;
1417     parameters.url = url;
1418     parameters.names = paramNames;
1419     parameters.values = paramValues;
1420     parameters.mimeType = mimeType;
1421     parameters.isFullFramePlugin = loadManually;
1422     parameters.shouldUseManualLoader = parameters.isFullFramePlugin && !m_frameCameFromPageCache;
1423 #if PLATFORM(MAC)
1424     parameters.layerHostingMode = webPage->layerHostingMode();
1425 #endif
1426
1427 #if PLUGIN_ARCHITECTURE(X11)
1428     // FIXME: This should really be X11-specific plug-in quirks.
1429     if (equalIgnoringCase(mimeType, "application/x-shockwave-flash")) {
1430         // Currently we don't support transparency and windowed mode.
1431         // Inject wmode=opaque to make Flash work in these conditions.
1432         size_t wmodeIndex = parameters.names.find("wmode");
1433         if (wmodeIndex == notFound) {
1434             parameters.names.append("wmode");
1435             parameters.values.append("opaque");
1436         } else if (equalIgnoringCase(parameters.values[wmodeIndex], "window"))
1437             parameters.values[wmodeIndex] = "opaque";
1438     } else if (equalIgnoringCase(mimeType, "application/x-webkit-test-netscape")) {
1439         parameters.names.append("windowedPlugin");
1440         parameters.values.append("false");
1441     }
1442 #endif
1443
1444     RefPtr<Plugin> plugin = webPage->createPlugin(m_frame, pluginElement, parameters);
1445     if (!plugin)
1446         return 0;
1447     
1448     return PluginView::create(pluginElement, plugin.release(), parameters);
1449 }
1450
1451 void WebFrameLoaderClient::redirectDataToPlugin(Widget* pluginWidget)
1452 {
1453     ASSERT(!m_pluginView);
1454     ASSERT(pluginWidget);
1455     
1456     m_pluginView = static_cast<PluginView*>(pluginWidget);
1457 }
1458
1459 PassRefPtr<Widget> WebFrameLoaderClient::createJavaAppletWidget(const IntSize& pluginSize, HTMLAppletElement* appletElement, const KURL& baseURL, const Vector<String>& paramNames, const Vector<String>& paramValues)
1460 {
1461     RefPtr<Widget> plugin = createPlugin(pluginSize, appletElement, KURL(), paramNames, paramValues, appletElement->serviceType(), false);
1462     if (!plugin) {
1463         if (WebPage* webPage = m_frame->page())
1464             webPage->send(Messages::WebPageProxy::DidFailToInitializePlugin(appletElement->serviceType()));
1465     }
1466     return plugin.release();
1467 }
1468
1469 #if ENABLE(PLUGIN_PROXY_FOR_VIDEO)
1470 PassRefPtr<Widget> WebFrameLoaderClient::createMediaPlayerProxyPlugin(const IntSize&, HTMLMediaElement*, const KURL&, const Vector<String>&, const Vector<String>&, const String&)
1471 {
1472     notImplemented();
1473     return 0;
1474 }
1475
1476 void WebFrameLoaderClient::hideMediaPlayerProxyPlugin(Widget*)
1477 {
1478     notImplemented();
1479 }
1480
1481 void WebFrameLoaderClient::showMediaPlayerProxyPlugin(Widget*)
1482 {
1483     notImplemented();
1484 }
1485 #endif
1486
1487 static bool pluginSupportsExtension(PluginData* pluginData, const String& extension)
1488 {
1489     ASSERT(extension.lower() == extension);
1490
1491     for (size_t i = 0; i < pluginData->mimes().size(); ++i) {
1492         const MimeClassInfo& mimeClassInfo = pluginData->mimes()[i];
1493
1494         if (mimeClassInfo.extensions.contains(extension))
1495             return true;
1496     }
1497     return false;
1498 }
1499
1500 ObjectContentType WebFrameLoaderClient::objectContentType(const KURL& url, const String& mimeTypeIn, bool shouldPreferPlugInsForImages)
1501 {
1502     // FIXME: This should be merged with WebCore::FrameLoader::defaultObjectContentType when the plugin code
1503     // is consolidated.
1504
1505     String mimeType = mimeTypeIn;
1506     if (mimeType.isEmpty()) {
1507         String extension = url.path().substring(url.path().reverseFind('.') + 1).lower();
1508
1509         // Try to guess the MIME type from the extension.
1510         mimeType = MIMETypeRegistry::getMIMETypeForExtension(extension);
1511
1512         if (mimeType.isEmpty()) {
1513             // Check if there's a plug-in around that can handle the extension.
1514             if (WebPage* webPage = m_frame->page()) {
1515                 if (PluginData* pluginData = webPage->corePage()->pluginData()) {
1516                     if (pluginSupportsExtension(pluginData, extension))
1517                         return ObjectContentNetscapePlugin;
1518                 }
1519             }
1520         }
1521     }
1522
1523     if (mimeType.isEmpty())
1524         return ObjectContentFrame;
1525
1526     bool plugInSupportsMIMEType = false;
1527     if (WebPage* webPage = m_frame->page()) {
1528         if (PluginData* pluginData = webPage->corePage()->pluginData()) {
1529             if (pluginData->supportsMimeType(mimeType))
1530                 plugInSupportsMIMEType = true;
1531         }
1532     }
1533     
1534     if (MIMETypeRegistry::isSupportedImageMIMEType(mimeType))
1535         return shouldPreferPlugInsForImages && plugInSupportsMIMEType ? ObjectContentNetscapePlugin : ObjectContentImage;
1536
1537     if (plugInSupportsMIMEType)
1538         return ObjectContentNetscapePlugin;
1539
1540     if (MIMETypeRegistry::isSupportedNonImageMIMEType(mimeType))
1541         return ObjectContentFrame;
1542
1543     return ObjectContentNone;
1544 }
1545
1546 String WebFrameLoaderClient::overrideMediaType() const
1547 {
1548     notImplemented();
1549     return String();
1550 }
1551
1552 void WebFrameLoaderClient::dispatchDidClearWindowObjectInWorld(DOMWrapperWorld* world)
1553 {
1554     WebPage* webPage = m_frame->page();
1555     if (!webPage)
1556         return;
1557
1558     webPage->injectedBundleLoaderClient().didClearWindowObjectForFrame(webPage, m_frame, world);
1559
1560 #if PLATFORM(GTK)
1561     // Ensure the accessibility hierarchy is updated.
1562     webPage->updateAccessibilityTree();
1563 #endif
1564 }
1565
1566
1567 void WebFrameLoaderClient::dispatchGlobalObjectAvailable(DOMWrapperWorld* world)
1568 {
1569     WebPage* webPage = m_frame->page();
1570     if (!webPage)
1571         return;
1572     
1573     webPage->injectedBundleLoaderClient().globalObjectIsAvailableForFrame(webPage, m_frame, world);
1574 }
1575
1576 void WebFrameLoaderClient::dispatchWillDisconnectDOMWindowExtensionFromGlobalObject(WebCore::DOMWindowExtension* extension)
1577 {
1578     WebPage* webPage = m_frame->page();
1579     if (!webPage)
1580         return;
1581         
1582     webPage->injectedBundleLoaderClient().willDisconnectDOMWindowExtensionFromGlobalObject(webPage, extension);
1583 }
1584
1585 void WebFrameLoaderClient::dispatchDidReconnectDOMWindowExtensionToGlobalObject(WebCore::DOMWindowExtension* extension)
1586 {
1587     WebPage* webPage = m_frame->page();
1588     if (!webPage)
1589         return;
1590         
1591     webPage->injectedBundleLoaderClient().didReconnectDOMWindowExtensionToGlobalObject(webPage, extension);
1592 }
1593
1594 void WebFrameLoaderClient::dispatchWillDestroyGlobalObjectForDOMWindowExtension(WebCore::DOMWindowExtension* extension)
1595 {
1596     WebPage* webPage = m_frame->page();
1597     if (!webPage)
1598         return;
1599         
1600     webPage->injectedBundleLoaderClient().willDestroyGlobalObjectForDOMWindowExtension(webPage, extension);
1601 }
1602
1603 void WebFrameLoaderClient::documentElementAvailable()
1604 {
1605     notImplemented();
1606 }
1607
1608 void WebFrameLoaderClient::didPerformFirstNavigation() const
1609 {
1610     notImplemented();
1611 }
1612
1613 void WebFrameLoaderClient::registerForIconNotification(bool listen)
1614 {
1615     notImplemented();
1616 }
1617
1618 #if PLATFORM(MAC)
1619     
1620 RemoteAXObjectRef WebFrameLoaderClient::accessibilityRemoteObject() 
1621 {
1622     return m_frame->page()->accessibilityRemoteObject();
1623 }
1624     
1625 #if ENABLE(MAC_JAVA_BRIDGE)
1626 jobject WebFrameLoaderClient::javaApplet(NSView*) { return 0; }
1627 #endif
1628
1629 NSCachedURLResponse* WebFrameLoaderClient::willCacheResponse(DocumentLoader*, unsigned long identifier, NSCachedURLResponse* response) const
1630 {
1631     WebPage* webPage = m_frame->page();
1632     if (!webPage)
1633         return response;
1634
1635     return webPage->injectedBundleResourceLoadClient().shouldCacheResponse(webPage, m_frame, identifier) ? response : nil;
1636 }
1637
1638 #endif // PLATFORM(MAC)
1639
1640 #if PLATFORM(WIN) && USE(CFNETWORK)
1641 bool WebFrameLoaderClient::shouldCacheResponse(DocumentLoader*, unsigned long identifier, const ResourceResponse&, const unsigned char* data, unsigned long long length)
1642 {
1643     WebPage* webPage = m_frame->page();
1644     if (!webPage)
1645         return true;
1646
1647     return webPage->injectedBundleResourceLoadClient().shouldCacheResponse(webPage, m_frame, identifier);
1648 }
1649 #endif // PLATFORM(WIN) && USE(CFNETWORK)
1650
1651 #if ENABLE(WEB_INTENTS)
1652 void WebFrameLoaderClient::dispatchIntent(PassRefPtr<IntentRequest> request)
1653 {
1654     WebPage* webPage = m_frame->page();
1655     if (!webPage)
1656         return;
1657
1658     RefPtr<APIObject> userData;
1659     RefPtr<InjectedBundleIntentRequest> bundleIntentRequest = InjectedBundleIntentRequest::create(request.get());
1660     webPage->injectedBundleLoaderClient().didReceiveIntentForFrame(webPage, m_frame, bundleIntentRequest.get(), userData);
1661
1662     IntentData intentData(request->intent());
1663     webPage->send(Messages::WebPageProxy::DidReceiveIntentForFrame(m_frame->frameID(), intentData, InjectedBundleUserMessageEncoder(userData.get())));
1664 }
1665 #endif
1666
1667 #if ENABLE(WEB_INTENTS_TAG)
1668 void WebFrameLoaderClient::registerIntentService(const String& action, const String& type, const KURL& href, const String& title, const String& disposition)
1669 {
1670     WebPage* webPage = m_frame->page();
1671     if (!webPage)
1672         return;
1673
1674     IntentServiceInfo serviceInfo;
1675     serviceInfo.action = action;
1676     serviceInfo.type = type;
1677     serviceInfo.href = href;
1678     serviceInfo.title = title;
1679     serviceInfo.disposition = disposition;
1680
1681     RefPtr<APIObject> userData;
1682     RefPtr<WebIntentServiceInfo> webIntentServiceInfo = WebIntentServiceInfo::create(serviceInfo);
1683     webPage->injectedBundleLoaderClient().registerIntentServiceForFrame(webPage, m_frame, webIntentServiceInfo.get(), userData);
1684
1685     webPage->send(Messages::WebPageProxy::RegisterIntentServiceForFrame(m_frame->frameID(), serviceInfo, InjectedBundleUserMessageEncoder(userData.get())));
1686 }
1687 #endif
1688
1689 bool WebFrameLoaderClient::shouldUsePluginDocument(const String& /*mimeType*/) const
1690 {
1691     notImplemented();
1692     return false;
1693 }
1694
1695 void WebFrameLoaderClient::didChangeScrollOffset()
1696 {
1697     WebPage* webPage = m_frame->page();
1698     if (!webPage)
1699         return;
1700
1701     if (!m_frame->isMainFrame())
1702         return;
1703
1704     // If this is called when tearing down a FrameView, the WebCore::Frame's
1705     // current FrameView will be null.
1706     if (!m_frame->coreFrame()->view())
1707         return;
1708
1709     webPage->didChangeScrollOffsetForMainFrame();
1710 }
1711
1712 bool WebFrameLoaderClient::shouldForceUniversalAccessFromLocalURL(const WebCore::KURL& url)
1713 {
1714     WebPage* webPage = m_frame->page();
1715     if (!webPage)
1716         return false;
1717
1718     return webPage->injectedBundleLoaderClient().shouldForceUniversalAccessFromLocalURL(webPage, url.string());
1719 }
1720
1721 PassRefPtr<FrameNetworkingContext> WebFrameLoaderClient::createNetworkingContext()
1722 {
1723     RefPtr<WebFrameNetworkingContext> context = WebFrameNetworkingContext::create(m_frame);
1724     return context.release();
1725 }
1726
1727 #if ENABLE(TIZEN_CERTIFICATE_HANDLING)
1728 bool WebFrameLoaderClient::dispatchDecidePolicyForCertificateError(bool isTrusted, const String& url, const String& certificate, int error)
1729 {
1730     WebPage* webPage = m_frame->page();
1731     if (!webPage)
1732         return false;
1733
1734     bool canContinue = false;
1735
1736     if (!webPage->sendSync(Messages::WebPageProxy::DecidePolicyForCertificateError(url, certificate, error), Messages::WebPageProxy::DecidePolicyForCertificateError::Reply(canContinue)))
1737         return false;
1738
1739     return canContinue;
1740 }
1741 #endif
1742
1743 } // namespace WebKit