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