2 * Copyright (C) 2010 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 "WebLoaderClient.h"
29 #include "ImmutableArray.h"
30 #include "WKAPICast.h"
31 #include "WebBackForwardListItem.h"
34 #if ENABLE(WEB_INTENTS)
35 #include "WebIntentData.h"
36 #include "WebIntentServiceInfo.h"
39 using namespace WebCore;
43 void WebLoaderClient::didStartProvisionalLoadForFrame(WebPageProxy* page, WebFrameProxy* frame, APIObject* userData)
45 if (!m_client.didStartProvisionalLoadForFrame)
48 m_client.didStartProvisionalLoadForFrame(toAPI(page), toAPI(frame), toAPI(userData), m_client.clientInfo);
51 void WebLoaderClient::didReceiveServerRedirectForProvisionalLoadForFrame(WebPageProxy* page, WebFrameProxy* frame, APIObject* userData)
53 if (!m_client.didReceiveServerRedirectForProvisionalLoadForFrame)
56 m_client.didReceiveServerRedirectForProvisionalLoadForFrame(toAPI(page), toAPI(frame), toAPI(userData), m_client.clientInfo);
59 void WebLoaderClient::didFailProvisionalLoadWithErrorForFrame(WebPageProxy* page, WebFrameProxy* frame, const ResourceError& error, APIObject* userData)
61 if (!m_client.didFailProvisionalLoadWithErrorForFrame)
64 m_client.didFailProvisionalLoadWithErrorForFrame(toAPI(page), toAPI(frame), toAPI(error), toAPI(userData), m_client.clientInfo);
67 void WebLoaderClient::didCommitLoadForFrame(WebPageProxy* page, WebFrameProxy* frame, APIObject* userData)
69 if (!m_client.didCommitLoadForFrame)
72 m_client.didCommitLoadForFrame(toAPI(page), toAPI(frame), toAPI(userData), m_client.clientInfo);
75 void WebLoaderClient::didFinishDocumentLoadForFrame(WebPageProxy* page, WebFrameProxy* frame, APIObject* userData)
77 if (!m_client.didFinishDocumentLoadForFrame)
80 m_client.didFinishDocumentLoadForFrame(toAPI(page), toAPI(frame), toAPI(userData), m_client.clientInfo);
83 void WebLoaderClient::didFinishLoadForFrame(WebPageProxy* page, WebFrameProxy* frame, APIObject* userData)
85 if (!m_client.didFinishLoadForFrame)
88 m_client.didFinishLoadForFrame(toAPI(page), toAPI(frame), toAPI(userData), m_client.clientInfo);
91 void WebLoaderClient::didFailLoadWithErrorForFrame(WebPageProxy* page, WebFrameProxy* frame, const ResourceError& error, APIObject* userData)
93 if (!m_client.didFailLoadWithErrorForFrame)
96 m_client.didFailLoadWithErrorForFrame(toAPI(page), toAPI(frame), toAPI(error), toAPI(userData), m_client.clientInfo);
99 void WebLoaderClient::didSameDocumentNavigationForFrame(WebPageProxy* page, WebFrameProxy* frame, SameDocumentNavigationType type, APIObject* userData)
101 if (!m_client.didSameDocumentNavigationForFrame)
104 m_client.didSameDocumentNavigationForFrame(toAPI(page), toAPI(frame), toAPI(type), toAPI(userData), m_client.clientInfo);
107 void WebLoaderClient::didReceiveTitleForFrame(WebPageProxy* page, const String& title, WebFrameProxy* frame, APIObject* userData)
109 if (!m_client.didReceiveTitleForFrame)
112 m_client.didReceiveTitleForFrame(toAPI(page), toAPI(title.impl()), toAPI(frame), toAPI(userData), m_client.clientInfo);
115 void WebLoaderClient::didFirstLayoutForFrame(WebPageProxy* page, WebFrameProxy* frame, APIObject* userData)
117 if (!m_client.didFirstLayoutForFrame)
120 m_client.didFirstLayoutForFrame(toAPI(page), toAPI(frame), toAPI(userData), m_client.clientInfo);
123 void WebLoaderClient::didFirstVisuallyNonEmptyLayoutForFrame(WebPageProxy* page, WebFrameProxy* frame, APIObject* userData)
125 if (!m_client.didFirstVisuallyNonEmptyLayoutForFrame)
128 m_client.didFirstVisuallyNonEmptyLayoutForFrame(toAPI(page), toAPI(frame), toAPI(userData), m_client.clientInfo);
131 void WebLoaderClient::didNewFirstVisuallyNonEmptyLayout(WebPageProxy* page, APIObject* userData)
133 if (!m_client.didNewFirstVisuallyNonEmptyLayout)
136 m_client.didNewFirstVisuallyNonEmptyLayout(toAPI(page), toAPI(userData), m_client.clientInfo);
139 void WebLoaderClient::didRemoveFrameFromHierarchy(WebPageProxy* page, WebFrameProxy* frame, APIObject* userData)
141 if (!m_client.didRemoveFrameFromHierarchy)
144 m_client.didRemoveFrameFromHierarchy(toAPI(page), toAPI(frame), toAPI(userData), m_client.clientInfo);
147 void WebLoaderClient::didDisplayInsecureContentForFrame(WebPageProxy* page, WebFrameProxy* frame, APIObject* userData)
149 if (!m_client.didDisplayInsecureContentForFrame)
152 m_client.didDisplayInsecureContentForFrame(toAPI(page), toAPI(frame), toAPI(userData), m_client.clientInfo);
155 void WebLoaderClient::didRunInsecureContentForFrame(WebPageProxy* page, WebFrameProxy* frame, APIObject* userData)
157 if (!m_client.didRunInsecureContentForFrame)
160 m_client.didRunInsecureContentForFrame(toAPI(page), toAPI(frame), toAPI(userData), m_client.clientInfo);
163 void WebLoaderClient::didDetectXSSForFrame(WebPageProxy* page, WebFrameProxy* frame, APIObject* userData)
165 if (!m_client.didDetectXSSForFrame)
168 m_client.didDetectXSSForFrame(toAPI(page), toAPI(frame), toAPI(userData), m_client.clientInfo);
171 #if ENABLE(WEB_INTENTS)
172 void WebLoaderClient::didReceiveIntentForFrame(WebPageProxy* page, WebFrameProxy* frame, WebIntentData* intentData, APIObject* userData)
174 if (!m_client.didReceiveIntentForFrame)
177 m_client.didReceiveIntentForFrame(toAPI(page), toAPI(frame), toAPI(intentData), toAPI(userData), m_client.clientInfo);
181 #if ENABLE(WEB_INTENTS_TAG)
182 void WebLoaderClient::registerIntentServiceForFrame(WebPageProxy* page, WebFrameProxy* frame, WebIntentServiceInfo* serviceInfo, APIObject* userData)
184 if (!m_client.registerIntentServiceForFrame)
187 m_client.registerIntentServiceForFrame(toAPI(page), toAPI(frame), toAPI(serviceInfo), toAPI(userData), m_client.clientInfo);
191 bool WebLoaderClient::canAuthenticateAgainstProtectionSpaceInFrame(WebPageProxy* page, WebFrameProxy* frame, WebProtectionSpace* protectionSpace)
193 if (!m_client.canAuthenticateAgainstProtectionSpaceInFrame)
196 return m_client.canAuthenticateAgainstProtectionSpaceInFrame(toAPI(page), toAPI(frame), toAPI(protectionSpace), m_client.clientInfo);
199 #if ENABLE(TIZEN_ON_AUTHENTICATION_REQUESTED)
200 bool WebLoaderClient::didReceiveAuthenticationChallengeInFrame(WebPageProxy* page, WebFrameProxy* frame, AuthenticationChallengeProxy* authenticationChallenge)
202 if (!m_client.didReceiveAuthenticationChallengeInFrame)
205 return m_client.didReceiveAuthenticationChallengeInFrame(toAPI(page), toAPI(frame), toAPI(authenticationChallenge), m_client.clientInfo);
208 void WebLoaderClient::didReceiveAuthenticationChallengeInFrame(WebPageProxy* page, WebFrameProxy* frame, AuthenticationChallengeProxy* authenticationChallenge)
210 if (!m_client.didReceiveAuthenticationChallengeInFrame)
213 m_client.didReceiveAuthenticationChallengeInFrame(toAPI(page), toAPI(frame), toAPI(authenticationChallenge), m_client.clientInfo);
217 void WebLoaderClient::didStartProgress(WebPageProxy* page)
219 if (!m_client.didStartProgress)
222 m_client.didStartProgress(toAPI(page), m_client.clientInfo);
225 void WebLoaderClient::didChangeProgress(WebPageProxy* page)
227 if (!m_client.didChangeProgress)
230 m_client.didChangeProgress(toAPI(page), m_client.clientInfo);
233 void WebLoaderClient::didFinishProgress(WebPageProxy* page)
235 if (!m_client.didFinishProgress)
238 m_client.didFinishProgress(toAPI(page), m_client.clientInfo);
241 void WebLoaderClient::processDidBecomeUnresponsive(WebPageProxy* page)
243 if (!m_client.processDidBecomeUnresponsive)
246 m_client.processDidBecomeUnresponsive(toAPI(page), m_client.clientInfo);
249 void WebLoaderClient::interactionOccurredWhileProcessUnresponsive(WebPageProxy* page)
251 if (!m_client.interactionOccurredWhileProcessUnresponsive)
254 m_client.interactionOccurredWhileProcessUnresponsive(toAPI(page), m_client.clientInfo);
257 void WebLoaderClient::processDidBecomeResponsive(WebPageProxy* page)
259 if (!m_client.processDidBecomeResponsive)
262 m_client.processDidBecomeResponsive(toAPI(page), m_client.clientInfo);
265 void WebLoaderClient::processDidCrash(WebPageProxy* page)
267 if (!m_client.processDidCrash)
270 m_client.processDidCrash(toAPI(page), m_client.clientInfo);
273 void WebLoaderClient::didChangeBackForwardList(WebPageProxy* page, WebBackForwardListItem* addedItem, Vector<RefPtr<APIObject> >* removedItems)
275 if (!m_client.didChangeBackForwardList)
278 RefPtr<ImmutableArray> removedItemsArray;
279 if (removedItems && !removedItems->isEmpty())
280 removedItemsArray = ImmutableArray::adopt(*removedItems);
282 m_client.didChangeBackForwardList(toAPI(page), toAPI(addedItem), toAPI(removedItemsArray.get()), m_client.clientInfo);
285 bool WebLoaderClient::shouldGoToBackForwardListItem(WebPageProxy* page, WebBackForwardListItem* item)
287 // We should only even considering sending the shouldGoToBackForwardListItem() client callback
288 // for version 0 clients. Later versioned clients should get willGoToBackForwardListItem() instead,
289 // but due to XPC race conditions this one might have been called instead.
290 if (m_client.version > 0 || !m_client.shouldGoToBackForwardListItem)
293 return m_client.shouldGoToBackForwardListItem(toAPI(page), toAPI(item), m_client.clientInfo);
296 void WebLoaderClient::willGoToBackForwardListItem(WebPageProxy* page, WebBackForwardListItem* item, APIObject* userData)
298 if (m_client.willGoToBackForwardListItem)
299 m_client.willGoToBackForwardListItem(toAPI(page), toAPI(item), toAPI(userData), m_client.clientInfo);
302 void WebLoaderClient::didFailToInitializePlugin(WebPageProxy* page, const String& mimeType)
304 if (m_client.didFailToInitializePlugin_deprecatedForUseWithV0)
305 m_client.didFailToInitializePlugin_deprecatedForUseWithV0(toAPI(page), toAPI(mimeType.impl()), m_client.clientInfo);
307 if (!m_client.pluginDidFail)
310 m_client.pluginDidFail(toAPI(page), kWKErrorCodeCannotLoadPlugIn, toAPI(mimeType.impl()), 0, 0, m_client.clientInfo);
313 void WebLoaderClient::didBlockInsecurePluginVersion(WebPageProxy* page, const String& mimeType, const String& pluginIdentifier, const String& pluginVersion)
315 if (!m_client.pluginDidFail)
318 m_client.pluginDidFail(toAPI(page), kWKErrorCodeInsecurePlugInVersion, toAPI(mimeType.impl()), toAPI(pluginIdentifier.impl()), toAPI(pluginVersion.impl()), m_client.clientInfo);
321 } // namespace WebKit