--- /dev/null
+/*
+ * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "runtime/browser/splash_screen.h"
+
+#include <algorithm>
+#include <map>
+#include <string>
+
+#if defined(HAVE_X11)
+#include <Ecore_X.h>
+#elif defined(HAVE_WAYLAND)
+#include <Ecore_Wayland.h>
+#endif
+#include <Evas_Legacy.h>
+
+#include "common/logger.h"
+#include "manifest_handlers/splash_screen_handler.h"
+#include "runtime/browser/native_window.h"
+
+using ScreenOrientation = runtime::NativeWindow::ScreenOrientation;
+
+namespace {
+
+enum class BorderOption { REPEAT = 1, STRETCH, ROUND };
+
+wgt::parse::ScreenOrientation ChooseOrientation(
+ const std::map<wgt::parse::ScreenOrientation,
+ wgt::parse::SplashScreenData>& splash_map,
+ ScreenOrientation screen_orientation) {
+ auto orientation_pair = splash_map.end();
+
+ if (screen_orientation ==
+ runtime::NativeWindow::ScreenOrientation::PORTRAIT_PRIMARY) {
+ orientation_pair =
+ splash_map.find(wgt::parse::ScreenOrientation::PORTRAIT);
+ } else {
+ orientation_pair =
+ splash_map.find(wgt::parse::ScreenOrientation::LANDSCAPE);
+ }
+ if (orientation_pair == splash_map.end())
+ orientation_pair = splash_map.find(wgt::parse::ScreenOrientation::AUTO);
+
+ if (orientation_pair != splash_map.end()) return orientation_pair->first;
+ return wgt::parse::ScreenOrientation::NONE;
+}
+
+bool ParseImageBorder(const std::vector<std::string>& borders,
+ std::vector<int>* border_values,
+ std::vector<BorderOption>* border_options) {
+ std::map<std::string, BorderOption> scaling_string;
+ scaling_string["repeat"] = BorderOption::REPEAT;
+ scaling_string["stretch"] = BorderOption::STRETCH;
+ scaling_string["round"] = BorderOption::ROUND;
+
+ for (const auto& border : borders) {
+ std::string::size_type px_index = border.find("px");
+ if (px_index != std::string::npos) {
+ std::string border_value(border.begin(), border.begin() + px_index);
+ border_values->push_back(std::atoi(border_value.c_str()));
+ }
+ for (const auto& border_string_val : scaling_string) {
+ std::string::size_type index = border.find(border_string_val.first);
+ if (index != std::string::npos) {
+ border_options->push_back(border_string_val.second);
+ }
+ }
+ }
+
+ LOGGER(DEBUG) << "Image border values:";
+ for (const auto& border_value : *border_values) {
+ LOGGER(DEBUG) << border_value;
+ }
+ LOGGER(DEBUG) << "Image border scaling values:";
+ for (const auto& border_option : *border_options) {
+ LOGGER(DEBUG) << static_cast<int>(border_option);
+ }
+
+ return !border_values->empty() && !border_options->empty();
+}
+
+} // namespace
+
+namespace runtime {
+
+SplashScreen::SplashScreen(
+ runtime::NativeWindow* window,
+ std::shared_ptr<const wgt::parse::SplashScreenInfo> ss_info,
+ const std::string& app_path)
+ : window_(window),
+ ss_info_(ss_info),
+ image_(nullptr),
+ background_(nullptr),
+ is_active_(false) {
+ LOGGER(DEBUG) << "start of create splash screen";
+ if (ss_info == nullptr) return;
+ auto splash_map = ss_info->splash_screen_data();
+ auto used_orientation =
+ ChooseOrientation(splash_map, window->natural_orientation());
+ if (used_orientation == wgt::parse::ScreenOrientation::NONE) return;
+
+ auto dimensions = GetDimensions();
+
+ SetBackground(splash_map[used_orientation], window->evas_object(),
+ dimensions, app_path);
+ SetImage(splash_map[used_orientation], window->evas_object(),
+ dimensions, app_path);
+ is_active_ = true;
+}
+
+
+void SplashScreen::HideSplashScreen(HideReason reason) {
+ if (!is_active_) return;
+ if (reason == HideReason::RENDERED &&
+ ss_info_->ready_when() != wgt::parse::ReadyWhen::FIRSTPAINT) {
+ return;
+ }
+ if (reason == HideReason::LOADFINISHED &&
+ ss_info_->ready_when() != wgt::parse::ReadyWhen::COMPLETE) {
+ return;
+ }
+ if (reason == HideReason::CUSTOM &&
+ ss_info_->ready_when() != wgt::parse::ReadyWhen::CUSTOM) {
+ return;
+ }
+
+ evas_object_hide(background_);
+ evas_object_hide(image_);
+ evas_object_del(background_);
+ evas_object_del(image_);
+ background_ = nullptr;
+ image_ = nullptr;
+ is_active_ = false;
+}
+
+std::pair<int, int> SplashScreen::GetDimensions() {
+ int w, h;
+#if defined(HAVE_X11)
+ uint16_t pid = getpid();
+ ecore_x_window_prop_property_set(elm_win_xwindow_get(window_.evas_object()),
+ ECORE_X_ATOM_NET_WM_PID,
+ ECORE_X_ATOM_CARDINAL, 32, &pid, 1);
+ ecore_x_vsync_animator_tick_source_set(
+ elm_win_xwindow_get(window_.evas_object()));
+ ecore_x_window_size_get(ecore_x_window_root_first_get(), &w, &h);
+#elif defined(HAVE_WAYLAND)
+ ecore_wl_screen_size_get(&w, &h);
+#endif
+ evas_object_resize(background_, w, h);
+ return std::make_pair(w, h);
+}
+
+void SplashScreen::SetBackground(
+ const wgt::parse::SplashScreenData& splash_data, Evas_Object* parent,
+ const SplashScreenBound& bound, const std::string& app_path) {
+ background_ = elm_bg_add(parent);
+ if (!background_) return;
+ evas_object_resize(background_, bound.first, bound.second);
+
+ if (splash_data.background_color != nullptr) {
+ elm_bg_color_set(background_,
+ splash_data.background_color->red,
+ splash_data.background_color->green,
+ splash_data.background_color->blue);
+ }
+
+ std::vector<int> border_values;
+ std::vector<BorderOption> border_options;
+
+ if (!splash_data.background_image.empty() &&
+ ParseImageBorder(
+ splash_data.image_border, &border_values, &border_options)) {
+ const std::string& background_image_path =
+ splash_data.background_image.front();
+
+ background_image_ = elm_image_add(background_);
+ evas_object_image_file_set(background_image_,
+ (app_path + background_image_path).c_str(),
+ NULL);
+ elm_image_aspect_fixed_set(background_image_, 0);
+ evas_object_image_border_center_fill_set(background_image_,
+ EVAS_BORDER_FILL_DEFAULT);
+
+ evas_object_resize(background_image_, bound.first, bound.second);
+
+ int border_l, border_r, border_t, border_b;
+ switch (border_values.size()) {
+ case 1:
+ border_l = border_r = border_t = border_b = -border_values[0];
+ break;
+ case 2:
+ border_t = border_b = border_values[0];
+ border_l = border_r = border_values[1];
+ break;
+ case 4:
+ border_t = border_values[0];
+ border_r = border_values[1];
+ border_b = border_values[2];
+ border_l = border_values[3];
+ break;
+ default:
+ border_l = border_r = border_t = border_b = 0;
+ }
+ evas_object_image_border_set(background_image_,
+ border_l,
+ border_r,
+ border_t,
+ border_b);
+ // TODO(a.szulakiewi): add scaling of horizontal and vertical borders
+ }
+
+ evas_object_show(background_);
+ evas_object_show(background_image_);
+}
+
+void SplashScreen::SetImage(
+ const wgt::parse::SplashScreenData& splash_data, Evas_Object* parent,
+ const SplashScreenBound& bound, const std::string& app_path) {
+ if (!background_) return;
+ image_ = elm_image_add(background_);
+ if (!image_) return;
+
+ const std::string& image_path = splash_data.image.front();
+ elm_image_file_set(image_, (app_path + image_path).c_str(), NULL);
+ evas_object_resize(image_, bound.first, bound.second);
+ evas_object_show(image_);
+}
+} // namespace runtime
#include "runtime/browser/popup_string.h"
#include "runtime/browser/vibration_manager.h"
#include "runtime/browser/web_view.h"
+#include "runtime/browser/splash_screen.h"
#ifndef INJECTED_BUNDLE_PATH
- #error INJECTED_BUNDLE_PATH is not set.
+#error INJECTED_BUNDLE_PATH is not set.
#endif
namespace runtime {
const char* kDebugKey = "debug";
const char* kPortKey = "port";
-const char* kAppControlEventScript = \
+const char* kAppControlEventScript =
"(function(){"
"var __event = document.createEvent(\"CustomEvent\");\n"
"__event.initCustomEvent(\"appcontrol\", true, true);\n"
"for (var i=0; i < window.frames.length; i++)\n"
"{ window.frames[i].document.dispatchEvent(__event); }"
"})()";
-const char* kBackKeyEventScript = \
+const char* kBackKeyEventScript =
"(function(){"
"var __event = document.createEvent(\"CustomEvent\");\n"
"__event.initCustomEvent(\"tizenhwkey\", true, true);\n"
"for (var i=0; i < window.frames.length; i++)\n"
"{ window.frames[i].document.dispatchEvent(__event); }"
"})()";
-const char* kMenuKeyEventScript = \
+const char* kMenuKeyEventScript =
"(function(){"
"var __event = document.createEvent(\"CustomEvent\");\n"
"__event.initCustomEvent(\"tizenhwkey\", true, true);\n"
"})()";
const char* kFullscreenPrivilege = "http://tizen.org/privilege/fullscreen";
const char* kFullscreenFeature = "fullscreen";
-const char* kNotificationPrivilege =
- "http://tizen.org/privilege/notification";
-const char* kLocationPrivilege =
- "http://tizen.org/privilege/location";
-const char* kStoragePrivilege =
- "http://tizen.org/privilege/unlimitedstorage";
-const char* kUsermediaPrivilege =
- "http://tizen.org/privilege/mediacapture";
+const char* kNotificationPrivilege = "http://tizen.org/privilege/notification";
+const char* kLocationPrivilege = "http://tizen.org/privilege/location";
+const char* kStoragePrivilege = "http://tizen.org/privilege/unlimitedstorage";
+const char* kUsermediaPrivilege = "http://tizen.org/privilege/mediacapture";
const char* kNotiIconFile = "noti_icon.png";
const char* kVisibilitySuspendFeature = "visibility,suspend";
bool FindPrivilege(common::ApplicationData* app_data,
const std::string& privilege) {
- if (app_data->permissions_info().get() == NULL)
- return false;
+ if (app_data->permissions_info().get() == NULL) return false;
auto it = app_data->permissions_info()->GetAPIPermissions().begin();
auto end = app_data->permissions_info()->GetAPIPermissions().end();
- for ( ; it != end; ++it) {
- if (*it == privilege)
- return true;
+ for (; it != end; ++it) {
+ if (*it == privilege) return true;
}
return false;
}
static void InitializeNotificationCallback(Ewk_Context* ewk_context,
WebApplication* app) {
- auto show = [](Ewk_Context*,
- Ewk_Notification* noti,
- void* user_data) {
+ auto show = [](Ewk_Context*, Ewk_Notification* noti, void* user_data) {
WebApplication* self = static_cast<WebApplication*>(user_data);
- if (self == NULL)
- return;
+ if (self == NULL) return;
uint64_t id = ewk_notification_id_get(noti);
- std::string title(ewk_notification_title_get(noti) ?
- ewk_notification_title_get(noti) : "");
- std::string body(ewk_notification_body_get(noti) ?
- ewk_notification_body_get(noti) : "");
+ std::string title(ewk_notification_title_get(noti)
+ ? ewk_notification_title_get(noti)
+ : "");
+ std::string body(
+ ewk_notification_body_get(noti) ? ewk_notification_body_get(noti) : "");
std::string icon_path = self->data_path() + "/" + kNotiIconFile;
if (!ewk_notification_icon_save_as_png(noti, icon_path.c_str())) {
icon_path = "";
if (NotificationManager::GetInstance()->Show(id, title, body, icon_path))
ewk_notification_showed(id);
};
- auto hide = [](Ewk_Context*,
- uint64_t noti_id,
- void *) {
+ auto hide = [](Ewk_Context*, uint64_t noti_id, void*) {
NotificationManager::GetInstance()->Hide(noti_id);
ewk_notification_closed(noti_id, EINA_FALSE);
};
- ewk_context_notification_callbacks_set(ewk_context,
- show,
- hide,
- app);
+ ewk_context_notification_callbacks_set(ewk_context, show, hide, app);
}
static Eina_Bool ExitAppIdlerCallback(void* data) {
return false;
}
- std::unique_ptr<common::AppControl>
- request(common::AppControl::MakeAppcontrolFromURL(url));
+ std::unique_ptr<common::AppControl> request(
+ common::AppControl::MakeAppcontrolFromURL(url));
if (request.get() == NULL || !request->LaunchRequest()) {
LOGGER(ERROR) << "Fail to send appcontrol request";
SLoggerE("Fail to send appcontrol request [%s]", url.c_str());
NativeWindow* window, std::unique_ptr<common::ApplicationData> app_data)
: launched_(false),
debug_mode_(false),
- ewk_context_(ewk_context_new_with_injected_bundle_path(
- INJECTED_BUNDLE_PATH)),
+ ewk_context_(
+ ewk_context_new_with_injected_bundle_path(INJECTED_BUNDLE_PATH)),
window_(window),
appid_(app_data->app_id()),
locale_manager_(new common::LocaleManager()),
app_data_(std::move(app_data)),
terminator_(NULL) {
- std::unique_ptr<char, decltype(std::free)*>
- path {app_get_data_path(), std::free};
+ std::unique_ptr<char, decltype(std::free)*> path{app_get_data_path(),
+ std::free};
app_data_path_ = path.get();
-
+ LOGGER(ERROR) << "path is " << path.get();
+ splash_screen_.reset(new SplashScreen(
+ window_, app_data_->splash_screen_info(), app_data_->application_path()));
resource_manager_.reset(
new common::ResourceManager(app_data_.get(), locale_manager_.get()));
- resource_manager_->set_base_resource_path(
- app_data_->application_path());
+ resource_manager_->set_base_resource_path(app_data_->application_path());
Initialize();
}
WebApplication::~WebApplication() {
- if (ewk_context_)
- ewk_context_delete(ewk_context_);
+ if (ewk_context_) ewk_context_delete(ewk_context_);
}
bool WebApplication::Initialize() {
// set persistent storage path
std::string cookie_path = data_path() + ".cookie";
ewk_cookie_manager_persistent_storage_set(
- cookie_manager, cookie_path.c_str(),
- EWK_COOKIE_PERSISTENT_STORAGE_SQLITE);
+ cookie_manager, cookie_path.c_str(),
+ EWK_COOKIE_PERSISTENT_STORAGE_SQLITE);
// vibration callback
auto vibration_start_callback = [](uint64_t ms, void*) {
auto vibration_stop_callback = [](void* /*user_data*/) {
platform::VibrationManager::GetInstance()->Stop();
};
- ewk_context_vibration_client_callbacks_set(ewk_context_,
- vibration_start_callback,
- vibration_stop_callback,
- NULL);
+ ewk_context_vibration_client_callbacks_set(
+ ewk_context_, vibration_start_callback, vibration_stop_callback, NULL);
auto download_callback = [](const char* downloadUrl, void* /*data*/) {
SendDownloadRequest(downloadUrl);
};
- ewk_context_did_start_download_callback_set(ewk_context_,
- download_callback,
+ ewk_context_did_start_download_callback_set(ewk_context_, download_callback,
this);
InitializeNotificationCallback(ewk_context_, this);
if (FindPrivilege(app_data_.get(), kFullscreenPrivilege)) {
ewk_context_tizen_extensible_api_string_set(ewk_context_,
- kFullscreenFeature,
- true);
+ kFullscreenFeature, true);
}
if (app_data_->setting_info() != NULL &&
app_data_->setting_info()->background_support_enabled()) {
+ ewk_context_tizen_extensible_api_string_set(
+ ewk_context_, kVisibilitySuspendFeature, true);
ewk_context_tizen_extensible_api_string_set(ewk_context_,
- kVisibilitySuspendFeature,
- true);
- ewk_context_tizen_extensible_api_string_set(ewk_context_,
- kBackgroundMusicFeature,
- true);
+ kBackgroundMusicFeature, true);
}
ewk_context_tizen_extensible_api_string_set(ewk_context_,
- kMediastreamRecordFeature,
- true);
+ kMediastreamRecordFeature, true);
ewk_context_tizen_extensible_api_string_set(ewk_context_,
- kEncryptedDatabaseFeature,
- true);
+ kEncryptedDatabaseFeature, true);
if (app_data_->setting_info() != NULL &&
- app_data_->setting_info()->screen_orientation()
- == wgt::parse::SettingInfo::ScreenOrientation::AUTO) {
+ app_data_->setting_info()->screen_orientation() ==
+ wgt::parse::SettingInfo::ScreenOrientation::AUTO) {
ewk_context_tizen_extensible_api_string_set(ewk_context_,
- kRotationLockFeature,
- true);
+ kRotationLockFeature, true);
} else if (app_data_->setting_info() != NULL &&
- app_data_->setting_info()->screen_orientation()
- == wgt::parse::SettingInfo::ScreenOrientation::PORTRAIT) {
- window_->SetRotationLock(
- NativeWindow::ScreenOrientation::PORTRAIT_PRIMARY);
+ app_data_->setting_info()->screen_orientation() ==
+ wgt::parse::SettingInfo::ScreenOrientation::PORTRAIT) {
+ window_->SetRotationLock(NativeWindow::ScreenOrientation::PORTRAIT_PRIMARY);
} else if (app_data_->setting_info() != NULL &&
- app_data_->setting_info()->screen_orientation()
- == wgt::parse::SettingInfo::ScreenOrientation::LANDSCAPE) {
+ app_data_->setting_info()->screen_orientation() ==
+ wgt::parse::SettingInfo::ScreenOrientation::LANDSCAPE) {
window_->SetRotationLock(
NativeWindow::ScreenOrientation::LANDSCAPE_PRIMARY);
}
if (app_data_->setting_info() != NULL &&
- app_data_->setting_info()->sound_mode()
- == wgt::parse::SettingInfo::SoundMode::EXCLUSIVE) {
- ewk_context_tizen_extensible_api_string_set(ewk_context_,
- kSoundModeFeature,
+ app_data_->setting_info()->sound_mode() ==
+ wgt::parse::SettingInfo::SoundMode::EXCLUSIVE) {
+ ewk_context_tizen_extensible_api_string_set(ewk_context_, kSoundModeFeature,
true);
}
if (app_data_->setting_info() != NULL &&
app_data_->setting_info()->background_vibration()) {
- ewk_context_tizen_extensible_api_string_set(ewk_context_,
- kBackgroundVibrationFeature,
- true);
+ ewk_context_tizen_extensible_api_string_set(
+ ewk_context_, kBackgroundVibrationFeature, true);
}
if (app_data_->widget_info() != NULL &&
// TODO(sngn.lee): find the proxy url
// ewk_context_proxy_uri_set(ewk_context_, ... );
- if (app_data_->csp_info() != NULL ||
- app_data_->csp_report_info() != NULL ||
+ if (app_data_->csp_info() != NULL || app_data_->csp_report_info() != NULL ||
app_data_->allowed_navigation_info() != NULL) {
security_model_version_ = 2;
if (app_data_->csp_info() == NULL ||
!app_data_->csp_report_info()->security_rules().empty()) {
csp_report_rule_ = app_data_->csp_report_info()->security_rules();
}
- ewk_context_tizen_extensible_api_string_set(ewk_context_,
- kCSPFeature,
+ ewk_context_tizen_extensible_api_string_set(ewk_context_, kCSPFeature,
EINA_TRUE);
} else {
security_model_version_ = 1;
SetupWebView(view);
// send widget info to injected bundle
- ewk_send_widget_info(ewk_context_, appid_.c_str(),
- elm_config_scale_get(),
- elm_theme_get(NULL),
- "");
+ ewk_send_widget_info(ewk_context_, appid_.c_str(), elm_config_scale_get(),
+ elm_theme_get(NULL), "");
std::unique_ptr<common::ResourceManager::Resource> res =
- resource_manager_->GetStartResource(appcontrol.get());
+ resource_manager_->GetStartResource(appcontrol.get());
view->SetDefaultEncoding(res->encoding());
STEP_PROFILE_END("OnCreate -> URL Set");
void WebApplication::AppControl(
std::unique_ptr<common::AppControl> appcontrol) {
std::unique_ptr<common::ResourceManager::Resource> res =
- resource_manager_->GetStartResource(appcontrol.get());
+ resource_manager_->GetStartResource(appcontrol.get());
bool do_reset = res->should_reset();
window_->SetContent(NULL);
WebView* front = view_stack_.front();
auto it = view_stack_.begin();
- for ( ; it != view_stack_.end(); ++it) {
+ for (; it != view_stack_.end(); ++it) {
if (*it != front) {
(*it)->Suspend();
delete *it;
}
auto it = view_stack_.begin();
- for ( ; it != view_stack_.end(); ++it) {
+ for (; it != view_stack_.end(); ++it) {
(*it)->Resume();
}
}
}
auto it = view_stack_.begin();
- for ( ; it != view_stack_.end(); ++it) {
+ for (; it != view_stack_.end(); ++it) {
(*it)->Suspend();
}
}
window_->SetContent(new_view->evas_object());
}
-void WebApplication::OnClosedWebView(WebView * view) {
- if (view_stack_.size() == 0)
- return;
+void WebApplication::OnClosedWebView(WebView* view) {
+ if (view_stack_.size() == 0) return;
WebView* current = view_stack_.front();
if (current == view) {
// Delete after the callback context(for ewk view) was not used
ecore_idler_add([](void* view) {
- WebView* obj = static_cast<WebView*>(view);
- delete obj;
- return EINA_FALSE;
- }, view);
+ WebView* obj = static_cast<WebView*>(view);
+ delete obj;
+ return EINA_FALSE;
+ },
+ view);
}
-void WebApplication::OnReceivedWrtMessage(
- WebView* /*view*/,
- Ewk_IPC_Wrt_Message_Data* msg) {
-
+void WebApplication::OnReceivedWrtMessage(WebView* /*view*/,
+ Ewk_IPC_Wrt_Message_Data* msg) {
Eina_Stringshare* msg_id = ewk_ipc_wrt_message_data_id_get(msg);
Eina_Stringshare* msg_ref_id = ewk_ipc_wrt_message_data_reference_id_get(msg);
Eina_Stringshare* msg_type = ewk_ipc_wrt_message_data_type_get(msg);
LOGGER(DEBUG) << "RecvMsg: type = " << msg_type;
LOGGER(DEBUG) << "RecvMsg: value = " << msg_value;
- #define TYPE_IS(x) (!strcmp(msg_type, x))
+#define TYPE_IS(x) (!strcmp(msg_type, x))
if (TYPE_IS("tizen://hide")) {
// One Way Message
window_->InActive();
LOGGER(ERROR) << "Failed to send response";
}
ewk_ipc_wrt_message_data_del(ans);
+ } else if (TYPE_IS("tizen://hide_splash_screen")) {
+ splash_screen_->HideSplashScreen(SplashScreen::HideReason::CUSTOM);
}
- #undef TYPE_IS
+
+
+#undef TYPE_IS
eina_stringshare_del(msg_value);
eina_stringshare_del(msg_type);
}
void WebApplication::OnOrientationLock(
- WebView* view,
- bool lock,
+ WebView* view, bool lock,
NativeWindow::ScreenOrientation preferred_rotation) {
- if (view_stack_.size() == 0)
- return;
+ if (view_stack_.size() == 0) return;
// Only top-most view can set the orientation relate operation
- if (view_stack_.front() != view)
- return;
-
- auto orientaion_setting = app_data_->setting_info() != NULL ?
- app_data_->setting_info()->screen_orientation() :
- // TODO(sngn.lee): check default value
- wgt::parse::SettingInfo::ScreenOrientation::AUTO;
+ if (view_stack_.front() != view) return;
+
+ auto orientaion_setting =
+ app_data_->setting_info() != NULL
+ ? app_data_->setting_info()->screen_orientation()
+ :
+ // TODO(sngn.lee): check default value
+ wgt::parse::SettingInfo::ScreenOrientation::AUTO;
if (orientaion_setting != wgt::parse::SettingInfo::ScreenOrientation::AUTO) {
return;
}
}
void WebApplication::OnHardwareKey(WebView* view, const std::string& keyname) {
- bool enabled = app_data_->setting_info() != NULL ?
- app_data_->setting_info()->hwkey_enabled() :
- true;
+ bool enabled = app_data_->setting_info() != NULL
+ ? app_data_->setting_info()->hwkey_enabled()
+ : true;
if (enabled && kKeyNameBack == keyname) {
view->EvalJavascript(kBackKeyEventScript);
} else if (enabled && kKeyNameMenu == keyname) {
locale_manager_->UpdateSystemLocale();
ewk_context_cache_clear(ewk_context_);
auto it = view_stack_.begin();
- for ( ; it != view_stack_.end(); ++it) {
+ for (; it != view_stack_.end(); ++it) {
(*it)->Reload();
}
}
int dlog_level = DLOG_DEBUG;
switch (level) {
case EWK_CONSOLE_MESSAGE_LEVEL_WARNING:
- dlog_level = DLOG_WARN;
- break;
+ dlog_level = DLOG_WARN;
+ break;
case EWK_CONSOLE_MESSAGE_LEVEL_ERROR:
- dlog_level = DLOG_ERROR;
- break;
+ dlog_level = DLOG_ERROR;
+ break;
default:
- dlog_level = DLOG_DEBUG;
- break;
+ dlog_level = DLOG_DEBUG;
+ break;
}
LOGGER_RAW(dlog_level, kConsoleMessageLogTag) << msg;
}
}
bool WebApplication::OnContextMenuDisabled(WebView* /*view*/) {
- return !(app_data_->setting_info() != NULL ?
- app_data_->setting_info()->context_menu_enabled() :
- true);
+ return !(app_data_->setting_info() != NULL
+ ? app_data_->setting_info()->context_menu_enabled()
+ : true);
}
void WebApplication::OnLoadStart(WebView* /*view*/) {
LOGGER(DEBUG) << "LoadStart";
}
+
void WebApplication::OnLoadFinished(WebView* /*view*/) {
LOGGER(DEBUG) << "LoadFinished";
+ splash_screen_->HideSplashScreen(SplashScreen::HideReason::LOADFINISHED);
}
+
void WebApplication::OnRendered(WebView* /*view*/) {
STEP_PROFILE_END("URL Set -> Rendered");
STEP_PROFILE_END("Start -> Launch Completed");
LOGGER(DEBUG) << "Rendered";
+ splash_screen_->HideSplashScreen(SplashScreen::HideReason::RENDERED);
}
void WebApplication::LaunchInspector(common::AppControl* appcontrol) {
- unsigned int port =
- ewk_context_inspector_server_start(ewk_context_, 0);
+ 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() };
+ data[kPortKey] = {ss.str()};
appcontrol->Reply(data);
}
}
void WebApplication::OnNotificationPermissionRequest(
- WebView*,
- const std::string& url,
+ WebView*, const std::string& url,
std::function<void(bool)> result_handler) {
auto db = common::AppDB::GetInstance();
- std::string reminder = db->Get(kDBPrivateSection,
- kNotificationPermissionPrefix + url);
+ std::string reminder =
+ db->Get(kDBPrivateSection, kNotificationPermissionPrefix + url);
if (reminder == "allowed") {
result_handler(true);
return;
popup->SetBody(popup_string::kPopupBodyWebNotification);
popup->SetCheckBox(popup_string::kPopupCheckRememberPreference);
popup->SetResultHandler(
- [db, result_handler, url](Popup* popup, void* /*user_data*/) {
- bool result = popup->GetButtonResult();
- bool remember = popup->GetCheckBoxResult();
- if (remember) {
- db->Set(kDBPrivateSection, kNotificationPermissionPrefix + url,
- result ? "allowed" : "denied");
- }
- result_handler(result);
- }, this);
+ [db, result_handler, url](Popup* popup, void* /*user_data*/) {
+ bool result = popup->GetButtonResult();
+ bool remember = popup->GetCheckBoxResult();
+ if (remember) {
+ db->Set(kDBPrivateSection, kNotificationPermissionPrefix + url,
+ result ? "allowed" : "denied");
+ }
+ result_handler(result);
+ },
+ this);
popup->Show();
}
void WebApplication::OnGeolocationPermissionRequest(
- WebView*,
- const std::string& url,
+ WebView*, const std::string& url,
std::function<void(bool)> result_handler) {
auto db = common::AppDB::GetInstance();
- std::string reminder = db->Get(kDBPrivateSection,
- kGeolocationPermissionPrefix + url);
+ std::string reminder =
+ db->Get(kDBPrivateSection, kGeolocationPermissionPrefix + url);
if (reminder == "allowed") {
result_handler(true);
return;
popup->SetBody(popup_string::kPopupBodyGeoLocation);
popup->SetCheckBox(popup_string::kPopupCheckRememberPreference);
popup->SetResultHandler(
- [db, result_handler, url](Popup* popup, void* /*user_data*/) {
- bool result = popup->GetButtonResult();
- bool remember = popup->GetCheckBoxResult();
- if (remember) {
- db->Set(kDBPrivateSection, kGeolocationPermissionPrefix + url,
- result ? "allowed" : "denied");
- }
- result_handler(result);
- }, this);
+ [db, result_handler, url](Popup* popup, void* /*user_data*/) {
+ bool result = popup->GetButtonResult();
+ bool remember = popup->GetCheckBoxResult();
+ if (remember) {
+ db->Set(kDBPrivateSection, kGeolocationPermissionPrefix + url,
+ result ? "allowed" : "denied");
+ }
+ result_handler(result);
+ },
+ this);
popup->Show();
}
-
-void WebApplication::OnQuotaExceed(
- WebView*,
- const std::string& url,
- std::function<void(bool)> result_handler) {
+void WebApplication::OnQuotaExceed(WebView*, const std::string& url,
+ std::function<void(bool)> result_handler) {
auto db = common::AppDB::GetInstance();
- std::string reminder = db->Get(kDBPrivateSection,
- kQuotaPermissionPrefix + url);
+ std::string reminder =
+ db->Get(kDBPrivateSection, kQuotaPermissionPrefix + url);
if (reminder == "allowed") {
result_handler(true);
return;
popup->SetBody(popup_string::kPopupBodyWebStorage);
popup->SetCheckBox(popup_string::kPopupCheckRememberPreference);
popup->SetResultHandler(
- [db, result_handler, url](Popup* popup, void* /*user_data*/) {
- bool result = popup->GetButtonResult();
- bool remember = popup->GetCheckBoxResult();
- if (remember) {
- db->Set(kDBPrivateSection, kQuotaPermissionPrefix + url,
- result ? "allowed" : "denied");
- }
- result_handler(result);
- }, this);
+ [db, result_handler, url](Popup* popup, void* /*user_data*/) {
+ bool result = popup->GetButtonResult();
+ bool remember = popup->GetCheckBoxResult();
+ if (remember) {
+ db->Set(kDBPrivateSection, kQuotaPermissionPrefix + url,
+ result ? "allowed" : "denied");
+ }
+ result_handler(result);
+ },
+ this);
popup->Show();
}
void WebApplication::OnAuthenticationRequest(
- WebView*,
- const std::string& /*url*/,
- const std::string& /*message*/,
- std::function<void(bool submit,
- const std::string& id,
- const std::string& password)
- > result_handler) {
+ WebView*, const std::string& /*url*/, const std::string& /*message*/,
+ std::function<void(bool submit, const std::string& id,
+ const std::string& password)> result_handler) {
Popup* popup = Popup::CreatePopup(window_);
popup->SetButtonType(Popup::ButtonType::LoginCancelButton);
popup->SetFirstEntry(popup_string::kPopupLabelAuthusername,
Popup::EntryType::PwEdit);
popup->SetTitle(popup_string::kPopupTitleAuthRequest);
popup->SetBody(popup_string::kPopupBodyAuthRequest);
- popup->SetResultHandler(
- [result_handler](Popup* popup, void* /*user_data*/) {
- bool result = popup->GetButtonResult();
- std::string id = popup->GetFirstEntryResult();
- std::string passwd = popup->GetSecondEntryResult();
- result_handler(result, id, passwd);
- }, this);
+ popup->SetResultHandler([result_handler](Popup* popup, void* /*user_data*/) {
+ bool result = popup->GetButtonResult();
+ std::string id = popup->GetFirstEntryResult();
+ std::string passwd = popup->GetSecondEntryResult();
+ result_handler(result, id, passwd);
+ },
+ this);
popup->Show();
}
void WebApplication::OnCertificateAllowRequest(
- WebView*,
- const std::string& /*url*/,
- const std::string& pem,
- std::function<void(bool allow)> result_handler) {
+ WebView*, const std::string& /*url*/, const std::string& pem,
+ std::function<void(bool allow)> result_handler) {
auto db = common::AppDB::GetInstance();
- std::string reminder = db->Get(kDBPrivateSection,
- kCertificateAllowPrefix + pem);
+ std::string reminder =
+ db->Get(kDBPrivateSection, kCertificateAllowPrefix + pem);
if (reminder == "allowed") {
result_handler(true);
return;
popup->SetBody(popup_string::kPopupBodyCert);
popup->SetCheckBox(popup_string::kPopupCheckRememberPreference);
popup->SetResultHandler(
- [db, result_handler, pem](Popup* popup, void* /*user_data*/) {
- bool result = popup->GetButtonResult();
- bool remember = popup->GetCheckBoxResult();
- if (remember) {
- db->Set(kDBPrivateSection, kCertificateAllowPrefix + pem,
- result ? "allowed" : "denied");
- }
- result_handler(result);
- }, this);
+ [db, result_handler, pem](Popup* popup, void* /*user_data*/) {
+ bool result = popup->GetButtonResult();
+ bool remember = popup->GetCheckBoxResult();
+ if (remember) {
+ db->Set(kDBPrivateSection, kCertificateAllowPrefix + pem,
+ result ? "allowed" : "denied");
+ }
+ result_handler(result);
+ },
+ this);
popup->Show();
}
void WebApplication::OnUsermediaPermissionRequest(
- WebView*,
- const std::string& url,
- std::function<void(bool)> result_handler) {
+ WebView*, const std::string& url,
+ std::function<void(bool)> result_handler) {
auto db = common::AppDB::GetInstance();
- std::string reminder = db->Get(kDBPrivateSection,
- kUsermediaPermissionPrefix + url);
+ std::string reminder =
+ db->Get(kDBPrivateSection, kUsermediaPermissionPrefix + url);
if (reminder == "allowed") {
result_handler(true);
return;
popup->SetBody(popup_string::kPopupBodyUserMedia);
popup->SetCheckBox(popup_string::kPopupCheckRememberPreference);
popup->SetResultHandler(
- [db, result_handler, url](Popup* popup, void* /*user_data*/) {
- bool result = popup->GetButtonResult();
- bool remember = popup->GetCheckBoxResult();
- if (remember) {
- db->Set(kDBPrivateSection, kUsermediaPermissionPrefix + url,
- result ? "allowed" : "denied");
- }
- result_handler(result);
- }, this);
+ [db, result_handler, url](Popup* popup, void* /*user_data*/) {
+ bool result = popup->GetButtonResult();
+ bool remember = popup->GetCheckBoxResult();
+ if (remember) {
+ db->Set(kDBPrivateSection, kUsermediaPermissionPrefix + url,
+ result ? "allowed" : "denied");
+ }
+ result_handler(result);
+ },
+ this);
popup->Show();
}