UIWebViewImpl-android.h 3.8 KB

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