diff options
author | Hyerim Bae <hyerim.bae@samsung.com> | 2012-08-31 15:46:10 +0900 |
---|---|---|
committer | Junghwan <junghwan.kang@samsung.com> | 2012-08-31 16:47:40 +0900 |
commit | c1f41e62df4e4881c8dee7b290008fa3320eafd2 (patch) | |
tree | 11da59c4b54bd5c224af949d777f84cf03fb9af9 | |
parent | 3195867dcfa14665c9288899f5b4211d6547a3bf (diff) | |
download | org.tizen.browser-c1f41e62df4e4881c8dee7b290008fa3320eafd2.tar.gz org.tizen.browser-c1f41e62df4e4881c8dee7b290008fa3320eafd2.tar.bz2 org.tizen.browser-c1f41e62df4e4881c8dee7b290008fa3320eafd2.zip |
[Title] Fix build error.
[Issue#] N/A
[Problem] Build error.
[Cause] The policy client code is too old.
[Solution] Sync with the master branch.
[Team] Browser UI
[Developer] hyerim.bae
[Request] N/A
Change-Id: I8d030674e44a540e0bc0cddb75d1e4b24c629a10
-rw-r--r--[-rwxr-xr-x] | src/browser-class.cpp | 2 | ||||
-rw-r--r--[-rwxr-xr-x] | src/browser-policy-client/browser-policy-decision-maker.cpp | 224 | ||||
-rw-r--r--[-rwxr-xr-x] | src/browser-policy-client/browser-policy-decision-maker.h | 22 | ||||
-rwxr-xr-x | src/browser-utility.cpp | 25 | ||||
-rwxr-xr-x | src/browser-utility.h | 9 | ||||
-rwxr-xr-x | src/include/browser-config.h | 25 |
6 files changed, 116 insertions, 191 deletions
diff --git a/src/browser-class.cpp b/src/browser-class.cpp index 2091ab3..c05ddac 100755..100644 --- a/src/browser-class.cpp +++ b/src/browser-class.cpp @@ -435,7 +435,7 @@ void Browser_Class::ewk_view_init(Evas_Object *ewk_view) evas_object_smart_callback_add(ewk_view, "request,geolocation,permission", Browser_Geolocation::__geolocation_permission_request_cb, m_browser_view); - m_download_policy->init(ewk_view_WKPage_get(ewk_view)); + m_download_policy->init(ewk_view); m_browser_view->m_context_menu->init(ewk_view); #ifdef USE_META_TAG m_browser_view->m_meta_tag->init(ewk_view); diff --git a/src/browser-policy-client/browser-policy-decision-maker.cpp b/src/browser-policy-client/browser-policy-decision-maker.cpp index 42c2e5e..9f764bf 100755..100644 --- a/src/browser-policy-client/browser-policy-decision-maker.cpp +++ b/src/browser-policy-client/browser-policy-decision-maker.cpp @@ -22,13 +22,15 @@ #include "browser-common-view.h" #include "browser-policy-decision-maker.h" +#include "ewk_policy_decision.h" Browser_Policy_Decision_Maker::Browser_Policy_Decision_Maker(Evas_Object *navi_bar, Browser_View *browser_view) : - m_wk_page_ref(NULL) + m_ewk_view(NULL) ,m_list_popup(NULL) ,m_app_list(NULL) ,m_navi_bar(navi_bar) ,m_browser_view(browser_view) + ,m_found_matched_app(EINA_FALSE) { BROWSER_LOGD("[%s]", __func__); @@ -49,31 +51,24 @@ Browser_Policy_Decision_Maker::~Browser_Policy_Decision_Maker(void) } } -void Browser_Policy_Decision_Maker::init(WKPageRef page_ref) +void Browser_Policy_Decision_Maker::init(Evas_Object *ewk_view) { BROWSER_LOGD("[%s]", __func__); - m_wk_page_ref = page_ref; + deinit(); + m_ewk_view = ewk_view; - WKPagePolicyClient policy_client = { - kWKPagePolicyClientCurrentVersion, /* version */ - this, /* clientInfo */ - __decide_policy_for_navigation_action, /* decidePolicyForNavigationAction */ - 0, /* decidePolicyForNewWindowAction; */ - __decide_policy_for_response_cb, /* decidePolicyForResponse */ - 0, /* unableToImplementPolicy */ - }; - - WKPageSetPagePolicyClient(m_wk_page_ref, &policy_client); + evas_object_smart_callback_add(m_ewk_view, "policy,navigation,decide", __decide_policy_for_navigation_action, this); + evas_object_smart_callback_add(m_ewk_view, "policy,response,decide", __decide_policy_for_response_cb, this); } void Browser_Policy_Decision_Maker::deinit(void) { BROWSER_LOGD("[%s]", __func__); - if (m_wk_page_ref) { - WKPagePolicyClient policy_client = {0, }; - WKPageSetPagePolicyClient(m_wk_page_ref, &policy_client); + if (m_ewk_view) { + evas_object_smart_callback_del(m_ewk_view, "policy,navigation,decide", __decide_policy_for_navigation_action); + evas_object_smart_callback_del(m_ewk_view, "policy,response,decide", __decide_policy_for_response_cb); } } @@ -203,139 +198,85 @@ Eina_Bool Browser_Policy_Decision_Maker::_handle_exscheme(void) return EINA_FALSE; } -void Browser_Policy_Decision_Maker::__decide_policy_for_navigation_action( - WKPageRef page, WKFrameRef frame, WKFrameNavigationType navigationType, - WKEventModifiers modifiers, WKEventMouseButton mouseButton, - WKURLRequestRef request, WKFramePolicyListenerRef listener, - WKTypeRef userData, const void* client_info) +void Browser_Policy_Decision_Maker::__decide_policy_for_navigation_action(void *data, Evas_Object *obj, void *event_info) { - if (!client_info) + if (!data) return; BROWSER_LOGD("%s", __func__); - Browser_Policy_Decision_Maker *decision_maker = (Browser_Policy_Decision_Maker *)client_info; + Browser_Policy_Decision_Maker *decision_maker = (Browser_Policy_Decision_Maker *)data; + Ewk_Policy_Decision *policy_decision = (Ewk_Policy_Decision *)event_info; - WKURLRef url_ref = WKURLRequestCopyURL(request); - WKStringRef url_string_ref = WKURLCopyString(url_ref); - decision_maker->m_url = decision_maker->_convert_WKStringRef_to_string(url_string_ref); - WKRelease(url_string_ref); - WKRelease(url_ref); + const char *url = ewk_policy_decision_url_get(policy_decision); + BROWSER_LOGD("<<< url = [%s]", url); + if (url && strlen(url)) + decision_maker->m_url = std::string(url); decision_maker->m_cookies.clear(); if (decision_maker->_handle_exscheme()) - WKFramePolicyListenerIgnore(listener); + ewk_policy_decision_ignore(policy_decision); else - WKFramePolicyListenerUse(listener); + ewk_policy_decision_use(policy_decision); } -void Browser_Policy_Decision_Maker::__decide_policy_for_response_cb( - WKPageRef page, WKFrameRef frame, - WKURLResponseRef response, WKURLRequestRef request, - WKFramePolicyListenerRef listener, WKTypeRef user_data, - const void *client_info) +void Browser_Policy_Decision_Maker::__decide_policy_for_response_cb(void *data, Evas_Object *obj, void *event_info) { - if (!client_info) + if (!data) return; - Browser_Policy_Decision_Maker *decision_maker = (Browser_Policy_Decision_Maker *)client_info; + Browser_Policy_Decision_Maker *decision_maker = (Browser_Policy_Decision_Maker *)data; + Ewk_Policy_Decision *policy_decision = (Ewk_Policy_Decision *)event_info; - WKStringRef content_type_ref = WKURLResponseEflCopyContentType(response); - string content_type = decision_maker->_convert_WKStringRef_to_string(content_type_ref); - int policy_type = decision_maker->_decide_policy_type(frame, content_type_ref, content_type); - WKRelease(content_type_ref); + Ewk_Policy_Decision_Type policy_type = ewk_policy_decision_type_get(policy_decision); switch (policy_type) { - case policy_use: + case EWK_POLICY_DECISION_USE: BROWSER_LOGD("policy_use"); - WKFramePolicyListenerUse(listener); + ewk_policy_decision_use(policy_decision); break; - case policy_download: + case EWK_POLICY_DECISION_DOWNLOAD: BROWSER_LOGD("policy_download"); - decision_maker->_request_download(request, response, content_type); - WKFramePolicyListenerIgnore(listener); + ewk_policy_decision_suspend(policy_decision); + decision_maker->_request_download(policy_decision); + ewk_policy_decision_ignore(policy_decision); break; - case policy_ignore: + case EWK_POLICY_DECISION_IGNORE: default: BROWSER_LOGD("policy_ignore"); - WKFramePolicyListenerIgnore(listener); + ewk_policy_decision_ignore(policy_decision); break; } } -/* Warning : MUST free() returned char* */ -char *Browser_Policy_Decision_Maker::_convert_WKStringRef_to_cstring(WKStringRef string_ref) -{ - if (!string_ref) - return NULL; - - size_t length = WKStringGetMaximumUTF8CStringSize(string_ref); - if (length <= 1) /* returned length is 1 if string_ref is blank. */ - return NULL; - - char *cstring = (char *)calloc(length, sizeof(char)); - if (!cstring) { - BROWSER_LOGE("calloc failed!"); - return NULL; - } - - WKStringGetUTF8CString(string_ref, cstring, length); - return cstring; -} - -string Browser_Policy_Decision_Maker::_convert_WKStringRef_to_string(WKStringRef string_ref) -{ - char *cstring = _convert_WKStringRef_to_cstring(string_ref); - if (!cstring) - return string(); - - string str(cstring); - free(cstring); - return str; -} - -int Browser_Policy_Decision_Maker::_decide_policy_type(WKFrameRef frame, WKStringRef content_type_ref, string &content_type) -{ - /* ToDo making a decision for SLP browser's policy system first */ - if (content_type.empty()) - return policy_download; - - if (WKFrameCanShowMIMEType(frame, content_type_ref)) - return policy_use; - - return policy_download; -} - -void Browser_Policy_Decision_Maker::_request_download(WKURLRequestRef request, WKURLResponseRef response, string& content_type) +void Browser_Policy_Decision_Maker::_request_download(Ewk_Policy_Decision *policy_decision) { string extension_name; string ambiguous_mime1 = "text/plain"; string ambiguous_mime2 = "application/octet-stream"; int ret = 0; - char buff[256] = {0,}; BROWSER_LOGD("[%s]", __func__); m_url.clear(); m_cookies.clear(); m_default_player_pkg_name.clear(); + m_found_matched_app = EINA_FALSE; - WKURLRef url_ref = WKURLRequestCopyURL(request); - WKStringRef url_string_ref = WKURLCopyString(url_ref); - m_url = _convert_WKStringRef_to_string(url_string_ref); - WKRelease(url_string_ref); - WKRelease(url_ref); + m_url = std::string(ewk_policy_decision_url_get(policy_decision)); - WKStringRef cookies_ref = WKURLRequestEflCopyCookies(request); - m_cookies = _convert_WKStringRef_to_string(cookies_ref); - WKRelease(cookies_ref); + m_cookies = std::string(ewk_policy_decision_cookie_get(policy_decision)); BROWSER_LOGD("url=[%s]", m_url.c_str()); BROWSER_LOGD("cookie=[%s]", m_cookies.c_str()); + std::string content_type; + content_type = std::string(ewk_policy_decision_response_mime_get(policy_decision)); + BROWSER_LOGD("content_type=[%s]", content_type.c_str()); + if (content_type.empty()) { BROWSER_LOGD("Download linked file from cotent menu"); if (!_launch_download_app(m_url.c_str(), m_cookies.c_str())) @@ -390,26 +331,44 @@ void Browser_Policy_Decision_Maker::_request_download(WKURLRequestRef request, W } #endif - /* If the default player is registered at AUL db, show list popup with the name of it */ - ret = aul_get_defapp_from_mime(content_type.c_str(), buff, (sizeof(buff)-1)); - if (ret == AUL_R_OK) { - m_default_player_pkg_name = buff; - BROWSER_LOGD("default app [%s]", m_default_player_pkg_name.c_str()); - } else { - BROWSER_LOGE("Fail to get default app"); + service_h service_handle = NULL; + if (service_create(&service_handle) < 0) { + BROWSER_LOGE("Fail to create service handle"); + return; } - /* Call streaming player app only if the default player is samsung music player or samsung video plyaer - * Otherwiser, call download app - */ - if (!m_default_player_pkg_name.empty() && (m_default_player_pkg_name.compare(SEC_VIDEO_PLAYER) == 0 || - m_default_player_pkg_name.compare(SEC_MUSIC_PLAYER) == 0)) { - if (!_show_app_list_popup()) - BROWSER_LOGE("_show_app_list_popup failed"); - } else { + if (!service_handle) { + BROWSER_LOGE("service handle is NULL"); + return; + } + + if (service_set_operation(service_handle, SERVICE_OPERATION_VIEW) < 0) { + BROWSER_LOGE("Fail to set service operation"); + service_destroy(service_handle); + return; + } + + if (service_set_mime(service_handle, content_type.c_str()) < 0) { + BROWSER_LOGE("Fail to set mime type"); + service_destroy(service_handle); + return; + } + + ret = service_foreach_app_matched(service_handle, __launch_matched_application_cb, this); + + if (ret < 0) { + BROWSER_LOGE("Fail to get default application by mime type"); + service_destroy(service_handle); + } + + if (m_found_matched_app == EINA_FALSE) { if (!_launch_download_app(m_url.c_str(), m_cookies.c_str())) BROWSER_LOGE("_launch_download_app failed"); + + service_destroy(service_handle); } + + return; } Eina_Bool Browser_Policy_Decision_Maker::_launch_download_app(const char *url, const char* cookie) @@ -544,6 +503,38 @@ void Browser_Policy_Decision_Maker::__internet_cb(void *data, Evas_Object *obj, __popup_response_cb(decision_maker, NULL, NULL); } +bool Browser_Policy_Decision_Maker::__launch_matched_application_cb(service_h service_handle, const char *package, void *data) +{ + BROWSER_LOGD("%s", __func__); + + if (!data) { + BROWSER_LOGD("unable to set Browser_Policy_Decision_Maker pointer"); + service_destroy(service_handle); + return false; + } + + Browser_Policy_Decision_Maker *decision_maker = (Browser_Policy_Decision_Maker *)data; + string pkg_name = package; + decision_maker->m_default_player_pkg_name = pkg_name; + + + if (!pkg_name.empty() && (pkg_name.compare(SEC_VIDEO_PLAYER) == 0 || pkg_name.compare(SEC_MUSIC_PLAYER) == 0)) { + BROWSER_LOGD("default app [%s]", pkg_name.c_str()); + if (!decision_maker->_show_app_list_popup()) + BROWSER_LOGE("_show_app_list_popup failed"); + else + decision_maker->m_found_matched_app = EINA_TRUE; + } else { + BROWSER_LOGE("Fail to get default app"); + if (!decision_maker->_launch_download_app(decision_maker->m_url.c_str(), decision_maker->m_cookies.c_str())) + BROWSER_LOGE("_launch_download_app failed"); + } + + service_destroy(service_handle); + + return true; +} + Eina_Bool Browser_Policy_Decision_Maker::_show_app_list_popup(void) { if (m_url.empty()) { @@ -585,6 +576,7 @@ Eina_Bool Browser_Policy_Decision_Maker::_show_app_list_popup(void) } elm_object_text_set(cancel_button, BR_STRING_CLOSE); elm_object_part_content_set(m_list_popup, "button1", cancel_button); + elm_object_style_set(cancel_button, "popup_button/default"); evas_object_smart_callback_add(cancel_button, "clicked", __popup_response_cb, this); return EINA_TRUE; diff --git a/src/browser-policy-client/browser-policy-decision-maker.h b/src/browser-policy-client/browser-policy-decision-maker.h index e78090a..5e7ae02 100755..100644 --- a/src/browser-policy-client/browser-policy-decision-maker.h +++ b/src/browser-policy-client/browser-policy-decision-maker.h @@ -33,7 +33,7 @@ public: Browser_Policy_Decision_Maker(Evas_Object *navi_bar, Browser_View *browser_view); ~Browser_Policy_Decision_Maker(void); - void init(WKPageRef page_ref); + void init(Evas_Object *ewk_view); void deinit(void); void pause(void); private: @@ -44,15 +44,8 @@ private: }; /* ewk view event callback functions */ - static void __decide_policy_for_navigation_action( - WKPageRef page, WKFrameRef frame, WKFrameNavigationType navigationType, - WKEventModifiers modifiers, WKEventMouseButton mouseButton, - WKURLRequestRef request, WKFramePolicyListenerRef listener, - WKTypeRef userData, const void* clientInfo); - static void __decide_policy_for_response_cb(WKPageRef page, WKFrameRef frame, - WKURLResponseRef response, WKURLRequestRef request, - WKFramePolicyListenerRef listener, WKTypeRef user_data, - const void *client_info); + static void __decide_policy_for_navigation_action(void *data, Evas_Object *obj, void *event_info); + static void __decide_policy_for_response_cb(void *data, Evas_Object *obj, void *event_info); /* download client callback functions */ static void __download_did_start_cb(const char *download_url, void *user_data); @@ -61,23 +54,22 @@ private: static void __popup_response_cb(void *data, Evas_Object *obj, void *event_info); static void __player_cb(void *data, Evas_Object *obj, void *event_info); static void __internet_cb(void *data, Evas_Object *obj, void *event_info); + static bool __launch_matched_application_cb(service_h service, const char *package, void *data); /* Warning : MUST free() returned char* */ - char *_convert_WKStringRef_to_cstring(WKStringRef string_ref); - string _convert_WKStringRef_to_string(WKStringRef string_ref); - int _decide_policy_type(WKFrameRef frame, WKStringRef content_type_ref, string &content_type); - void _request_download(WKURLRequestRef request, WKURLResponseRef response, string& content_type); + void _request_download(Ewk_Policy_Decision *policy_decision); Eina_Bool _launch_download_app(const char *url, const char *cookies = NULL); string _get_extension_name_from_url(string &url); Eina_Bool _show_app_list_popup(void); const char *_get_app_name_from_pkg_name(string& pkg_name); Eina_Bool _handle_exscheme(void); - WKPageRef m_wk_page_ref; + Evas_Object *m_ewk_view; Evas_Object *m_navi_bar; Evas_Object *m_list_popup; Evas_Object *m_app_list; Browser_View *m_browser_view; + Eina_Bool m_found_matched_app; string m_url; string m_cookies; diff --git a/src/browser-utility.cpp b/src/browser-utility.cpp index 6bc805a..0f7510f 100755 --- a/src/browser-utility.cpp +++ b/src/browser-utility.cpp @@ -575,28 +575,3 @@ bool br_preference_unset_changed_cb(const char *key) return true; } -Browser_Utility::Browser_Utility(void) -{ - BROWSER_LOGD("[%s]", __func__); -} - -Browser_Utility::~Browser_Utility(void) -{ - BROWSER_LOGD("[%s]", __func__); -} - -std::string Browser_Utility::convert_WKStringRef(WKStringRef string_ref) -{ - BROWSER_LOGD("[%s]", __func__); - std::string return_string; - int string_length = WKStringGetMaximumUTF8CStringSize(string_ref); - char *buffer =(char *)calloc(string_length + 1, sizeof(char)); - if (buffer) { - WKStringGetUTF8CString(string_ref, buffer, string_length); - return_string = std::string(buffer); - free(buffer); - } - - return return_string; -} - diff --git a/src/browser-utility.h b/src/browser-utility.h index 9c4bbb7..7d5a3f1 100755 --- a/src/browser-utility.h +++ b/src/browser-utility.h @@ -56,14 +56,5 @@ bool br_preference_unset_changed_cb(const char *key); } #endif -class Browser_Utility { -public: - Browser_Utility(void); - ~Browser_Utility(void); - - std::string convert_WKStringRef(WKStringRef string_ref); -private: -}; - #endif /* BROWSER_UTILITY_H */ diff --git a/src/include/browser-config.h b/src/include/browser-config.h index cc2f4ec..6343048 100755 --- a/src/include/browser-config.h +++ b/src/include/browser-config.h @@ -63,31 +63,6 @@ #define BUILDING_EFL__
#include <EWebKit2.h>
-#if 0
-#include <WebKit2/WebKit2.h>
-#include <WebKit2/EWebKit2.h>
-
-#include <WebKit2/WKArray.h>
-#include <WebKit2/WKContextMenuItem.h>
-#include <WebKit2/WKContextMenuItemTypes.h>
-#include <WebKit2/WKContextTizen.h>
-#include <WebKit2/WKContextPrivate.h>
-#include <WebKit2/WKCookieManager.h>
-#include <WebKit2/WKDictionary.h>
-#include <WebKit2/WKDownload.h>
-#include <WebKit2/WKIconDatabase.h>
-#include <WebKit2/WKIconDatabaseEfl.h>
-#include <WebKit2/WKImageCairo.h>
-#include <WebKit2/WKGeolocationManager.h>
-#include <WebKit2/WKGeolocationPermissionRequest.h>
-#include <WebKit2/WKPageTizen.h>
-#include <WebKit2/WKPreferencesEfl.h>
-#include <WebKit2/WKResourceCacheManager.h>
-#include <WebKit2/WKSecurityOrigin.h>
-#include <WebKit2/WKURLRequestEfl.h>
-#include <WebKit2/WKURLResponseEfl.h>
-#endif
-
#define BROWSER_PACKAGE_NAME "browser"
#define BROWSER_EDJE_DIR "/opt/apps/org.tizen.browser/res/edje"
#define BROWSER_LOCALE_DIR "/opt/apps/org.tizen.browser/res/locale"
|