summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDariusz Frankiewicz <d.frankiewic@samsung.com>2016-07-19 14:24:47 +0200
committerHye Kyoung Hwang <cookie@samsung.com>2016-07-22 01:59:57 -0700
commit00406a6a8a416b1bf0c214151bd95f35148ae864 (patch)
tree019ce3f2698dac9128940dbe5d81bb5e56d2f93f
parent64444a86610091dc678a1e03b0f228ced65fe97d (diff)
downloadbrowser-00406a6a8a416b1bf0c214151bd95f35148ae864.tar.gz
browser-00406a6a8a416b1bf0c214151bd95f35148ae864.tar.bz2
browser-00406a6a8a416b1bf0c214151bd95f35148ae864.zip
[Issue] n/a [Problem] While we're navigating back and close webview then crash happens when we try to download some items. [Cause] Webview context was null after close tab because of bad this assignment. [Solution] Move implementation of download request from webview to webengine service. [Verify] Open image from context menu in new tab, close this tab by back key and next try to download this image from origin page. Change-Id: I0498a1ecfd0ff47f0fb3ebc23da18d54aba223fe
-rwxr-xr-xcore/DownloadControl/DownloadControl.h8
-rw-r--r--services/SimpleUI/SimplePopup.h9
-rw-r--r--services/WebEngineService/WebEngineService.cpp47
-rw-r--r--services/WebEngineService/WebEngineService.h4
-rwxr-xr-xservices/WebEngineService/WebView.cpp28
-rw-r--r--services/WebEngineService/WebView.h10
6 files changed, 53 insertions, 53 deletions
diff --git a/core/DownloadControl/DownloadControl.h b/core/DownloadControl/DownloadControl.h
index 70ae9dc2..f442f4df 100755
--- a/core/DownloadControl/DownloadControl.h
+++ b/core/DownloadControl/DownloadControl.h
@@ -60,6 +60,14 @@
#define BROWSER_DATA_SCHEME_DOWNLOAD_ALLOW_MAX_COUNT 100000
#define APP_LIST_HEIGHT (230 * efl_scale)
+typedef enum _download_popup_type {
+ DOWNLOAD_UNABLE_TO_DOWNLOAD = 0,
+ DOWNLOAD_STARTING_DOWNLOAD,
+ DOWNLOAD_SAVEDPAGES,
+ DOWNLOAD_FAIL,
+ DOWNLOAD_ONLY_HTTP_OR_HTTPS_URLS
+} download_popup_type;
+
struct popup_callback
{
public:
diff --git a/services/SimpleUI/SimplePopup.h b/services/SimpleUI/SimplePopup.h
index 875778a5..d19cd0f4 100644
--- a/services/SimpleUI/SimplePopup.h
+++ b/services/SimpleUI/SimplePopup.h
@@ -26,14 +26,7 @@
#include "AbstractPopup.h"
#include "PopupButtons.h"
#include "WebConfirmation.h"
-
-typedef enum _download_popup_type{
- DOWNLOAD_UNABLE_TO_DOWNLOAD = 0,
- DOWNLOAD_STARTING_DOWNLOAD,
- DOWNLOAD_SAVEDPAGES,
- DOWNLOAD_FAIL,
- DOWNLOAD_ONLY_HTTP_OR_HTTPS_URLS,
-} download_popup_type;
+#include "DownloadControl/DownloadControl.h"
namespace tizen_browser
{
diff --git a/services/WebEngineService/WebEngineService.cpp b/services/WebEngineService/WebEngineService.cpp
index 29a021fd..3a876344 100644
--- a/services/WebEngineService/WebEngineService.cpp
+++ b/services/WebEngineService/WebEngineService.cpp
@@ -42,6 +42,9 @@ WebEngineService::WebEngineService()
, m_currentTabId(TabId::NONE)
, m_currentWebView(nullptr)
, m_tabIdCreated(-1)
+ #if PROFILE_MOBILE
+ , m_downloadControl(nullptr)
+ #endif
{
m_mostRecentTab.clear();
m_tabs.clear();
@@ -60,6 +63,9 @@ WebEngineService::WebEngineService()
WebEngineService::~WebEngineService()
{
BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__);
+ #if PROFILE_MOBILE
+ delete m_downloadControl;
+ #endif
}
void WebEngineService::destroyTabs()
@@ -88,6 +94,12 @@ void WebEngineService::init(void * guiParent)
m_guiParent = guiParent;
m_initialised = true;
}
+
+#if PROFILE_MOBILE
+ Ewk_Context *context = ewk_context_default_get();
+ ewk_context_did_start_download_callback_set(context , _download_request_cb, this);
+ m_downloadControl = new DownloadControl();
+#endif
}
void WebEngineService::preinitializeWebViewCache()
@@ -110,7 +122,6 @@ void WebEngineService::connectSignals(std::shared_ptr<WebView> webView)
webView->favIconChanged.connect(boost::bind(&WebEngineService::_favIconChanged, this, _1));
webView->titleChanged.connect(boost::bind(&WebEngineService::_titleChanged, this, _1));
webView->uriChanged.connect(boost::bind(&WebEngineService::_uriChanged, this, _1));
- webView->downloadStarted.connect(boost::bind(&WebEngineService::_downloadStarted, this, _1));
webView->loadFinished.connect(boost::bind(&WebEngineService::_loadFinished, this));
webView->loadStarted.connect(boost::bind(&WebEngineService::_loadStarted, this));
webView->loadStop.connect(boost::bind(&WebEngineService::_loadStop, this));
@@ -395,11 +406,6 @@ void WebEngineService::_uriChanged(const std::string & uri)
uriChanged(uri);
}
-void WebEngineService::_downloadStarted(int status)
-{
- downloadStarted(status);
-}
-
void WebEngineService::_loadFinished()
{
loadFinished();
@@ -789,6 +795,35 @@ void WebEngineService::_setWrongCertificatePem(const std::string& uri, const std
}
#if PROFILE_MOBILE
+void WebEngineService::_download_request_cb(const char *download_uri, void *data)
+{
+ BROWSER_LOGD("[%s:%d] download_uri= [%s]", __PRETTY_FUNCTION__, __LINE__, download_uri);
+
+ WebEngineService *wes = static_cast<WebEngineService *>(data);
+
+ if (!strncmp(download_uri, "data:", strlen("data:"))) {
+ wes->downloadStarted(DOWNLOAD_STARTING_DOWNLOAD);
+ BROWSER_LOGD("[%s:%d] download start..", __PRETTY_FUNCTION__, __LINE__);
+
+ if (wes->m_downloadControl->handle_data_scheme(download_uri) == EINA_TRUE) {
+ BROWSER_LOGD("[%s:%d] saved..", __PRETTY_FUNCTION__, __LINE__);
+ wes->downloadStarted(DOWNLOAD_SAVEDPAGES);
+ } else {
+ BROWSER_LOGD("[%s:%d] fail..", __PRETTY_FUNCTION__, __LINE__);
+ wes->downloadStarted(DOWNLOAD_FAIL);
+ }
+ } else if (strncmp(download_uri, "http://", strlen("http://")) &&
+ strncmp(download_uri, "https://", strlen("https://"))) {
+ BROWSER_LOGD("[%s:%d] Only http or https URLs can be downloaded", __PRETTY_FUNCTION__, __LINE__);
+ wes->downloadStarted(DOWNLOAD_ONLY_HTTP_OR_HTTPS_URLS);
+ return;
+ } else {
+ wes->downloadStarted(wes->m_downloadControl->launch_download_app(download_uri) == EINA_TRUE);
+ }
+ wes->m_downloadControl->launch_download_app(download_uri);
+}
+
+
int WebEngineService::_getRotation()
{
BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__);
diff --git a/services/WebEngineService/WebEngineService.h b/services/WebEngineService/WebEngineService.h
index f673a669..7ccd46bb 100644
--- a/services/WebEngineService/WebEngineService.h
+++ b/services/WebEngineService/WebEngineService.h
@@ -31,6 +31,7 @@
#include "AbstractWebEngine/TabOrigin.h"
#include "SnapshotType.h"
#include "BrowserImage.h"
+#include "DownloadControl/DownloadControl.h"
namespace tizen_browser {
namespace basic_webengine {
@@ -224,7 +225,6 @@ private:
void _favIconChanged(std::shared_ptr<tizen_browser::tools::BrowserImage> bi);
void _titleChanged(const std::string&);
void _uriChanged(const std::string &);
- void _downloadStarted(int status);
void _loadFinished();
void _loadStarted();
void _loadStop();
@@ -243,6 +243,7 @@ private:
void setWebViewSettings(std::shared_ptr<WebView> webView);
void _unsecureConnection();
void _findOnPage(const std::string& str);
+ static void _download_request_cb(const char *download_uri, void *data);
#endif
/**
@@ -279,6 +280,7 @@ private:
int m_tabIdCreated;
#if PROFILE_MOBILE
std::map<WebEngineSettings, bool> m_settings;
+ DownloadControl *m_downloadControl;
#endif
};
diff --git a/services/WebEngineService/WebView.cpp b/services/WebEngineService/WebView.cpp
index d696605e..681f7d93 100755
--- a/services/WebEngineService/WebView.cpp
+++ b/services/WebEngineService/WebView.cpp
@@ -137,7 +137,6 @@ void WebView::init(bool desktopMode, TabOrigin origin, Evas_Object*)
setupEwkSettings();
registerCallbacks();
#if PROFILE_MOBILE
- ewk_context_did_start_download_callback_set(ewk_view_context_get(m_ewkView), __download_request_cb, this);
m_downloadControl = new DownloadControl();
orientationChanged();
#endif
@@ -1713,33 +1712,6 @@ void WebView::__policy_navigation_decide_cb(void *data, Evas_Object * /*obj*/, v
}
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);
-
- WebView *wv = (WebView *)data;
-
- if (!strncmp(download_uri, "data:", strlen("data:"))){
- wv->downloadStarted(DOWNLOAD_STARTING_DOWNLOAD);
- BROWSER_LOGD("[%s:%d] download start..", __PRETTY_FUNCTION__, __LINE__);
-
- if (wv->m_downloadControl->handle_data_scheme(download_uri) == EINA_TRUE){
- BROWSER_LOGD("[%s:%d] saved..", __PRETTY_FUNCTION__, __LINE__);
- wv->downloadStarted(DOWNLOAD_SAVEDPAGES);
- }
- else{
- BROWSER_LOGD("[%s:%d] fail..", __PRETTY_FUNCTION__, __LINE__);
- wv->downloadStarted(DOWNLOAD_FAIL);
- }
- } else if (strncmp(download_uri, "http://", strlen("http://")) && strncmp(download_uri, "https://", strlen("https://"))) {
- BROWSER_LOGD("[%s:%d] Only http or https URLs can be downloaded", __PRETTY_FUNCTION__, __LINE__);
- wv->downloadStarted(DOWNLOAD_ONLY_HTTP_OR_HTTPS_URLS);
- return;
- } else {
- wv->downloadStarted(wv->m_downloadControl->launch_download_app(download_uri) == EINA_TRUE);
- }
-}
#endif
} /* namespace webengine_service */
diff --git a/services/WebEngineService/WebView.h b/services/WebEngineService/WebView.h
index dd5d4007..688616df 100644
--- a/services/WebEngineService/WebView.h
+++ b/services/WebEngineService/WebView.h
@@ -62,14 +62,6 @@ typedef enum _custom_context_menu_item_tag {
CUSTOM_CONTEXT_MENU_ITEM_SEND_EMAIL,
CUSTOM_CONTEXT_MENU_ITEM_SEND_ADD_TO_CONTACT,
} custom_context_menu_item_tag;
-
-typedef enum _download_popup_type{
- DOWNLOAD_UNABLE_TO_DOWNLOAD = 0,
- DOWNLOAD_STARTING_DOWNLOAD,
- DOWNLOAD_SAVEDPAGES,
- DOWNLOAD_FAIL,
- DOWNLOAD_ONLY_HTTP_OR_HTTPS_URLS,
-} download_popup_type;
#endif
namespace tizen_browser {
@@ -270,7 +262,6 @@ public:
boost::signals2::signal<void (std::shared_ptr<tizen_browser::tools::BrowserImage>, tizen_browser::tools::SnapshotType snapshot_type)> snapshotCaptured;
boost::signals2::signal<void (const std::string&)> titleChanged;
boost::signals2::signal<void (const std::string)> uriChanged;
- boost::signals2::signal<void (int)> downloadStarted;
boost::signals2::signal<void (const std::string&)> findOnPage;
boost::signals2::signal<void ()> loadFinished;
@@ -361,7 +352,6 @@ private:
// 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
// Screenshot capture