2 * Copyright (C) 2010, 2011 Apple Inc. All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
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.
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.
27 #include "WebFrameLoaderClient.h"
29 #if ENABLE(TIZEN_WEBKIT2_ABOUT_MEMORY)
30 #include "AboutDataTizen.h"
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"
48 #include "WebFrameNetworkingContext.h"
49 #include "WebFullScreenManager.h"
50 #include "WebIconDatabaseMessages.h"
51 #include "WebNavigationDataStore.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>
80 #if ENABLE(WEB_INTENTS)
81 #include "InjectedBundleIntentRequest.h"
82 #include "IntentData.h"
83 #include <WebCore/IntentRequest.h>
86 #if ENABLE(WEB_INTENTS_TAG)
87 #include "IntentServiceInfo.h"
88 #include "WebIntentServiceInfo.h"
91 using namespace WebCore;
95 WebFrameLoaderClient::WebFrameLoaderClient(WebFrame* frame)
97 , m_hasSentResponseToPluginView(false)
98 , m_frameHasCustomRepresentation(false)
99 , m_frameCameFromPageCache(false)
103 WebFrameLoaderClient::~WebFrameLoaderClient()
107 void WebFrameLoaderClient::frameLoaderDestroyed()
109 m_frame->invalidate();
111 // Balances explicit ref() in WebFrame::createMainFrame and WebFrame::createSubframe.
115 bool WebFrameLoaderClient::hasHTMLView() const
117 return !m_frameHasCustomRepresentation;
120 bool WebFrameLoaderClient::hasWebView() const
122 return m_frame->page();
125 void WebFrameLoaderClient::makeRepresentation(DocumentLoader*)
130 void WebFrameLoaderClient::forceLayout()
135 void WebFrameLoaderClient::forceLayoutForNonHTML()
140 void WebFrameLoaderClient::setCopiesOnScroll()
145 void WebFrameLoaderClient::detachedFromParent2()
147 WebPage* webPage = m_frame->page();
151 RefPtr<APIObject> userData;
153 // Notify the bundle client.
154 webPage->injectedBundleLoaderClient().didRemoveFrameFromHierarchy(webPage, m_frame, userData);
156 // Notify the UIProcess.
157 webPage->send(Messages::WebPageProxy::DidRemoveFrameFromHierarchy(m_frame->frameID(), InjectedBundleUserMessageEncoder(userData.get())));
161 void WebFrameLoaderClient::detachedFromParent3()
166 void WebFrameLoaderClient::assignIdentifierToInitialRequest(unsigned long identifier, DocumentLoader* loader, const ResourceRequest& request)
168 WebPage* webPage = m_frame->page();
172 bool pageIsProvisionallyLoading = false;
173 if (FrameLoader* frameLoader = loader->frameLoader())
174 pageIsProvisionallyLoading = frameLoader->provisionalDocumentLoader() == loader;
176 webPage->injectedBundleResourceLoadClient().didInitiateLoadForResource(webPage, m_frame, identifier, request, pageIsProvisionallyLoading);
177 webPage->send(Messages::WebPageProxy::DidInitiateLoadForResource(m_frame->frameID(), identifier, request, pageIsProvisionallyLoading));
180 void WebFrameLoaderClient::dispatchWillSendRequest(DocumentLoader*, unsigned long identifier, ResourceRequest& request, const ResourceResponse& redirectResponse)
182 WebPage* webPage = m_frame->page();
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);
197 webPage->injectedBundleResourceLoadClient().willSendRequestForFrame(webPage, m_frame, identifier, request, redirectResponse);
200 if (request.isNull()) {
201 // FIXME: We should probably send a message saying we cancelled the request for the resource.
205 webPage->send(Messages::WebPageProxy::DidSendRequestForResource(m_frame->frameID(), identifier, request, redirectResponse));
208 bool WebFrameLoaderClient::shouldUseCredentialStorage(DocumentLoader*, unsigned long identifier)
210 WebPage* webPage = m_frame->page();
214 return webPage->injectedBundleResourceLoadClient().shouldUseCredentialStorage(webPage, m_frame, identifier);
217 void WebFrameLoaderClient::dispatchDidReceiveAuthenticationChallenge(DocumentLoader*, unsigned long, const AuthenticationChallenge& challenge)
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.
222 WebPage* webPage = m_frame->page();
226 AuthenticationManager::shared().didReceiveAuthenticationChallenge(m_frame, challenge);
229 void WebFrameLoaderClient::dispatchDidCancelAuthenticationChallenge(DocumentLoader*, unsigned long identifier, const AuthenticationChallenge&)
234 #if USE(PROTECTION_SPACE_AUTH_CALLBACK)
235 bool WebFrameLoaderClient::canAuthenticateAgainstProtectionSpace(DocumentLoader*, unsigned long, const ProtectionSpace& protectionSpace)
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.
240 WebPage* webPage = m_frame->page();
244 bool canAuthenticate;
245 if (!webPage->sendSync(Messages::WebPageProxy::CanAuthenticateAgainstProtectionSpaceInFrame(m_frame->frameID(), protectionSpace), Messages::WebPageProxy::CanAuthenticateAgainstProtectionSpaceInFrame::Reply(canAuthenticate)))
248 return canAuthenticate;
252 void WebFrameLoaderClient::dispatchDidReceiveResponse(DocumentLoader*, unsigned long identifier, const ResourceResponse& response)
254 WebPage* webPage = m_frame->page();
258 webPage->injectedBundleResourceLoadClient().didReceiveResponseForResource(webPage, m_frame, identifier, response);
259 webPage->send(Messages::WebPageProxy::DidReceiveResponseForResource(m_frame->frameID(), identifier, response));
262 void WebFrameLoaderClient::dispatchDidReceiveContentLength(DocumentLoader*, unsigned long identifier, int dataLength)
264 WebPage* webPage = m_frame->page();
268 webPage->injectedBundleResourceLoadClient().didReceiveContentLengthForResource(webPage, m_frame, identifier, dataLength);
269 webPage->send(Messages::WebPageProxy::DidReceiveContentLengthForResource(m_frame->frameID(), identifier, dataLength));
272 void WebFrameLoaderClient::dispatchDidFinishLoading(DocumentLoader*, unsigned long identifier)
274 WebPage* webPage = m_frame->page();
278 webPage->injectedBundleResourceLoadClient().didFinishLoadForResource(webPage, m_frame, identifier);
279 webPage->send(Messages::WebPageProxy::DidFinishLoadForResource(m_frame->frameID(), identifier));
282 void WebFrameLoaderClient::dispatchDidFailLoading(DocumentLoader*, unsigned long identifier, const ResourceError& error)
284 WebPage* webPage = m_frame->page();
288 webPage->injectedBundleResourceLoadClient().didFailLoadForResource(webPage, m_frame, identifier, error);
289 webPage->send(Messages::WebPageProxy::DidFailLoadForResource(m_frame->frameID(), identifier, error));
292 bool WebFrameLoaderClient::dispatchDidLoadResourceFromMemoryCache(DocumentLoader*, const ResourceRequest&, const ResourceResponse&, int length)
298 void WebFrameLoaderClient::dispatchDidHandleOnloadEvents()
300 WebPage* webPage = m_frame->page();
304 // Notify the bundle client.
305 webPage->injectedBundleLoaderClient().didHandleOnloadEventsForFrame(webPage, m_frame);
308 void WebFrameLoaderClient::dispatchDidReceiveServerRedirectForProvisionalLoad()
310 WebPage* webPage = m_frame->page();
314 DocumentLoader* provisionalLoader = m_frame->coreFrame()->loader()->provisionalDocumentLoader();
315 const String& url = provisionalLoader->url().string();
316 RefPtr<APIObject> userData;
318 // Notify the bundle client.
319 webPage->injectedBundleLoaderClient().didReceiveServerRedirectForProvisionalLoadForFrame(webPage, m_frame, userData);
321 // Notify the UIProcess.
322 webPage->send(Messages::WebPageProxy::DidReceiveServerRedirectForProvisionalLoadForFrame(m_frame->frameID(), url, InjectedBundleUserMessageEncoder(userData.get())));
325 void WebFrameLoaderClient::dispatchDidCancelClientRedirect()
327 WebPage* webPage = m_frame->page();
331 // Notify the bundle client.
332 webPage->injectedBundleLoaderClient().didCancelClientRedirectForFrame(webPage, m_frame);
335 void WebFrameLoaderClient::dispatchWillPerformClientRedirect(const KURL& url, double interval, double fireDate)
337 WebPage* webPage = m_frame->page();
341 // Notify the bundle client.
342 webPage->injectedBundleLoaderClient().willPerformClientRedirectForFrame(webPage, m_frame, url.string(), interval, fireDate);
345 void WebFrameLoaderClient::dispatchDidChangeLocationWithinPage()
347 WebPage* webPage = m_frame->page();
351 RefPtr<APIObject> userData;
353 // Notify the bundle client.
354 webPage->injectedBundleLoaderClient().didSameDocumentNavigationForFrame(webPage, m_frame, SameDocumentNavigationAnchorNavigation, userData);
356 // Notify the UIProcess.
357 webPage->send(Messages::WebPageProxy::DidSameDocumentNavigationForFrame(m_frame->frameID(), SameDocumentNavigationAnchorNavigation, m_frame->coreFrame()->document()->url().string(), InjectedBundleUserMessageEncoder(userData.get())));
360 void WebFrameLoaderClient::dispatchDidPushStateWithinPage()
362 WebPage* webPage = m_frame->page();
366 RefPtr<APIObject> userData;
368 // Notify the bundle client.
369 webPage->injectedBundleLoaderClient().didSameDocumentNavigationForFrame(webPage, m_frame, SameDocumentNavigationSessionStatePush, userData);
371 // Notify the UIProcess.
372 webPage->send(Messages::WebPageProxy::DidSameDocumentNavigationForFrame(m_frame->frameID(), SameDocumentNavigationSessionStatePush, m_frame->coreFrame()->document()->url().string(), InjectedBundleUserMessageEncoder(userData.get())));
375 void WebFrameLoaderClient::dispatchDidReplaceStateWithinPage()
377 WebPage* webPage = m_frame->page();
381 RefPtr<APIObject> userData;
383 // Notify the bundle client.
384 webPage->injectedBundleLoaderClient().didSameDocumentNavigationForFrame(webPage, m_frame, SameDocumentNavigationSessionStateReplace, userData);
386 // Notify the UIProcess.
387 webPage->send(Messages::WebPageProxy::DidSameDocumentNavigationForFrame(m_frame->frameID(), SameDocumentNavigationSessionStateReplace, m_frame->coreFrame()->document()->url().string(), InjectedBundleUserMessageEncoder(userData.get())));
390 void WebFrameLoaderClient::dispatchDidPopStateWithinPage()
392 WebPage* webPage = m_frame->page();
396 RefPtr<APIObject> userData;
398 // Notify the bundle client.
399 webPage->injectedBundleLoaderClient().didSameDocumentNavigationForFrame(webPage, m_frame, SameDocumentNavigationSessionStatePop, userData);
401 // Notify the UIProcess.
402 webPage->send(Messages::WebPageProxy::DidSameDocumentNavigationForFrame(m_frame->frameID(), SameDocumentNavigationSessionStatePop, m_frame->coreFrame()->document()->url().string(), InjectedBundleUserMessageEncoder(userData.get())));
405 void WebFrameLoaderClient::dispatchWillClose()
410 void WebFrameLoaderClient::dispatchDidReceiveIcon()
412 #if ENABLE(TIZEN_ICON_DATABASE)
413 WebPage* webPage = m_frame->page();
416 // Notify the UIProcess.
417 webPage->send(Messages::WebPageProxy::DidReceiveIcon());
421 WebProcess::shared().connection()->send(Messages::WebIconDatabase::DidReceiveIconForPageURL(m_frame->url()), 0);
424 void WebFrameLoaderClient::dispatchDidStartProvisionalLoad()
426 WebPage* webPage = m_frame->page();
430 #if ENABLE(FULLSCREEN_API)
431 if (m_frame->coreFrame()->document()->webkitIsFullScreen())
432 webPage->fullScreenManager()->close();
435 webPage->findController().hideFindUI();
436 webPage->sandboxExtensionTracker().didStartProvisionalLoad(m_frame);
438 DocumentLoader* provisionalLoader = m_frame->coreFrame()->loader()->provisionalDocumentLoader();
439 const String& url = provisionalLoader->url().string();
440 RefPtr<APIObject> userData;
442 // Notify the bundle client.
443 webPage->injectedBundleLoaderClient().didStartProvisionalLoadForFrame(webPage, m_frame, userData);
445 String unreachableURL = provisionalLoader->unreachableURL().string();
447 // Notify the UIProcess.
448 webPage->send(Messages::WebPageProxy::DidStartProvisionalLoadForFrame(m_frame->frameID(), url, unreachableURL, InjectedBundleUserMessageEncoder(userData.get())));
451 void WebFrameLoaderClient::dispatchDidReceiveTitle(const StringWithDirection& title)
453 WebPage* webPage = m_frame->page();
457 RefPtr<APIObject> userData;
459 // Notify the bundle client.
460 // FIXME: use direction of title.
461 webPage->injectedBundleLoaderClient().didReceiveTitleForFrame(webPage, title.string(), m_frame, userData);
463 // Notify the UIProcess.
464 webPage->send(Messages::WebPageProxy::DidReceiveTitleForFrame(m_frame->frameID(), title.string(), InjectedBundleUserMessageEncoder(userData.get())));
467 void WebFrameLoaderClient::dispatchDidChangeIcons(WebCore::IconType)
472 void WebFrameLoaderClient::dispatchDidCommitLoad()
474 WebPage* webPage = m_frame->page();
478 const ResourceResponse& response = m_frame->coreFrame()->loader()->documentLoader()->response();
479 RefPtr<APIObject> userData;
481 // Notify the bundle client.
482 webPage->injectedBundleLoaderClient().didCommitLoadForFrame(webPage, m_frame, userData);
484 webPage->sandboxExtensionTracker().didCommitProvisionalLoad(m_frame);
486 // Notify the UIProcess.
488 webPage->send(Messages::WebPageProxy::DidCommitLoadForFrame(m_frame->frameID(), response.mimeType(), m_frameHasCustomRepresentation, PlatformCertificateInfo(response), InjectedBundleUserMessageEncoder(userData.get())));
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());
497 #if ENABLE(TIZEN_SCREEN_READER)
498 webPage->updateScreenReaderFocus(0);
502 void WebFrameLoaderClient::dispatchDidFailProvisionalLoad(const ResourceError& error)
504 WebPage* webPage = m_frame->page();
508 RefPtr<APIObject> userData;
510 // Notify the bundle client.
511 webPage->injectedBundleLoaderClient().didFailProvisionalLoadWithErrorForFrame(webPage, m_frame, error, userData);
513 webPage->sandboxExtensionTracker().didFailProvisionalLoad(m_frame);
515 // Notify the UIProcess.
516 webPage->send(Messages::WebPageProxy::DidFailProvisionalLoadForFrame(m_frame->frameID(), error, InjectedBundleUserMessageEncoder(userData.get())));
518 // If we have a load listener, notify it.
519 if (WebFrame::LoadListener* loadListener = m_frame->loadListener())
520 loadListener->didFailLoad(m_frame, error.isCancellation());
523 void WebFrameLoaderClient::dispatchDidFailLoad(const ResourceError& error)
525 WebPage* webPage = m_frame->page();
529 RefPtr<APIObject> userData;
531 // Notify the bundle client.
532 webPage->injectedBundleLoaderClient().didFailLoadWithErrorForFrame(webPage, m_frame, error, userData);
534 // Notify the UIProcess.
535 webPage->send(Messages::WebPageProxy::DidFailLoadForFrame(m_frame->frameID(), error, InjectedBundleUserMessageEncoder(userData.get())));
537 // If we have a load listener, notify it.
538 if (WebFrame::LoadListener* loadListener = m_frame->loadListener())
539 loadListener->didFailLoad(m_frame, error.isCancellation());
542 void WebFrameLoaderClient::dispatchDidFinishDocumentLoad()
544 WebPage* webPage = m_frame->page();
548 RefPtr<APIObject> userData;
550 // Notify the bundle client.
551 webPage->injectedBundleLoaderClient().didFinishDocumentLoadForFrame(webPage, m_frame, userData);
553 // Notify the UIProcess.
554 webPage->send(Messages::WebPageProxy::DidFinishDocumentLoadForFrame(m_frame->frameID(), InjectedBundleUserMessageEncoder(userData.get())));
557 void WebFrameLoaderClient::dispatchDidFinishLoad()
559 WebPage* webPage = m_frame->page();
563 RefPtr<APIObject> userData;
565 // Notify the bundle client.
566 webPage->injectedBundleLoaderClient().didFinishLoadForFrame(webPage, m_frame, userData);
568 // Notify the UIProcess.
569 webPage->send(Messages::WebPageProxy::DidFinishLoadForFrame(m_frame->frameID(), InjectedBundleUserMessageEncoder(userData.get())));
571 // If we have a load listener, notify it.
572 if (WebFrame::LoadListener* loadListener = m_frame->loadListener())
573 loadListener->didFinishLoad(m_frame);
576 void WebFrameLoaderClient::dispatchDidFirstLayout()
578 WebPage* webPage = m_frame->page();
582 RefPtr<APIObject> userData;
584 // Notify the bundle client.
585 webPage->injectedBundleLoaderClient().didFirstLayoutForFrame(webPage, m_frame, userData);
587 // Notify the UIProcess.
588 webPage->send(Messages::WebPageProxy::DidFirstLayoutForFrame(m_frame->frameID(), InjectedBundleUserMessageEncoder(userData.get())));
590 if (m_frame == m_frame->page()->mainWebFrame() && !webPage->corePage()->settings()->suppressesIncrementalRendering())
591 webPage->drawingArea()->setLayerTreeStateIsFrozen(false);
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());
599 void WebFrameLoaderClient::dispatchDidFirstVisuallyNonEmptyLayout()
601 WebPage* webPage = m_frame->page();
605 RefPtr<APIObject> userData;
607 // Notify the bundle client.
608 webPage->injectedBundleLoaderClient().didFirstVisuallyNonEmptyLayoutForFrame(webPage, m_frame, userData);
610 // Notify the UIProcess.
611 webPage->send(Messages::WebPageProxy::DidFirstVisuallyNonEmptyLayoutForFrame(m_frame->frameID(), InjectedBundleUserMessageEncoder(userData.get())));
614 void WebFrameLoaderClient::dispatchDidNewFirstVisuallyNonEmptyLayout()
616 WebPage* webPage = m_frame->page();
620 RefPtr<APIObject> userData;
622 // Notify the bundle client.
623 webPage->injectedBundleLoaderClient().didNewFirstVisuallyNonEmptyLayout(webPage, userData);
625 // Notify the UIProcess.
626 webPage->send(Messages::WebPageProxy::DidNewFirstVisuallyNonEmptyLayout(InjectedBundleUserMessageEncoder(userData.get())));
629 void WebFrameLoaderClient::dispatchDidLayout()
631 WebPage* webPage = m_frame->page();
635 // Notify the bundle client.
636 webPage->injectedBundleLoaderClient().didLayoutForFrame(webPage, m_frame);
638 webPage->recomputeShortCircuitHorizontalWheelEventsState();
640 // NOTE: Unlike the other layout notifications, this does not notify the
641 // the UIProcess for every call.
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();
650 Frame* WebFrameLoaderClient::dispatchCreatePage(const NavigationAction& navigationAction)
652 WebPage* webPage = m_frame->page();
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);
661 return newPage->mainFrame();
664 void WebFrameLoaderClient::dispatchShow()
666 WebPage* webPage = m_frame->page();
673 void WebFrameLoaderClient::dispatchDecidePolicyForResponse(FramePolicyFunction function, const ResourceResponse& response, const ResourceRequest& request)
675 WebPage* webPage = m_frame->page();
679 if (!request.url().string()) {
680 (m_frame->coreFrame()->loader()->policyChecker()->*function)(PolicyUse);
684 RefPtr<APIObject> userData;
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);
693 uint64_t listenerID = m_frame->setUpPolicyListener(function);
694 bool receivedPolicyAction = false;
695 uint64_t policyAction;
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)))
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);
707 void WebFrameLoaderClient::dispatchDecidePolicyForNewWindowAction(FramePolicyFunction function, const NavigationAction& navigationAction, const ResourceRequest& request, PassRefPtr<FormState> formState, const String& frameName)
709 WebPage* webPage = m_frame->page();
713 RefPtr<APIObject> userData;
715 RefPtr<InjectedBundleNavigationAction> action = InjectedBundleNavigationAction::create(m_frame, navigationAction, formState);
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);
725 uint64_t listenerID = m_frame->setUpPolicyListener(function);
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())));
731 void WebFrameLoaderClient::dispatchDecidePolicyForNavigationAction(FramePolicyFunction function, const NavigationAction& navigationAction, const ResourceRequest& request, PassRefPtr<FormState> formState)
733 WebPage* webPage = m_frame->page();
737 // Always ignore requests with empty URLs.
738 if (request.isEmpty()) {
739 (m_frame->coreFrame()->loader()->policyChecker()->*function)(PolicyIgnore);
743 RefPtr<APIObject> userData;
745 RefPtr<InjectedBundleNavigationAction> action = InjectedBundleNavigationAction::create(m_frame, navigationAction, formState);
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);
754 uint64_t listenerID = m_frame->setUpPolicyListener(function);
755 bool receivedPolicyAction = false;
756 uint64_t policyAction;
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)))
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);
768 void WebFrameLoaderClient::cancelPolicyCheck()
770 m_frame->invalidatePolicyListener();
773 void WebFrameLoaderClient::dispatchUnableToImplementPolicy(const ResourceError& error)
775 WebPage* webPage = m_frame->page();
779 RefPtr<APIObject> userData;
781 // Notify the bundle client.
782 webPage->injectedBundlePolicyClient().unableToImplementPolicy(webPage, m_frame, error, userData);
784 // Notify the UIProcess.
785 webPage->send(Messages::WebPageProxy::UnableToImplementPolicy(m_frame->frameID(), error, InjectedBundleUserMessageEncoder(userData.get())));
788 void WebFrameLoaderClient::dispatchWillSendSubmitEvent(PassRefPtr<FormState> prpFormState)
790 WebPage* webPage = m_frame->page();
794 RefPtr<FormState> formState = prpFormState;
795 HTMLFormElement* form = formState->form();
796 WebFrame* sourceFrame = static_cast<WebFrameLoaderClient*>(formState->sourceDocument()->frame()->loader()->client())->webFrame();
798 webPage->injectedBundleFormClient().willSendSubmitEvent(webPage, form, m_frame, sourceFrame, formState->textFieldValues());
801 void WebFrameLoaderClient::dispatchWillSubmitForm(FramePolicyFunction function, PassRefPtr<FormState> prpFormState)
803 WebPage* webPage = m_frame->page();
807 // FIXME: Pass more of the form state.
808 RefPtr<FormState> formState = prpFormState;
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();
814 RefPtr<APIObject> userData;
815 webPage->injectedBundleFormClient().willSubmitForm(webPage, form, m_frame, sourceFrame, values, userData);
818 uint64_t listenerID = m_frame->setUpPolicyListener(function);
819 StringPairVector valuesVector(values);
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())));
824 webPage->send(Messages::WebPageProxy::WillSubmitForm(m_frame->frameID(), sourceFrame->frameID(), valuesVector, listenerID, InjectedBundleUserMessageEncoder(userData.get())));
828 void WebFrameLoaderClient::revertToProvisionalState(DocumentLoader*)
833 void WebFrameLoaderClient::setMainDocumentError(DocumentLoader*, const ResourceError& error)
838 m_pluginView->manualLoadDidFail(error);
840 m_hasSentResponseToPluginView = false;
843 void WebFrameLoaderClient::willChangeEstimatedProgress()
848 void WebFrameLoaderClient::didChangeEstimatedProgress()
853 void WebFrameLoaderClient::postProgressStartedNotification()
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());
860 webPage->drawingArea()->didStartProgress();
863 if (m_frame->isMainFrame())
864 webPage->send(Messages::WebPageProxy::DidStartProgress());
869 void WebFrameLoaderClient::postProgressEstimateChangedNotification()
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));
879 void WebFrameLoaderClient::postProgressFinishedNotification()
881 if (WebPage* webPage = m_frame->page()) {
882 if (m_frame->isMainFrame()) {
883 // Notify the bundle client.
884 webPage->injectedBundleLoaderClient().didFinishProgress(webPage);
886 webPage->send(Messages::WebPageProxy::DidFinishProgress());
887 #if ENABLE(TIZEN_LAYER_FLUSH_THROTTLING)
888 webPage->drawingArea()->didFinishProgress();
894 void WebFrameLoaderClient::setMainFrameDocumentReady(bool)
899 #if ENABLE(TIZEN_DOWNLOAD_ATTRIBUTE)
900 void WebFrameLoaderClient::startDownload(const ResourceRequest& request, const String& suggestedName)
902 m_frame->startDownload(request, suggestedName);
905 void WebFrameLoaderClient::startDownload(const ResourceRequest& request, const String& /* suggestedName */)
907 m_frame->startDownload(request);
911 void WebFrameLoaderClient::willChangeTitle(DocumentLoader*)
916 void WebFrameLoaderClient::didChangeTitle(DocumentLoader*)
921 void WebFrameLoaderClient::committedLoad(DocumentLoader* loader, const char* data, int length)
923 // If we're loading a custom representation, we don't want to hand off the data to WebCore.
924 if (m_frameHasCustomRepresentation)
928 loader->commitData(data, length);
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()));
935 // Calling commitData did not create the plug-in view.
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
946 m_hasSentResponseToPluginView = true;
948 m_pluginView->manualLoadDidReceiveData(data, length);
951 void WebFrameLoaderClient::finishedLoading(DocumentLoader* loader)
954 if (m_frameHasCustomRepresentation) {
955 WebPage* webPage = m_frame->page();
959 RefPtr<SharedBuffer> mainResourceData = loader->mainResourceData();
960 CoreIPC::DataReference dataReference(reinterpret_cast<const uint8_t*>(mainResourceData ? mainResourceData->data() : 0), mainResourceData ? mainResourceData->size() : 0);
962 webPage->send(Messages::WebPageProxy::DidFinishLoadingDataForCustomRepresentation(loader->response().suggestedFilename(), dataReference));
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());
972 // Protect against the above call nulling out the plug-in (by trying to cancel the load for example).
977 m_pluginView->manualLoadDidFinishLoading();
979 m_hasSentResponseToPluginView = false;
983 void WebFrameLoaderClient::updateGlobalHistory()
985 WebPage* webPage = m_frame->page();
986 if (!webPage || !webPage->pageGroup()->isVisibleToHistoryClient())
989 DocumentLoader* loader = m_frame->coreFrame()->loader()->documentLoader();
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();
997 WebProcess::shared().connection()->send(Messages::WebContext::DidNavigateWithNavigationData(webPage->pageID(), data, m_frame->frameID()), 0);
1000 void WebFrameLoaderClient::updateGlobalHistoryRedirectLinks()
1002 WebPage* webPage = m_frame->page();
1003 if (!webPage || !webPage->pageGroup()->isVisibleToHistoryClient())
1006 DocumentLoader* loader = m_frame->coreFrame()->loader()->documentLoader();
1007 ASSERT(loader->unreachableURL().isEmpty());
1010 if (!loader->clientRedirectSourceForHistory().isNull()) {
1011 WebProcess::shared().connection()->send(Messages::WebContext::DidPerformClientRedirect(webPage->pageID(),
1012 loader->clientRedirectSourceForHistory(), loader->clientRedirectDestinationForHistory(), m_frame->frameID()), 0);
1016 if (!loader->serverRedirectSourceForHistory().isNull()) {
1017 WebProcess::shared().connection()->send(Messages::WebContext::DidPerformServerRedirect(webPage->pageID(),
1018 loader->serverRedirectSourceForHistory(), loader->serverRedirectDestinationForHistory(), m_frame->frameID()), 0);
1022 bool WebFrameLoaderClient::shouldGoToHistoryItem(HistoryItem* item) const
1024 WebPage* webPage = m_frame->page();
1028 uint64_t itemID = WebBackForwardListProxy::idForItem(item);
1030 // We should never be considering navigating to an item that is not actually in the back/forward list.
1031 ASSERT_NOT_REACHED();
1035 RefPtr<InjectedBundleBackForwardListItem> bundleItem = InjectedBundleBackForwardListItem::create(item);
1036 RefPtr<APIObject> userData;
1038 // Ask the bundle client first
1039 bool shouldGoToBackForwardListItem = webPage->injectedBundleLoaderClient().shouldGoToBackForwardListItem(webPage, bundleItem.get(), userData);
1040 if (!shouldGoToBackForwardListItem)
1043 if (webPage->willGoToBackForwardItemCallbackEnabled()) {
1044 webPage->send(Messages::WebPageProxy::WillGoToBackForwardListItem(itemID, InjectedBundleUserMessageEncoder(userData.get())));
1048 if (!webPage->sendSync(Messages::WebPageProxy::ShouldGoToBackForwardListItem(itemID), Messages::WebPageProxy::ShouldGoToBackForwardListItem::Reply(shouldGoToBackForwardListItem)))
1051 return shouldGoToBackForwardListItem;
1054 bool WebFrameLoaderClient::shouldStopLoadingForHistoryItem(HistoryItem* item) const
1059 void WebFrameLoaderClient::didDisplayInsecureContent()
1061 WebPage* webPage = m_frame->page();
1065 RefPtr<APIObject> userData;
1067 webPage->injectedBundleLoaderClient().didDisplayInsecureContentForFrame(webPage, m_frame, userData);
1069 webPage->send(Messages::WebPageProxy::DidDisplayInsecureContentForFrame(m_frame->frameID(), InjectedBundleUserMessageEncoder(userData.get())));
1072 void WebFrameLoaderClient::didRunInsecureContent(SecurityOrigin*, const KURL&)
1074 WebPage* webPage = m_frame->page();
1078 RefPtr<APIObject> userData;
1080 webPage->injectedBundleLoaderClient().didRunInsecureContentForFrame(webPage, m_frame, userData);
1082 webPage->send(Messages::WebPageProxy::DidRunInsecureContentForFrame(m_frame->frameID(), InjectedBundleUserMessageEncoder(userData.get())));
1085 void WebFrameLoaderClient::didDetectXSS(const KURL&, bool)
1087 WebPage* webPage = m_frame->page();
1091 RefPtr<APIObject> userData;
1093 webPage->injectedBundleLoaderClient().didDetectXSSForFrame(webPage, m_frame, userData);
1095 webPage->send(Messages::WebPageProxy::DidDetectXSSForFrame(m_frame->frameID(), InjectedBundleUserMessageEncoder(userData.get())));
1098 ResourceError WebFrameLoaderClient::cancelledError(const ResourceRequest& request)
1100 return WebKit::cancelledError(request);
1103 ResourceError WebFrameLoaderClient::blockedError(const ResourceRequest& request)
1105 return WebKit::blockedError(request);
1108 ResourceError WebFrameLoaderClient::cannotShowURLError(const ResourceRequest& request)
1110 return WebKit::cannotShowURLError(request);
1113 ResourceError WebFrameLoaderClient::interruptedForPolicyChangeError(const ResourceRequest& request)
1115 return WebKit::interruptedForPolicyChangeError(request);
1118 ResourceError WebFrameLoaderClient::cannotShowMIMETypeError(const ResourceResponse& response)
1120 return WebKit::cannotShowMIMETypeError(response);
1123 ResourceError WebFrameLoaderClient::fileDoesNotExistError(const ResourceResponse& response)
1125 return WebKit::fileDoesNotExistError(response);
1128 ResourceError WebFrameLoaderClient::pluginWillHandleLoadError(const ResourceResponse& response)
1130 return WebKit::pluginWillHandleLoadError(response);
1133 bool WebFrameLoaderClient::shouldFallBack(const ResourceError& error)
1135 DEFINE_STATIC_LOCAL(const ResourceError, cancelledError, (this->cancelledError(ResourceRequest())));
1136 DEFINE_STATIC_LOCAL(const ResourceError, pluginWillHandleLoadError, (this->pluginWillHandleLoadError(ResourceResponse())));
1138 if (error.errorCode() == cancelledError.errorCode() && error.domain() == cancelledError.domain())
1141 if (error.errorCode() == pluginWillHandleLoadError.errorCode() && error.domain() == pluginWillHandleLoadError.domain())
1145 DEFINE_STATIC_LOCAL(const ResourceError, errorInterruptedForPolicyChange, (this->interruptedForPolicyChangeError(ResourceRequest())));
1147 if (error.errorCode() == errorInterruptedForPolicyChange.errorCode() && error.domain() == errorInterruptedForPolicyChange.domain())
1154 bool WebFrameLoaderClient::canHandleRequest(const ResourceRequest&) const
1160 bool WebFrameLoaderClient::canShowMIMEType(const String& MIMEType) const
1166 bool WebFrameLoaderClient::canShowMIMETypeAsHTML(const String& MIMEType) const
1171 bool WebFrameLoaderClient::representationExistsForURLScheme(const String& URLScheme) const
1177 String WebFrameLoaderClient::generatedMIMETypeForURLScheme(const String& URLScheme) const
1183 void WebFrameLoaderClient::frameLoadCompleted()
1185 WebPage* webPage = m_frame->page();
1189 if (m_frame == m_frame->page()->mainWebFrame())
1190 webPage->drawingArea()->setLayerTreeStateIsFrozen(false);
1193 void WebFrameLoaderClient::saveViewStateToItem(HistoryItem*)
1198 void WebFrameLoaderClient::restoreViewState()
1200 // Inform the UI process of the scale factor.
1201 double scaleFactor = m_frame->coreFrame()->loader()->history()->currentItem()->pageScaleFactor();
1203 // A scale factor of 0.0 means the history item actually has the "default scale factor" of 1.0.
1206 m_frame->page()->send(Messages::WebPageProxy::PageScaleFactorDidChange(scaleFactor));
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());
1214 void WebFrameLoaderClient::provisionalLoadStarted()
1216 WebPage* webPage = m_frame->page();
1220 if (m_frame == m_frame->page()->mainWebFrame())
1221 webPage->drawingArea()->setLayerTreeStateIsFrozen(true);
1224 void WebFrameLoaderClient::didFinishLoad()
1226 // If we have a load listener, notify it.
1227 if (WebFrame::LoadListener* loadListener = m_frame->loadListener())
1228 loadListener->didFinishLoad(m_frame);
1231 void WebFrameLoaderClient::prepareForDataSourceReplacement()
1236 PassRefPtr<DocumentLoader> WebFrameLoaderClient::createDocumentLoader(const ResourceRequest& request, const SubstituteData& data)
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());
1250 substituteDataLocal = data;
1252 return DocumentLoader::create(request, substituteDataLocal);
1254 return DocumentLoader::create(request, data);
1258 void WebFrameLoaderClient::setTitle(const StringWithDirection& title, const KURL& url)
1260 WebPage* webPage = m_frame->page();
1261 if (!webPage || !webPage->pageGroup()->isVisibleToHistoryClient())
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);
1269 String WebFrameLoaderClient::userAgent(const KURL&)
1271 WebPage* webPage = m_frame->page();
1275 return webPage->userAgent();
1278 #if ENABLE(TIZEN_CUSTOM_HEADERS)
1279 WebCore::HTTPHeaderMap WebFrameLoaderClient::customHeaders(const KURL&)
1281 WebPage* webPage = m_frame->page();
1283 return WebCore::HTTPHeaderMap();
1285 return webPage->customHeaders();
1289 void WebFrameLoaderClient::savePlatformDataToCachedFrame(CachedFrame*)
1293 void WebFrameLoaderClient::transitionToCommittedFromCachedFrame(CachedFrame*)
1295 WebPage* webPage = m_frame->page();
1296 bool isMainFrame = webPage->mainWebFrame() == m_frame;
1298 const ResourceResponse& response = m_frame->coreFrame()->loader()->documentLoader()->response();
1299 m_frameHasCustomRepresentation = isMainFrame && WebProcess::shared().shouldUseCustomRepresentationForResponse(response);
1300 m_frameCameFromPageCache = true;
1302 #if ENABLE(TIZEN_WEBKIT2_POPUP_INTERNAL)
1303 TIZEN_LOGI(" isMainFrame:%d", isMainFrame);
1305 webPage->notifyTransitionToCommitted(false);
1309 void WebFrameLoaderClient::transitionToCommittedForNewPage()
1311 WebPage* webPage = m_frame->page();
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();
1319 IntRect currentFixedVisibleContentRect = m_frame->coreFrame()->view() ? m_frame->coreFrame()->view()->fixedVisibleContentRect() : IntRect();
1322 const ResourceResponse& response = m_frame->coreFrame()->loader()->documentLoader()->response();
1323 m_frameHasCustomRepresentation = isMainFrame && WebProcess::shared().shouldUseCustomRepresentationForResponse(response);
1324 m_frameCameFromPageCache = false;
1326 m_frame->coreFrame()->createView(webPage->size(), backgroundColor, /* transparent */ false, IntSize(), currentFixedVisibleContentRect, shouldUseFixedLayout);
1327 m_frame->coreFrame()->view()->setTransparent(!webPage->drawsBackground());
1329 #if ENABLE(TIZEN_WEBKIT2_POPUP_INTERNAL)
1330 TIZEN_LOGI(" isMainFrame:%d", isMainFrame);
1332 webPage->notifyTransitionToCommitted(true);
1336 void WebFrameLoaderClient::didSaveToPageCache()
1338 WebPage* webPage = m_frame->page();
1342 if (m_frame->isMainFrame())
1345 webPage->send(Messages::WebPageProxy::DidSaveFrameToPageCache(m_frame->frameID()));
1348 void WebFrameLoaderClient::didRestoreFromPageCache()
1350 WebPage* webPage = m_frame->page();
1354 if (m_frame->isMainFrame())
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()));
1361 void WebFrameLoaderClient::dispatchDidBecomeFrameset(bool value)
1363 WebPage* webPage = m_frame->page();
1367 webPage->send(Messages::WebPageProxy::FrameDidBecomeFrameSet(m_frame->frameID(), value));
1370 bool WebFrameLoaderClient::canCachePage() const
1372 // We cannot cache frames that have custom representations because they are
1373 // rendered in the UIProcess.
1374 return !m_frameHasCustomRepresentation;
1377 void WebFrameLoaderClient::download(ResourceHandle* handle, const ResourceRequest& request, const ResourceResponse& response)
1379 m_frame->convertHandleToDownload(handle, request, response);
1382 PassRefPtr<Frame> WebFrameLoaderClient::createFrame(const KURL& url, const String& name, HTMLFrameOwnerElement* ownerElement,
1383 const String& referrer, bool allowsScrolling, int marginWidth, int marginHeight)
1385 WebPage* webPage = m_frame->page();
1387 RefPtr<WebFrame> subframe = WebFrame::createSubframe(webPage, name, ownerElement);
1389 Frame* coreSubframe = subframe->coreFrame();
1393 // The creation of the frame may have run arbitrary JavaScript that removed it from the page already.
1394 if (!coreSubframe->page())
1397 m_frame->coreFrame()->loader()->loadURLIntoChildFrame(url, referrer, coreSubframe);
1399 // The frame's onload handler may have removed it from the document.
1400 if (!subframe->coreFrame())
1402 ASSERT(subframe->coreFrame() == coreSubframe);
1403 if (!coreSubframe->tree()->parent())
1406 return coreSubframe;
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)
1411 ASSERT(paramNames.size() == paramValues.size());
1413 WebPage* webPage = m_frame->page();
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;
1424 parameters.layerHostingMode = webPage->layerHostingMode();
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");
1444 RefPtr<Plugin> plugin = webPage->createPlugin(m_frame, pluginElement, parameters);
1448 return PluginView::create(pluginElement, plugin.release(), parameters);
1451 void WebFrameLoaderClient::redirectDataToPlugin(Widget* pluginWidget)
1453 ASSERT(!m_pluginView);
1454 ASSERT(pluginWidget);
1456 m_pluginView = static_cast<PluginView*>(pluginWidget);
1459 PassRefPtr<Widget> WebFrameLoaderClient::createJavaAppletWidget(const IntSize& pluginSize, HTMLAppletElement* appletElement, const KURL& baseURL, const Vector<String>& paramNames, const Vector<String>& paramValues)
1461 RefPtr<Widget> plugin = createPlugin(pluginSize, appletElement, KURL(), paramNames, paramValues, appletElement->serviceType(), false);
1463 if (WebPage* webPage = m_frame->page())
1464 webPage->send(Messages::WebPageProxy::DidFailToInitializePlugin(appletElement->serviceType()));
1466 return plugin.release();
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&)
1476 void WebFrameLoaderClient::hideMediaPlayerProxyPlugin(Widget*)
1481 void WebFrameLoaderClient::showMediaPlayerProxyPlugin(Widget*)
1487 static bool pluginSupportsExtension(PluginData* pluginData, const String& extension)
1489 ASSERT(extension.lower() == extension);
1491 for (size_t i = 0; i < pluginData->mimes().size(); ++i) {
1492 const MimeClassInfo& mimeClassInfo = pluginData->mimes()[i];
1494 if (mimeClassInfo.extensions.contains(extension))
1500 ObjectContentType WebFrameLoaderClient::objectContentType(const KURL& url, const String& mimeTypeIn, bool shouldPreferPlugInsForImages)
1502 // FIXME: This should be merged with WebCore::FrameLoader::defaultObjectContentType when the plugin code
1505 String mimeType = mimeTypeIn;
1506 if (mimeType.isEmpty()) {
1507 String extension = url.path().substring(url.path().reverseFind('.') + 1).lower();
1509 // Try to guess the MIME type from the extension.
1510 mimeType = MIMETypeRegistry::getMIMETypeForExtension(extension);
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;
1523 if (mimeType.isEmpty())
1524 return ObjectContentFrame;
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;
1534 if (MIMETypeRegistry::isSupportedImageMIMEType(mimeType))
1535 return shouldPreferPlugInsForImages && plugInSupportsMIMEType ? ObjectContentNetscapePlugin : ObjectContentImage;
1537 if (plugInSupportsMIMEType)
1538 return ObjectContentNetscapePlugin;
1540 if (MIMETypeRegistry::isSupportedNonImageMIMEType(mimeType))
1541 return ObjectContentFrame;
1543 return ObjectContentNone;
1546 String WebFrameLoaderClient::overrideMediaType() const
1552 void WebFrameLoaderClient::dispatchDidClearWindowObjectInWorld(DOMWrapperWorld* world)
1554 WebPage* webPage = m_frame->page();
1558 webPage->injectedBundleLoaderClient().didClearWindowObjectForFrame(webPage, m_frame, world);
1561 // Ensure the accessibility hierarchy is updated.
1562 webPage->updateAccessibilityTree();
1567 void WebFrameLoaderClient::dispatchGlobalObjectAvailable(DOMWrapperWorld* world)
1569 WebPage* webPage = m_frame->page();
1573 webPage->injectedBundleLoaderClient().globalObjectIsAvailableForFrame(webPage, m_frame, world);
1576 void WebFrameLoaderClient::dispatchWillDisconnectDOMWindowExtensionFromGlobalObject(WebCore::DOMWindowExtension* extension)
1578 WebPage* webPage = m_frame->page();
1582 webPage->injectedBundleLoaderClient().willDisconnectDOMWindowExtensionFromGlobalObject(webPage, extension);
1585 void WebFrameLoaderClient::dispatchDidReconnectDOMWindowExtensionToGlobalObject(WebCore::DOMWindowExtension* extension)
1587 WebPage* webPage = m_frame->page();
1591 webPage->injectedBundleLoaderClient().didReconnectDOMWindowExtensionToGlobalObject(webPage, extension);
1594 void WebFrameLoaderClient::dispatchWillDestroyGlobalObjectForDOMWindowExtension(WebCore::DOMWindowExtension* extension)
1596 WebPage* webPage = m_frame->page();
1600 webPage->injectedBundleLoaderClient().willDestroyGlobalObjectForDOMWindowExtension(webPage, extension);
1603 void WebFrameLoaderClient::documentElementAvailable()
1608 void WebFrameLoaderClient::didPerformFirstNavigation() const
1613 void WebFrameLoaderClient::registerForIconNotification(bool listen)
1620 RemoteAXObjectRef WebFrameLoaderClient::accessibilityRemoteObject()
1622 return m_frame->page()->accessibilityRemoteObject();
1625 #if ENABLE(MAC_JAVA_BRIDGE)
1626 jobject WebFrameLoaderClient::javaApplet(NSView*) { return 0; }
1629 NSCachedURLResponse* WebFrameLoaderClient::willCacheResponse(DocumentLoader*, unsigned long identifier, NSCachedURLResponse* response) const
1631 WebPage* webPage = m_frame->page();
1635 return webPage->injectedBundleResourceLoadClient().shouldCacheResponse(webPage, m_frame, identifier) ? response : nil;
1638 #endif // PLATFORM(MAC)
1640 #if PLATFORM(WIN) && USE(CFNETWORK)
1641 bool WebFrameLoaderClient::shouldCacheResponse(DocumentLoader*, unsigned long identifier, const ResourceResponse&, const unsigned char* data, unsigned long long length)
1643 WebPage* webPage = m_frame->page();
1647 return webPage->injectedBundleResourceLoadClient().shouldCacheResponse(webPage, m_frame, identifier);
1649 #endif // PLATFORM(WIN) && USE(CFNETWORK)
1651 #if ENABLE(WEB_INTENTS)
1652 void WebFrameLoaderClient::dispatchIntent(PassRefPtr<IntentRequest> request)
1654 WebPage* webPage = m_frame->page();
1658 RefPtr<APIObject> userData;
1659 RefPtr<InjectedBundleIntentRequest> bundleIntentRequest = InjectedBundleIntentRequest::create(request.get());
1660 webPage->injectedBundleLoaderClient().didReceiveIntentForFrame(webPage, m_frame, bundleIntentRequest.get(), userData);
1662 IntentData intentData(request->intent());
1663 webPage->send(Messages::WebPageProxy::DidReceiveIntentForFrame(m_frame->frameID(), intentData, InjectedBundleUserMessageEncoder(userData.get())));
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)
1670 WebPage* webPage = m_frame->page();
1674 IntentServiceInfo serviceInfo;
1675 serviceInfo.action = action;
1676 serviceInfo.type = type;
1677 serviceInfo.href = href;
1678 serviceInfo.title = title;
1679 serviceInfo.disposition = disposition;
1681 RefPtr<APIObject> userData;
1682 RefPtr<WebIntentServiceInfo> webIntentServiceInfo = WebIntentServiceInfo::create(serviceInfo);
1683 webPage->injectedBundleLoaderClient().registerIntentServiceForFrame(webPage, m_frame, webIntentServiceInfo.get(), userData);
1685 webPage->send(Messages::WebPageProxy::RegisterIntentServiceForFrame(m_frame->frameID(), serviceInfo, InjectedBundleUserMessageEncoder(userData.get())));
1689 bool WebFrameLoaderClient::shouldUsePluginDocument(const String& /*mimeType*/) const
1695 void WebFrameLoaderClient::didChangeScrollOffset()
1697 WebPage* webPage = m_frame->page();
1701 if (!m_frame->isMainFrame())
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())
1709 webPage->didChangeScrollOffsetForMainFrame();
1712 bool WebFrameLoaderClient::shouldForceUniversalAccessFromLocalURL(const WebCore::KURL& url)
1714 WebPage* webPage = m_frame->page();
1718 return webPage->injectedBundleLoaderClient().shouldForceUniversalAccessFromLocalURL(webPage, url.string());
1721 PassRefPtr<FrameNetworkingContext> WebFrameLoaderClient::createNetworkingContext()
1723 RefPtr<WebFrameNetworkingContext> context = WebFrameNetworkingContext::create(m_frame);
1724 return context.release();
1727 #if ENABLE(TIZEN_CERTIFICATE_HANDLING)
1728 bool WebFrameLoaderClient::dispatchDecidePolicyForCertificateError(bool isTrusted, const String& url, const String& certificate, int error)
1730 WebPage* webPage = m_frame->page();
1734 bool canContinue = false;
1736 if (!webPage->sendSync(Messages::WebPageProxy::DecidePolicyForCertificateError(url, certificate, error), Messages::WebPageProxy::DecidePolicyForCertificateError::Reply(canContinue)))
1743 } // namespace WebKit