Modified: trunk/Source/WebKit2/UIProcess/API/gtk/WebKitLoaderClient.cpp (177277 => 177278)
--- trunk/Source/WebKit2/UIProcess/API/gtk/WebKitLoaderClient.cpp 2014-12-15 13:40:08 UTC (rev 177277)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/WebKitLoaderClient.cpp 2014-12-15 13:41:26 UTC (rev 177278)
@@ -21,6 +21,7 @@
#include "config.h"
#include "WebKitLoaderClient.h"
+#include "APILoaderClient.h"
#include "WebKitBackForwardListPrivate.h"
#include "WebKitPrivate.h"
#include "WebKitURIResponsePrivate.h"
@@ -32,135 +33,95 @@
using namespace WebKit;
using namespace WebCore;
-static void didStartProvisionalLoadForFrame(WKPageRef, WKFrameRef frame, WKTypeRef /* userData */, const void* clientInfo)
-{
- if (!WKFrameIsMainFrame(frame))
- return;
+class LoaderClient : public API::LoaderClient {
+public:
+ explicit LoaderClient(WebKitWebView* webView)
+ : m_webView(webView)
+ {
+ }
- webkitWebViewLoadChanged(WEBKIT_WEB_VIEW(clientInfo), WEBKIT_LOAD_STARTED);
-}
+private:
+ void didStartProvisionalLoadForFrame(WebPageProxy*, WebFrameProxy* frame, uint64_t /* navigationID */, API::Object* /* userData */) override
+ {
+ if (!frame->isMainFrame())
+ return;
+ webkitWebViewLoadChanged(m_webView, WEBKIT_LOAD_STARTED);
+ }
-static void didReceiveServerRedirectForProvisionalLoadForFrame(WKPageRef, WKFrameRef frame, WKTypeRef /* userData */, const void* clientInfo)
-{
- if (!WKFrameIsMainFrame(frame))
- return;
+ void didReceiveServerRedirectForProvisionalLoadForFrame(WebPageProxy*, WebFrameProxy* frame, uint64_t /* navigationID */, API::Object* /* userData */) override
+ {
+ if (!frame->isMainFrame())
+ return;
+ webkitWebViewLoadChanged(m_webView, WEBKIT_LOAD_REDIRECTED);
+ }
- webkitWebViewLoadChanged(WEBKIT_WEB_VIEW(clientInfo), WEBKIT_LOAD_REDIRECTED);
-}
+ void didFailProvisionalLoadWithErrorForFrame(WebPageProxy*, WebFrameProxy* frame, uint64_t /* navigationID */, const ResourceError& resourceError, API::Object* /* userData */) override
+ {
+ if (!frame->isMainFrame())
+ return;
+ GUniquePtr<GError> error(g_error_new_literal(g_quark_from_string(resourceError.domain().utf8().data()),
+ toWebKitError(resourceError.errorCode()), resourceError.localizedDescription().utf8().data()));
+ if (resourceError.tlsErrors()) {
+ webkitWebViewLoadFailedWithTLSErrors(m_webView, resourceError.failingURL().utf8().data(), error.get(),
+ static_cast<GTlsCertificateFlags>(resourceError.tlsErrors()), resourceError.certificate());
+ } else
+ webkitWebViewLoadFailed(m_webView, WEBKIT_LOAD_STARTED, resourceError.failingURL().utf8().data(), error.get());
+ }
-static void didFailProvisionalLoadWithErrorForFrame(WKPageRef, WKFrameRef frame, WKErrorRef error, WKTypeRef /* userData */, const void* clientInfo)
-{
- if (!WKFrameIsMainFrame(frame))
- return;
+ void didCommitLoadForFrame(WebPageProxy*, WebFrameProxy* frame, uint64_t /* navigationID */, API::Object* /* userData */) override
+ {
+ if (!frame->isMainFrame())
+ return;
+ webkitWebViewLoadChanged(m_webView, WEBKIT_LOAD_COMMITTED);
+ }
- const ResourceError& resourceError = toImpl(error)->platformError();
- GUniquePtr<GError> webError(g_error_new_literal(g_quark_from_string(resourceError.domain().utf8().data()),
- toWebKitError(resourceError.errorCode()), resourceError.localizedDescription().utf8().data()));
- if (resourceError.tlsErrors()) {
- webkitWebViewLoadFailedWithTLSErrors(WEBKIT_WEB_VIEW(clientInfo), resourceError.failingURL().utf8().data(), webError.get(),
- static_cast<GTlsCertificateFlags>(resourceError.tlsErrors()), resourceError.certificate());
- } else
- webkitWebViewLoadFailed(WEBKIT_WEB_VIEW(clientInfo), WEBKIT_LOAD_STARTED, resourceError.failingURL().utf8().data(), webError.get());
-}
+ void didFinishLoadForFrame(WebPageProxy*, WebFrameProxy* frame, uint64_t /* navigationID */, API::Object* /* userData */) override
+ {
+ if (!frame->isMainFrame())
+ return;
+ webkitWebViewLoadChanged(m_webView, WEBKIT_LOAD_FINISHED);
+ }
-static void didCommitLoadForFrame(WKPageRef, WKFrameRef frame, WKTypeRef /* userData */, const void* clientInfo)
-{
- if (!WKFrameIsMainFrame(frame))
- return;
+ void didFailLoadWithErrorForFrame(WebPageProxy*, WebFrameProxy* frame, uint64_t /* navigationID */, const ResourceError& resourceError, API::Object* /* userData */) override
+ {
+ if (!frame->isMainFrame())
+ return;
+ GUniquePtr<GError> error(g_error_new_literal(g_quark_from_string(resourceError.domain().utf8().data()),
+ toWebKitError(resourceError.errorCode()), resourceError.localizedDescription().utf8().data()));
+ webkitWebViewLoadFailed(m_webView, WEBKIT_LOAD_COMMITTED, resourceError.failingURL().utf8().data(), error.get());
+ }
- webkitWebViewLoadChanged(WEBKIT_WEB_VIEW(clientInfo), WEBKIT_LOAD_COMMITTED);
-}
+ void didDisplayInsecureContentForFrame(WebPageProxy*, WebFrameProxy*, API::Object* /* userData */) override
+ {
+ webkitWebViewInsecureContentDetected(m_webView, WEBKIT_INSECURE_CONTENT_DISPLAYED);
+ }
-static void didFinishLoadForFrame(WKPageRef, WKFrameRef frame, WKTypeRef /* userData */, const void* clientInfo)
-{
- if (!WKFrameIsMainFrame(frame))
- return;
+ void didRunInsecureContentForFrame(WebPageProxy*, WebFrameProxy*, API::Object* /* userData */) override
+ {
+ webkitWebViewInsecureContentDetected(m_webView, WEBKIT_INSECURE_CONTENT_RUN);
+ }
- webkitWebViewLoadChanged(WEBKIT_WEB_VIEW(clientInfo), WEBKIT_LOAD_FINISHED);
-}
+ void didChangeBackForwardList(WebPageProxy*, WebBackForwardListItem* addedItem, Vector<RefPtr<WebBackForwardListItem>> removedItems) override
+ {
+ webkitBackForwardListChanged(webkit_web_view_get_back_forward_list(m_webView), addedItem, removedItems);
+ }
-static void didFailLoadWithErrorForFrame(WKPageRef, WKFrameRef frame, WKErrorRef error, WKTypeRef, const void* clientInfo)
-{
- if (!WKFrameIsMainFrame(frame))
- return;
+ void didReceiveAuthenticationChallengeInFrame(WebPageProxy*, WebFrameProxy*, AuthenticationChallengeProxy* authenticationChallenge) override
+ {
+ webkitWebViewHandleAuthenticationChallenge(m_webView, authenticationChallenge);
+ }
- const ResourceError& resourceError = toImpl(error)->platformError();
- GUniquePtr<GError> webError(g_error_new_literal(g_quark_from_string(resourceError.domain().utf8().data()),
- toWebKitError(resourceError.errorCode()), resourceError.localizedDescription().utf8().data()));
- webkitWebViewLoadFailed(WEBKIT_WEB_VIEW(clientInfo), WEBKIT_LOAD_COMMITTED,
- resourceError.failingURL().utf8().data(), webError.get());
-}
+ void processDidCrash(WebPageProxy*) override
+ {
+ webkitWebViewWebProcessCrashed(m_webView);
+ }
-static void didDisplayInsecureContentForFrame(WKPageRef, WKFrameRef, WKTypeRef /* userData */, const void *clientInfo)
-{
- webkitWebViewInsecureContentDetected(WEBKIT_WEB_VIEW(clientInfo), WEBKIT_INSECURE_CONTENT_DISPLAYED);
-}
+ WebKitWebView* m_webView;
+};
-static void didRunInsecureContentForFrame(WKPageRef, WKFrameRef, WKTypeRef /* userData */, const void *clientInfo)
-{
- webkitWebViewInsecureContentDetected(WEBKIT_WEB_VIEW(clientInfo), WEBKIT_INSECURE_CONTENT_RUN);
-}
-
-static void didChangeBackForwardList(WKPageRef, WKBackForwardListItemRef addedItem, WKArrayRef removedItems, const void* clientInfo)
-{
- webkitBackForwardListChanged(webkit_web_view_get_back_forward_list(WEBKIT_WEB_VIEW(clientInfo)), toImpl(addedItem), toImpl(removedItems));
-}
-
-static void didReceiveAuthenticationChallengeInFrame(WKPageRef, WKFrameRef, WKAuthenticationChallengeRef authenticationChallenge, const void *clientInfo)
-{
- webkitWebViewHandleAuthenticationChallenge(WEBKIT_WEB_VIEW(clientInfo), toImpl(authenticationChallenge));
-}
-
-static void processDidCrash(WKPageRef, const void* clientInfo)
-{
- webkitWebViewWebProcessCrashed(WEBKIT_WEB_VIEW(clientInfo));
-}
-
void attachLoaderClientToView(WebKitWebView* webView)
{
- WKPageLoaderClientV3 wkLoaderClient = {
- {
- 3, // version
- webView, // clientInfo
- },
- didStartProvisionalLoadForFrame,
- didReceiveServerRedirectForProvisionalLoadForFrame,
- didFailProvisionalLoadWithErrorForFrame,
- didCommitLoadForFrame,
- 0, // didFinishDocumentLoadForFrame
- didFinishLoadForFrame,
- didFailLoadWithErrorForFrame,
- 0, // didSameDocumentNavigationForFrame
- 0, // didReceiveTitleForFrame,
- 0, // didFirstLayoutForFrame
- 0, // didFirstVisuallyNonEmptyLayoutForFrame
- 0, // didRemoveFrameFromHierarchy
- didDisplayInsecureContentForFrame,
- didRunInsecureContentForFrame,
- 0, // canAuthenticateAgainstProtectionSpaceInFrame
- didReceiveAuthenticationChallengeInFrame,
- 0, // didStartProgress
- 0, // didChangeProgress,
- 0, // didFinishProgress
- 0, // didBecomeUnresponsive
- 0, // didBecomeResponsive
- processDidCrash,
- didChangeBackForwardList,
- 0, // shouldGoToBackForwardListItem
- 0, // didFailToInitializePlugin
- 0, // didDetectXSSForFrame
- 0, // didFirstVisuallyNonEmptyLayoutForFrame
- 0, // willGoToBackForwardListItem
- 0, // interactionOccurredWhileProcessUnresponsive
- 0, // pluginDidFail_deprecatedForUseWithV1
- 0, // didReceiveIntentForFrame
- 0, // registerIntentServiceForFrame
- 0, // didLayout
- 0, // pluginLoadPolicy_deprecatedForUseWithV2
- 0, // pluginDidFail
- 0, // pluginLoadPolicy
- };
- WKPageRef wkPage = toAPI(webkitWebViewBaseGetPage(WEBKIT_WEB_VIEW_BASE(webView)));
- WKPageSetPageLoaderClient(wkPage, &wkLoaderClient.base);
+ WebPageProxy* page = webkitWebViewBaseGetPage(WEBKIT_WEB_VIEW_BASE(webView));
+ page->setLoaderClient(std::make_unique<LoaderClient>(webView));
}