#include <dpl/string.h>
#include <dpl/foreach.h>
+#include <Elementary.h>
+#include <efl_assist.h>
#include <pcrecpp.h>
-#include <vconf.h>
#include <sysman.h>
#include <widget_model.h>
+#include <dpl/log/secure_log.h>
+#include <system_settings.h>
#include <dpl/wrt-dao-ro/widget_dao_read_only.h>
-#include <dpl/wrt-dao-ro/vconf_config.h>
#include <dpl/utils/wrt_global_settings.h>
-#include <common/application_data.h>
+#include <application_data.h>
#include <common/application_launcher.h>
+#include <common/message_support.h>
#include <common/scheme.h>
#include <common/view_logic_apps_support.h>
#include <common/view_logic_custom_header_support.h>
-#include <common/view_logic_password_support.h>
#include <common/view_logic_security_support.h>
#include <common/view_logic_security_origin_support.h>
#include <common/view_logic_certificate_support.h>
#include <common/view_logic_storage_support.h>
#include <common/view_logic_uri_support.h>
-#include <common/view_logic_user_agent_support.h>
#include <common/view_logic_vibration_support.h>
#include <view_logic_authentication_challenge_support.h>
+#include <view_logic_certificate_confirm_support.h>
+#include <view_logic_geolocation_support.h>
+#include <view_logic_message_support.h>
+#include <view_logic_orientation_support.h>
#include <view_logic_scheme_support.h>
-#include <view_logic_geolocation_support_webkit2.h>
#include <view_logic_usermedia_support.h>
+#include <view_logic_web_notification_data.h>
#include <view_logic_web_notification_support.h>
-
-#include <view_logic_certificate_confirm_support.h>
-#include "bundles/plugin_module_support.h"
-#include <popup-runner/PopupInvoker.h>
+#include <view_logic_web_notification_permission_support.h>
+#include <view_logic_web_storage_support.h>
#include <EWebKit2.h>
+#include <dpl/localization/w3c_file_localization.h>
#include <js_overlay_types.h>
+#include <dispatch_event_support.h>
#include <i_runnable_widget_object.h>
#include <profiling_util.h>
#include <wrt-commons/custom-handler-dao-ro/CustomHandlerDatabase.h>
#include <wrt-commons/custom-handler-dao-rw/custom_handler_dao.h>
#include <popup-runner/PopupInvoker.h>
-
-#include <appsvc/appsvc.h>
+#include <plugins-ipc-message/ipc_message_support.h>
+#include <appsvc.h>
namespace {
-const char * const bundlePath = "/usr/lib/wrt-wk2-bundles/libwrt-wk2-bundle.so";
-const char * const uriBlockedMessageName = "uri_blocked_msg";
-const char * const uriChangedMessageName = "uri_changed_msg";
-const char * const URICHANGE_PLUGIN_STOP_ONLY = "plugin_stop_only";
-const char * const URICHANGE_PLUGIN_RESTART = "plugin_restart";
-const char * const URICHANGE_PLUGIN_NO_CHANGE = "plugin_no_change";
-const char * const URICHANGE_BLOCKED_URL = "null";
-const char* PATTERN_URI_CHANGE = "^(([^:/\\?#]+)://[^\\?#]*)";
-const int MAX_NUM_CONTEXT_MENU_ITEMS = 10;
// IME State value
const char * const IME_STATE_ON = "on";
const char * const IME_STATE_OFF = "off";
const char CONTENT_HANDLER_ASK_MSG[] = "Add content?";
const char CONTENT_HANDLER_ASK_TITLE[] = "Add content";
const char CONTENT_HANDLER_AKS_REMEMBER[] = "Remember dicision";
-const char * const CERTIFICATE_CONFIRM_REQUEST_ASK_TITLE =
- "Certification Info";
-const char * const CERTIFICATE_CONFIRM_REQUEST_ASK_BODY =
- "This site's security certificate is not trusted! Do you acess this site?";
-const wchar_t* BACKGROUND_ENABLED = L"background_enabled";
+const char* const DEFAULT_ENCODING = "UTF-8";
+#ifdef CSP_ENABLED
+const char* const DEFAULT_CSP_POLICY =
+ "default-src *; script-src 'self'; style-src 'self'; object-src 'none';";
+#endif
+// SCHEME
+const char * const SCHEME_BOX_SLASH = "box://";
+const double ORIENTATION_THRESHOLD = 0.5;
} // anonymous namespace
std::map<const std::string,
const Evas_Smart_Cb> ViewLogic::m_ewkCallbacksMap = {
{ "load,started", &ViewLogic::loadStartedCallback },
{ "load,finished", &ViewLogic::loadFinishedCallback },
- { "title,changed", &ViewLogic::titleChangedCallback },
+ { "load,progress,started", &ViewLogic::loadProgressStartedCallback },
{ "load,progress", &ViewLogic::loadProgressCallback },
{ "load,progress,finished", &ViewLogic::loadProgressFinishedCallback },
{ "process,crashed", &ViewLogic::processCrashedCallback },
{ "policy,response,decide", &ViewLogic::pageResponseDecideCallback },
// WKPageContextMenuClient
{ "contextmenu,customize", &ViewLogic::contextmenuCustomizeCallback },
- // WKPageFormClient
- { "form,submit", &ViewLogic::formSubmitCallback },
// EWK Geolocation Callback
{ "geolocation,permission,request",
&ViewLogic::geolocationPermissionRequestCallback },
{ "notification,cancel", &ViewLogic::notificationCancelCallback },
{ "notification,permission,request",
&ViewLogic::notificationPermissionRequestCallback },
-
{ "fullscreen,enterfullscreen", &ViewLogic::enterFullscreenCallback },
{ "fullscreen,exitfullscreen", &ViewLogic::exitFullscreenCallback },
// IME Callback
{ "request,certificate,confirm",
&ViewLogic::certificateConfirmRequestCallback },
{ "authentication,challenge",
- &ViewLogic::authenticationChallengeRequestCallback }
+ &ViewLogic::authenticationChallengeRequestCallback },
+ { "frame,rendered",
+ &ViewLogic::viewFrameRenderedCallback },
+ { "mediacontrol,rotate,horizontal",
+ &ViewLogic::mediacontrolRotateHorizontal },
+ { "mediacontrol,rotate,vertical",
+ &ViewLogic::mediacontrolRotateVertical },
+ { "mediacontrol,rotate,exit",
+ &ViewLogic::mediacontrolRotateExit },
+ { "popup,reply,wait,start",
+ &ViewLogic::popupReplyWaitStart },
+ { "popup,reply,wait,finish",
+ &ViewLogic::popupReplyWaitFinish },
};
ViewLogic::ViewLogic() :
m_imeHeight(0),
m_isBackgroundReload(false),
m_isBackgroundSupport(false),
+ m_rotateAngle(0),
+ m_deferredRotateAngle(
+ ViewModule::OrientationSupport::DEFERRED_ORIENTATION_EMPTY),
+ m_orientationThresholdTimer(NULL),
+ m_isPopupReplyWait(false),
+ m_isFullscreenByPlatform(false),
m_appsSupport(new ViewModule::AppsSupport()),
- m_vibrationSupport(new ViewModule::VibrationSupport())
+ m_vibrationSupport(new ViewModule::VibrationSupport()),
+ m_webNotificationSupport(new ViewModule::WebNotificationSupport())
{
ApplicationLauncherSingleton::Instance().Touch();
}
const char *theme = elm_theme_get(NULL);
if (theme) {
m_theme = theme;
- LogInfo("theme is " << m_theme);
+ LogDebug("theme is " << m_theme);
}
// set members
m_window = window;
Evas* canvas = evas_object_evas_get(m_window);
- return createEwkView(canvas);
+
+ if (!createEwkView(canvas)) {
+ return false;
+ }
+
+ return true;
}
void ViewLogic::prepareView(WidgetModel* m, const std::string &startUrl)
ADD_PROFILING_POINT("initializeSupport", "start");
initializeSupport();
ADD_PROFILING_POINT("initializeSupport", "stop");
- setStartPage();
ewkClientInit(m_currentEwkView);
ADD_PROFILING_POINT("prepareEwkView", "start");
prepareEwkView(m_currentEwkView);
ADD_PROFILING_POINT("prepareEwkView", "stop");
initializePluginLoading();
+ initializeXwindowHandle();
}
void ViewLogic::showWidget()
{
LogDebug("showing widget");
Assert(NULL != m_currentEwkView && "ewk_view not created at this point");
- if (m_currentUri.empty()) {
+ std::string url =
+ ViewModule::UriSupport::getUri(m_model, m_startUrl);
+ if (url.empty()) {
LogError("Localized current URI doesn't exist");
return;
}
-
- LogInfo("m_currentUri: " << m_currentUri);
+ LogDebug("url : " << url);
// load page
- ewk_view_url_set(m_currentEwkView, m_currentUri.c_str());
+ ewk_view_url_set(m_currentEwkView, url.c_str());
if (!m_cbs->bufferSet.empty()) {
m_cbs->bufferSet(m_currentEwkView);
LogDebug("hiding widget");
ViewModule::StorageSupport::deinitializeStorage(m_model);
m_appsSupport->deinitialize();
-
m_vibrationSupport->deinitialize();
+ m_webNotificationSupport->deinitialize();
+ system_settings_unset_changed_cb(SYSTEM_SETTINGS_KEY_FONT_TYPE);
while (!m_ewkViewList.empty()) {
- LogInfo("pop webview: " << m_ewkViewList.back());
+ LogDebug("pop webview: " << m_ewkViewList.back());
removeEwkView(m_ewkViewList.back());
}
m_ewkViewList.clear();
void ViewLogic::suspendWidget()
{
- LogInfo("Pausing widget");
+ LogDebug("Pausing widget");
Assert(m_model);
if (!m_currentEwkView) {
LogWarning("Cannot suspend widget without view");
} else {
setEwkViewInvisible(m_currentEwkView);
+
if (!m_isBackgroundSupport) {
+ FOREACH(it, m_ewkViewList) {
+ if (*it != m_currentEwkView) {
+ suspendWebkit(*it);
+ }
+ }
+
suspendWebkit(m_currentEwkView);
}
}
- evas_object_focus_set(m_currentEwkView, EINA_FALSE);
-
// call user callback
if (!m_cbs->suspend.empty()) {
m_cbs->suspend(true);
void ViewLogic::resumeWidget()
{
- LogInfo("Resume widget");
+ LogDebug("Resume widget");
Assert(m_model);
- if (m_currentEwkView) {
+ if (m_currentEwkView)
+ {
setEwkViewVisible(m_currentEwkView);
+
if (!m_isBackgroundSupport) {
+ FOREACH(it, m_ewkViewList) {
+ if (*it != m_currentEwkView) {
+ resumeWebkit(*it);
+ }
+ }
+
resumeWebkit(m_currentEwkView);
}
}
* elm_win_raise(m_window);
* }
*/
- evas_object_focus_set(m_currentEwkView, EINA_TRUE);
// call user callback
if (!m_cbs->resume.empty()) {
void ViewLogic::resetWidget()
{
- LogInfo("Resetting Widget");
-
- // destory all webview
- while (!m_ewkViewList.empty()) {
- LogInfo("pop webview: " << m_ewkViewList.back());
- removeEwkView(m_ewkViewList.back());
- }
- m_ewkViewList.clear();
-
- // create new webview
- createEwkView(evas_object_evas_get(m_window));
- setStartPage();
- ewkClientInit(m_currentEwkView);
- prepareEwkView(m_currentEwkView);
-
- // check if current url is service url for this tizen service
- std::string requestedUri =
- ViewModule::UriSupport::getUri(m_model, m_startUrl);
- DPL::OptionalString servicedUri = ViewModule::UriSupport::localizeURI(
- DPL::FromUTF8String(requestedUri.c_str()),
- m_model);
-
- initializePluginLoading();
+ LogDebug("Resetting Widget");
- // webview activated
- m_currentUri = DPL::ToUTF8String(*servicedUri);
- ewk_view_url_set(m_currentEwkView, m_currentUri.c_str());
- elm_win_activate(m_window);
- evas_object_focus_set(m_currentEwkView, EINA_TRUE);
+ // handling case of WebProcess is locked
+ if (m_isPopupReplyWait) {
+ // resume web application
+ LogDebug("WebProcess is locked");
+ if (m_currentEwkView) {
+ setEwkViewVisible(m_currentEwkView);
+ if (!m_isBackgroundSupport) {
+ resumeWebkit(m_currentEwkView);
+ }
+ }
+ // webview activated
+ elm_win_activate(m_window);
- // call user callback
- if (!m_cbs->reset.empty()) {
- m_cbs->reset(true);
- }
- if (!m_cbs->bufferSet.empty()) {
- m_cbs->bufferSet(m_currentEwkView);
+ // call user callback
+ if (!m_cbs->reset.empty()) {
+ m_cbs->reset(false);
+ }
+ } else {
+ // reset web application
+ // destory all webview
+ while (!m_ewkViewList.empty()) {
+ LogDebug("pop webview: " << m_ewkViewList.back());
+ removeEwkView(m_ewkViewList.back());
+ }
+ m_ewkViewList.clear();
+ m_currentEwkView = NULL;
+
+ // create new webview
+ createEwkView(evas_object_evas_get(m_window));
+ ewkClientInit(m_currentEwkView);
+ prepareEwkView(m_currentEwkView);
+
+ // check if current url is service url for this tizen service
+ std::string url =
+ ViewModule::UriSupport::getUri(m_model, m_startUrl);
+
+ initializePluginLoading();
+ // webview activated
+ ewk_view_url_set(m_currentEwkView, url.c_str());
+ elm_win_activate(m_window);
+
+ // call user callback
+ if (!m_cbs->reset.empty()) {
+ m_cbs->reset(true);
+ }
+ if (!m_cbs->bufferSet.empty()) {
+ m_cbs->bufferSet(m_currentEwkView);
+ }
}
}
} else {
if (1 >= m_ewkViewList.size()) {
// If there is no previous page, widget move to backgroud.
- LogInfo("Widget move to backgroud");
+ LogDebug("Widget move to backgroud");
elm_win_lower(m_window);
} else {
// Back to previous webview
- LogInfo("Widget move to previous webview");
+ LogDebug("Widget move to previous webview");
m_closedEwkView = m_currentEwkView;
ecore_idler_add(windowCloseIdlerCallback, this);
}
void ViewLogic::reloadStartPage()
{
- LogInfo("Reload Start Page");
+ LogDebug("Reload Start Page");
// prevent fail to load plugin bundle side
m_isBackgroundReload = true;
createEwkView(evas_object_evas_get(m_window));
ewkClientInit(m_currentEwkView);
- setStartPage();
prepareEwkView(m_currentEwkView);
initializePluginLoading();
// load page
- ewk_view_url_set(m_currentEwkView, m_currentUri.c_str());
+ std::string url = ViewModule::UriSupport::getUri(m_model, m_startUrl);
+ ewk_view_url_set(m_currentEwkView, url.c_str());
// show ewkView
if (!m_cbs->bufferSet.empty()) {
m_cbs->bufferSet(m_currentEwkView);
}
- LogInfo("Reloading Start Page is done!");
+ LogDebug("Reloading Start Page is done!");
}
Evas_Object* ViewLogic::getCurrentWebview()
{
- LogInfo("get current webview");
+ LogDebug("get current webview");
return m_currentEwkView;
}
void ViewLogic::fireJavascriptEvent(int event, void* data)
{
- PluginModuleSupport::dispatchJavaScriptEvent(
+ ViewLogicMessageSupport::dispatchJavaScriptEvent(
m_ewkContext,
static_cast<WrtPlugins::W3C::CustomEventType>(event),
data);
void ViewLogic::checkSyncMessageFromBundle(
const char* name,
- const char* body,
+ const char* /*body*/,
char** returnData)
{
LogDebug("didReceiveSynchronousMessage called");
Assert(name);
- Assert(returnData);
- if (!body) {
- LogDebug("body is empty");
- *returnData = NULL;
- return;
+ LogDebug("received : " << name);
+ if (!strcmp(name, Message::TizenScheme::GET_WINDOW_HANDLE)) {
+ if (m_window) {
+ Ecore_X_Window handle = elm_win_xwindow_get(m_window);
+ if (handle != 0) {
+ std::stringstream ss;
+ ss << handle;
+ std::string ret = ss.str();
+ if (returnData) {
+ *returnData = strdup(ret.c_str());
+ }
+ } else {
+ LogDebug("X window isn't exist");
+ }
+ }
}
+}
- LogDebug("received : " << name);
- std::string result;
- if (!strcmp(name, uriBlockedMessageName)) {
+void ViewLogic::checkAsyncMessageFromBundle(const char* name, const char* body)
+{
+ Assert(name);
+ _D("received : %s", name);
+
+ if (!strcmp(name, Message::ToUIProcess::BLOCKED_URL)) {
// Currently WebProcess informs obly about blocked
// URI - URI localization and security chekcs are
- // done by WebProcess itself (see: wrt-wk2-bundle.cpp
+ // done by WebProcess itself (see: wrt-injected-bundle.cpp
// and bundle_uri_handling.cpp)
- result = requestUrlBlocked(std::string(body));
- } else if (!strcmp(name, uriChangedMessageName)) {
- result = requestUrlChanged(std::string(body));
- }
+ requestUrlBlocked(std::string(body));
+ } else if (!strcmp(name, Message::TizenScheme::CLEAR_ALL_COOKIES)) {
+ Ewk_Cookie_Manager* cookieManager =
+ ewk_context_cookie_manager_get(m_ewkContext);
+ if (!cookieManager) {
+ _E("Fail to get cookieManager");
+ return;
+ }
+ ewk_cookie_manager_cookies_clear(cookieManager);
+ } else if (!strcmp(name, IPCMessageSupport::TIZEN_CHANGE_USERAGENT)) {
+ std::string msgBody = (body) ? (body) : "";
- *returnData = strdup(result.c_str());
+ std::string strId = msgBody.substr(0, msgBody.find_first_of('_'));
+ std::string strBody = msgBody.substr(msgBody.find_first_of('_')+1);
+ _D("Id: %s , Body %s", strId.c_str(), strBody.c_str());
+
+ ewk_view_user_agent_set(m_currentEwkView, strBody.c_str());
+ _D("get UA: %s", ewk_view_user_agent_get(m_currentEwkView));
+
+ IPCMessageSupport::replyAsyncMessageToWebProcess(m_ewkContext,
+ atoi(strId.c_str()),
+ "success");
+ return;
+ } else if (!strcmp(name, IPCMessageSupport::TIZEN_DELETE_ALL_COOKIES)) {
+ std::string msgBody = (body) ? (body) : "";
+ std::string strId = msgBody.substr(0, msgBody.find_first_of('_'));
+ std::string strBody = msgBody.substr(msgBody.find_first_of('_')+1);
+
+ Ewk_Cookie_Manager* cookieManager =
+ ewk_context_cookie_manager_get(m_ewkContext);
+ if (!cookieManager) {
+ _E("Fail to get cookieManager");
+ IPCMessageSupport::replyAsyncMessageToWebProcess(
+ m_ewkContext,
+ atoi(strId.c_str()),
+ "error");
+ return;
+ }
+ ewk_cookie_manager_cookies_clear(cookieManager);
+ IPCMessageSupport::replyAsyncMessageToWebProcess(m_ewkContext,
+ atoi(strId.c_str()),
+ "success");
+ return;
+ } else if (!strcmp(name, IPCMessageSupport::TIZEN_EXIT) ||
+ !strcmp(name, IPCMessageSupport::TIZEN_HIDE))
+ {
+ bool ret =
+ ViewModule::SchemeSupport::HandleTizenScheme(name,
+ m_window,
+ m_currentEwkView);
+ if (ret == false) {
+ _E("Fail to handle tizen scheme %s", name);
+ }
+ // Not need to send reply
+ return;
+ } else {
+ _W("Not defined message");
+ }
}
void ViewLogic::downloadData(const char* url)
{
- LogInfo("enter");
+ LogDebug("enter");
if (!url) {
return;
}
-
m_appsSupport->downloadRequest(url, NULL, NULL);
}
void ViewLogic::activateVibration(bool on, uint64_t time)
{
- LogInfo("enter");
+ LogDebug("enter");
if (on) {
m_vibrationSupport->startVibration(static_cast<long>(time));
} else {
== BackgroundSupport_Enable)
{
LogDebug("Background support enabled, set process active");
- pid_t pid = getpid();
- sysman_inform_active(pid);
+ sysman_inform_active(getpid());
m_isBackgroundSupport = true;
}
-#ifndef DEPRECATED_SETTING_STRING
- else {
- WrtDB::WidgetDAOReadOnly dao(m_model->TizenId);
- WrtDB::PropertyDAOReadOnly::WidgetPropertyValue bgEnableValue =
- dao.getPropertyValue(DPL::String(BACKGROUND_ENABLED));
-
- if (!bgEnableValue.IsNull() && !bgEnableValue->compare(L"true")) {
- //skip suspendWidget
- LogDebug("Background support enabled, set process active");
- pid_t pid = getpid();
- sysman_inform_active(pid);
- m_isBackgroundSupport = true;
- }
- }
-#endif
+ system_settings_set_changed_cb(SYSTEM_SETTINGS_KEY_FONT_TYPE,
+ systemSettingsChangedCallback,
+ this);
- m_schemeSupport.reset(new SchemeSupport(m_model->Type.Get().appType));
ViewModule::StorageSupport::initializeStorage(m_model);
- m_appsSupport->initialize(m_model);
+ m_appsSupport->initialize(m_model, elm_win_xwindow_get(m_window));
m_securityOriginSupport.reset(new ViewModule::SecurityOriginSupport(m_model));
m_certificateSupport.reset(new ViewModule::CertificateSupport(m_model));
-
m_vibrationSupport->initialize();
+ m_webNotificationSupport->initialize(m_model->TzPkgId.Get());
}
void ViewLogic::initializePluginLoading()
{
// inform wrt information for plugin loading to web process
- PluginModuleSupport::start(
+ ViewLogicMessageSupport::start(
m_ewkContext,
m_model->TizenId,
elm_config_scale_get(),
ApplicationDataSingleton::Instance().getEncodedBundle(),
- m_theme.c_str(),
- m_model->SettingList.Get().isEncrypted());
+ m_theme.c_str());
+}
+
+void ViewLogic::initializeXwindowHandle()
+{
+ if (m_window) {
+ unsigned int handle = elm_win_xwindow_get(m_window);
+ ViewLogicMessageSupport::setXwindowHandle(
+ m_ewkContext,
+ handle);
+ }
}
void ViewLogic::ewkClientInit(Evas_Object *wkView)
wkView,
orientationLockCallback,
this);
+ ewk_view_exceeded_database_quota_callback_set(
+ wkView,
+ exceededDatabaseQuotaCallback,
+ this);
+ ewk_view_exceeded_indexed_database_quota_callback_set(
+ wkView,
+ exceededIndexedDatabaseQuotaCallback,
+ this);
+ ewk_view_exceeded_local_file_system_quota_callback_set(
+ wkView,
+ exceededLocalFileSystemQuotaCallback,
+ this);
+ ea_object_event_callback_add(wkView,
+ EA_CALLBACK_BACK,
+ eaKeyCallback,
+ this);
+ ea_object_event_callback_add(wkView,
+ EA_CALLBACK_MORE,
+ eaKeyCallback,
+ this);
+#if 0 // FIXME!!! elm_access_object_register has not landed yet
+ // Always register access object even application doesn't support
+ // accessibility. In case of accessibility isn't supported, efl_assist
+ // shows warning message by syspopup.
+ // initScreenReaderSupport is related method. (window_data.cpp)
+ elm_access_object_register(wkView, m_window);
+#endif
}
void ViewLogic::ewkClientDeinit(Evas_Object *wkView)
it->first.c_str(),
it->second);
}
- ewk_view_orientation_lock_callback_set(
- wkView,
- NULL,
- NULL);
+ ewk_view_orientation_lock_callback_set(wkView, NULL, NULL);
+ ewk_view_exceeded_database_quota_callback_set(wkView, NULL, NULL);
+ ewk_view_exceeded_indexed_database_quota_callback_set(wkView, NULL, NULL);
+ ewk_view_exceeded_local_file_system_quota_callback_set(wkView, NULL, NULL);
+ ea_object_event_callback_del(wkView,
+ EA_CALLBACK_BACK,
+ eaKeyCallback);
+ ea_object_event_callback_del(wkView,
+ EA_CALLBACK_MORE,
+ eaKeyCallback);
+ if (m_orientationThresholdTimer) {
+ ecore_timer_del(m_orientationThresholdTimer);
+ m_orientationThresholdTimer = NULL;
+ }
+ // FIXME!!!! elm_access_object_unregister has not landed in
+ // tizen 3.0 elementary yet
+ // elm_access_object_unregister(wkView);
}
bool ViewLogic::createEwkView(Evas* canvas)
{
- LogDebug("createEwkVeiw");
+ LogDebug("createEwkView");
Assert(canvas);
ADD_PROFILING_POINT("ewk_view_add_with_context", "start");
Evas_Object* newEwkView = ewk_view_add_with_context(
setEwkViewInvisible(m_currentEwkView);
}
- LogInfo("push webview: " << newEwkView);
+ LogDebug("push webview: " << newEwkView);
m_ewkViewList.push_back(newEwkView);
m_currentEwkView = newEwkView;
return true;
}
-void ViewLogic::setStartPage()
-{
- /* Start URI (as other uris) is now localized
- * on WebProcess side */
- m_currentUri = ViewModule::UriSupport::getUri(m_model, m_startUrl);
-}
-
void ViewLogic::prepareEwkView(Evas_Object *wkView)
{
LogDebug("prepareEwkView called");
Assert(wkView);
-
-#ifdef CSP_ENABLED
- LogInfo("Setting CSP default policy");
- ewk_context_tizen_extensible_api_set(
- m_ewkContext, EWK_EXTENSIBLE_API_CSP, true);
- // setting CSP policy rules
- // temporary turn off
- //ewk_view_content_security_policy_set(
- // wkView,
- // "default-src '*'; script-src 'self'; style-src 'self'; object-src 'none';",
- // EWK_ENFORCE_POLICY);
- //LogInfo("Default policy set");
-
- DPL::OptionalString policy = m_model->CspPolicy.Get();
-
- if (!(policy.IsNull()))
- {
- LogDebug("CSP policy present in manifest: " << *policy);
- ewk_view_content_security_policy_set(
- wkView, DPL::ToUTF8String(*policy).c_str(), EWK_ENFORCE_POLICY);
- } else {
- LogDebug("Config CSP policy is not present");
- }
-
- policy = m_model->CspReportOnlyPolicy.Get();
- if (!(policy.IsNull()))
- {
- LogDebug("CSP report only policy present in manifest: " << *policy);
- ewk_view_content_security_policy_set(
- wkView, DPL::ToUTF8String(*policy).c_str(), EWK_REPORT_ONLY);
- } else {
- LogDebug("Config CSP report only policy is not present");
- }
-
- LogInfo("CSP set.");
-#endif
-
Ewk_Settings* settings = ewk_view_settings_get(wkView);
// set user agent
std::string customUserAgent = m_model->SettingList.Get().getUserAgent();
if (customUserAgent.empty()) {
- auto userAgentString =
- ViewModule::UserAgentSupport::getUserAgentFromVconf();
- if (!userAgentString.empty()) {
- LogDebug("Setting user agent as: " << userAgentString);
- ewk_view_user_agent_set(wkView, userAgentString.c_str());
- }
+ LogDebug("Setting user agent as: default");
+ ewk_view_user_agent_set(wkView, NULL);
+ std::string defaultUA = ewk_view_user_agent_get(wkView);
+ LogDebug("webkit's UA: " << defaultUA);
} else {
LogDebug("Setting custom user agent as: " << customUserAgent);
ewk_view_user_agent_set(wkView, customUserAgent.c_str());
// webkit NPAPI plugins is always on in wrt
ewk_settings_plugins_enabled_set(settings, EINA_TRUE);
-
- // The followings are not implemeted yet by webkit2
- // ewk_view_setting_accelerated_compositing_enable_set(EINA_TRUE);
- // ewk_view_mode_set();
- // ewk_view_setting_enable_specified_plugin_set(EINA_TRUE,
- // FLASH_MIME_TYPE);
- // ewk_view_setting_html5video_external_player_enable_set(EINA_FALSE);
- // ewk_view_show_ime_on_autofocus_set(EINA_TRUE);
- // elm_webview_show_magnifier_set(EINA_FALSE);
ewk_settings_javascript_enabled_set(settings, EINA_TRUE);
ewk_settings_loads_images_automatically_set(settings, EINA_TRUE);
// WRT should not fit web contents to device width automatically as default.
// Fitting to device width should be handled by web content using viewport meta tag.
ewk_settings_auto_fitting_set(settings, EINA_FALSE);
+ ewk_settings_autofill_password_form_enabled_set(settings, EINA_TRUE);
+ ewk_settings_form_candidate_data_enabled_set(settings, EINA_TRUE);
- // disable zoom option when user click the input field
- // this option is useful with the normal website
- // for the make user friendly, disable auto zoom in the webapp
- // The followings are not implemeted yet by webkit2
- // elm_webview_input_field_zoom_set(EINA_FALSE);
-
- // set cookie database path
- // The followings are not implemeted yet by webkit2
- // ewk_cookies_file_set(dao.getCookieDatabasePath().c_str()));
-
- // set visibility to WebCore. This value will be used for html5.
- // also, this value will be changed in the suspend, resume
- // or create window, close window.
ewk_view_page_visibility_state_set(wkView,
EWK_PAGE_VISIBILITY_STATE_VISIBLE,
EINA_TRUE);
+
+ std::string encoding = DEFAULT_ENCODING;
+ OptionalWidgetStartFileInfo fileInfo =
+ W3CFileLocalization::getStartFileInfo(m_model->TizenId);
+#if 0 // FIXME!!!! ewk_settings_is_encoding_valid has not landed yet
+ if (!fileInfo.IsNull()) {
+ std::string file_encoding = DPL::ToUTF8String((*fileInfo).encoding);
+
+ if(EINA_TRUE == ewk_settings_is_encoding_valid(
+ file_encoding.c_str())){
+ encoding = file_encoding;
+ _D("Found custom encoding in DB: %s", encoding.c_str());
+ }
+
+ }
+#endif
+ _D("Setting encoding: %s", encoding.c_str());
+ if (ewk_settings_default_encoding_set(settings,encoding.c_str())) {
+ _D("Encoding set properly");
+ } else {
+ _E("Error while setting encoding");
+ }
+
+#ifdef CSP_ENABLED
+ if (m_model->SecurityModelVersion.Get() ==
+ WrtDB::WidgetSecurityModelVersion::WIDGET_SECURITY_MODEL_V2)
+ {
+ // setting CSP policy rules
+ DPL::OptionalString policy = m_model->CspReportOnlyPolicy.Get();
+ if (!policy.IsNull()) {
+ LogDebug("CSP report only policy present in manifest: " << *policy);
+ ewk_view_content_security_policy_set(
+ wkView,
+ DPL::ToUTF8String(*policy).c_str(),
+ EWK_REPORT_ONLY);
+ }
+
+ policy = m_model->CspPolicy.Get();
+ if (!policy.IsNull()) {
+ LogDebug("CSP policy present in manifest: " << *policy);
+ ewk_view_content_security_policy_set(
+ wkView,
+ DPL::ToUTF8String(*policy).c_str(),
+ EWK_ENFORCE_POLICY);
+ } else {
+ ewk_view_content_security_policy_set(
+ wkView,
+ DEFAULT_CSP_POLICY,
+ EWK_ENFORCE_POLICY);
+ }
+ }
+#endif
}
void ViewLogic::removeEwkView(Evas_Object *wkView)
{
- LogInfo("removeEwkView called");
+ LogDebug("removeEwkView called");
Assert(wkView);
Assert(0 != m_ewkViewList.size());
m_ewkViewList.remove(wkView);
}
-void ViewLogic::resumeEwkView(Evas_Object *wkView)
-{
- LogInfo("resumeEwkView called");
- Assert(wkView);
-
- // register webview callback
- ewkClientInit(wkView);
-
- // resume webkit
- resumeWebkit(wkView);
-
- return;
-}
-
-void ViewLogic::suspendEwkView(Evas_Object *wkView)
-{
- LogInfo("suspendEwkView called");
- Assert(wkView);
-
- // suspend webkit
- suspendWebkit(wkView);
-
- // unregister webview callbacks
- ewkClientDeinit(wkView);
- return;
-}
-
void ViewLogic::setEwkViewInvisible(Evas_Object *wkView)
{
- LogInfo("setEwkViewInvisible called");
+ LogDebug("setEwkViewInvisible called");
Assert(wkView);
ewk_view_page_visibility_state_set(wkView,
void ViewLogic::setEwkViewVisible(Evas_Object *wkView)
{
- LogInfo("setEwkViewVisible called");
+ LogDebug("setEwkViewVisible called");
Assert(wkView);
ewk_view_page_visibility_state_set(wkView,
void ViewLogic::resumeWebkit(Evas_Object *wkView)
{
- LogDebug("resumeWebkit");
+ LogDebug("resumeWebkit : " << wkView);
Assert(wkView);
- // resume NPAPI plugin
- // The followings are not implemeted yet by webkit2
- // ewk_view_pause_or_resume_plugins(false);
- // ewk_view_pause_or_resume_video_audio(false);
- // ewk_view_javascript_resume();
- // ewk_view_enable_render();
- // ewk_view_reduce_plugins_frame_rate(false);
ewk_view_resume(wkView);
+ // FIXME!!!! ewk_view_foreground_set has not landed yet
+ // ewk_view_foreground_set(wkView, true);
return;
}
void ViewLogic::suspendWebkit(Evas_Object *wkView)
{
- LogDebug("suspendWebkit");
+ LogDebug("suspendWebkit : " << wkView);
Assert(wkView);
- // suspend the followings
- // The followings are not implemeted yet by webkit2
- // ewk_view_pause_or_resume_plugins(true);
- // ewk_view_pause_or_resume_video_audio(true);
ewk_view_suspend(wkView);
+ // FIXME!!!! ewk_view_foreground_set has not landed in the
+ // tizen 3.0 elementary project yet
+ // ewk_view_foreground_set(wkView, false);
return;
}
LogDebug("loadStartedCallback called");
Assert(data);
ViewLogic* This = static_cast<ViewLogic*>(data);
- evas_object_focus_set(This->m_currentEwkView, EINA_TRUE);
// call loadFinish callback to wrt-client
if (!This->m_cbs->loadStart.empty()) {
return;
}
- // check if this loading is for blocked url
- if (This->m_blockedUri == url) {
- if (ewk_view_back_possible(This->m_currentEwkView)) {
- // go back to previous page
- LogDebug("go to previous page");
- ewk_view_back(This->m_currentEwkView);
- } else {
- // stop current page
- LogDebug("remove current page");
- ewk_view_stop(This->m_currentEwkView);
- ecore_idler_add(windowCloseIdlerCallback, This);
- }
- This->m_blockedUri = std::string();
- return;
- }
-
- DPL::OptionalString jsOptionalString =
- ViewModule::PasswordSupport::jsForAutoFillData(url);
- if (jsOptionalString.IsNull()) {
- LogError("Fail to get JS String");
- } else {
- std::string jsStr = DPL::ToUTF8String(*jsOptionalString).c_str();
-
- if (EINA_FALSE == ewk_view_script_execute(
- This->m_currentEwkView,
- jsStr.c_str(),
- didRunJavaScriptCallback,
- This))
- {
- LogError("JS for auto fill data failed.");
- }
- }
-
// call loadFinish callback to wrt-client
if (!This->m_cbs->loadFinish.empty()) {
This->m_cbs->loadFinish(obj);
// set only encoded bundle
double scale = elm_config_scale_get();
- PluginModuleSupport::setCustomProperties(
+ ViewLogicMessageSupport::setCustomProperties(
This->m_ewkContext,
&scale,
ApplicationDataSingleton::Instance().getEncodedBundle());
- // check if 'appsevice' event is registed at the current frames.
- // If so, dispatch the event to frames.
- PluginModuleSupport::dispatchJavaScriptEvent(
- This->m_ewkContext,
- WrtPlugins::W3C::ServiceCustomEvent,
- NULL);
// In this case, widget is reloaded in the background.
// After finished load, bundle should disconnent callback.
}
}
-void ViewLogic::titleChangedCallback(
+void ViewLogic::loadProgressStartedCallback(
void* data,
- Evas_Object* obj,
- void* eventInfo)
+ Evas_Object* /*obj*/,
+ void* /*eventInfo*/)
{
- LogDebug("titleChangedCallback called");
+ _D("loadProgressStartedCallback called");
Assert(data);
ViewLogic* This = static_cast<ViewLogic*>(data);
- Assert(eventInfo);
- const char* title = static_cast<char*>(eventInfo);
-
- if (0 == strlen(title)) {
- LogDebug("title data is empty");
- This->m_currentTitle = std::string();
- return;
- }
- LogDebug("Title = [" << title << "]");
- bool ret = This->m_schemeSupport->HandleTizenScheme(
- title,
- This->m_window,
- This->m_currentEwkView);
- // if result is true, this is tizen scheme
- // and then, title is reset to page's real title
- if (ret) {
- std::string script = "document.title = \"";
- script += This->m_currentTitle;
- script +="\";";
- ewk_view_script_execute(obj, script.c_str(), didRunJavaScriptCallback, This);
- } else {
- This->m_currentTitle = std::string(title);
+ if (!This->m_cbs->progressStarted.empty()) {
+ This->m_cbs->progressStarted();
}
}
+
void ViewLogic::loadProgressCallback(
- void* /*data*/,
- Evas_Object* /*obj*/,
+ void* data,
+ Evas_Object* obj,
void* eventInfo)
{
+ _D("loadProgressCallback called");
+ Assert(data);
+ Assert(eventInfo);
+ ViewLogic const * const view = static_cast<ViewLogic const * const>(data);
double* progress = static_cast<double*>(eventInfo);
LogDebug("didChangeProgressCallback progress = " << *progress);
+ if (!view->m_cbs->progress.empty()) {
+ Assert(obj);
+ view->m_cbs->progress(obj, *progress);
+ }
}
void ViewLogic::loadProgressFinishedCallback(
Evas_Object* /*obj*/,
void* eventInfo)
{
- LogInfo("processCrashedCallback");
+ LogDebug("processCrashedCallback");
Assert(data);
ViewLogic const * const view =
static_cast<ViewLogic const * const>(data);
Evas_Object* newEwkView = This->m_currentEwkView;
// initialize new ewkview
- This->setStartPage();
This->ewkClientInit(newEwkView);
This->prepareEwkView(newEwkView);
void ViewLogic::policyNavigationDecideCallback(
void* data,
- Evas_Object* /*obj*/,
+ Evas_Object* obj,
void* eventInfo)
{
LogDebug("policyNavigationDecideCallback called");
Ewk_Policy_Decision* policyDecision =
static_cast<Ewk_Policy_Decision*>(eventInfo);
- if (This->m_schemeSupport->filterURIByScheme(policyDecision,
- false,
- This->m_model,
- This->m_window,
- This->m_currentEwkView))
+ // handle blocked url
+ const char* url = ewk_policy_decision_url_get(policyDecision);
+
+ // call user delegate callback
+ if (!This->m_cbs->navigationDecide.empty()) {
+ std::string navigationUri(url);
+ This->m_cbs->navigationDecide(obj, navigationUri);
+ if (!navigationUri.compare(0, 6, SCHEME_BOX_SLASH)) {
+ ewk_policy_decision_ignore(policyDecision);
+ return;
+ }
+ }
+
+ if (url && strlen(url) != 0) {
+ if (This->m_blockedUri == url) {
+ LogDebug("Blocked url = " << url);
+ This->m_blockedUri = std::string();
+ ewk_policy_decision_ignore(policyDecision);
+ return;
+ }
+ }
+
+ if (ViewModule::SchemeSupport::filterURIByScheme(policyDecision,
+ false,
+ This->m_window,
+ This->m_currentEwkView))
{
LogDebug("use");
ewk_policy_decision_use(policyDecision);
* and the previous one is shown. This is not an elegant solution
* but we don't have a better one.
*/
- LogInfo("Scheme has been handled externally. Removing empty view.");
+ LogDebug("Scheme has been handled externally. Removing empty view.");
if (ewk_view_back_possible(This->m_currentEwkView)) {
// go back to previous WKPage
ewk_view_back(This->m_currentEwkView);
} else {
// stop current WKPage
ewk_view_stop(This->m_currentEwkView);
+ This->m_closedEwkView = This->m_currentEwkView;
ecore_idler_add(windowCloseIdlerCallback, This);
}
}
Ewk_Policy_Decision* policyDecision =
static_cast<Ewk_Policy_Decision*>(eventInfo);
- if (This->m_schemeSupport->filterURIByScheme(policyDecision,
- true,
- This->m_model,
- This->m_window,
- This->m_currentEwkView))
+ // handle blocked url
+ const char* url = ewk_policy_decision_url_get(policyDecision);
+ if (url && strlen(url) != 0) {
+ if (This->m_blockedUri == url) {
+ LogDebug("Blocked url = " << url);
+ This->m_blockedUri = std::string();
+ ewk_policy_decision_ignore(policyDecision);
+ return;
+ }
+ }
+
+ if (ViewModule::SchemeSupport::filterURIByScheme(policyDecision,
+ true,
+ This->m_window,
+ This->m_currentEwkView))
{
ewk_policy_decision_use(policyDecision);
} else {
ewk_context_menu_item_remove(menu, item);
continue;
+ case EWK_CONTEXT_MENU_ITEM_TAG_DOWNLOAD_IMAGE_TO_DISK:
+ ewk_context_menu_item_remove(menu, item);
+ continue;
+
default:
idx++;
break;
}
}
-void ViewLogic::formSubmitCallback(
- void* /*data*/,
- Evas_Object* /*obj*/,
- void* eventInfo)
-{
- LogDebug("formSubmitCallback called");
- Assert(eventInfo);
- Ewk_Form_Data* formData = static_cast<Ewk_Form_Data*>(eventInfo);
-
- const char* uri = ewk_form_data_url_get(formData);
- if (!uri) {
- LogError("URL is empty");
- return;
- }
-
- Eina_Hash* userData = ewk_form_data_values_get(formData);
- ViewModule::PasswordSupport::submitClicked(uri, userData);
-}
-
void ViewLogic::geolocationPermissionRequestCallback(
void* data,
Evas_Object* /*obj*/,
Ewk_Geolocation_Permission_Request* permissionRequest =
static_cast<Ewk_Geolocation_Permission_Request*>(eventInfo);
- if (This->m_securityOriginSupport->isNeedPermissionCheck(
- SecurityOriginDB::FEATURE_GEOLOCATION)
- == WrtDB::SETTINGS_TYPE_OFF)
- {
+ if (This->m_model->GeolocationUsage.Get() == WrtDB::SETTINGS_TYPE_OFF) {
ewk_geolocation_permission_request_set(permissionRequest, EINA_FALSE);
return;
}
- ViewModule::GeolocationSupport::Webkit2::geolocationPermissionRequest(
- This->m_window,
+ ViewModule::GeolocationSupport::geolocationPermissionRequest(
+ This->m_currentEwkView,
This->m_securityOriginSupport->getSecurityOriginDAO(),
eventInfo);
}
Evas_Object* /*obj*/,
void* eventInfo)
{
- LogDebug("notificationShowCallback called");
- Assert(data);
- ViewLogic* This = static_cast<ViewLogic*>(data);
-
Assert(eventInfo);
- Ewk_Notification* noti = static_cast<Ewk_Notification*>(eventInfo);
+ Ewk_Notification* ewkNotification =
+ static_cast<Ewk_Notification*>(eventInfo);
+ ViewModule::WebNotificationDataPtr notiData(
+ new ViewModule::WebNotificationData(ewkNotification));
- using namespace ViewModule::WebNotification;
+ _D("notification id : %u", notiData->getEwkNotiId());
+ _D("notification iconURL : %s", notiData->getIconUrl());
+ _D("notification title : %s", notiData->getTitle());
+ _D("notification body : %s", notiData->getBody());
- WebNotificationDataPtr notiData(
- new WebNotificationData(
- This->m_model,
- ewk_notification_id_get(noti)));
-
- DPL::OptionalString string =
- DPL::FromUTF8String(ewk_notification_icon_url_get(noti));
- if (!string.IsNull()) {
- notiData->m_iconURL = DPL::ToUTF8String(*string);
- }
- string = DPL::FromUTF8String(ewk_notification_title_get(noti));
- if (!string.IsNull()) {
- notiData->m_title = DPL::ToUTF8String(*string);
- }
- string = DPL::FromUTF8String(ewk_notification_body_get(noti));
- if (!string.IsNull()) {
- notiData->m_body = DPL::ToUTF8String(*string);
+ Assert(data);
+ ViewLogic* This = static_cast<ViewLogic*>(data);
+ if (This->m_webNotificationSupport->show(notiData)) {
+ ewk_notification_showed(This->m_ewkContext, notiData->getEwkNotiId());
}
-
- LogInfo("notification id : " << notiData->m_id);
- LogInfo("notification iconURL : " << notiData->m_iconURL);
- LogInfo("notification title : " << notiData->m_title);
- LogInfo("notification body : " << notiData->m_body);
-
- showWebNotification(notiData);
- ewk_notification_showed(This->m_ewkContext, ewk_notification_id_get(noti));
}
void ViewLogic::notificationCancelCallback(
- void* /*data*/,
- Evas_Object* /*obj*/,
- void* /*eventInfo*/)
+ void* data,
+ Evas_Object* obj,
+ void* eventInfo)
{
- LogDebug("notificationCancelCallback called");
+ Assert(eventInfo);
+ uint64_t ewkNotiId = *static_cast<uint64_t*>(eventInfo);
+
+ Assert(data);
+ ViewLogic* This = static_cast<ViewLogic*>(data);
+ Ewk_Notification* ewkNotification =
+ static_cast<Ewk_Notification*>(
+ This->m_webNotificationSupport->hide(ewkNotiId));
+ if (ewkNotification) {
+ Assert(obj);
+ Eina_List* list = NULL;
+ list = eina_list_append(list, ewkNotification);
+ ewk_view_notification_closed(obj, list);
+ eina_list_free(list);
+ }
}
void ViewLogic::notificationPermissionRequestCallback(
LogDebug("notificationPermissionRequestCallback called");
Assert(data);
ViewLogic* This = static_cast<ViewLogic*>(data);
- if (This->m_securityOriginSupport->isNeedPermissionCheck(
- SecurityOriginDB::FEATURE_WEB_NOTIFICATION)
- == WrtDB::SETTINGS_TYPE_OFF)
- {
- Ewk_Notification_Permission_Request* request =
- static_cast<Ewk_Notification_Permission_Request*>(eventInfo);
- ewk_notification_permission_request_set(
- request,
- EINA_FALSE);
- return;
- }
Assert(eventInfo);
- ViewModule::WebNotification::webNotificationPermissionRequest(
- This->m_window,
+ ViewModule::WebNotificationPermissionSupport::permissionRequest(
+ This->m_currentEwkView,
This->m_securityOriginSupport->getSecurityOriginDAO(),
eventInfo);
return;
// EWK Orientation Callback
Eina_Bool ViewLogic::orientationLockCallback(
Evas_Object* obj,
- Eina_Bool /*needLock*/,
+ Eina_Bool needLock,
int orientation,
void* data)
{
Assert(data);
ViewLogic* This = static_cast<ViewLogic*>(data);
- if (orientation & EWK_SCREEN_ORIENTATION_PORTRAIT_PRIMARY) {
- LogDebug("orientation is portrait-primary");
- elm_win_rotation_with_resize_set(This->m_window, 0);
- ewk_view_orientation_send(obj, 0);
- } else if (orientation & EWK_SCREEN_ORIENTATION_LANDSCAPE_PRIMARY) {
- LogDebug("orientation is landscape-primary");
- elm_win_rotation_with_resize_set(This->m_window, 270);
- ewk_view_orientation_send(obj, 90);
- } else if (orientation & EWK_SCREEN_ORIENTATION_PORTRAIT_SECONDARY) {
- LogDebug("orientation is portrait-secondary");
- elm_win_rotation_with_resize_set(This->m_window, 180);
- ewk_view_orientation_send(obj, 180);
- } else if (orientation & EWK_SCREEN_ORIENTATION_LANDSCAPE_SECONDARY) {
- LogDebug("orientation is landscape-secondary");
- elm_win_rotation_with_resize_set(This->m_window, 90);
- ewk_view_orientation_send(obj, -90);
+ if (This->m_orientationThresholdTimer) {
+ LogDebug("previous orientationLock isn't finished");
+ // Previous API call isn't finished. Keep angle and run it.
+ if (needLock == EINA_TRUE) {
+ // Screen.lockOrientation
+ This->m_deferredRotateAngle = orientation;
+ } else {
+ // Screen.unlockOrientation
+ This->m_deferredRotateAngle =
+ ViewModule::OrientationSupport::DEFERRED_ORIENTATION_UNLOCK;
+ }
+ return EINA_TRUE;
+ }
+
+ This->m_rotateAngle = orientation;
+
+ if (needLock == EINA_TRUE) {
+ // Screen.lockOrientation
+ int w3cAngle =
+ ViewModule::OrientationSupport::getW3COrientationAngle(orientation);
+ int winAngle =
+ ViewModule::OrientationSupport::getWinOrientationAngle(orientation);
+ ViewModule::OrientationSupport::setEwkOrientation(obj, w3cAngle);
+ if (!This->m_cbs->setOrientation.empty()) {
+ This->m_cbs->setOrientation(winAngle);
+ }
} else {
- LogDebug("Wrong orientation is set");
- return EINA_FALSE;
+ // Screen.unlockOrientation
+ if (This->m_model->SettingList.Get().getRotationValue() ==
+ Screen_AutoRotation)
+ {
+ if (!This->m_cbs->setOrientation.empty()) {
+ This->m_cbs->setOrientation(OrientationAngle::Window::UNLOCK);
+ }
+ This->m_rotateAngle = 0;
+ }
}
return EINA_TRUE;
}
// Fullscreen API callbacks
void ViewLogic::enterFullscreenCallback(
void* data,
- Evas_Object* /*obj*/,
- void* /*eventInfo*/)
+ Evas_Object* obj,
+ void* eventInfo)
{
- LogInfo("enterFullscreenCallback called");
+ LogDebug("enterFullscreenCallback called");
Assert(data);
ViewLogic* This = static_cast<ViewLogic*>(data);
- if (!This->m_cbs->toggleFullscreen.empty()) {
- This->m_cbs->toggleFullscreen(true);
+ ViewLogicMessageSupport::setViewmodes(
+ This->m_ewkContext,
+ "fullscreen");
+
+ if (eventInfo) {
+ This->m_isFullscreenByPlatform =
+ *static_cast<Eina_Bool*>(eventInfo) == EINA_TRUE;
+ }
+ if (!This->m_cbs->enterFullscreen.empty()) {
+ This->m_cbs->enterFullscreen(obj);
}
}
+
void ViewLogic::exitFullscreenCallback(
void* data,
- Evas_Object* /*obj*/,
+ Evas_Object* obj,
void* /*eventInfo*/)
{
- LogInfo("exitFullscreenCallback called");
+ LogDebug("exitFullscreenCallback called");
Assert(data);
ViewLogic* This = static_cast<ViewLogic*>(data);
- if (!This->m_cbs->toggleFullscreen.empty()) {
- This->m_cbs->toggleFullscreen(false);
+ ViewLogicMessageSupport::setViewmodes(
+ This->m_ewkContext,
+ Message::ToInjectedBundle::SET_VIEWMODES_MSGBODY_EXIT);
+
+ This->m_isFullscreenByPlatform = false;
+ if (!This->m_cbs->exitFullscreen.empty()) {
+ This->m_cbs->exitFullscreen(obj);
}
}
using namespace WrtPlugins::W3C;
SoftKeyboardChangeArgs args;
args.state = IME_STATE_OFF;
-
This->fireJavascriptEvent(
static_cast<int>(SoftKeyboardChangeCustomEvent),
&args);
Assert(data);
ViewLogic* This = static_cast<ViewLogic*>(data);
ViewModule::UsermediaSupport::usermediaPermissionRequest(
- This->m_window,
+ This->m_currentEwkView,
This->m_securityOriginSupport->getSecurityOriginDAO(),
eventInfo);
}
const char* result,
void* /*userData*/)
{
- LogInfo("didRunJavaScriptCallback called");
- LogInfo("result = " << result);
+ LogDebug("didRunJavaScriptCallback called");
+ LogDebug("result = " << result);
+}
+
+void ViewLogic::eaKeyCallback(void* data, Evas_Object* obj, void* eventInfo)
+{
+ Assert(data);
+ ViewLogic* This = static_cast<ViewLogic*>(data);
+
+ Ea_Callback_Type keyType =
+ static_cast<Ea_Callback_Type>(reinterpret_cast<intptr_t>(eventInfo));
+
+ LogDebug("Key = [" << keyType << "]");
+
+ std::string keyName;
+ if (keyType == EA_CALLBACK_BACK) {
+ Assert(obj);
+#if 0 // FIXME!!!! ewk_view_text_selection_clear has not landed yet
+ // Call fullscreen exit API
+ // In case of fullscreen is entered by platform(default video tag),
+ // automatically exit fullscreen when backkey is selected
+ if (This->m_isFullscreenByPlatform) {
+ ewk_view_fullscreen_exit(obj);
+ return;
+ }
+
+ // Call text selection clear API
+ // In case of current state is selection mode,
+ // application doesn't need to handle back key
+ if (EINA_TRUE == ewk_view_text_selection_clear(obj)) {
+ return;
+ }
+#endif
+ keyName = KeyName::BACK;
+ } else if (keyType == EA_CALLBACK_MORE) {
+ keyName = KeyName::MENU;
+ } else {
+ return;
+ }
+
+ if (This->m_model->SettingList.Get().getHWkeyEvent() == HWkeyEvent_Enable)
+ {
+ DispatchEventSupport::dispatchHwKeyEvent(obj, keyName);
+ }
+ This->m_cbs->hwkey(keyName);
+
+ return;
}
Eina_Bool ViewLogic::windowCloseIdlerCallback(void* data)
return ECORE_CALLBACK_CANCEL;
}
+Eina_Bool ViewLogic::exceededDatabaseQuotaCallback(Evas_Object* obj,
+ Ewk_Security_Origin* origin,
+ const char* ,
+ unsigned long long ,
+ void* data)
+{
+ LogDebug("exceededDatabaseQuotaCallback called");
+ Assert(data);
+ ViewLogic* This = static_cast<ViewLogic*>(data);
+ Assert(obj);
+
+ if (This->m_model->WebStorageUsage.Get() == WrtDB::SETTINGS_TYPE_OFF) {
+ ewk_view_exceeded_database_quota_reply(obj, EINA_FALSE);
+ return EINA_TRUE;
+ }
+
+ ViewModule::WebStorageSupport::createPermissionRequest(
+ This->m_currentEwkView,
+ This->m_securityOriginSupport->getSecurityOriginDAO(),
+ obj,
+ origin,
+ ewk_view_exceeded_database_quota_reply);
+ return EINA_TRUE;
+}
+
+Eina_Bool ViewLogic::exceededIndexedDatabaseQuotaCallback(Evas_Object* obj,
+ Ewk_Security_Origin* origin,
+ long long ,
+ void* data)
+{
+ LogDebug("exceededIndexedDatabaseQuotaCallback called");
+ Assert(data);
+ ViewLogic* This = static_cast<ViewLogic*>(data);
+ Assert(obj);
+
+ if (This->m_model->WebStorageUsage.Get() == WrtDB::SETTINGS_TYPE_OFF) {
+ ewk_view_exceeded_indexed_database_quota_reply(obj, EINA_FALSE);
+ return EINA_TRUE;
+ }
+
+ ViewModule::WebStorageSupport::createPermissionRequest(
+ This->m_currentEwkView,
+ This->m_securityOriginSupport->getSecurityOriginDAO(),
+ obj,
+ origin,
+ ewk_view_exceeded_indexed_database_quota_reply);
+ return EINA_TRUE;
+}
+
+Eina_Bool ViewLogic::exceededLocalFileSystemQuotaCallback(Evas_Object* obj,
+ Ewk_Security_Origin* origin,
+ long long ,
+ void* data)
+{
+ LogDebug("exceededLocalFileSystemQuotaCallback called");
+ Assert(data);
+ ViewLogic* This = static_cast<ViewLogic*>(data);
+ Assert(obj);
+
+
+ if (This->m_model->WebStorageUsage.Get() == WrtDB::SETTINGS_TYPE_OFF) {
+ ewk_view_exceeded_local_file_system_quota_reply(obj, EINA_FALSE);
+ return EINA_TRUE;
+ }
+
+ ViewModule::WebStorageSupport::createPermissionRequest(
+ This->m_currentEwkView,
+ This->m_securityOriginSupport->getSecurityOriginDAO(),
+ obj,
+ origin,
+ ewk_view_exceeded_local_file_system_quota_reply);
+ return EINA_TRUE;
+}
+
void ViewLogic::certificateConfirmRequestCallback(
void* data,
Evas_Object* /*obj*/,
ViewLogic* This = static_cast<ViewLogic*>(data);
Assert(eventInfo);
ViewModule::CertificateConfirmSupport::certificatePermissionRequest(
- This->m_window,
+ This->m_currentEwkView,
This->m_certificateSupport->getCertificateDAO(),
eventInfo);
}
void* eventInfo)
{
LogDebug("authenticationChallengeRequestCallback called");
-
Assert(data);
+ Assert(eventInfo);
+
ViewLogic* This = static_cast<ViewLogic*>(data);
const char* url = ewk_view_url_get(This->m_currentEwkView);
if (!url || strlen(url) == 0) {
- url = This->m_currentUri.c_str();
+ Ewk_Auth_Challenge* authChallenge = static_cast<Ewk_Auth_Challenge*>(eventInfo);
+ ewk_auth_challenge_credential_cancel(authChallenge);
+ return;
}
- Assert(eventInfo);
ViewModule::AuthenticationChallengeSupport::authenticationChallengeRequest(
This->m_currentEwkView,
url,
eventInfo);
}
-std::string ViewLogic::requestUrlBlocked(const std::string& blockedUrl)
+void ViewLogic::viewFrameRenderedCallback(
+ void* /*data*/,
+ Evas_Object* /*obj*/,
+ void* /*eventInfo*/)
{
- LogInfo("enter");
+ static bool logEnable = (getenv("WRT_FRAME_RENDERED_LOG_ENABLE") != NULL);
- if (m_model->Type.Get().appType == WrtDB::APP_TYPE_TIZENWEBAPP) {
- // block this page and open it in browser
- LogDebug("Request was blocked by WARP: " << blockedUrl);
- LogDebug("open browser : " << blockedUrl);
- bundle* bundleData = bundle_create();
- appsvc_set_operation(bundleData, APPSVC_OPERATION_VIEW);
- appsvc_set_uri(bundleData, blockedUrl.c_str());
- CONTROLLER_POST_EVENT(
- ApplicationLauncher,
- ApplicationLauncherEvents::LaunchApplicationByAppService(
- bundleData,
- NULL,
- NULL));
+ if (logEnable)
+ {
+ LogDebug("enter");
}
+}
- // set block url. This is used on load finished callback
- m_blockedUri = blockedUrl;
+void ViewLogic::mediacontrolRotateHorizontal(void* data,
+ Evas_Object* obj,
+ void* /*eventInfo*/)
+{
+ LogDebug("mediacontrolRotateHorizontal called");
+ Assert(data);
+ Assert(obj);
+ ViewLogic* This = static_cast<ViewLogic*>(data);
+ ViewModule::OrientationSupport::setEwkOrientation(
+ obj,
+ OrientationAngle::W3C::Landscape::PRIMARY);
+ if (!This->m_cbs->setOrientation.empty()) {
+ This->m_cbs->setOrientation(
+ OrientationAngle::Window::Landscape::PRIMARY);
+ }
+}
- // This is used in case of returning previous page
- return URICHANGE_PLUGIN_NO_CHANGE;
+void ViewLogic::mediacontrolRotateVertical(void* data,
+ Evas_Object* obj,
+ void* /*eventInfo*/)
+{
+ LogDebug("mediacontrolRotateVertical called");
+ Assert(data);
+ Assert(obj);
+ ViewLogic* This = static_cast<ViewLogic*>(data);
+ ViewModule::OrientationSupport::setEwkOrientation(
+ obj,
+ OrientationAngle::W3C::Portrait::PRIMARY);
+ if (!This->m_cbs->setOrientation.empty()) {
+ This->m_cbs->setOrientation(
+ OrientationAngle::Window::Portrait::PRIMARY);
+ }
}
-std::string ViewLogic::requestUrlChanged(const std::string& changedUrl)
+void ViewLogic::mediacontrolRotateExit(void* data,
+ Evas_Object* obj,
+ void* /*eventInfo*/)
{
- using namespace ViewModule::SecuritySupport;
+ LogDebug("mediacontrolRotateExit called");
+ Assert(data);
+ Assert(obj);
+ ViewLogic* This = static_cast<ViewLogic*>(data);
+
+ int w3cAngle = 0;
+ int winAngle = 0;
+ if (This->m_rotateAngle == 0) {
+ // application hasn't call orientation lock
+ WidgetSettingScreenLock screenLock =
+ This->m_model->SettingList.Get().getRotationValue();
+ if (screenLock == Screen_Portrait) {
+ w3cAngle = OrientationAngle::W3C::Portrait::PRIMARY;
+ winAngle = OrientationAngle::Window::Portrait::PRIMARY;
+ } else if (screenLock == Screen_Landscape) {
+ w3cAngle = OrientationAngle::W3C::Landscape::PRIMARY;
+ winAngle = OrientationAngle::Window::Landscape::PRIMARY;
+ } else if (screenLock == Screen_AutoRotation) {
+ if (!This->m_cbs->setOrientation.empty()) {
+ This->m_cbs->setOrientation(OrientationAngle::Window::UNLOCK);
+ }
+ return;
+ }
+ } else {
+ // Restore previous orientation
+ w3cAngle =
+ ViewModule::OrientationSupport::getW3COrientationAngle(
+ This->m_rotateAngle);
+ winAngle =
+ ViewModule::OrientationSupport::getWinOrientationAngle(
+ This->m_rotateAngle);
+ }
+
+ ViewModule::OrientationSupport::setEwkOrientation(obj, w3cAngle);
+ if (!This->m_cbs->setOrientation.empty()) {
+ This->m_cbs->setOrientation(winAngle);
+ }
+
+}
- LogInfo("changed url: " << changedUrl);
+Eina_Bool ViewLogic::orientationThresholdTimerCallback(void* data)
+{
+ LogDebug("orientationThresholdTimerCallback");
+ ViewLogic* This = static_cast<ViewLogic*>(data);
- // Check if this url with 'http' or 'https' is included in whitelist,
- // which has lists of accessible external documents and
- // used for ONLY Tizen app
- std::string matchedScheme;
- std::string matchedUri;
- pcrecpp::RE(PATTERN_URI_CHANGE).PartialMatch(changedUrl.c_str(),
- &matchedUri,
- &matchedScheme);
- ViewModule::Scheme scheme(matchedScheme);
- if (scheme.GetType() == ViewModule::Scheme::HTTP ||
- scheme.GetType() == ViewModule::Scheme::HTTPS)
+ if (This->m_deferredRotateAngle ==
+ ViewModule::OrientationSupport::DEFERRED_ORIENTATION_EMPTY)
{
- if (m_model->Type.Get().appType == WrtDB::APP_TYPE_TIZENWEBAPP) {
- if (!checkWhitelist(changedUrl.c_str())) {
- LogInfo("This uri is not included in white document list");
- return URICHANGE_PLUGIN_STOP_ONLY;
+ // There is no defered orientation API call
+ This->m_orientationThresholdTimer = NULL;
+ return ECORE_CALLBACK_CANCEL;
+ }
+
+ if (This->m_deferredRotateAngle != This->m_rotateAngle) {
+ This->m_rotateAngle = This->m_deferredRotateAngle;
+ int w3cAngle = 0;
+ int winAngle = 0;
+ if (This->m_rotateAngle == 0) {
+ WidgetSettingScreenLock screenLock =
+ This->m_model->SettingList.Get().getRotationValue();
+ if (screenLock == Screen_Portrait) {
+ w3cAngle = OrientationAngle::W3C::Portrait::PRIMARY;
+ winAngle = OrientationAngle::Window::Portrait::PRIMARY;
+ } else if (screenLock == Screen_Landscape) {
+ w3cAngle = OrientationAngle::W3C::Landscape::PRIMARY;
+ winAngle = OrientationAngle::Window::Landscape::PRIMARY;
+ } else if (screenLock == Screen_AutoRotation) {
+ if (!This->m_cbs->setOrientation.empty()) {
+ This->m_cbs->setOrientation(OrientationAngle::Window::UNLOCK);
+ }
+ This->m_orientationThresholdTimer = NULL;
+ return ECORE_CALLBACK_CANCEL;
}
- LogInfo("This url is included in WhiteList");
} else {
- // For WAC app, WRT should block access of device api
- // for external documents
- return URICHANGE_PLUGIN_STOP_ONLY;
+ // Restore previous orientation
+ w3cAngle =
+ ViewModule::OrientationSupport::getW3COrientationAngle(
+ This->m_rotateAngle);
+ winAngle =
+ ViewModule::OrientationSupport::getWinOrientationAngle(
+ This->m_rotateAngle);
+ }
+
+ ViewModule::OrientationSupport::setEwkOrientation(
+ This->m_currentEwkView,
+ w3cAngle);
+ if (!This->m_cbs->setOrientation.empty()) {
+ This->m_cbs->setOrientation(winAngle);
}
+ This->m_deferredRotateAngle =
+ ViewModule::OrientationSupport::DEFERRED_ORIENTATION_EMPTY;
+ return ECORE_CALLBACK_RENEW;
}
- m_currentUri = changedUrl;
- return URICHANGE_PLUGIN_RESTART;
+ This->m_orientationThresholdTimer = NULL;
+ return ECORE_CALLBACK_CANCEL;
+}
+
+void ViewLogic::popupReplyWaitStart(void* data,
+ Evas_Object* /*obj*/,
+ void* /*eventInfo*/)
+{
+ LogDebug("called");
+ Assert(data);
+ ViewLogic* This = static_cast<ViewLogic*>(data);
+ This->m_isPopupReplyWait = true;
+}
+
+void ViewLogic::popupReplyWaitFinish(void* data,
+ Evas_Object* /*obj*/,
+ void* /*eventInfo*/)
+{
+ LogDebug("called");
+ Assert(data);
+ ViewLogic* This = static_cast<ViewLogic*>(data);
+ This->m_isPopupReplyWait = false;
+}
+
+void ViewLogic::requestUrlBlocked(const std::string& blockedUrl)
+{
+ LogDebug("enter");
+
+ // block this page and open it in browser
+ LogDebug("Request was blocked : " << blockedUrl);
+ service_h serviceHandle = NULL;
+ service_create(&serviceHandle);
+ service_set_operation(serviceHandle, SERVICE_OPERATION_VIEW);
+ service_set_uri(serviceHandle, blockedUrl.c_str());
+ CONTROLLER_POST_EVENT(
+ ApplicationLauncher,
+ ApplicationLauncherEvents::LaunchApplicationByAppService(
+ serviceHandle,
+ NULL,
+ NULL));
+ // set block url. This is used on load finished callback
+ m_blockedUri = blockedUrl;
}
void ViewLogic::windowClose()
// get latest ewkView
m_currentEwkView = m_ewkViewList.back();
- const char* uri = ewk_view_url_get(m_currentEwkView);
- if (NULL == uri || 0 == strlen(uri)) {
- m_currentUri.clear();
- } else {
- m_currentUri = uri;
- }
- // resume ewkView
- /* In case we support many pages in parallel
- * then view is not suspended*/
- //resumeEwkView(m_currentEwkView);
setEwkViewVisible(m_currentEwkView);
// show ewkView
}
}
+void ViewLogic::systemSettingsChangedCallback(system_settings_key_e key,
+ void* data)
+{
+ LogDebug("systemSettingsChanged");
+ LogDebug("System setting Key is [" << key << "]");
+
+ Assert(data);
+ ViewLogic* This = static_cast<ViewLogic*>(data);
+
+ if (SYSTEM_SETTINGS_KEY_FONT_TYPE == key) {
+ if (!This->m_currentEwkView) {
+ LogError("ewkView isn't initialized");
+ return;
+ }
+ ewk_view_use_settings_font(This->m_currentEwkView);
+ } else {
+ LogError("Unregister system callback is called");
+ }
+}
+