1/*
2 * Copyright (C) 2010 Patrick Gansterer <paroga@paroga.com>
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 AND ITS CONTRIBUTORS "AS IS" AND ANY
14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
15 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
16 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
17 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
18 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
19 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
20 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
21 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
22 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23 */
24
25#include "config.h"
26#include "ChromeClientWinCE.h"
27
28#include "FileChooser.h"
29#include "Icon.h"
30#include "NotImplemented.h"
31#include "NavigationAction.h"
32#include "PopupMenuWin.h"
33#include "SearchPopupMenuWin.h"
34#include "WebView.h"
35#include <wtf/text/CString.h>
36
37using namespace WebCore;
38
39namespace WebKit {
40
41ChromeClientWinCE::ChromeClientWinCE(WebView* webView)
42    : m_webView(webView)
43{
44    ASSERT(m_webView);
45}
46
47void ChromeClientWinCE::chromeDestroyed()
48{
49    delete this;
50}
51
52FloatRect ChromeClientWinCE::windowRect()
53{
54    if (!m_webView)
55        return FloatRect();
56
57    RECT rect;
58    m_webView->frameRect(&rect);
59    return rect;
60}
61
62void ChromeClientWinCE::setWindowRect(const FloatRect&)
63{
64    notImplemented();
65}
66
67FloatRect ChromeClientWinCE::pageRect()
68{
69    return windowRect();
70}
71
72float ChromeClientWinCE::scaleFactor()
73{
74    return 1.0;
75}
76
77void ChromeClientWinCE::focus()
78{
79    notImplemented();
80}
81
82void ChromeClientWinCE::unfocus()
83{
84    notImplemented();
85}
86
87Page* ChromeClientWinCE::createWindow(Frame*, const FrameLoadRequest&, const WindowFeatures&, const NavigationAction&)
88{
89    notImplemented();
90    return 0;
91}
92
93void ChromeClientWinCE::show()
94{
95    notImplemented();
96}
97
98bool ChromeClientWinCE::canRunModal()
99{
100    notImplemented();
101    return false;
102}
103
104void ChromeClientWinCE::runModal()
105{
106    notImplemented();
107}
108
109void ChromeClientWinCE::setToolbarsVisible(bool)
110{
111    notImplemented();
112}
113
114bool ChromeClientWinCE::toolbarsVisible()
115{
116    return false;
117}
118
119void ChromeClientWinCE::setStatusbarVisible(bool)
120{
121    notImplemented();
122}
123
124bool ChromeClientWinCE::statusbarVisible()
125{
126    notImplemented();
127    return false;
128}
129
130void ChromeClientWinCE::setScrollbarsVisible(bool)
131{
132    notImplemented();
133}
134
135bool ChromeClientWinCE::scrollbarsVisible()
136{
137    notImplemented();
138    return false;
139}
140
141void ChromeClientWinCE::setMenubarVisible(bool)
142{
143    notImplemented();
144}
145
146bool ChromeClientWinCE::menubarVisible()
147{
148    notImplemented();
149    return false;
150}
151
152void ChromeClientWinCE::setResizable(bool)
153{
154    notImplemented();
155}
156
157void ChromeClientWinCE::closeWindowSoon()
158{
159    PostMessageW(m_webView->windowHandle(), WM_CLOSE, 0, 0);
160}
161
162bool ChromeClientWinCE::canTakeFocus(FocusDirection)
163{
164    return true;
165}
166
167void ChromeClientWinCE::takeFocus(FocusDirection)
168{
169    unfocus();
170}
171
172void ChromeClientWinCE::focusedNodeChanged(Node*)
173{
174    notImplemented();
175}
176
177void ChromeClientWinCE::focusedFrameChanged(Frame*)
178{
179}
180
181bool ChromeClientWinCE::canRunBeforeUnloadConfirmPanel()
182{
183    return true;
184}
185
186bool ChromeClientWinCE::runBeforeUnloadConfirmPanel(const String& message, Frame* frame)
187{
188    return runJavaScriptConfirm(frame, message);
189}
190
191void ChromeClientWinCE::addMessageToConsole(MessageSource, MessageType, MessageLevel, const String&, unsigned int, const String&)
192{
193    notImplemented();
194}
195
196void ChromeClientWinCE::runJavaScriptAlert(Frame*, const String& message)
197{
198    m_webView->runJavaScriptAlert(message);
199}
200
201bool ChromeClientWinCE::runJavaScriptConfirm(Frame*, const String& message)
202{
203    return m_webView->runJavaScriptConfirm(message);
204}
205
206bool ChromeClientWinCE::runJavaScriptPrompt(Frame*, const String& message, const String& defaultValue, String& result)
207{
208    return m_webView->runJavaScriptPrompt(message, defaultValue, result);
209}
210
211void ChromeClientWinCE::setStatusbarText(const String&)
212{
213    notImplemented();
214}
215
216bool ChromeClientWinCE::shouldInterruptJavaScript()
217{
218    notImplemented();
219    return false;
220}
221
222KeyboardUIMode ChromeClientWinCE::keyboardUIMode()
223{
224    return KeyboardAccessTabsToLinks;
225}
226
227IntRect ChromeClientWinCE::windowResizerRect() const
228{
229    notImplemented();
230    return IntRect();
231}
232
233void ChromeClientWinCE::invalidateWindow(const IntRect&, bool)
234{
235    notImplemented();
236}
237
238void ChromeClientWinCE::invalidateContentsAndWindow(const IntRect& updateRect, bool immediate)
239{
240    RECT rect = updateRect;
241    InvalidateRect(m_webView->windowHandle(), &rect, FALSE);
242
243    if (immediate)
244        UpdateWindow(m_webView->windowHandle());
245}
246
247void ChromeClientWinCE::invalidateContentsForSlowScroll(const IntRect& updateRect, bool immediate)
248{
249    invalidateContentsAndWindow(updateRect, immediate);
250}
251
252void ChromeClientWinCE::scroll(const IntSize&, const IntRect& rectToScroll, const IntRect&)
253{
254    invalidateContentsAndWindow(rectToScroll, false);
255}
256
257IntRect ChromeClientWinCE::windowToScreen(const IntRect& rect) const
258{
259    notImplemented();
260    return rect;
261}
262
263IntPoint ChromeClientWinCE::screenToWindow(const IntPoint& point) const
264{
265    notImplemented();
266    return point;
267}
268
269PlatformPageClient ChromeClientWinCE::platformPageClient() const
270{
271    notImplemented();
272    return 0;
273}
274
275void ChromeClientWinCE::contentsSizeChanged(Frame*, const IntSize&) const
276{
277    notImplemented();
278}
279
280void ChromeClientWinCE::scrollRectIntoView(const IntRect&, const ScrollView*) const
281{
282    notImplemented();
283}
284
285void ChromeClientWinCE::scrollbarsModeDidChange() const
286{
287    notImplemented();
288}
289
290void ChromeClientWinCE::mouseDidMoveOverElement(const HitTestResult&, unsigned)
291{
292    notImplemented();
293}
294
295void ChromeClientWinCE::setToolTip(const String&, TextDirection)
296{
297    notImplemented();
298}
299
300void ChromeClientWinCE::print(Frame*)
301{
302    notImplemented();
303}
304
305#if ENABLE(DATABASE)
306void ChromeClientWinCE::exceededDatabaseQuota(Frame*, const String&)
307{
308    notImplemented();
309}
310#endif
311
312#if ENABLE(OFFLINE_WEB_APPLICATIONS)
313void ChromeClientWinCE::reachedMaxAppCacheSize(int64_t)
314{
315    notImplemented();
316}
317
318void ChromeClientWinCE::reachedApplicationCacheOriginQuota(SecurityOrigin*)
319{
320    notImplemented();
321}
322#endif
323
324#if ENABLE(TOUCH_EVENTS)
325void ChromeClientWinCE::needTouchEvents(bool)
326{
327    notImplemented();
328}
329#endif
330
331#if USE(ACCELERATED_COMPOSITING)
332void ChromeClientWinCE::attachRootGraphicsLayer(Frame*, GraphicsLayer*)
333{
334    notImplemented();
335}
336
337void ChromeClientWinCE::setNeedsOneShotDrawingSynchronization()
338{
339    notImplemented();
340}
341
342void ChromeClientWinCE::scheduleCompositingLayerSync()
343{
344    notImplemented();
345}
346#endif
347
348void ChromeClientWinCE::runOpenPanel(Frame*, PassRefPtr<FileChooser> prpFileChooser)
349{
350    notImplemented();
351}
352
353void ChromeClientWinCE::chooseIconForFiles(const Vector<String>& filenames, FileChooser* chooser)
354{
355    chooser->iconLoaded(Icon::createIconForFiles(filenames));
356}
357
358void ChromeClientWinCE::setCursor(const Cursor&)
359{
360    notImplemented();
361}
362
363void ChromeClientWinCE::setLastSetCursorToCurrentCursor()
364{
365    notImplemented();
366}
367
368void ChromeClientWinCE::formStateDidChange(const Node*)
369{
370    notImplemented();
371}
372
373void ChromeClientWinCE::requestGeolocationPermissionForFrame(Frame*, Geolocation*)
374{
375    notImplemented();
376}
377
378void ChromeClientWinCE::cancelGeolocationPermissionRequestForFrame(Frame*, Geolocation*)
379{
380    notImplemented();
381}
382
383bool ChromeClientWinCE::selectItemWritingDirectionIsNatural()
384{
385    return false;
386}
387
388bool ChromeClientWinCE::selectItemAlignmentFollowsMenuWritingDirection()
389{
390    return false;
391}
392
393PassRefPtr<PopupMenu> ChromeClientWinCE::createPopupMenu(PopupMenuClient* client) const
394{
395    return adoptRef(new PopupMenuWin(client));
396}
397
398PassRefPtr<SearchPopupMenu> ChromeClientWinCE::createSearchPopupMenu(PopupMenuClient* client) const
399{
400    return adoptRef(new SearchPopupMenuWin(client));
401}
402
403} // namespace WebKit
404