|
1 /* |
|
2 Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) |
|
3 |
|
4 This library is free software; you can redistribute it and/or |
|
5 modify it under the terms of the GNU Library General Public |
|
6 License as published by the Free Software Foundation; either |
|
7 version 2 of the License, or (at your option) any later version. |
|
8 |
|
9 This library is distributed in the hope that it will be useful, |
|
10 but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
12 Library General Public License for more details. |
|
13 |
|
14 You should have received a copy of the GNU Library General Public License |
|
15 along with this library; see the file COPYING.LIB. If not, write to |
|
16 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
|
17 Boston, MA 02110-1301, USA. |
|
18 */ |
|
19 |
|
20 #include "ClientImpl.h" |
|
21 |
|
22 #include "WebFrameProxy.h" |
|
23 #include "WKAPICast.h" |
|
24 #include "WKStringQt.h" |
|
25 #include "WKURLQt.h" |
|
26 #include <qwkpage.h> |
|
27 #include <qwkpage_p.h> |
|
28 #include <WKFrame.h> |
|
29 |
|
30 using namespace WebKit; |
|
31 |
|
32 static QWKPage* toQWKPage(const void* clientInfo) |
|
33 { |
|
34 if (clientInfo) |
|
35 return reinterpret_cast<QWKPage*>(const_cast<void*>(clientInfo)); |
|
36 return 0; |
|
37 } |
|
38 |
|
39 void qt_wk_didStartProvisionalLoadForFrame(WKPageRef page, WKFrameRef frame, const void* clientInfo) |
|
40 { |
|
41 if (!WKFrameIsMainFrame(frame)) |
|
42 return; |
|
43 emit toQWKPage(clientInfo)->loadStarted(); |
|
44 QWKPagePrivate::get(toQWKPage(clientInfo))->updateNavigationActions(); |
|
45 } |
|
46 |
|
47 void qt_wk_didReceiveServerRedirectForProvisionalLoadForFrame(WKPageRef page, WKFrameRef frame, const void* clientInfo) |
|
48 { |
|
49 } |
|
50 |
|
51 void qt_wk_didFailProvisionalLoadWithErrorForFrame(WKPageRef page, WKFrameRef frame, const void* clientInfo) |
|
52 { |
|
53 } |
|
54 |
|
55 void qt_wk_didCommitLoadForFrame(WKPageRef page, WKFrameRef frame, const void* clientInfo) |
|
56 { |
|
57 if (!WKFrameIsMainFrame(frame)) |
|
58 return; |
|
59 WebFrameProxy* wkframe = toWK(frame); |
|
60 QString urlStr(wkframe->url()); |
|
61 QUrl qUrl = urlStr; |
|
62 emit toQWKPage(clientInfo)->urlChanged(qUrl); |
|
63 QWKPagePrivate::get(toQWKPage(clientInfo))->updateNavigationActions(); |
|
64 } |
|
65 |
|
66 void qt_wk_didFinishLoadForFrame(WKPageRef page, WKFrameRef frame, const void* clientInfo) |
|
67 { |
|
68 if (!WKFrameIsMainFrame(frame)) |
|
69 return; |
|
70 emit toQWKPage(clientInfo)->loadFinished(true); |
|
71 QWKPagePrivate::get(toQWKPage(clientInfo))->updateNavigationActions(); |
|
72 } |
|
73 |
|
74 void qt_wk_didFailLoadWithErrorForFrame(WKPageRef page, WKFrameRef frame, const void* clientInfo) |
|
75 { |
|
76 if (!WKFrameIsMainFrame(frame)) |
|
77 return; |
|
78 emit toQWKPage(clientInfo)->loadFinished(false); |
|
79 QWKPagePrivate::get(toQWKPage(clientInfo))->updateNavigationActions(); |
|
80 } |
|
81 |
|
82 void qt_wk_didReceiveTitleForFrame(WKPageRef page, WKStringRef title, WKFrameRef frame, const void* clientInfo) |
|
83 { |
|
84 if (!WKFrameIsMainFrame(frame)) |
|
85 return; |
|
86 QString qTitle = WKStringCopyQString(title); |
|
87 emit toQWKPage(clientInfo)->titleChanged(qTitle); |
|
88 } |
|
89 |
|
90 void qt_wk_didFirstLayoutForFrame(WKPageRef page, WKFrameRef frame, const void* clientInfo) |
|
91 { |
|
92 if (!WKFrameIsMainFrame(frame)) |
|
93 return; |
|
94 emit toQWKPage(clientInfo)->initialLayoutCompleted(); |
|
95 } |
|
96 |
|
97 void qt_wk_didFirstVisuallyNonEmptyLayoutForFrame(WKPageRef page, WKFrameRef frame, const void* clientInfo) |
|
98 { |
|
99 if (!WKFrameIsMainFrame(frame)) |
|
100 return; |
|
101 // FIXME: emit toWKView(clientInfo)->initialLayoutCompleted(); |
|
102 } |
|
103 |
|
104 void qt_wk_didStartProgress(WKPageRef page, const void* clientInfo) |
|
105 { |
|
106 emit toQWKPage(clientInfo)->loadProgress(0); |
|
107 } |
|
108 |
|
109 void qt_wk_didChangeProgress(WKPageRef page, const void* clientInfo) |
|
110 { |
|
111 emit toQWKPage(clientInfo)->loadProgress(WKPageGetEstimatedProgress(page) * 100); |
|
112 } |
|
113 |
|
114 void qt_wk_didFinishProgress(WKPageRef page, const void* clientInfo) |
|
115 { |
|
116 emit toQWKPage(clientInfo)->loadProgress(100); |
|
117 } |
|
118 |
|
119 void qt_wk_didBecomeUnresponsive(WKPageRef page, const void* clientInfo) |
|
120 { |
|
121 } |
|
122 |
|
123 void qt_wk_didBecomeResponsive(WKPageRef page, const void* clientInfo) |
|
124 { |
|
125 } |
|
126 |
|
127 WKPageRef qt_wk_createNewPage(WKPageRef page, const void* clientInfo) |
|
128 { |
|
129 QWKPage* wkPage = toQWKPage(clientInfo); |
|
130 QWKPagePrivate* d = QWKPagePrivate::get(wkPage); |
|
131 QWKPage::CreateNewPageFn createNewPageFn = d->createNewPageFn; |
|
132 |
|
133 if (!createNewPageFn) |
|
134 return 0; |
|
135 |
|
136 if (QWKPage* newPage = createNewPageFn(wkPage)) |
|
137 return newPage->pageRef(); |
|
138 |
|
139 return 0; |
|
140 } |
|
141 |
|
142 void qt_wk_showPage(WKPageRef page, const void* clientInfo) |
|
143 { |
|
144 } |
|
145 |
|
146 void qt_wk_close(WKPageRef page, const void* clientInfo) |
|
147 { |
|
148 } |
|
149 |
|
150 void qt_wk_runJavaScriptAlert(WKPageRef page, WKStringRef alertText, WKFrameRef frame, const void* clientInfo) |
|
151 { |
|
152 } |