Generate UUID for PWA icon file name 62/129462/4
authorPawel Niemirski <p.niemirski@samsung.com>
Tue, 16 May 2017 10:41:05 +0000 (12:41 +0200)
committerHye Kyoung Hwang <cookie@samsung.com>
Thu, 18 May 2017 04:44:01 +0000 (04:44 +0000)
Previous implementation was using original icon file name, however,
it turned out that we can have two or more applications with the same
icon name (e.g. naver.com and PWA hub). This is why some PWA apps
change their icon after installation of another app.

As a solution, we generate UUID for PWA icon file name.

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

Change-Id: Ieed03450ca67186b432ef3bef58928764e45a58c
Signed-off-by: Pawel Niemirski <p.niemirski@samsung.com>
services/WebEngineService/WebView.cpp

index c26b4a4..e4efb4d 100755 (executable)
@@ -30,6 +30,9 @@
 #include <boost/algorithm/string/regex.hpp>
 #include <boost/algorithm/string/classification.hpp>
 #include <boost/algorithm/string/split.hpp>
+#include <boost/uuid/uuid.hpp>
+#include <boost/uuid/uuid_generators.hpp>
+#include <boost/uuid/uuid_io.hpp>
 #include <Elementary.h>
 
 #include "URIschemes.h"
@@ -425,8 +428,7 @@ void WebView::setPWAData(const std::string& serviceWorkerURL)
     }
 
     std::string str_icon_src = m_manifestData.icons.begin()->src;
-    auto result = str_icon_src.substr(str_icon_src.find_last_of("/"), str_icon_src.length());
-    s_icon = DOWNLOAD_PATH + result;
+    s_icon = DOWNLOAD_PATH + boost::uuids::to_string(boost::uuids::random_generator()());
     request_file_download(m_manifestData.icons.begin()->src, s_icon, __download_result_cb, nullptr);
 
     if (m_manifestData.m_push_id.empty())