2014-08-26 14:26:37 +08:00
|
|
|
/****************************************************************************
|
2018-01-29 16:25:32 +08:00
|
|
|
Copyright (c) 2014-2016 Chukong Technologies Inc.
|
|
|
|
Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd.
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2014-08-26 14:26:37 +08:00
|
|
|
http://www.cocos2d-x.org
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2014-08-26 14:26:37 +08:00
|
|
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
of this software and associated documentation files (the "Software"), to deal
|
|
|
|
in the Software without restriction, including without limitation the rights
|
|
|
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
copies of the Software, and to permit persons to whom the Software is
|
|
|
|
furnished to do so, subject to the following conditions:
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2014-08-26 14:26:37 +08:00
|
|
|
The above copyright notice and this permission notice shall be included in
|
|
|
|
all copies or substantial portions of the Software.
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2014-08-26 14:26:37 +08:00
|
|
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
|
|
THE SOFTWARE.
|
|
|
|
****************************************************************************/
|
2019-10-23 14:58:31 +08:00
|
|
|
#pragma once
|
2014-08-25 14:01:18 +08:00
|
|
|
|
2015-03-24 20:23:51 +08:00
|
|
|
/// @cond DO_NOT_SHOW
|
2014-08-25 14:01:18 +08:00
|
|
|
|
|
|
|
#include <iosfwd>
|
2015-12-17 12:08:14 +08:00
|
|
|
#include <stdint.h>
|
2014-08-25 14:01:18 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
namespace cocos2d
|
|
|
|
{
|
|
|
|
class Data;
|
|
|
|
class Renderer;
|
|
|
|
class Mat4;
|
2014-08-26 14:26:37 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
namespace ui
|
|
|
|
{
|
|
|
|
class WebView;
|
2014-08-25 14:01:18 +08:00
|
|
|
}
|
2021-12-25 10:04:45 +08:00
|
|
|
} // namespace cocos2d
|
|
|
|
|
|
|
|
namespace cocos2d
|
|
|
|
{
|
|
|
|
namespace ui
|
|
|
|
{
|
|
|
|
|
|
|
|
class WebViewImpl
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
WebViewImpl(cocos2d::ui::WebView* webView);
|
2014-08-25 14:01:18 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
virtual ~WebViewImpl();
|
2014-08-25 14:01:18 +08:00
|
|
|
|
2021-12-26 23:26:34 +08:00
|
|
|
void setJavascriptInterfaceScheme(std::string_view scheme);
|
2014-08-25 14:01:18 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
void loadData(const cocos2d::Data& data,
|
2021-12-26 23:26:34 +08:00
|
|
|
std::string_view MIMEType,
|
|
|
|
std::string_view encoding,
|
|
|
|
std::string_view baseURL);
|
2014-08-25 14:01:18 +08:00
|
|
|
|
2021-12-26 23:26:34 +08:00
|
|
|
void loadHTMLString(std::string_view string, std::string_view baseURL);
|
2014-08-25 14:01:18 +08:00
|
|
|
|
2021-12-26 23:26:34 +08:00
|
|
|
void loadURL(std::string_view url);
|
|
|
|
void loadURL(std::string_view url, bool cleanCachedData);
|
2014-08-25 14:01:18 +08:00
|
|
|
|
2021-12-26 23:26:34 +08:00
|
|
|
void loadFile(std::string_view fileName);
|
2014-08-25 14:01:18 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
void stopLoading();
|
2014-08-25 14:01:18 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
void reload();
|
2014-08-25 14:01:18 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
bool canGoBack();
|
2014-08-25 14:01:18 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
bool canGoForward();
|
2014-08-25 14:01:18 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
void goBack();
|
2014-08-25 14:01:18 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
void goForward();
|
2014-08-25 14:01:18 +08:00
|
|
|
|
2021-12-26 23:26:34 +08:00
|
|
|
void evaluateJS(std::string_view js);
|
2014-08-25 14:01:18 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
void setScalesPageToFit(const bool scalesPageToFit);
|
2014-08-25 14:01:18 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
virtual void draw(cocos2d::Renderer* renderer, cocos2d::Mat4 const& transform, uint32_t flags);
|
2014-08-25 14:01:18 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
virtual void setVisible(bool visible);
|
2014-08-25 14:01:18 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
void setBounces(bool bounces);
|
2014-08-25 14:01:18 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
void setOpacityWebView(float opacity);
|
2014-08-25 14:01:18 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
float getOpacityWebView() const;
|
2016-05-24 18:27:59 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
void setBackgroundTransparent();
|
2014-08-25 14:01:18 +08:00
|
|
|
|
2021-12-26 23:26:34 +08:00
|
|
|
static bool shouldStartLoading(const int viewTag, std::string_view url);
|
|
|
|
static void didFinishLoading(const int viewTag, std::string_view url);
|
|
|
|
static void didFailLoading(const int viewTag, std::string_view url);
|
|
|
|
static void onJsCallback(const int viewTag, std::string_view message);
|
2014-08-25 14:01:18 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
private:
|
|
|
|
int _viewTag;
|
|
|
|
WebView* _webView;
|
|
|
|
};
|
2014-08-25 14:01:18 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
} // namespace ui
|
|
|
|
} // namespace cocos2d
|
2014-09-10 03:18:31 +08:00
|
|
|
|
2015-03-24 20:23:51 +08:00
|
|
|
/// @endcond
|