Update untranslated text
[framework/web/webkit-efl.git] / Source / WebKit2 / UIProcess / WebLoaderClient.cpp
1 /*
2  * Copyright (C) 2010 Apple Inc. All rights reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
7  * 1. Redistributions of source code must retain the above copyright
8  *    notice, this list of conditions and the following disclaimer.
9  * 2. Redistributions in binary form must reproduce the above copyright
10  *    notice, this list of conditions and the following disclaimer in the
11  *    documentation and/or other materials provided with the distribution.
12  *
13  * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
14  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
15  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
17  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
23  * THE POSSIBILITY OF SUCH DAMAGE.
24  */
25
26 #include "config.h"
27 #include "WebLoaderClient.h"
28
29 #include "ImmutableArray.h"
30 #include "WKAPICast.h"
31 #include "WebBackForwardListItem.h"
32 #include <string.h>
33
34 #if ENABLE(WEB_INTENTS)
35 #include "WebIntentData.h"
36 #include "WebIntentServiceInfo.h"
37 #endif
38
39 using namespace WebCore;
40
41 namespace WebKit {
42
43 void WebLoaderClient::didStartProvisionalLoadForFrame(WebPageProxy* page, WebFrameProxy* frame, APIObject* userData)
44 {
45     if (!m_client.didStartProvisionalLoadForFrame)
46         return;
47
48     m_client.didStartProvisionalLoadForFrame(toAPI(page), toAPI(frame), toAPI(userData), m_client.clientInfo);
49 }
50
51 void WebLoaderClient::didReceiveServerRedirectForProvisionalLoadForFrame(WebPageProxy* page, WebFrameProxy* frame, APIObject* userData)
52 {
53     if (!m_client.didReceiveServerRedirectForProvisionalLoadForFrame)
54         return;
55
56     m_client.didReceiveServerRedirectForProvisionalLoadForFrame(toAPI(page), toAPI(frame), toAPI(userData), m_client.clientInfo);
57 }
58
59 void WebLoaderClient::didFailProvisionalLoadWithErrorForFrame(WebPageProxy* page, WebFrameProxy* frame, const ResourceError& error, APIObject* userData)
60 {
61     if (!m_client.didFailProvisionalLoadWithErrorForFrame)
62         return;
63
64     m_client.didFailProvisionalLoadWithErrorForFrame(toAPI(page), toAPI(frame), toAPI(error), toAPI(userData), m_client.clientInfo);
65 }
66
67 void WebLoaderClient::didCommitLoadForFrame(WebPageProxy* page, WebFrameProxy* frame, APIObject* userData)
68 {
69     if (!m_client.didCommitLoadForFrame)
70         return;
71
72     m_client.didCommitLoadForFrame(toAPI(page), toAPI(frame), toAPI(userData), m_client.clientInfo);
73 }
74
75 void WebLoaderClient::didFinishDocumentLoadForFrame(WebPageProxy* page, WebFrameProxy* frame, APIObject* userData)
76 {
77     if (!m_client.didFinishDocumentLoadForFrame)
78         return;
79
80     m_client.didFinishDocumentLoadForFrame(toAPI(page), toAPI(frame), toAPI(userData), m_client.clientInfo);
81 }
82
83 void WebLoaderClient::didFinishLoadForFrame(WebPageProxy* page, WebFrameProxy* frame, APIObject* userData)
84 {
85     if (!m_client.didFinishLoadForFrame)
86         return;
87
88     m_client.didFinishLoadForFrame(toAPI(page), toAPI(frame), toAPI(userData), m_client.clientInfo);
89 }
90
91 void WebLoaderClient::didFailLoadWithErrorForFrame(WebPageProxy* page, WebFrameProxy* frame, const ResourceError& error, APIObject* userData)
92 {
93     if (!m_client.didFailLoadWithErrorForFrame)
94         return;
95
96     m_client.didFailLoadWithErrorForFrame(toAPI(page), toAPI(frame), toAPI(error), toAPI(userData), m_client.clientInfo);
97 }
98
99 void WebLoaderClient::didSameDocumentNavigationForFrame(WebPageProxy* page, WebFrameProxy* frame, SameDocumentNavigationType type, APIObject* userData)
100 {
101     if (!m_client.didSameDocumentNavigationForFrame)
102         return;
103
104     m_client.didSameDocumentNavigationForFrame(toAPI(page), toAPI(frame), toAPI(type), toAPI(userData), m_client.clientInfo);
105 }
106
107 void WebLoaderClient::didReceiveTitleForFrame(WebPageProxy* page, const String& title, WebFrameProxy* frame, APIObject* userData)
108 {
109     if (!m_client.didReceiveTitleForFrame)
110         return;
111
112     m_client.didReceiveTitleForFrame(toAPI(page), toAPI(title.impl()), toAPI(frame), toAPI(userData), m_client.clientInfo);
113 }
114
115 void WebLoaderClient::didFirstLayoutForFrame(WebPageProxy* page, WebFrameProxy* frame, APIObject* userData)
116 {
117     if (!m_client.didFirstLayoutForFrame)
118         return;
119
120     m_client.didFirstLayoutForFrame(toAPI(page), toAPI(frame), toAPI(userData), m_client.clientInfo);
121 }
122
123 void WebLoaderClient::didFirstVisuallyNonEmptyLayoutForFrame(WebPageProxy* page, WebFrameProxy* frame, APIObject* userData)
124 {
125     if (!m_client.didFirstVisuallyNonEmptyLayoutForFrame)
126         return;
127
128     m_client.didFirstVisuallyNonEmptyLayoutForFrame(toAPI(page), toAPI(frame), toAPI(userData), m_client.clientInfo);
129 }
130
131 void WebLoaderClient::didNewFirstVisuallyNonEmptyLayout(WebPageProxy* page, APIObject* userData)
132 {
133     if (!m_client.didNewFirstVisuallyNonEmptyLayout)
134         return;
135
136     m_client.didNewFirstVisuallyNonEmptyLayout(toAPI(page), toAPI(userData), m_client.clientInfo);
137 }
138
139 void WebLoaderClient::didRemoveFrameFromHierarchy(WebPageProxy* page, WebFrameProxy* frame, APIObject* userData)
140 {
141     if (!m_client.didRemoveFrameFromHierarchy)
142         return;
143
144     m_client.didRemoveFrameFromHierarchy(toAPI(page), toAPI(frame), toAPI(userData), m_client.clientInfo);
145 }
146
147 void WebLoaderClient::didDisplayInsecureContentForFrame(WebPageProxy* page, WebFrameProxy* frame, APIObject* userData)
148 {
149     if (!m_client.didDisplayInsecureContentForFrame)
150         return;
151
152     m_client.didDisplayInsecureContentForFrame(toAPI(page), toAPI(frame), toAPI(userData), m_client.clientInfo);
153 }
154
155 void WebLoaderClient::didRunInsecureContentForFrame(WebPageProxy* page, WebFrameProxy* frame, APIObject* userData)
156 {
157     if (!m_client.didRunInsecureContentForFrame)
158         return;
159
160     m_client.didRunInsecureContentForFrame(toAPI(page), toAPI(frame), toAPI(userData), m_client.clientInfo);
161 }
162
163 void WebLoaderClient::didDetectXSSForFrame(WebPageProxy* page, WebFrameProxy* frame, APIObject* userData)
164 {
165     if (!m_client.didDetectXSSForFrame)
166         return;
167
168     m_client.didDetectXSSForFrame(toAPI(page), toAPI(frame), toAPI(userData), m_client.clientInfo);
169 }
170
171 #if ENABLE(WEB_INTENTS)
172 void WebLoaderClient::didReceiveIntentForFrame(WebPageProxy* page, WebFrameProxy* frame, WebIntentData* intentData, APIObject* userData)
173 {
174     if (!m_client.didReceiveIntentForFrame)
175         return;
176
177     m_client.didReceiveIntentForFrame(toAPI(page), toAPI(frame), toAPI(intentData), toAPI(userData), m_client.clientInfo);
178 }
179 #endif
180
181 #if ENABLE(WEB_INTENTS_TAG)
182 void WebLoaderClient::registerIntentServiceForFrame(WebPageProxy* page, WebFrameProxy* frame, WebIntentServiceInfo* serviceInfo, APIObject* userData)
183 {
184     if (!m_client.registerIntentServiceForFrame)
185         return;
186
187     m_client.registerIntentServiceForFrame(toAPI(page), toAPI(frame), toAPI(serviceInfo), toAPI(userData), m_client.clientInfo);
188 }
189 #endif
190
191 bool WebLoaderClient::canAuthenticateAgainstProtectionSpaceInFrame(WebPageProxy* page, WebFrameProxy* frame, WebProtectionSpace* protectionSpace)
192 {
193     if (!m_client.canAuthenticateAgainstProtectionSpaceInFrame)
194         return false;
195
196     return m_client.canAuthenticateAgainstProtectionSpaceInFrame(toAPI(page), toAPI(frame), toAPI(protectionSpace), m_client.clientInfo);
197 }
198
199 #if ENABLE(TIZEN_ON_AUTHENTICATION_REQUESTED)
200 bool WebLoaderClient::didReceiveAuthenticationChallengeInFrame(WebPageProxy* page, WebFrameProxy* frame, AuthenticationChallengeProxy* authenticationChallenge)
201 {
202     if (!m_client.didReceiveAuthenticationChallengeInFrame)
203         return false;
204
205     return m_client.didReceiveAuthenticationChallengeInFrame(toAPI(page), toAPI(frame), toAPI(authenticationChallenge), m_client.clientInfo);
206 }
207 #else
208 void WebLoaderClient::didReceiveAuthenticationChallengeInFrame(WebPageProxy* page, WebFrameProxy* frame, AuthenticationChallengeProxy* authenticationChallenge)
209 {
210     if (!m_client.didReceiveAuthenticationChallengeInFrame)
211         return;
212
213     m_client.didReceiveAuthenticationChallengeInFrame(toAPI(page), toAPI(frame), toAPI(authenticationChallenge), m_client.clientInfo);
214 }
215 #endif
216
217 void WebLoaderClient::didStartProgress(WebPageProxy* page)
218 {
219     if (!m_client.didStartProgress)
220         return;
221
222     m_client.didStartProgress(toAPI(page), m_client.clientInfo);
223 }
224
225 void WebLoaderClient::didChangeProgress(WebPageProxy* page)
226 {
227     if (!m_client.didChangeProgress)
228         return;
229
230     m_client.didChangeProgress(toAPI(page), m_client.clientInfo);
231 }
232
233 void WebLoaderClient::didFinishProgress(WebPageProxy* page)
234 {
235     if (!m_client.didFinishProgress)
236         return;
237
238     m_client.didFinishProgress(toAPI(page), m_client.clientInfo);
239 }
240
241 void WebLoaderClient::processDidBecomeUnresponsive(WebPageProxy* page)
242 {
243     if (!m_client.processDidBecomeUnresponsive)
244         return;
245
246     m_client.processDidBecomeUnresponsive(toAPI(page), m_client.clientInfo);
247 }
248
249 void WebLoaderClient::interactionOccurredWhileProcessUnresponsive(WebPageProxy* page)
250 {
251     if (!m_client.interactionOccurredWhileProcessUnresponsive)
252         return;
253
254     m_client.interactionOccurredWhileProcessUnresponsive(toAPI(page), m_client.clientInfo);
255 }
256
257 void WebLoaderClient::processDidBecomeResponsive(WebPageProxy* page)
258 {
259     if (!m_client.processDidBecomeResponsive)
260         return;
261
262     m_client.processDidBecomeResponsive(toAPI(page), m_client.clientInfo);
263 }
264
265 void WebLoaderClient::processDidCrash(WebPageProxy* page)
266 {
267     if (!m_client.processDidCrash)
268         return;
269
270     m_client.processDidCrash(toAPI(page), m_client.clientInfo);
271 }
272
273 void WebLoaderClient::didChangeBackForwardList(WebPageProxy* page, WebBackForwardListItem* addedItem, Vector<RefPtr<APIObject> >* removedItems)
274 {
275     if (!m_client.didChangeBackForwardList)
276         return;
277
278     RefPtr<ImmutableArray> removedItemsArray;
279     if (removedItems && !removedItems->isEmpty())
280         removedItemsArray = ImmutableArray::adopt(*removedItems);
281
282     m_client.didChangeBackForwardList(toAPI(page), toAPI(addedItem), toAPI(removedItemsArray.get()), m_client.clientInfo);
283 }
284
285 bool WebLoaderClient::shouldGoToBackForwardListItem(WebPageProxy* page, WebBackForwardListItem* item)
286 {
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)
291         return true;
292
293     return m_client.shouldGoToBackForwardListItem(toAPI(page), toAPI(item), m_client.clientInfo);
294 }
295
296 void WebLoaderClient::willGoToBackForwardListItem(WebPageProxy* page, WebBackForwardListItem* item, APIObject* userData)
297 {
298     if (m_client.willGoToBackForwardListItem)
299         m_client.willGoToBackForwardListItem(toAPI(page), toAPI(item), toAPI(userData), m_client.clientInfo);
300 }
301
302 void WebLoaderClient::didFailToInitializePlugin(WebPageProxy* page, const String& mimeType)
303 {
304     if (m_client.didFailToInitializePlugin_deprecatedForUseWithV0)
305         m_client.didFailToInitializePlugin_deprecatedForUseWithV0(toAPI(page), toAPI(mimeType.impl()), m_client.clientInfo);
306
307     if (!m_client.pluginDidFail)
308         return;
309
310     m_client.pluginDidFail(toAPI(page), kWKErrorCodeCannotLoadPlugIn, toAPI(mimeType.impl()), 0, 0, m_client.clientInfo);
311 }
312
313 void WebLoaderClient::didBlockInsecurePluginVersion(WebPageProxy* page, const String& mimeType, const String& pluginIdentifier, const String& pluginVersion)
314 {
315     if (!m_client.pluginDidFail)
316         return;
317
318     m_client.pluginDidFail(toAPI(page), kWKErrorCodeInsecurePlugInVersion, toAPI(mimeType.impl()), toAPI(pluginIdentifier.impl()), toAPI(pluginVersion.impl()), m_client.clientInfo);
319 }
320
321 } // namespace WebKit