summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKamil Nowac <k.nowac@samsung.com>2016-09-29 12:25:56 +0200
committerHyeKyoung Hwang <cookie@samsung.com>2016-10-28 11:11:33 +0900
commit03c445295cf41fc8d8d2175266d6f10fe194c133 (patch)
tree20c6db0197357e86952306a5ead9fac179164b2c
parentc4e350e5a24e0d660741a3d7de681909aac14237 (diff)
downloadbrowser-03c445295cf41fc8d8d2175266d6f10fe194c133.tar.gz
browser-03c445295cf41fc8d8d2175266d6f10fe194c133.tar.bz2
browser-03c445295cf41fc8d8d2175266d6f10fe194c133.zip
Make sure all tabs are deleted from database
[Issue] http://suprem.sec.samsung.net/jira/browse/TWF-1642 [Problem] Reset Browser does not clear all tabs [Solution] Remove ids marked as deleted [Verify] Open few tabs. Reset browser. Situation described in Issue should not occur Change-Id: If06006a34325f4cf5078ecd337ca9f103a0f3dca
-rw-r--r--services/SimpleUI/SimpleUI.cpp10
-rw-r--r--services/TabService/TabService.cpp20
-rw-r--r--services/TabService/TabService.h5
3 files changed, 29 insertions, 6 deletions
diff --git a/services/SimpleUI/SimpleUI.cpp b/services/SimpleUI/SimpleUI.cpp
index 1e80ace8..67869715 100644
--- a/services/SimpleUI/SimpleUI.cpp
+++ b/services/SimpleUI/SimpleUI.cpp
@@ -1786,12 +1786,10 @@ void SimpleUI::onResetBrowserButton(PopupButtons button, std::shared_ptr< PopupD
m_webEngine->clearFormData();
// Close all openend tabs
- std::vector<std::shared_ptr<tizen_browser::basic_webengine::TabContent>> openedTabs = m_webEngine->getTabContents();
- for (auto it = openedTabs.begin(); it < openedTabs.end(); ++it) {
- tizen_browser::basic_webengine::TabId id = it->get()->getId();
- m_tabService->removeTab(id);
- m_webEngine->closeTab(id);
- }
+ auto openedTabs = m_webEngine->getTabContents();
+ for (const auto& it : openedTabs)
+ m_webEngine->closeTab(it.get()->getId());
+ m_tabService->clearAll();
m_certificateContents->clear();
m_storageService->getCertificateStorage().deleteAllEntries();
m_storageService->getFoldersStorage().deleteAllFolders();
diff --git a/services/TabService/TabService.cpp b/services/TabService/TabService.cpp
index d114e04f..19eccbcc 100644
--- a/services/TabService/TabService.cpp
+++ b/services/TabService/TabService.cpp
@@ -205,11 +205,31 @@ void TabService::clearFromCache(const basic_webengine::TabId& tabId) {
m_thumbMap.erase(tabId.get());
}
+void TabService::clearAll()
+{
+ int* items = nullptr;
+ int count;
+ if (bp_tab_adaptor_get_full_ids_p(&items, &count) < 0) {
+ errorPrint("bp_tab_adaptor_get_full_ids_p");
+ }
+ for (int i = 0; i < count; ++i) {
+ auto id = basic_webengine::TabId(items[i]);
+ clearFromDatabase(id);
+ }
+ m_thumbMap.clear();
+}
+
void TabService::clearFromDatabase(const basic_webengine::TabId& tabId)
{
if (bp_tab_adaptor_delete(tabId.get()) < 0) {
errorPrint("bp_tab_adaptor_delete");
}
+ if (bp_tab_adaptor_set_deleted(tabId.get()) < 0) {
+ errorPrint("bp_tab_adaptor_set_deleted");
+ }
+ if (bp_tab_adaptor_clear_deleted_ids() < 0) {
+ errorPrint("bp_tab_adaptor_clear_deleted_ids");
+ }
}
void TabService::saveThumbDatabase(const basic_webengine::TabId& tabId,
diff --git a/services/TabService/TabService.h b/services/TabService/TabService.h
index 0259d2df..b998e4e2 100644
--- a/services/TabService/TabService.h
+++ b/services/TabService/TabService.h
@@ -66,6 +66,11 @@ public:
void removeTab(const basic_webengine::TabId& tabId);
/**
+ * Remove all items from the cache and database.
+ */
+ void clearAll();
+
+ /**
* Set thumb images for given TabContent objects: get them from
* cache or database or generate them by taking screenshots.
*/