Add http prefix to quickaccess url and remove it from title. 23/88023/3
authorDariusz Frankiewicz <d.frankiewic@samsung.com>
Mon, 12 Sep 2016 13:59:46 +0000 (15:59 +0200)
committerDariusz Frankiewicz <d.frankiewic@samsung.com>
Tue, 13 Sep 2016 08:56:43 +0000 (10:56 +0200)
[Issue]    http://suprem.sec.samsung.net/jira/browse/TWF-2098
[Problem]  Manually added url without http prefix cannot be loaded.
[Solution] Add http prefix to url in quickaccess. Also removed this
           prefix from label on quickaccess items.
[Verify]   Add some page witout http and try to load it.

Change-Id: I9d1e50799d296a0c24e9d99240ca75d5a5d3a3e5

services/SimpleUI/SimpleUI.cpp

index 43d572931b161a0aecf0f4d405c55a6ce65e9bd5..19bc43c0f36236466c2f9a31337f160bd549573f 100755 (executable)
@@ -889,7 +889,22 @@ void SimpleUI::addQuickAccessItem(const std::string& name)
 {
     BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__);
 
-    m_favoriteService->addBookmark(name, name, std::string(),
+    std::string url = name;
+    std::string title;
+
+    //TODO: extract all prefixes to external file
+    if (!strncmp(name.c_str(), "http://", strlen("http://")))
+        title = name.substr(strlen("http://"), std::string::npos);
+    else if (!strncmp(name.c_str(), "https://", strlen("https://")))
+        title = name.substr(strlen("https://"), std::string::npos);
+    else if (!strncmp(name.c_str(), "ftp://", strlen("ftp://")))
+        title = name.substr(strlen("ftp://"), std::string::npos);
+    else {
+        url = std::string("http://") + name;
+        title = name;
+    }
+
+    m_favoriteService->addBookmark(url, title, std::string(),
         std::shared_ptr<tizen_browser::tools::BrowserImage>(),
         std::shared_ptr<tizen_browser::tools::BrowserImage>(), m_favoriteService->getQuickAccessRoot());
     showQuickAccess();
@@ -1669,6 +1684,14 @@ void SimpleUI::addQuickAccess()
     item.title = m_webEngine->getTitle();
     item.url = m_webEngine->getURI();
 
+    //TODO: extract all prefixes to external file
+    if (!strncmp(item.title.c_str(), "http://", strlen("http://")))
+        item.title = item.title.substr(strlen("http://"), std::string::npos);
+    else if (!strncmp(item.title.c_str(), "https://", strlen("https://")))
+        item.title = item.title.substr(strlen("https://"), std::string::npos);
+    else if (!strncmp(item.title.c_str(), "ftp://", strlen("ftp://")))
+        item.title = item.title.substr(strlen("ftp://"), std::string::npos);
+
     addBookmark(item);
 
     //TODO: display toast message