blob: 3d119a583f8a304ccfeaea8c57a3c62688c793a5 [file] [log] [blame]
The Android Open Source Project8e35f3c2009-03-03 19:30:52 -08001/*
2 * Copyright (C) 2007 Kevin Ollivier <kevino@theolliviers.com>
3 *
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
16 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
18 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
19 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
20 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
21 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
22 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
23 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
25 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28#include "config.h"
29#include "ChromeClientWx.h"
30#include "FileChooser.h"
31#include "FloatRect.h"
32#include "FrameLoadRequest.h"
33#include "NotImplemented.h"
34#include "PlatformString.h"
35
36#include <stdio.h>
37
38#include <wx/wxprec.h>
39#ifndef WX_PRECOMP
40 #include <wx/wx.h>
41#endif
42#include <wx/textdlg.h>
43#include <wx/tooltip.h>
44
45#include "WebBrowserShell.h"
46#include "WebView.h"
47#include "WebViewPrivate.h"
48
49namespace WebCore {
50
51ChromeClientWx::ChromeClientWx(wxWebView* webView)
52{
53 m_webView = webView;
54}
55
56ChromeClientWx::~ChromeClientWx()
57{
58}
59
60void ChromeClientWx::chromeDestroyed()
61{
62 notImplemented();
63}
64
65void ChromeClientWx::setWindowRect(const FloatRect&)
66{
67 notImplemented();
68}
69
70FloatRect ChromeClientWx::windowRect()
71{
72 notImplemented();
73 return FloatRect();
74}
75
76FloatRect ChromeClientWx::pageRect()
77{
78 notImplemented();
79 return FloatRect();
80}
81
82float ChromeClientWx::scaleFactor()
83{
84 notImplemented();
85 return 0.0;
86}
87
88void ChromeClientWx::focus()
89{
90 notImplemented();
91}
92
93void ChromeClientWx::unfocus()
94{
95 notImplemented();
96}
97
98bool ChromeClientWx::canTakeFocus(FocusDirection)
99{
100 notImplemented();
101 return false;
102}
103
104void ChromeClientWx::takeFocus(FocusDirection)
105{
106 notImplemented();
107}
108
109
110Page* ChromeClientWx::createWindow(Frame*, const FrameLoadRequest& request, const WindowFeatures&)
111{
112
113 // FIXME: Create a EVT_WEBKIT_NEW_WINDOW event, and only run this code
114 // when that event is not handled.
115
116 Page* myPage = 0;
117 wxWebBrowserShell* newFrame = new wxWebBrowserShell(wxTheApp->GetAppName());
118
119 if (newFrame->webview) {
120 newFrame->webview->LoadURL(request.resourceRequest().url().string());
121 newFrame->Show(true);
122
123 WebViewPrivate* impl = newFrame->webview->m_impl;
124 if (impl)
125 myPage = impl->frame->page();
126 }
127
128 return myPage;
129}
130
131Page* ChromeClientWx::createModalDialog(Frame*, const FrameLoadRequest&)
132{
133 notImplemented();
134 return 0;
135}
136
137void ChromeClientWx::show()
138{
139 notImplemented();
140}
141
142bool ChromeClientWx::canRunModal()
143{
144 notImplemented();
145 return false;
146}
147
148void ChromeClientWx::runModal()
149{
150 notImplemented();
151}
152
153void ChromeClientWx::setToolbarsVisible(bool)
154{
155 notImplemented();
156}
157
158bool ChromeClientWx::toolbarsVisible()
159{
160 notImplemented();
161 return false;
162}
163
164void ChromeClientWx::setStatusbarVisible(bool)
165{
166 notImplemented();
167}
168
169bool ChromeClientWx::statusbarVisible()
170{
171 notImplemented();
172 return false;
173}
174
175void ChromeClientWx::setScrollbarsVisible(bool)
176{
177 notImplemented();
178}
179
180bool ChromeClientWx::scrollbarsVisible()
181{
182 notImplemented();
183 return false;
184}
185
186void ChromeClientWx::setMenubarVisible(bool)
187{
188 notImplemented();
189}
190
191bool ChromeClientWx::menubarVisible()
192{
193 notImplemented();
194 return false;
195}
196
197void ChromeClientWx::setResizable(bool)
198{
199 notImplemented();
200}
201
202void ChromeClientWx::addMessageToConsole(const String& message,
203 unsigned int lineNumber,
204 const String& sourceID)
205{
206 if (m_webView) {
207 wxWebViewConsoleMessageEvent wkEvent(m_webView);
208 wkEvent.SetMessage(message);
209 wkEvent.SetLineNumber(lineNumber);
210 wkEvent.SetSourceID(sourceID);
211 m_webView->GetEventHandler()->ProcessEvent(wkEvent);
212 }
213}
214
215bool ChromeClientWx::canRunBeforeUnloadConfirmPanel()
216{
217 notImplemented();
218 return true;
219}
220
221bool ChromeClientWx::runBeforeUnloadConfirmPanel(const String& string,
222 Frame* frame)
223{
224 wxMessageDialog dialog(NULL, string, wxT("Confirm Action?"), wxYES_NO);
225 return dialog.ShowModal() == wxYES;
226}
227
228void ChromeClientWx::closeWindowSoon()
229{
230 notImplemented();
231}
232
233/*
234 Sites for testing prompts:
235 Alert - just type in a bad web address or http://www.htmlite.com/JS002.php
236 Prompt - http://www.htmlite.com/JS007.php
237 Confirm - http://www.htmlite.com/JS006.php
238*/
239
240void ChromeClientWx::runJavaScriptAlert(Frame* frame, const String& string)
241{
242 wxMessageBox(string, wxT("JavaScript Alert"), wxOK);
243}
244
245bool ChromeClientWx::runJavaScriptConfirm(Frame* frame, const String& string)
246{
247 wxMessageDialog dialog(NULL, string, wxT("JavaScript Confirm"), wxYES_NO);
248 dialog.Centre();
249 return (dialog.ShowModal() == wxID_YES);
250}
251
252bool ChromeClientWx::runJavaScriptPrompt(Frame* frame, const String& message, const String& defaultValue, String& result)
253{
254 wxTextEntryDialog dialog(NULL, message, wxT("JavaScript Prompt"), wxEmptyString, wxOK | wxCANCEL);
255 dialog.Centre();
256 if (dialog.ShowModal() == wxID_OK) {
257 result = dialog.GetValue();
258 return true;
259 }
260
261 return false;
262}
263
264void ChromeClientWx::setStatusbarText(const String&)
265{
266 notImplemented();
267}
268
269bool ChromeClientWx::shouldInterruptJavaScript()
270{
271 notImplemented();
272 return false;
273}
274
275bool ChromeClientWx::tabsToLinks() const
276{
277 notImplemented();
278 return false;
279}
280
281IntRect ChromeClientWx::windowResizerRect() const
282{
283 notImplemented();
284 return IntRect();
285}
286
287void ChromeClientWx::repaint(const IntRect& rect, bool contentChanged, bool immediate, bool repaintContentOnly)
288{
289 if (!m_webView)
290 return;
291
292 if (contentChanged)
293 m_webView->RefreshRect(rect);
294
295 if (immediate) {
296 m_webView->Update();
297 }
298}
299
300IntRect ChromeClientWx::windowToScreen(const IntRect& rect) const
301{
302 notImplemented();
303 return rect;
304}
305
306IntPoint ChromeClientWx::screenToWindow(const IntPoint& point) const
307{
308 notImplemented();
309 return point;
310}
311
312PlatformWidget ChromeClientWx::platformWindow() const
313{
314 return 0;
315}
316
317void ChromeClientWx::scrollBackingStore(int dx, int dy,
318 const IntRect& scrollViewRect,
319 const IntRect& clipRect)
320{
321 notImplemented();
322}
323
324void ChromeClientWx::updateBackingStore()
325{
326 notImplemented();
327}
328
329void ChromeClientWx::mouseDidMoveOverElement(const HitTestResult&, unsigned modifierFlags)
330{
331 notImplemented();
332}
333
334void ChromeClientWx::setToolTip(const String& tip)
335{
336 wxToolTip* tooltip = m_webView->GetToolTip();
337 if (!tooltip || tooltip->GetTip() != wxString(tip))
338 m_webView->SetToolTip(tip);
339}
340
341void ChromeClientWx::print(Frame*)
342{
343 notImplemented();
344}
345
346void ChromeClientWx::exceededDatabaseQuota(Frame*, const String&)
347{
348 notImplemented();
349}
350
351void ChromeClientWx::scroll(const IntSize&, const IntRect&, const IntRect&)
352{
353 notImplemented();
354}
355
356void ChromeClientWx::runOpenPanel(Frame*, PassRefPtr<FileChooser>)
357{
358 notImplemented();
359}
360
361}