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 "WebBackForwardListItem.h"
31 #include "WKAPICast.h"
34 using namespace WebCore;
38 void WebLoaderClient::didStartProvisionalLoadForFrame(WebPageProxy* page, WebFrameProxy* frame, APIObject* userData)
40 if (!m_client.didStartProvisionalLoadForFrame)
43 m_client.didStartProvisionalLoadForFrame(toAPI(page), toAPI(frame), toAPI(userData), m_client.clientInfo);
46 void WebLoaderClient::didReceiveServerRedirectForProvisionalLoadForFrame(WebPageProxy* page, WebFrameProxy* frame, APIObject* userData)
48 if (!m_client.didReceiveServerRedirectForProvisionalLoadForFrame)
51 m_client.didReceiveServerRedirectForProvisionalLoadForFrame(toAPI(page), toAPI(frame), toAPI(userData), m_client.clientInfo);
54 void WebLoaderClient::didFailProvisionalLoadWithErrorForFrame(WebPageProxy* page, WebFrameProxy* frame, const ResourceError& error, APIObject* userData)
56 if (!m_client.didFailProvisionalLoadWithErrorForFrame)
59 m_client.didFailProvisionalLoadWithErrorForFrame(toAPI(page), toAPI(frame), toAPI(error), toAPI(userData), m_client.clientInfo);
62 void WebLoaderClient::didCommitLoadForFrame(WebPageProxy* page, WebFrameProxy* frame, APIObject* userData)
64 if (!m_client.didCommitLoadForFrame)
67 m_client.didCommitLoadForFrame(toAPI(page), toAPI(frame), toAPI(userData), m_client.clientInfo);
70 void WebLoaderClient::didFinishDocumentLoadForFrame(WebPageProxy* page, WebFrameProxy* frame, APIObject* userData)
72 if (!m_client.didFinishDocumentLoadForFrame)
75 m_client.didFinishDocumentLoadForFrame(toAPI(page), toAPI(frame), toAPI(userData), m_client.clientInfo);
78 void WebLoaderClient::didFinishLoadForFrame(WebPageProxy* page, WebFrameProxy* frame, APIObject* userData)
80 if (!m_client.didFinishLoadForFrame)
83 m_client.didFinishLoadForFrame(toAPI(page), toAPI(frame), toAPI(userData), m_client.clientInfo);
86 void WebLoaderClient::didFailLoadWithErrorForFrame(WebPageProxy* page, WebFrameProxy* frame, const ResourceError& error, APIObject* userData)
88 if (!m_client.didFailLoadWithErrorForFrame)
91 m_client.didFailLoadWithErrorForFrame(toAPI(page), toAPI(frame), toAPI(error), toAPI(userData), m_client.clientInfo);
94 void WebLoaderClient::didSameDocumentNavigationForFrame(WebPageProxy* page, WebFrameProxy* frame, SameDocumentNavigationType type, APIObject* userData)
96 if (!m_client.didSameDocumentNavigationForFrame)
99 m_client.didSameDocumentNavigationForFrame(toAPI(page), toAPI(frame), toAPI(type), toAPI(userData), m_client.clientInfo);
102 void WebLoaderClient::didReceiveTitleForFrame(WebPageProxy* page, const String& title, WebFrameProxy* frame, APIObject* userData)
104 if (!m_client.didReceiveTitleForFrame)
107 m_client.didReceiveTitleForFrame(toAPI(page), toAPI(title.impl()), toAPI(frame), toAPI(userData), m_client.clientInfo);
110 void WebLoaderClient::didFirstLayoutForFrame(WebPageProxy* page, WebFrameProxy* frame, APIObject* userData)
112 if (!m_client.didFirstLayoutForFrame)
115 m_client.didFirstLayoutForFrame(toAPI(page), toAPI(frame), toAPI(userData), m_client.clientInfo);
118 void WebLoaderClient::didFirstVisuallyNonEmptyLayoutForFrame(WebPageProxy* page, WebFrameProxy* frame, APIObject* userData)
120 if (!m_client.didFirstVisuallyNonEmptyLayoutForFrame)
123 m_client.didFirstVisuallyNonEmptyLayoutForFrame(toAPI(page), toAPI(frame), toAPI(userData), m_client.clientInfo);
126 void WebLoaderClient::didRemoveFrameFromHierarchy(WebPageProxy* page, WebFrameProxy* frame, APIObject* userData)
128 if (!m_client.didRemoveFrameFromHierarchy)
131 m_client.didRemoveFrameFromHierarchy(toAPI(page), toAPI(frame), toAPI(userData), m_client.clientInfo);
134 void WebLoaderClient::didDisplayInsecureContentForFrame(WebPageProxy* page, WebFrameProxy* frame, APIObject* userData)
136 if (!m_client.didDisplayInsecureContentForFrame)
139 m_client.didDisplayInsecureContentForFrame(toAPI(page), toAPI(frame), toAPI(userData), m_client.clientInfo);
142 void WebLoaderClient::didRunInsecureContentForFrame(WebPageProxy* page, WebFrameProxy* frame, APIObject* userData)
144 if (!m_client.didRunInsecureContentForFrame)
147 m_client.didRunInsecureContentForFrame(toAPI(page), toAPI(frame), toAPI(userData), m_client.clientInfo);
150 bool WebLoaderClient::canAuthenticateAgainstProtectionSpaceInFrame(WebPageProxy* page, WebFrameProxy* frame, WebProtectionSpace* protectionSpace)
152 if (!m_client.canAuthenticateAgainstProtectionSpaceInFrame)
155 return m_client.canAuthenticateAgainstProtectionSpaceInFrame(toAPI(page), toAPI(frame), toAPI(protectionSpace), m_client.clientInfo);
158 void WebLoaderClient::didReceiveAuthenticationChallengeInFrame(WebPageProxy* page, WebFrameProxy* frame, AuthenticationChallengeProxy* authenticationChallenge)
160 if (!m_client.didReceiveAuthenticationChallengeInFrame)
163 m_client.didReceiveAuthenticationChallengeInFrame(toAPI(page), toAPI(frame), toAPI(authenticationChallenge), m_client.clientInfo);
166 void WebLoaderClient::didStartProgress(WebPageProxy* page)
168 if (!m_client.didStartProgress)
171 m_client.didStartProgress(toAPI(page), m_client.clientInfo);
174 void WebLoaderClient::didChangeProgress(WebPageProxy* page)
176 if (!m_client.didChangeProgress)
179 m_client.didChangeProgress(toAPI(page), m_client.clientInfo);
182 void WebLoaderClient::didFinishProgress(WebPageProxy* page)
184 if (!m_client.didFinishProgress)
187 m_client.didFinishProgress(toAPI(page), m_client.clientInfo);
190 void WebLoaderClient::processDidBecomeUnresponsive(WebPageProxy* page)
192 if (!m_client.processDidBecomeUnresponsive)
195 m_client.processDidBecomeUnresponsive(toAPI(page), m_client.clientInfo);
198 void WebLoaderClient::processDidBecomeResponsive(WebPageProxy* page)
200 if (!m_client.processDidBecomeResponsive)
203 m_client.processDidBecomeResponsive(toAPI(page), m_client.clientInfo);
206 void WebLoaderClient::processDidCrash(WebPageProxy* page)
208 if (!m_client.processDidCrash)
211 m_client.processDidCrash(toAPI(page), m_client.clientInfo);
214 void WebLoaderClient::didChangeBackForwardList(WebPageProxy* page, WebBackForwardListItem* addedItem, Vector<RefPtr<APIObject> >* removedItems)
216 if (!m_client.didChangeBackForwardList)
219 RefPtr<ImmutableArray> removedItemsArray;
220 if (removedItems && !removedItems->isEmpty())
221 removedItemsArray = ImmutableArray::adopt(*removedItems);
223 m_client.didChangeBackForwardList(toAPI(page), toAPI(addedItem), toAPI(removedItemsArray.get()), m_client.clientInfo);
226 bool WebLoaderClient::shouldGoToBackForwardListItem(WebPageProxy* page, WebBackForwardListItem* item)
228 if (!m_client.shouldGoToBackForwardListItem)
231 return m_client.shouldGoToBackForwardListItem(toAPI(page), toAPI(item), m_client.clientInfo);
234 void WebLoaderClient::didFailToInitializePlugin(WebPageProxy* page, const String& mimeType)
236 if (!m_client.didFailToInitializePlugin)
239 m_client.didFailToInitializePlugin(toAPI(page), toAPI(mimeType.impl()), m_client.clientInfo);
242 } // namespace WebKit