PageRenderTime 26ms CodeModel.GetById 22ms RepoModel.GetById 0ms app.codeStats 0ms

/tags/Galeking1.0/WebKit/wx/WebKitSupport/ChromeClientWx.cpp

https://github.com/weissms/owb-mirror
C++ | 409 lines | 308 code | 66 blank | 35 comment | 22 complexity | 6687f20ae2120493f9a80d222c2ac8a7 MD5 | raw file
  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. #include "config.h"
  28. #include "ChromeClientWx.h"
  29. #include "Console.h"
  30. #include "FileChooser.h"
  31. #include "FloatRect.h"
  32. #include "FrameLoadRequest.h"
  33. #include "NotImplemented.h"
  34. #include "PlatformString.h"
  35. #include <stdio.h>
  36. #include <wx/wxprec.h>
  37. #ifndef WX_PRECOMP
  38. #include <wx/wx.h>
  39. #endif
  40. #include <wx/textdlg.h>
  41. #include <wx/tooltip.h>
  42. #include "WebBrowserShell.h"
  43. #include "WebView.h"
  44. #include "WebViewPrivate.h"
  45. namespace WebCore {
  46. ChromeClientWx::ChromeClientWx(wxWebView* webView)
  47. {
  48. m_webView = webView;
  49. }
  50. ChromeClientWx::~ChromeClientWx()
  51. {
  52. }
  53. void ChromeClientWx::chromeDestroyed()
  54. {
  55. notImplemented();
  56. }
  57. void ChromeClientWx::setWindowRect(const FloatRect&)
  58. {
  59. notImplemented();
  60. }
  61. FloatRect ChromeClientWx::windowRect()
  62. {
  63. notImplemented();
  64. return FloatRect();
  65. }
  66. FloatRect ChromeClientWx::pageRect()
  67. {
  68. notImplemented();
  69. return FloatRect();
  70. }
  71. float ChromeClientWx::scaleFactor()
  72. {
  73. notImplemented();
  74. return 0.0;
  75. }
  76. void ChromeClientWx::focus()
  77. {
  78. notImplemented();
  79. }
  80. void ChromeClientWx::unfocus()
  81. {
  82. notImplemented();
  83. }
  84. bool ChromeClientWx::canTakeFocus(FocusDirection)
  85. {
  86. notImplemented();
  87. return false;
  88. }
  89. void ChromeClientWx::takeFocus(FocusDirection)
  90. {
  91. notImplemented();
  92. }
  93. Page* ChromeClientWx::createWindow(Frame*, const FrameLoadRequest& request, const WindowFeatures&)
  94. {
  95. // FIXME: Create a EVT_WEBKIT_NEW_WINDOW event, and only run this code
  96. // when that event is not handled.
  97. Page* myPage = 0;
  98. wxWebBrowserShell* newFrame = new wxWebBrowserShell(wxTheApp->GetAppName());
  99. if (newFrame->webview) {
  100. newFrame->webview->LoadURL(request.resourceRequest().url().string());
  101. newFrame->Show(true);
  102. WebViewPrivate* impl = newFrame->webview->m_impl;
  103. if (impl)
  104. myPage = impl->page;
  105. }
  106. return myPage;
  107. }
  108. Page* ChromeClientWx::createModalDialog(Frame*, const FrameLoadRequest&)
  109. {
  110. notImplemented();
  111. return 0;
  112. }
  113. void ChromeClientWx::show()
  114. {
  115. notImplemented();
  116. }
  117. bool ChromeClientWx::canRunModal()
  118. {
  119. notImplemented();
  120. return false;
  121. }
  122. void ChromeClientWx::runModal()
  123. {
  124. notImplemented();
  125. }
  126. void ChromeClientWx::setToolbarsVisible(bool)
  127. {
  128. notImplemented();
  129. }
  130. bool ChromeClientWx::toolbarsVisible()
  131. {
  132. notImplemented();
  133. return false;
  134. }
  135. void ChromeClientWx::setStatusbarVisible(bool)
  136. {
  137. notImplemented();
  138. }
  139. bool ChromeClientWx::statusbarVisible()
  140. {
  141. notImplemented();
  142. return false;
  143. }
  144. void ChromeClientWx::setScrollbarsVisible(bool)
  145. {
  146. notImplemented();
  147. }
  148. bool ChromeClientWx::scrollbarsVisible()
  149. {
  150. notImplemented();
  151. return false;
  152. }
  153. void ChromeClientWx::setMenubarVisible(bool)
  154. {
  155. notImplemented();
  156. }
  157. bool ChromeClientWx::menubarVisible()
  158. {
  159. notImplemented();
  160. return false;
  161. }
  162. void ChromeClientWx::setResizable(bool)
  163. {
  164. notImplemented();
  165. }
  166. void ChromeClientWx::addMessageToConsole(MessageSource source,
  167. MessageType type,
  168. MessageLevel level,
  169. const String& message,
  170. unsigned int lineNumber,
  171. const String& sourceID)
  172. {
  173. if (m_webView) {
  174. wxWebViewConsoleMessageEvent wkEvent(m_webView);
  175. wkEvent.SetMessage(message);
  176. wkEvent.SetLineNumber(lineNumber);
  177. wkEvent.SetSourceID(sourceID);
  178. m_webView->GetEventHandler()->ProcessEvent(wkEvent);
  179. }
  180. }
  181. bool ChromeClientWx::canRunBeforeUnloadConfirmPanel()
  182. {
  183. notImplemented();
  184. return true;
  185. }
  186. bool ChromeClientWx::runBeforeUnloadConfirmPanel(const String& string,
  187. Frame* frame)
  188. {
  189. wxMessageDialog dialog(NULL, string, wxT("Confirm Action?"), wxYES_NO);
  190. return dialog.ShowModal() == wxYES;
  191. }
  192. void ChromeClientWx::closeWindowSoon()
  193. {
  194. notImplemented();
  195. }
  196. /*
  197. Sites for testing prompts:
  198. Alert - just type in a bad web address or http://www.htmlite.com/JS002.php
  199. Prompt - http://www.htmlite.com/JS007.php
  200. Confirm - http://www.htmlite.com/JS006.php
  201. */
  202. void ChromeClientWx::runJavaScriptAlert(Frame* frame, const String& string)
  203. {
  204. if (m_webView) {
  205. wxWebViewAlertEvent wkEvent(m_webView);
  206. wkEvent.SetMessage(string);
  207. if (!m_webView->GetEventHandler()->ProcessEvent(wkEvent))
  208. wxMessageBox(string, wxT("JavaScript Alert"), wxOK);
  209. }
  210. }
  211. bool ChromeClientWx::runJavaScriptConfirm(Frame* frame, const String& string)
  212. {
  213. bool result = false;
  214. if (m_webView) {
  215. wxWebViewConfirmEvent wkEvent(m_webView);
  216. wkEvent.SetMessage(string);
  217. if (m_webView->GetEventHandler()->ProcessEvent(wkEvent))
  218. result = wkEvent.GetReturnCode() == wxID_YES;
  219. else {
  220. wxMessageDialog dialog(NULL, string, wxT("JavaScript Confirm"), wxYES_NO);
  221. dialog.Centre();
  222. result = (dialog.ShowModal() == wxID_YES);
  223. }
  224. }
  225. return result;
  226. }
  227. bool ChromeClientWx::runJavaScriptPrompt(Frame* frame, const String& message, const String& defaultValue, String& result)
  228. {
  229. if (m_webView) {
  230. wxWebViewPromptEvent wkEvent(m_webView);
  231. wkEvent.SetMessage(message);
  232. wkEvent.SetResponse(defaultValue);
  233. if (m_webView->GetEventHandler()->ProcessEvent(wkEvent)) {
  234. result = wkEvent.GetResponse();
  235. return true;
  236. }
  237. else {
  238. wxTextEntryDialog dialog(NULL, message, wxT("JavaScript Prompt"), wxEmptyString, wxOK | wxCANCEL);
  239. dialog.Centre();
  240. if (dialog.ShowModal() == wxID_OK) {
  241. result = dialog.GetValue();
  242. return true;
  243. }
  244. }
  245. }
  246. return false;
  247. }
  248. void ChromeClientWx::setStatusbarText(const String&)
  249. {
  250. notImplemented();
  251. }
  252. bool ChromeClientWx::shouldInterruptJavaScript()
  253. {
  254. notImplemented();
  255. return false;
  256. }
  257. bool ChromeClientWx::tabsToLinks() const
  258. {
  259. notImplemented();
  260. return false;
  261. }
  262. IntRect ChromeClientWx::windowResizerRect() const
  263. {
  264. notImplemented();
  265. return IntRect();
  266. }
  267. void ChromeClientWx::repaint(const IntRect& rect, bool contentChanged, bool immediate, bool repaintContentOnly)
  268. {
  269. if (!m_webView)
  270. return;
  271. if (contentChanged)
  272. m_webView->RefreshRect(rect);
  273. if (immediate) {
  274. m_webView->Update();
  275. }
  276. }
  277. IntRect ChromeClientWx::windowToScreen(const IntRect& rect) const
  278. {
  279. notImplemented();
  280. return rect;
  281. }
  282. IntPoint ChromeClientWx::screenToWindow(const IntPoint& point) const
  283. {
  284. notImplemented();
  285. return point;
  286. }
  287. PlatformWidget ChromeClientWx::platformWindow() const
  288. {
  289. return 0;
  290. }
  291. void ChromeClientWx::contentsSizeChanged(Frame*, const IntSize&) const
  292. {
  293. notImplemented();
  294. }
  295. void ChromeClientWx::scrollBackingStore(int dx, int dy,
  296. const IntRect& scrollViewRect,
  297. const IntRect& clipRect)
  298. {
  299. notImplemented();
  300. }
  301. void ChromeClientWx::updateBackingStore()
  302. {
  303. notImplemented();
  304. }
  305. void ChromeClientWx::mouseDidMoveOverElement(const HitTestResult&, unsigned modifierFlags)
  306. {
  307. notImplemented();
  308. }
  309. void ChromeClientWx::setToolTip(const String& tip, TextDirection)
  310. {
  311. wxToolTip* tooltip = m_webView->GetToolTip();
  312. if (!tooltip || tooltip->GetTip() != wxString(tip))
  313. m_webView->SetToolTip(tip);
  314. }
  315. void ChromeClientWx::print(Frame*)
  316. {
  317. notImplemented();
  318. }
  319. #if ENABLE(DATABASE)
  320. void ChromeClientWx::exceededDatabaseQuota(Frame*, const String&)
  321. {
  322. notImplemented();
  323. }
  324. #endif
  325. void ChromeClientWx::scroll(const IntSize&, const IntRect&, const IntRect&)
  326. {
  327. notImplemented();
  328. }
  329. void ChromeClientWx::runOpenPanel(Frame*, PassRefPtr<FileChooser>)
  330. {
  331. notImplemented();
  332. }
  333. bool ChromeClientWx::setCursor(PlatformCursorHandle)
  334. {
  335. notImplemented();
  336. return false;
  337. }
  338. void ChromeClientWx::requestGeolocationPermissionForFrame(Frame*, Geolocation*)
  339. {
  340. // See the comment in WebCore/page/ChromeClient.h
  341. notImplemented();
  342. }
  343. }