The Android Open Source Project | 8e35f3c | 2009-03-03 19:30:52 -0800 | [diff] [blame^] | 1 | /* |
| 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 | |
| 49 | namespace WebCore { |
| 50 | |
| 51 | ChromeClientWx::ChromeClientWx(wxWebView* webView) |
| 52 | { |
| 53 | m_webView = webView; |
| 54 | } |
| 55 | |
| 56 | ChromeClientWx::~ChromeClientWx() |
| 57 | { |
| 58 | } |
| 59 | |
| 60 | void ChromeClientWx::chromeDestroyed() |
| 61 | { |
| 62 | notImplemented(); |
| 63 | } |
| 64 | |
| 65 | void ChromeClientWx::setWindowRect(const FloatRect&) |
| 66 | { |
| 67 | notImplemented(); |
| 68 | } |
| 69 | |
| 70 | FloatRect ChromeClientWx::windowRect() |
| 71 | { |
| 72 | notImplemented(); |
| 73 | return FloatRect(); |
| 74 | } |
| 75 | |
| 76 | FloatRect ChromeClientWx::pageRect() |
| 77 | { |
| 78 | notImplemented(); |
| 79 | return FloatRect(); |
| 80 | } |
| 81 | |
| 82 | float ChromeClientWx::scaleFactor() |
| 83 | { |
| 84 | notImplemented(); |
| 85 | return 0.0; |
| 86 | } |
| 87 | |
| 88 | void ChromeClientWx::focus() |
| 89 | { |
| 90 | notImplemented(); |
| 91 | } |
| 92 | |
| 93 | void ChromeClientWx::unfocus() |
| 94 | { |
| 95 | notImplemented(); |
| 96 | } |
| 97 | |
| 98 | bool ChromeClientWx::canTakeFocus(FocusDirection) |
| 99 | { |
| 100 | notImplemented(); |
| 101 | return false; |
| 102 | } |
| 103 | |
| 104 | void ChromeClientWx::takeFocus(FocusDirection) |
| 105 | { |
| 106 | notImplemented(); |
| 107 | } |
| 108 | |
| 109 | |
| 110 | Page* 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 | |
| 131 | Page* ChromeClientWx::createModalDialog(Frame*, const FrameLoadRequest&) |
| 132 | { |
| 133 | notImplemented(); |
| 134 | return 0; |
| 135 | } |
| 136 | |
| 137 | void ChromeClientWx::show() |
| 138 | { |
| 139 | notImplemented(); |
| 140 | } |
| 141 | |
| 142 | bool ChromeClientWx::canRunModal() |
| 143 | { |
| 144 | notImplemented(); |
| 145 | return false; |
| 146 | } |
| 147 | |
| 148 | void ChromeClientWx::runModal() |
| 149 | { |
| 150 | notImplemented(); |
| 151 | } |
| 152 | |
| 153 | void ChromeClientWx::setToolbarsVisible(bool) |
| 154 | { |
| 155 | notImplemented(); |
| 156 | } |
| 157 | |
| 158 | bool ChromeClientWx::toolbarsVisible() |
| 159 | { |
| 160 | notImplemented(); |
| 161 | return false; |
| 162 | } |
| 163 | |
| 164 | void ChromeClientWx::setStatusbarVisible(bool) |
| 165 | { |
| 166 | notImplemented(); |
| 167 | } |
| 168 | |
| 169 | bool ChromeClientWx::statusbarVisible() |
| 170 | { |
| 171 | notImplemented(); |
| 172 | return false; |
| 173 | } |
| 174 | |
| 175 | void ChromeClientWx::setScrollbarsVisible(bool) |
| 176 | { |
| 177 | notImplemented(); |
| 178 | } |
| 179 | |
| 180 | bool ChromeClientWx::scrollbarsVisible() |
| 181 | { |
| 182 | notImplemented(); |
| 183 | return false; |
| 184 | } |
| 185 | |
| 186 | void ChromeClientWx::setMenubarVisible(bool) |
| 187 | { |
| 188 | notImplemented(); |
| 189 | } |
| 190 | |
| 191 | bool ChromeClientWx::menubarVisible() |
| 192 | { |
| 193 | notImplemented(); |
| 194 | return false; |
| 195 | } |
| 196 | |
| 197 | void ChromeClientWx::setResizable(bool) |
| 198 | { |
| 199 | notImplemented(); |
| 200 | } |
| 201 | |
| 202 | void 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 | |
| 215 | bool ChromeClientWx::canRunBeforeUnloadConfirmPanel() |
| 216 | { |
| 217 | notImplemented(); |
| 218 | return true; |
| 219 | } |
| 220 | |
| 221 | bool 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 | |
| 228 | void 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 | |
| 240 | void ChromeClientWx::runJavaScriptAlert(Frame* frame, const String& string) |
| 241 | { |
| 242 | wxMessageBox(string, wxT("JavaScript Alert"), wxOK); |
| 243 | } |
| 244 | |
| 245 | bool 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 | |
| 252 | bool 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 | |
| 264 | void ChromeClientWx::setStatusbarText(const String&) |
| 265 | { |
| 266 | notImplemented(); |
| 267 | } |
| 268 | |
| 269 | bool ChromeClientWx::shouldInterruptJavaScript() |
| 270 | { |
| 271 | notImplemented(); |
| 272 | return false; |
| 273 | } |
| 274 | |
| 275 | bool ChromeClientWx::tabsToLinks() const |
| 276 | { |
| 277 | notImplemented(); |
| 278 | return false; |
| 279 | } |
| 280 | |
| 281 | IntRect ChromeClientWx::windowResizerRect() const |
| 282 | { |
| 283 | notImplemented(); |
| 284 | return IntRect(); |
| 285 | } |
| 286 | |
| 287 | void 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 | |
| 300 | IntRect ChromeClientWx::windowToScreen(const IntRect& rect) const |
| 301 | { |
| 302 | notImplemented(); |
| 303 | return rect; |
| 304 | } |
| 305 | |
| 306 | IntPoint ChromeClientWx::screenToWindow(const IntPoint& point) const |
| 307 | { |
| 308 | notImplemented(); |
| 309 | return point; |
| 310 | } |
| 311 | |
| 312 | PlatformWidget ChromeClientWx::platformWindow() const |
| 313 | { |
| 314 | return 0; |
| 315 | } |
| 316 | |
| 317 | void ChromeClientWx::scrollBackingStore(int dx, int dy, |
| 318 | const IntRect& scrollViewRect, |
| 319 | const IntRect& clipRect) |
| 320 | { |
| 321 | notImplemented(); |
| 322 | } |
| 323 | |
| 324 | void ChromeClientWx::updateBackingStore() |
| 325 | { |
| 326 | notImplemented(); |
| 327 | } |
| 328 | |
| 329 | void ChromeClientWx::mouseDidMoveOverElement(const HitTestResult&, unsigned modifierFlags) |
| 330 | { |
| 331 | notImplemented(); |
| 332 | } |
| 333 | |
| 334 | void 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 | |
| 341 | void ChromeClientWx::print(Frame*) |
| 342 | { |
| 343 | notImplemented(); |
| 344 | } |
| 345 | |
| 346 | void ChromeClientWx::exceededDatabaseQuota(Frame*, const String&) |
| 347 | { |
| 348 | notImplemented(); |
| 349 | } |
| 350 | |
| 351 | void ChromeClientWx::scroll(const IntSize&, const IntRect&, const IntRect&) |
| 352 | { |
| 353 | notImplemented(); |
| 354 | } |
| 355 | |
| 356 | void ChromeClientWx::runOpenPanel(Frame*, PassRefPtr<FileChooser>) |
| 357 | { |
| 358 | notImplemented(); |
| 359 | } |
| 360 | |
| 361 | } |