UIWebViewImpl-android.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. /****************************************************************************
  2. Copyright (c) 2014-2017 Chukong Technologies Inc.
  3. http://www.cocos2d-x.org
  4. Permission is hereby granted, free of charge, to any person obtaining a copy
  5. of this software and associated documentation files (the "Software"), to deal
  6. in the Software without restriction, including without limitation the rights
  7. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  8. copies of the Software, and to permit persons to whom the Software is
  9. furnished to do so, subject to the following conditions:
  10. The above copyright notice and this permission notice shall be included in
  11. all copies or substantial portions of the Software.
  12. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  13. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  14. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  15. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  16. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  17. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  18. THE SOFTWARE.
  19. ****************************************************************************/
  20. #ifndef __COCOS2D__UI__WEBVIEWIMPL_ANDROID_H_
  21. #define __COCOS2D__UI__WEBVIEWIMPL_ANDROID_H_
  22. /// @cond DO_NOT_SHOW
  23. #ifdef __ANDROID__
  24. #include <iosfwd>
  25. #include <stdint.h>
  26. namespace cocos2d {
  27. class Data;
  28. class Renderer;
  29. class Mat4;
  30. namespace experimental {
  31. namespace ui{
  32. class WebView;
  33. }
  34. }
  35. }
  36. namespace cocos2d {
  37. namespace experimental {
  38. namespace ui{
  39. class WebViewImpl {
  40. public:
  41. WebViewImpl(cocos2d::experimental::ui::WebView *webView);
  42. virtual ~WebViewImpl();
  43. void setJavascriptInterfaceScheme(const std::string &scheme);
  44. void loadData(const cocos2d::Data &data, const std::string &MIMEType, const std::string &encoding, const std::string &baseURL);
  45. void loadHTMLString(const std::string &string, const std::string &baseURL);
  46. void loadURL(const std::string &url);
  47. void loadURL(const std::string &url, bool cleanCachedData);
  48. void loadFile(const std::string &fileName);
  49. void stopLoading();
  50. void reload();
  51. bool canGoBack();
  52. bool canGoForward();
  53. void goBack();
  54. void goForward();
  55. void evaluateJS(const std::string &js);
  56. void setScalesPageToFit(const bool scalesPageToFit);
  57. virtual void draw(cocos2d::Renderer *renderer, cocos2d::Mat4 const &transform, uint32_t flags);
  58. virtual void setVisible(bool visible);
  59. void setBounces(bool bounces);
  60. static bool shouldStartLoading(const int viewTag, const std::string &url);
  61. static void didFinishLoading(const int viewTag, const std::string &url);
  62. static void didFailLoading(const int viewTag, const std::string &url);
  63. static void onJsCallback(const int viewTag, const std::string &message);
  64. private:
  65. int _viewTag;
  66. WebView *_webView;
  67. };
  68. } // namespace ui
  69. } // namespace experimental
  70. } //cocos2d
  71. #endif // __ANDROID__
  72. /// @endcond
  73. #endif /* __COCOS2D__UI__WEBVIEWIMPL_ANDROID_H_ */