[PWE] Modify Browser to react on callbacks with Manifest and SW 09/128309/7
authorPawel Niemirski <p.niemirski@samsung.com>
Wed, 26 Apr 2017 14:34:08 +0000 (16:34 +0200)
committerPawel Niemirski <p.niemirski@samsung.com>
Wed, 10 May 2017 09:24:10 +0000 (11:24 +0200)
This CL removes unneeded code related to old installation method
and adds ewk_view_app_installation_request_callback_set call
in order to handle installation requests triggered by
window.navigator.installApp JS API.

Bug: suprem.sec.samsung.net/jira/browse/RWASP-913

Change-Id: I834948ee66bec15cd216528061dc5628d66d9c74
Signed-off-by: Pawel Niemirski <p.niemirski@samsung.com>
core/AbstractWebEngine/AbstractWebEngine.h
core/main.cpp
services/WebEngineService/WebView.cpp
services/WebEngineService/WebView.h

index 7cd97c44b39afd2d547e63cd1c1ece0d84aa7152..76fd4a9a6c978770500452873192dd8af8baf9d8 100755 (executable)
@@ -599,6 +599,18 @@ public:
      */
     boost::signals2::signal<unsigned(const std::string&, const std::string&, const std::string&)> installPWA;
 
+#if PWE_SHUB
+    /**
+     * Get PWA service worker uri
+     */
+    boost::signals2::signal<std::string()> getPWAServiceWorkerURI;
+
+    /**
+     * Get PWA uri
+     */
+    boost::signals2::signal<std::string()> getPWAURI;
+#endif
+
     /**
      * Stores PWA shortcut in DB
      */
index b71919092b8d1c527eae24bad8e6f82bf6bef6d0..2e1a147132aead7b33a4d3155390852f41624d9a 100755 (executable)
@@ -44,6 +44,9 @@
 const char *engineCommandLineFlags[] = {
   "process-per-tab",
   "allow-file-access-from-files",
+#if PWE_SHUB
+  "enable-tizen-app-container",
+#endif
 };
 
 std::vector<char*> browser_argv;
index d0c48f31dfa131d970eb2c124cadd754a7ded103..c26b4a49178ac79d4e979e4e98af27a76fe21174 100755 (executable)
@@ -304,6 +304,9 @@ void WebView::registerCallbacks()
     evas_object_smart_callback_add(m_ewkView, "notification,permission,reply", __notification_reply_cb, this);
 
     ewk_view_did_change_theme_color_callback_set(m_ewkView, __theme_color_changed, this);
+#if PWE_SHUB
+    ewk_view_app_installation_request_callback_set(m_ewkView, __install_pwa_request_cb, this);
+#endif
 }
 
 void WebView::unregisterCallbacks()
@@ -409,7 +412,7 @@ void WebView::handleManifest()
     m_manifestVector.clear();
 }
 
-void WebView::setPWAData()
+void WebView::setPWAData(const std::string& serviceWorkerURL)
 {
     BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__);
     s_name = m_manifestData.name;
@@ -464,6 +467,10 @@ void WebView::setPWAData()
         + "&pwa_icon_count=" + std::to_string(m_manifestData.icons_count)
         + "&pwa_icon_src=" + std::string(text = curl_easy_escape(curl,
             m_manifestData.icons.begin()->src.c_str(), m_manifestData.icons.begin()->src.length()));
+#if PWE_SHUB
+    if (!serviceWorkerURL.empty())
+        retVal += "&pwa_serviceWorkerUri=" + serviceWorkerURL;
+#endif
     curl_free(text);
     curl_easy_cleanup(curl);
 
@@ -1754,6 +1761,20 @@ void WebView::__policy_navigation_decide_cb(void *data, Evas_Object * /*obj*/, v
     ewk_policy_decision_use(policy_decision);
 }
 
+#if PWE_SHUB
+void WebView::__install_pwa_request_cb(Evas_Object* ewk_view, Ewk_App_Installation_Request* request, void* user_data)
+{
+    BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__);
+    auto webView = static_cast<WebView*>(user_data);
+    Ewk_View_Request_Manifest* manifest = ewk_app_installation_request_manifest_get(request);
+    webView->__setManifestData(ewk_view, manifest, user_data);
+    const char* tmp = ewk_app_installation_request_service_worker_url_get(request);
+    std::string serviceWorkerURL = (tmp) ? tmp : "";
+    // Trigger installation
+    webView->setPWAData(serviceWorkerURL);
+}
+#endif
+
 } /* namespace webengine_service */
 } /* end of basic_webengine */
 } /* end of tizen_browser */
index c7b9a9b490c08cabde53c40176ef319af7376c30..459c297330b713e26cdcb20b491494f0f8ccff01 100755 (executable)
@@ -148,7 +148,8 @@ public:
     void handleManifest();
     void addManifestTypeToHandle(const ManifestType &type) { m_manifestVector.push_back(type); }
 
-    void setPWAData();
+    void setPWAData(const std::string& serviceWorkerURL = "");
+
     void request_file_download(const std::string& uri, const std::string& file_path, download_finish_callback cb, void *data);
 
     struct download_request
@@ -441,6 +442,10 @@ private:
     // Screenshot capture
     static void __screenshotCaptured(Evas_Object* image, void* user_data);
 
+#if PWE_SHUB
+    static void __install_pwa_request_cb(Evas_Object* /*ewk_view*/, Ewk_App_Installation_Request* request, void* user_data);
+#endif
+
     Evas_Object * m_parent;
     TabId m_tabId;
     Evas_Object * m_ewkView;