diff options
author | Dariusz Frankiewicz <d.frankiewic@samsung.com> | 2016-03-02 10:52:23 +0100 |
---|---|---|
committer | Dariusz Frankiewicz <d.frankiewic@samsung.com> | 2016-03-03 00:20:46 -0800 |
commit | 1e27d7f762f71383e4b1868c8b685a81af7c5d84 (patch) | |
tree | 8c469ae686a698bce87ce69300a0491309934776 | |
parent | 1f2dc6404ddc0851963f36f9e42f50b4a51a7b33 (diff) | |
download | browser-1e27d7f762f71383e4b1868c8b685a81af7c5d84.tar.gz browser-1e27d7f762f71383e4b1868c8b685a81af7c5d84.tar.bz2 browser-1e27d7f762f71383e4b1868c8b685a81af7c5d84.zip |
Launching anotner apps from app_control.
[Issue] http://10.113.136.204/jira/browse/TWF-355?filter=12460
[Problem] There is no possibility to launch email or telephone app from
url inside web page.
[Cause] Lack of implementation.
[Solution] Implement missing functionality.
[Verify] Check on web pages if urls with (mailto:, tel:, sms:) open
proper applications.
Change-Id: I4e8298d3a04dc32522c40df504d8d5ce44a756c6
-rwxr-xr-x | manifest.xml.in | 1 | ||||
-rw-r--r-- | services/WebEngineService/URIschemes.h | 39 | ||||
-rwxr-xr-x | services/WebEngineService/WebView.cpp | 194 | ||||
-rw-r--r-- | services/WebEngineService/WebView.h | 7 |
4 files changed, 241 insertions, 0 deletions
diff --git a/manifest.xml.in b/manifest.xml.in index 9e2f40cf..04653fc9 100755 --- a/manifest.xml.in +++ b/manifest.xml.in @@ -76,5 +76,6 @@ <privilege>http://tizen.org/privilege/web-history.admin</privilege> <privilege>http://tizen.org/privilege/haptic</privilege> <privilege>http://tizen.org/privilege/camera</privilege> + <privilege>http://tizen.org/privilege/call</privilege> </privileges> </manifest> diff --git a/services/WebEngineService/URIschemes.h b/services/WebEngineService/URIschemes.h new file mode 100644 index 00000000..b847701e --- /dev/null +++ b/services/WebEngineService/URIschemes.h @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2016 Samsung Electronics Co., Ltd. + * + * 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. + */ + +#ifndef URISCHEMES_H +#define URISCHEMES_H + +namespace tizen_browser { + +const char* HTTP_SCHEME = "http://"; +const char* HTTPS_SCHEME = "https://"; +const char* FILE_SCHEME = "file://"; +const char* FTP_SCHEME = "ftp://"; +const char* TIZENSTORE_SCHEME = "tizenstore://"; +const char* MAILTO_SCHEME = "mailto:"; +const char* TEL_SCHEME = "tel:"; +const char* TELTO_SCHEME = "telto:"; +const char* CALLTO_SCHEME = "callto:"; +const char* SMS_SCHEME = "sms:"; +const char* SMSTO_SCHEME = "smsto:"; + +const char* TIZENSTORE_APP_ID = "org.tizen.tizenstore"; //Tizen store package ID + +} /* end of tizen_browser */ + +#endif // URISCHEMES_H + diff --git a/services/WebEngineService/WebView.cpp b/services/WebEngineService/WebView.cpp index b94e0f10..ac3c6a48 100755 --- a/services/WebEngineService/WebView.cpp +++ b/services/WebEngineService/WebView.cpp @@ -33,6 +33,7 @@ #include <Elementary.h> #include <Evas.h> +#include "URIschemes.h" #include "app_i18n.h" #include "AbstractWebEngine/AbstractWebEngine.h" #include "app_common.h" @@ -224,6 +225,7 @@ void WebView::registerCallbacks() evas_object_smart_callback_add(m_ewkView, "close,window", __closeWindowRequest, this); #if PROFILE_MOBILE evas_object_smart_callback_add(m_ewkView, "policy,response,decide", __policy_response_decide_cb, this); + evas_object_smart_callback_add(m_ewkView, "policy,navigation,decide", __policy_navigation_decide_cb, this); #endif evas_object_smart_callback_add(m_ewkView, "geolocation,permission,request", __geolocationPermissionRequest, this); evas_object_smart_callback_add(m_ewkView, "usermedia,permission,request", __usermediaPermissionRequest, this); @@ -263,6 +265,7 @@ void WebView::unregisterCallbacks() evas_object_smart_callback_del_full(m_ewkView, "close,window", __closeWindowRequest, this); #if PROFILE_MOBILE evas_object_smart_callback_del_full(m_ewkView, "policy,response,decide", __policy_response_decide_cb, this); + evas_object_smart_callback_del_full(m_ewkView, "policy,navigation,decide", __policy_navigation_decide_cb, this); #endif evas_object_smart_callback_del_full(m_ewkView, "geolocation,permission,request", __geolocationPermissionRequest, this); evas_object_smart_callback_del_full(m_ewkView, "usermedia,permission,request", __usermediaPermissionRequest, this); @@ -290,6 +293,176 @@ void WebView::setupEwkSettings() ewk_settings_uses_keypad_without_user_action_set(settings, EINA_FALSE); } +Eina_Bool WebView::handle_scheme(const char *uri) +{ + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + + if (!strncmp(uri, HTTP_SCHEME, strlen(HTTP_SCHEME))) + return EINA_FALSE; + else if (!strncmp(uri, HTTPS_SCHEME, strlen(HTTPS_SCHEME))) + return EINA_FALSE; + else if (!strncmp(uri, FILE_SCHEME, strlen(FILE_SCHEME))) + return EINA_FALSE; + else if (!strncmp(uri, TIZENSTORE_SCHEME, strlen(TIZENSTORE_SCHEME))) { + launch_tizenstore(uri); + return EINA_TRUE; + } + else if (!strncmp(uri, MAILTO_SCHEME, strlen(MAILTO_SCHEME))) { + launch_email(uri); + return EINA_TRUE; + } + else if (!strncmp(uri, TEL_SCHEME, strlen(TEL_SCHEME))) { + launch_dialer(uri); + return EINA_TRUE; + } + else if (!strncmp(uri, TELTO_SCHEME, strlen(TELTO_SCHEME))) { + std::string request_uri = std::string(TEL_SCHEME) + std::string(uri + strlen(TELTO_SCHEME)); + launch_dialer(request_uri.c_str()); + return EINA_TRUE; + } + else if (!strncmp(uri, CALLTO_SCHEME, strlen(CALLTO_SCHEME))) { + std::string request_uri = std::string(TEL_SCHEME) + std::string(uri + strlen(CALLTO_SCHEME)); + launch_dialer(request_uri.c_str()); + return EINA_TRUE; + } + else if (!strncmp(uri, SMS_SCHEME, strlen(SMS_SCHEME))) { + launch_message(uri); + return EINA_TRUE; + } + else if (!strncmp(uri, SMSTO_SCHEME, strlen(SMSTO_SCHEME))) { + std::string request_uri = std::string(SMS_SCHEME) + std::string(uri + strlen(SMSTO_SCHEME)); + launch_message(request_uri.c_str()); + return EINA_TRUE; + } + + return EINA_FALSE; +} + +Eina_Bool WebView::launch_email(const char *uri) +{ + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + + app_control_h app_control = NULL; + if (app_control_create(&app_control) < 0) { + BROWSER_LOGE("[%s:%d] Fail to app_control_create", __PRETTY_FUNCTION__, __LINE__); + return EINA_FALSE; + } + if (app_control_set_operation(app_control, APP_CONTROL_OPERATION_COMPOSE) < 0) { + BROWSER_LOGE("Fail to app_control_set_operation"); + app_control_destroy(app_control); + return EINA_FALSE; + } + if (app_control_set_uri(app_control, uri) < 0) { + BROWSER_LOGE("Fail to app_control_set_uri"); + app_control_destroy(app_control); + return EINA_FALSE; + } + if (app_control_send_launch_request(app_control, NULL, NULL) < 0) { + BROWSER_LOGE("Fail to app_control_send_launch_request"); + app_control_destroy(app_control); + return EINA_FALSE; + } + app_control_destroy(app_control); + + return EINA_TRUE; +} + +Eina_Bool WebView::launch_dialer(const char *uri) +{ + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + + app_control_h app_control = NULL; + if (app_control_create(&app_control) < 0) { + BROWSER_LOGE("Fail to create app_control handle"); + return EINA_FALSE; + } + if (app_control_set_operation(app_control, APP_CONTROL_OPERATION_DIAL) < 0) { + BROWSER_LOGE("Fail to app_control_set_operation"); + app_control_destroy(app_control); + return EINA_FALSE; + } + if (app_control_set_uri(app_control, uri) < 0) { + BROWSER_LOGE("app_control_add_extra_data is failed."); + app_control_destroy(app_control); + return EINA_FALSE; + } + if (app_control_send_launch_request(app_control, NULL, NULL) < 0) { + BROWSER_LOGE("Fail to launch app_control operation"); + app_control_destroy(app_control); + return EINA_FALSE; + } + app_control_destroy(app_control); + + return EINA_TRUE; +} + +Eina_Bool WebView::launch_message(const char *uri) +{ + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + + app_control_h app_control = NULL; + if (app_control_create(&app_control) < 0) { + BROWSER_LOGE("Fail to create app_control handle"); + return EINA_FALSE; + } + if (app_control_set_operation(app_control, APP_CONTROL_OPERATION_COMPOSE) < 0) { + BROWSER_LOGE("Fail to set app_control operation"); + app_control_destroy(app_control); + return EINA_FALSE; + } + if (app_control_set_uri(app_control, uri) < 0) { + BROWSER_LOGE("Fail to set extra data"); + app_control_destroy(app_control); + return EINA_FALSE; + } + if (app_control_send_launch_request(app_control, NULL, NULL) < 0) { + BROWSER_LOGE("Fail to launch app_control operation"); + app_control_destroy(app_control); + return EINA_FALSE; + } + app_control_destroy(app_control); + + return EINA_TRUE; +} + +Eina_Bool WebView::launch_tizenstore(const char *uri) +{ + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + + app_control_h app_control = NULL; + if (app_control_create(&app_control) < 0) { + BROWSER_LOGE("Fail to create app_control handle"); + return EINA_FALSE; + } + if (!app_control) { + BROWSER_LOGE("Fail to create app_control handle"); + return EINA_FALSE; + } + if (app_control_set_operation(app_control, APP_CONTROL_OPERATION_VIEW) < 0) { + BROWSER_LOGE("Fail to set app_control operation"); + app_control_destroy(app_control); + return EINA_FALSE; + } + if (app_control_set_uri(app_control, uri) < 0) { + BROWSER_LOGE("Fail to set uri operation"); + app_control_destroy(app_control); + return EINA_FALSE; + } + if (app_control_set_app_id(app_control, TIZENSTORE_APP_ID) < 0) { + BROWSER_LOGE("Fail to app_control_set_app_id"); + app_control_destroy(app_control); + return EINA_FALSE; + } + if (app_control_send_launch_request(app_control, NULL, NULL) < 0) { + BROWSER_LOGE("Fail to launch app_control operation"); + app_control_destroy(app_control); + return EINA_FALSE; + } + app_control_destroy(app_control); + + return EINA_TRUE; +} + Evas_Object * WebView::getLayout() { return m_ewkView; @@ -1420,6 +1593,27 @@ void WebView::__policy_response_decide_cb(void *data, Evas_Object * /* obj */, v } } +void WebView::__policy_navigation_decide_cb(void *data, Evas_Object * /*obj*/, void *event_info) +{ + BROWSER_LOGD("[%s:%d]", __PRETTY_FUNCTION__, __LINE__); + WebView *wv = (WebView *)data; + + Ewk_Policy_Decision *policy_decision = (Ewk_Policy_Decision *)event_info; + const char *uri = ewk_policy_decision_url_get(policy_decision); + BROWSER_LOGD("uri = [%s]", uri); + + Eina_Bool is_scheme_handled = wv->handle_scheme(uri); + + if (is_scheme_handled) { + BROWSER_LOGD("Scheme handled"); + ewk_policy_decision_ignore(policy_decision); + if (!wv->isBackEnabled()) + wv = NULL; + return; + } + ewk_policy_decision_use(policy_decision); +} + void WebView::__download_request_cb(const char *download_uri, void *data) { BROWSER_LOGD("[%s:%d] download_uri= [%s]", __PRETTY_FUNCTION__, __LINE__, download_uri); diff --git a/services/WebEngineService/WebView.h b/services/WebEngineService/WebView.h index c18a65e0..81a00a47 100644 --- a/services/WebEngineService/WebView.h +++ b/services/WebEngineService/WebView.h @@ -285,6 +285,12 @@ private: void unregisterCallbacks(); void setupEwkSettings(); + Eina_Bool handle_scheme(const char *uri); + Eina_Bool launch_email(const char *uri); + Eina_Bool launch_dialer(const char *uri); + Eina_Bool launch_message(const char *uri); + Eina_Bool launch_tizenstore(const char *uri); + static std::string securityOriginToUri(const Ewk_Security_Origin *); static void __setFocusToEwkView(void * data, Evas * e, Evas_Object * obj, void * event_info); static void __newWindowRequest(void * data, Evas_Object *, void *out); @@ -339,6 +345,7 @@ private: #if PROFILE_MOBILE // downloads static void __policy_response_decide_cb(void *data, Evas_Object *obj, void *event_info); + static void __policy_navigation_decide_cb(void *data, Evas_Object *obj, void *event_info); static void __download_request_cb(const char *download_uri, void *data); #endif |