return true;
}
+bool launchDownloader(std::string& url, std::string& cookie)
+{
+ LogD("enter");
+
+ service_h handle = NULL;
+ int ret = SERVICE_ERROR_NONE;
+
+ if (url.empty()) {
+ LogD("invalid arguments");
+ return false;
+ }
+
+ ret = service_create(&handle);
+ if (ret != SERVICE_ERROR_NONE) {
+ LogD("failed to create service");
+ return false;
+ }
+
+ ret = service_set_operation(handle, SERVICE_OPERATION_DOWNLOAD);
+ if (ret != SERVICE_ERROR_NONE) {
+ LogD("failed to set operation");
+ service_destroy(handle);
+ return false;
+ }
+
+ ret = service_set_uri(handle, url.c_str());
+ if (ret != SERVICE_ERROR_NONE) {
+ LogD("failed to set url");
+ service_destroy(handle);
+ return false;
+ }
+
+ if (!cookie.empty()) {
+ ret = service_add_extra_data(handle, "cookie", cookie.c_str());
+ if (ret != SERVICE_ERROR_NONE) {
+ LogD("failed to set cookie");
+ service_destroy(handle);
+ return false;
+ }
+ }
+
+ ret = service_send_launch_request(handle, NULL, NULL);
+ if (ret != SERVICE_ERROR_NONE) {
+ LogD("failed to request launch");
+ service_destroy(handle);
+ return false;
+ }
+
+ LogD("success to launch downloader");
+ service_destroy(handle);
+
+ return true;
+}
+
} // AppControl
} // Service
namespace AppControl {
bool launchBrowser(std::string& url);
+bool launchDownloader(std::string& url, std::string& cookie);
}
} // Service
#include <Eina.h>
#include <ewk_context.h>
#include <ewk_view.h>
+#include <ewk_policy_decision.h>
#include <Core/Util/Log.h>
+#include <Core/Service/AppControl.h>
#include "WebView.h"
// injection javascript file regarding creating js object used by box and pd
{
LogD("enter");
+ Ewk_Policy_Decision *policyDecision = static_cast<Ewk_Policy_Decision *>(eventInfo);
+ Ewk_Policy_Decision_Type policyType = ewk_policy_decision_type_get(policyDecision);
+ std::string url(ewk_policy_decision_url_get(policyDecision));
+ std::string cookie(ewk_policy_decision_cookie_get(policyDecision));
+ const char* contentType = ewk_policy_decision_response_mime_get(policyDecision);
+
+ switch (policyType) {
+ case EWK_POLICY_DECISION_USE:
+ LogD("policy use");
+ ewk_policy_decision_use(policyDecision);
+ break;
+
+ case EWK_POLICY_DECISION_DOWNLOAD:
+ LogD("policy download: %s, %s, %s", url.c_str(), cookie.c_str(), contentType);
+ ewk_policy_decision_suspend(policyDecision);
+ Service::AppControl::launchDownloader(url, cookie);
+ ewk_policy_decision_ignore(policyDecision);
+ break;
+
+ case EWK_POLICY_DECISION_IGNORE:
+ default:
+ LogD("policy ignore");
+ ewk_policy_decision_ignore(policyDecision);
+ break;
+ }
+
+ if (policyType == EWK_POLICY_DECISION_DOWNLOAD) {
+ if (ewk_view_back_possible(obj)) {
+ ewk_view_back(obj);
+ } else {
+ // TODO Add handling code in case that new window is opened
+ //ecore_idler_add(windowCloseIdlerCallback, data);
+ }
+ }
+
WebView* This = static_cast<WebView*>(data);
This->didPageResponseDecide(obj);
}