|
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 "InjectedBundlePageLoaderClient.h" |
|
27 |
|
28 #include "WKAPICast.h" |
|
29 #include "WKBundleAPICast.h" |
|
30 #include <WebCore/PlatformString.h> |
|
31 |
|
32 using namespace WebCore; |
|
33 |
|
34 namespace WebKit { |
|
35 |
|
36 InjectedBundlePageLoaderClient::InjectedBundlePageLoaderClient() |
|
37 { |
|
38 initialize(0); |
|
39 } |
|
40 |
|
41 void InjectedBundlePageLoaderClient::initialize(WKBundlePageLoaderClient* client) |
|
42 { |
|
43 if (client && !client->version) |
|
44 m_client = *client; |
|
45 else |
|
46 memset(&m_client, 0, sizeof(m_client)); |
|
47 } |
|
48 |
|
49 void InjectedBundlePageLoaderClient::didStartProvisionalLoadForFrame(WebPage* page, WebFrame* frame) |
|
50 { |
|
51 if (m_client.didStartProvisionalLoadForFrame) |
|
52 m_client.didStartProvisionalLoadForFrame(toRef(page), toRef(frame), m_client.clientInfo); |
|
53 } |
|
54 |
|
55 void InjectedBundlePageLoaderClient::didReceiveServerRedirectForProvisionalLoadForFrame(WebPage* page, WebFrame* frame) |
|
56 { |
|
57 if (m_client.didReceiveServerRedirectForProvisionalLoadForFrame) |
|
58 m_client.didReceiveServerRedirectForProvisionalLoadForFrame(toRef(page), toRef(frame), m_client.clientInfo); |
|
59 } |
|
60 |
|
61 void InjectedBundlePageLoaderClient::didFailProvisionalLoadWithErrorForFrame(WebPage* page, WebFrame* frame) |
|
62 { |
|
63 if (m_client.didFailProvisionalLoadWithErrorForFrame) |
|
64 m_client.didFailProvisionalLoadWithErrorForFrame(toRef(page), toRef(frame), m_client.clientInfo); |
|
65 } |
|
66 |
|
67 void InjectedBundlePageLoaderClient::didCommitLoadForFrame(WebPage* page, WebFrame* frame) |
|
68 { |
|
69 if (m_client.didCommitLoadForFrame) |
|
70 m_client.didCommitLoadForFrame(toRef(page), toRef(frame), m_client.clientInfo); |
|
71 } |
|
72 |
|
73 void InjectedBundlePageLoaderClient::didFinishLoadForFrame(WebPage* page, WebFrame* frame) |
|
74 { |
|
75 if (m_client.didFinishLoadForFrame) |
|
76 m_client.didFinishLoadForFrame(toRef(page), toRef(frame), m_client.clientInfo); |
|
77 } |
|
78 |
|
79 void InjectedBundlePageLoaderClient::didFailLoadWithErrorForFrame(WebPage* page, WebFrame* frame) |
|
80 { |
|
81 if (m_client.didFailLoadWithErrorForFrame) |
|
82 m_client.didFailLoadWithErrorForFrame(toRef(page), toRef(frame), m_client.clientInfo); |
|
83 } |
|
84 |
|
85 void InjectedBundlePageLoaderClient::didReceiveTitleForFrame(WebPage* page, const String& title, WebFrame* frame) |
|
86 { |
|
87 if (m_client.didReceiveTitleForFrame) |
|
88 m_client.didReceiveTitleForFrame(toRef(page), toRef(title.impl()), toRef(frame), m_client.clientInfo); |
|
89 } |
|
90 |
|
91 void InjectedBundlePageLoaderClient::didClearWindowObjectForFrame(WebPage* page, WebFrame* frame, JSGlobalContextRef context, JSObjectRef window) |
|
92 { |
|
93 if (m_client.didClearWindowObjectForFrame) |
|
94 m_client.didClearWindowObjectForFrame(toRef(page), toRef(frame), context, window, m_client.clientInfo); |
|
95 } |
|
96 |
|
97 } // namespace WebKit |