Fix for https://bugs.webkit.org/show_bug.cgi?id=41073
[WebKit.git] / WebKit2 / WebProcess / InjectedBundle / InjectedBundlePageClient.cpp
1 /*
2  *  InjectedBundlePageClient.cpp
3  *  WebKit2
4  *
5  *  Created by Sam Weinig on 6/16/10.
6  *  Copyright 2010 Apple Inc. All rights reserved.
7  *
8  */
9
10 #include "InjectedBundlePageClient.h"
11
12 #include "WKAPICast.h"
13 #include "WKBundleAPICast.h"
14 #include <WebCore/PlatformString.h>
15
16 using namespace WebCore;
17
18 namespace WebKit {
19
20 InjectedBundlePageClient::InjectedBundlePageClient()
21 {
22     initialize(0);
23 }
24
25 void InjectedBundlePageClient::initialize(WKBundlePageClient* client)
26 {
27     if (client && !client->version)
28         m_client = *client;
29     else 
30         memset(&m_client, 0, sizeof(m_client));
31 }
32
33 void InjectedBundlePageClient::didStartProvisionalLoadForFrame(WebPage* page, WebFrame* frame)
34 {
35     if (m_client.didStartProvisionalLoadForFrame)
36         m_client.didStartProvisionalLoadForFrame(toRef(page), toRef(frame), m_client.clientInfo);
37 }
38
39 void InjectedBundlePageClient::didReceiveServerRedirectForProvisionalLoadForFrame(WebPage* page, WebFrame* frame)
40 {
41     if (m_client.didReceiveServerRedirectForProvisionalLoadForFrame)
42         m_client.didReceiveServerRedirectForProvisionalLoadForFrame(toRef(page), toRef(frame), m_client.clientInfo);
43 }
44
45 void InjectedBundlePageClient::didFailProvisionalLoadWithErrorForFrame(WebPage* page, WebFrame* frame)
46 {
47     if (m_client.didFailProvisionalLoadWithErrorForFrame)
48         m_client.didFailProvisionalLoadWithErrorForFrame(toRef(page), toRef(frame), m_client.clientInfo);
49 }
50
51 void InjectedBundlePageClient::didCommitLoadForFrame(WebPage* page, WebFrame* frame)
52 {
53     if (m_client.didCommitLoadForFrame)
54         m_client.didCommitLoadForFrame(toRef(page), toRef(frame), m_client.clientInfo);
55 }
56
57 void InjectedBundlePageClient::didFinishLoadForFrame(WebPage* page, WebFrame* frame)
58 {
59     if (m_client.didFinishLoadForFrame)
60         m_client.didFinishLoadForFrame(toRef(page), toRef(frame), m_client.clientInfo);
61 }
62
63 void InjectedBundlePageClient::didFailLoadWithErrorForFrame(WebPage* page, WebFrame* frame)
64 {
65     if (m_client.didFailLoadWithErrorForFrame)
66         m_client.didFailLoadWithErrorForFrame(toRef(page), toRef(frame), m_client.clientInfo);
67 }
68
69 void InjectedBundlePageClient::didReceiveTitleForFrame(WebPage* page, const String& title, WebFrame* frame)
70 {
71     if (m_client.didReceiveTitleForFrame)
72         m_client.didReceiveTitleForFrame(toRef(page), toRef(title.impl()), toRef(frame), m_client.clientInfo);
73 }
74
75 void InjectedBundlePageClient::didClearWindowObjectForFrame(WebPage* page, WebFrame* frame, JSContextRef ctx, JSObjectRef window)
76 {
77     if (m_client.didClearWindowObjectForFrame)
78         m_client.didClearWindowObjectForFrame(toRef(page), toRef(frame), ctx, window, m_client.clientInfo);
79 }
80
81 } // namespace WebKit