2 * Copyright (C) 2007 Kevin Ollivier <kevino@theolliviers.com>
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
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.
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.
29 #include "ChromeClientWx.h"
30 #include "FloatRect.h"
31 #include "FrameLoadRequest.h"
32 #include "NotImplemented.h"
33 #include "PlatformString.h"
37 #include <wx/wxprec.h>
41 #include <wx/textdlg.h>
45 #include "WebViewPrivate.h"
49 ChromeClientWx::ChromeClientWx(wxWebView* webView)
54 ChromeClientWx::~ChromeClientWx()
58 void ChromeClientWx::chromeDestroyed()
63 void ChromeClientWx::setWindowRect(const FloatRect&)
68 FloatRect ChromeClientWx::windowRect()
74 FloatRect ChromeClientWx::pageRect()
80 float ChromeClientWx::scaleFactor()
86 void ChromeClientWx::focus()
91 void ChromeClientWx::unfocus()
96 bool ChromeClientWx::canTakeFocus(FocusDirection)
102 void ChromeClientWx::takeFocus(FocusDirection)
108 Page* ChromeClientWx::createWindow(Frame*, const FrameLoadRequest& request, const WindowFeatures&)
111 // FIXME: Create a EVT_WEBKIT_NEW_WINDOW event, and only run this code
112 // when that event is not handled.
115 wxWebFrame* newFrame = new wxWebFrame(wxTheApp->GetAppName());
117 if (newFrame->webview) {
118 newFrame->webview->LoadURL(request.resourceRequest().url().string());
119 newFrame->Show(true);
121 WebViewPrivate* impl = newFrame->webview->m_impl;
123 myPage = impl->frame->page();
129 Page* ChromeClientWx::createModalDialog(Frame*, const FrameLoadRequest&)
135 void ChromeClientWx::show()
140 bool ChromeClientWx::canRunModal()
146 void ChromeClientWx::runModal()
151 void ChromeClientWx::setToolbarsVisible(bool)
156 bool ChromeClientWx::toolbarsVisible()
162 void ChromeClientWx::setStatusbarVisible(bool)
167 bool ChromeClientWx::statusbarVisible()
173 void ChromeClientWx::setScrollbarsVisible(bool)
178 bool ChromeClientWx::scrollbarsVisible()
184 void ChromeClientWx::setMenubarVisible(bool)
189 bool ChromeClientWx::menubarVisible()
195 void ChromeClientWx::setResizable(bool)
200 void ChromeClientWx::addMessageToConsole(const String& message,
201 unsigned int lineNumber,
202 const String& sourceID)
205 wxWebViewConsoleMessageEvent wkEvent(m_webView);
206 wkEvent.SetMessage(message);
207 wkEvent.SetLineNumber(lineNumber);
208 wkEvent.SetSourceID(sourceID);
209 m_webView->GetEventHandler()->ProcessEvent(wkEvent);
213 bool ChromeClientWx::canRunBeforeUnloadConfirmPanel()
219 bool ChromeClientWx::runBeforeUnloadConfirmPanel(const String& string,
222 wxMessageDialog dialog(NULL, string, wxT("Confirm Action?"), wxYES_NO);
223 return dialog.ShowModal() == wxYES;
226 void ChromeClientWx::closeWindowSoon()
232 Sites for testing prompts:
233 Alert - just type in a bad web address or http://www.htmlite.com/JS002.php
234 Prompt - http://www.htmlite.com/JS007.php
235 Confirm - http://www.htmlite.com/JS006.php
238 void ChromeClientWx::runJavaScriptAlert(Frame* frame, const String& string)
240 wxMessageBox(string, wxT("JavaScript Alert"), wxOK);
243 bool ChromeClientWx::runJavaScriptConfirm(Frame* frame, const String& string)
245 wxMessageDialog dialog(NULL, string, wxT("JavaScript Confirm"), wxYES_NO);
247 return (dialog.ShowModal() == wxID_YES);
250 bool ChromeClientWx::runJavaScriptPrompt(Frame* frame, const String& message, const String& defaultValue, String& result)
252 wxTextEntryDialog dialog(NULL, message, wxT("JavaScript Prompt"), wxEmptyString, wxOK | wxCANCEL);
254 if (dialog.ShowModal() == wxID_OK) {
255 result = dialog.GetValue();
262 void ChromeClientWx::setStatusbarText(const String&)
267 bool ChromeClientWx::shouldInterruptJavaScript()
273 bool ChromeClientWx::tabsToLinks() const
279 IntRect ChromeClientWx::windowResizerRect() const
285 void ChromeClientWx::addToDirtyRegion(const IntRect&)
290 void ChromeClientWx::scrollBackingStore(int dx, int dy,
291 const IntRect& scrollViewRect,
292 const IntRect& clipRect)
297 void ChromeClientWx::updateBackingStore()
302 void ChromeClientWx::mouseDidMoveOverElement(const HitTestResult&, unsigned modifierFlags)
307 void ChromeClientWx::setToolTip(const String&)
311 void ChromeClientWx::print(Frame*)
316 unsigned long long ChromeClientWx::requestQuotaIncreaseForNewDatabase(Frame*, SecurityOrigin*, const String&, unsigned long long)
322 unsigned long long ChromeClientWx::requestQuotaIncreaseForDatabaseOperation(Frame*, SecurityOrigin*, const String&, unsigned long long)