[ Problem ] Current visible tab is not loaded on browser relaunch.
[ Cause ] The latest tab which was added to browser-provider tab adaptor
is assumed as the tab that was vsible when browser was killed.
The user might have switched to some older tab; in that case,
the currently opened tab should be loaded on browser relaunch.
[ Solution ] Save the currently visible tab id to browser-provider tab
adaptor's 'is_activated' property. During browser relaunch,
i.e restoring last session, check the property and accordingly
load the tab's url.
Change-Id: I8637d89f531eef456e82c44f66d44594eb81a1a1
Signed-off-by: Gajendra N <gajendra.n@samsung.com>
Signed-off-by: cookie <cookie@samsung.com>
}
}
+void SimpleUI::destroyUI() {
+ BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__);
+ m_tabService->setVisibleTabAsActivated(m_webEngine->currentTabId().get());
+ m_webEngine->destroyTabs();
+}
+
void SimpleUI::restoreLastSession() {
BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__);
auto vec(m_tabService->getAllTabs());
+ int lastShownTabId = -1;
for (const auto& i : *vec) {
+ if (m_tabService->wasTabIdActivated(i.getId().get()))
+ lastShownTabId = i.getId().get();
+
openNewTab(i.getUrl(), i.getTitle(),
boost::optional<int>(i.getId().get()), false,
i.getOrigin());
}
+ if (lastShownTabId != -1)
+ switchToTab(lastShownTabId);
}
void SimpleUI::loadUIServices() {
void suspend() final override { m_webEngine->suspend(); };
void resume() final override;
void languageChanged() final override { m_languageChanged = true; };
- void destroyUI() final override { m_webEngine->destroyTabs(); };
+ void destroyUI() final override;
enum class rotationLock {
noLock = 0,
return adaptorId;
}
+bool TabService::wasTabIdActivated(int tabId)
+{
+ BROWSER_LOGD("[%s:%d]", __PRETTY_FUNCTION__, __LINE__);
+ int activated = 0;
+ if (bp_tab_adaptor_get_activated(tabId, &activated) < 0) {
+ errorPrint("bp_tab_adaptor_get_activated");
+ }
+ return activated;
+}
+
+void TabService::setVisibleTabAsActivated(int tabId)
+{
+ BROWSER_LOGD("[%s:%d]", __PRETTY_FUNCTION__, __LINE__);
+ int* items = nullptr;
+ int count;
+ if (bp_tab_adaptor_get_full_ids_p(&items, &count) < 0 || !count) {
+ errorPrint("bp_tab_adaptor_get_full_ids_p");
+ return;
+ }
+ for (int i = 0; i < count; ++i) {
+ if (tabId == items[i])
+ continue;
+
+ bp_tab_info_fmt info;
+ if (bp_tab_adaptor_get_easy_all(items[i], &info) < 0) {
+ errorPrint("bp_tab_adaptor_get_easy_all");
+ continue;
+ }
+ if (bp_tab_adaptor_set_activated(items[i], false) < 0) {
+ errorPrint("bp_tab_adaptor_set_activated");
+ continue;
+ }
+ }
+ if (bp_tab_adaptor_set_activated(tabId, true) < 0) {
+ errorPrint("bp_tab_adaptor_set_activated");
+ }
+}
+
void TabService::errorPrint(std::string method) const
{
int error_code = bp_tab_adaptor_get_errorcode();
std::shared_ptr<std::vector<basic_webengine::TabContent> > getAllTabs();
/**
+ * Sets visible tab as activated while browser is being killed,
+ * so that the tabId's url will be loaded on browser relaunch.
+ */
+ void setVisibleTabAsActivated(int tabId);
+
+ /**
+ * @brief Get activated/deactivated value of the tab.
+ * @return true if activated, false otherwise.
+ */
+ bool wasTabIdActivated(int tabId);
+
+ /**
* Remove image thumb for given id from the cache and database.
*/
void removeTab(const basic_webengine::TabId& tabId);