#include <ewk_chromium.h>
#include <algorithm>
#include <memory>
+#include <sstream>
+#include <vector>
+#include <map>
#include "common/message_types.h"
#include "common/command_line.h"
const char* kConsoleLogEnableKey = "WRT_CONSOLE_LOG_ENABLE";
const char* kConsoleMessageLogTag = "ConsoleMessage";
+ const char* kDebugKey = "debug";
+ const char* kPortKey = "port";
+
+
const char* kAppControlEventScript = \
"(function(){"
"var __event = document.createEvent(\"CustomEvent\");\n"
appid_(appid),
ewk_context_(ewk_context_new()),
locale_manager_(new LocaleManager()),
- app_data_(new ApplicationData(appid)) {
+ app_data_(new ApplicationData(appid)),
+ debug_mode_(false) {
// app_data_path
std::unique_ptr<char, decltype(std::free)*>
path {app_get_data_path(), std::free};
appid_(app_data->app_id()),
ewk_context_(ewk_context_new()),
locale_manager_(new LocaleManager()),
- app_data_(std::move(app_data)) {
+ app_data_(std::move(app_data)),
+ debug_mode_(false) {
// app_data_path
std::unique_ptr<char, decltype(std::free)*>
path {app_get_data_path(), std::free};
EVAS_CALLBACK_RESIZE,
callback, NULL);
+ if (appcontrol->data(kDebugKey) == "true") {
+ debug_mode_ = true;
+ LaunchInspector(appcontrol.get());
+ }
+
// TODO(sngn.lee): check the below code location.
// in Wearable, webkit can render contents before show window
// but Mobile, webkit can't render contents before show window
// Send Event
SendAppControlEvent();
}
+
+ if (!debug_mode_ && appcontrol->data(kDebugKey) == "true") {
+ debug_mode_ = true;
+ LaunchInspector(appcontrol.get());
+ }
window_->Active();
}
void WebApplication::OnConsoleMessage(const std::string& msg, int level) {
static bool enabled = (getenv(kConsoleLogEnableKey) != NULL);
- // TODO(sngn.lee): check debug mode
- if (true/*debug mode*/ || enabled) {
+ if (debug_mode_ || enabled) {
int dlog_level = DLOG_DEBUG;
switch (level) {
case EWK_CONSOLE_MESSAGE_LEVEL_WARNING:
LoggerD("Rendered");
}
-
-
+void WebApplication::LaunchInspector(wrt::AppControl* appcontrol) {
+ unsigned int port =
+ ewk_context_inspector_server_start(ewk_context_, 0);
+ std::stringstream ss;
+ ss << port;
+ std::map<std::string, std::vector<std::string>> data;
+ data[kPortKey] = { ss.str() };
+ appcontrol->Reply(data);
+}
} // namespace wrt