2014-08-26 14:26:37 +08:00
|
|
|
/****************************************************************************
|
2015-03-24 20:23:51 +08:00
|
|
|
Copyright (c) 2014-2015 Chukong Technologies Inc.
|
2014-08-26 14:26:37 +08:00
|
|
|
|
|
|
|
http://www.cocos2d-x.org
|
|
|
|
|
|
|
|
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:
|
|
|
|
|
|
|
|
The above copyright notice and this permission notice shall be included in
|
|
|
|
all copies or substantial portions of the Software.
|
|
|
|
|
|
|
|
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.
|
|
|
|
****************************************************************************/
|
2014-08-25 14:01:18 +08:00
|
|
|
|
2014-09-15 16:56:51 +08:00
|
|
|
#ifndef __COCOS2D__UI__WEBVIEWIMPL_ANDROID_H_
|
|
|
|
#define __COCOS2D__UI__WEBVIEWIMPL_ANDROID_H_
|
2015-03-24 20:23:51 +08:00
|
|
|
/// @cond DO_NOT_SHOW
|
2014-08-25 14:01:18 +08:00
|
|
|
|
2014-09-10 03:18:31 +08:00
|
|
|
#ifdef __ANDROID__
|
|
|
|
|
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
|
|
|
|
|
|
|
namespace cocos2d {
|
2014-08-26 14:26:37 +08:00
|
|
|
class Data;
|
|
|
|
class Renderer;
|
|
|
|
class Mat4;
|
|
|
|
|
|
|
|
namespace experimental {
|
|
|
|
namespace ui{
|
|
|
|
class WebView;
|
|
|
|
}
|
|
|
|
}
|
2014-08-25 14:01:18 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
namespace cocos2d {
|
2014-08-26 14:26:37 +08:00
|
|
|
namespace experimental {
|
|
|
|
namespace ui{
|
2014-08-25 14:01:18 +08:00
|
|
|
|
2014-08-26 14:26:37 +08:00
|
|
|
class WebViewImpl {
|
|
|
|
public:
|
|
|
|
WebViewImpl(cocos2d::experimental::ui::WebView *webView);
|
2014-08-25 14:01:18 +08:00
|
|
|
|
2014-08-26 14:26:37 +08:00
|
|
|
virtual ~WebViewImpl();
|
2014-08-25 14:01:18 +08:00
|
|
|
|
2014-08-26 14:26:37 +08:00
|
|
|
void setJavascriptInterfaceScheme(const std::string &scheme);
|
2014-08-25 14:01:18 +08:00
|
|
|
|
2014-08-26 14:26:37 +08:00
|
|
|
void loadData(const cocos2d::Data &data, const std::string &MIMEType, const std::string &encoding, const std::string &baseURL);
|
2014-08-25 14:01:18 +08:00
|
|
|
|
2014-08-26 14:26:37 +08:00
|
|
|
void loadHTMLString(const std::string &string, const std::string &baseURL);
|
2014-08-25 14:01:18 +08:00
|
|
|
|
2014-09-15 18:14:04 +08:00
|
|
|
void loadURL(const std::string &url);
|
2014-08-25 14:01:18 +08:00
|
|
|
|
2014-08-26 14:26:37 +08:00
|
|
|
void loadFile(const std::string &fileName);
|
2014-08-25 14:01:18 +08:00
|
|
|
|
2014-08-26 14:26:37 +08:00
|
|
|
void stopLoading();
|
2014-08-25 14:01:18 +08:00
|
|
|
|
2014-08-26 14:26:37 +08:00
|
|
|
void reload();
|
2014-08-25 14:01:18 +08:00
|
|
|
|
2014-08-26 14:26:37 +08:00
|
|
|
bool canGoBack();
|
2014-08-25 14:01:18 +08:00
|
|
|
|
2014-08-26 14:26:37 +08:00
|
|
|
bool canGoForward();
|
2014-08-25 14:01:18 +08:00
|
|
|
|
2014-08-26 14:26:37 +08:00
|
|
|
void goBack();
|
2014-08-25 14:01:18 +08:00
|
|
|
|
2014-08-26 14:26:37 +08:00
|
|
|
void goForward();
|
2014-08-25 14:01:18 +08:00
|
|
|
|
2014-08-26 14:26:37 +08:00
|
|
|
void evaluateJS(const std::string &js);
|
2014-08-25 14:01:18 +08:00
|
|
|
|
2014-08-26 14:26:37 +08:00
|
|
|
void setScalesPageToFit(const bool scalesPageToFit);
|
2014-08-25 14:01:18 +08:00
|
|
|
|
2014-08-26 14:26:37 +08:00
|
|
|
virtual void draw(cocos2d::Renderer *renderer, cocos2d::Mat4 const &transform, uint32_t flags);
|
2014-08-25 14:01:18 +08:00
|
|
|
|
2014-08-26 14:26:37 +08:00
|
|
|
virtual void setVisible(bool visible);
|
2014-08-25 14:01:18 +08:00
|
|
|
|
2016-05-24 18:27:59 +08:00
|
|
|
void setBounces(bool bounces);
|
|
|
|
|
2014-08-26 14:26:37 +08:00
|
|
|
static bool shouldStartLoading(const int viewTag, const std::string &url);
|
|
|
|
static void didFinishLoading(const int viewTag, const std::string &url);
|
|
|
|
static void didFailLoading(const int viewTag, const std::string &url);
|
|
|
|
static void onJsCallback(const int viewTag, const std::string &message);
|
2014-08-25 14:01:18 +08:00
|
|
|
|
2014-08-26 14:26:37 +08:00
|
|
|
private:
|
|
|
|
int _viewTag;
|
|
|
|
WebView *_webView;
|
|
|
|
};
|
2014-08-25 14:01:18 +08:00
|
|
|
|
2014-08-26 14:26:37 +08:00
|
|
|
} // namespace ui
|
|
|
|
} // namespace experimental
|
|
|
|
} //cocos2d
|
2014-08-25 14:01:18 +08:00
|
|
|
|
2014-09-10 03:18:31 +08:00
|
|
|
#endif // __ANDROID__
|
|
|
|
|
2015-03-24 20:23:51 +08:00
|
|
|
/// @endcond
|
2014-09-15 16:56:51 +08:00
|
|
|
#endif /* __COCOS2D__UI__WEBVIEWIMPL_ANDROID_H_ */
|