void SimpleUI::tabLimitPopupButtonClicked(PopupButtons button) {
BROWSER_LOGD("[%s:%d]", __PRETTY_FUNCTION__, __LINE__);
+
+ // While showing the popup, we have already created new tab for window.open() request,
+ // so when user selects OK button, we retain the tab and close the oldest tab.
+ // Otherwise, i.e, if user selects CANCEL button, we just close the current tab.
if (button == OK) {
BROWSER_LOGD("[%s:%d] Closing oldest tab and opening requested",
__PRETTY_FUNCTION__, __LINE__);
- if (m_tabUI->getPopupDecision())
- m_storageService->getSettingsStorage().setSettingsBool(
- TAB_LIMIT_DECISION, true);
+ m_storageService->getSettingsStorage().setSettingsBool(
+ TAB_LIMIT_DECISION, m_tabUI->getPopupDecision());
closeOldestTab();
- switchToTab(m_webEngine->openRequestedPage());
+ } else if (button == CANCEL) {
+ closeTab(m_webEngine->currentTabId());
}
while (m_popupVector.size() > 1)
m_popupVector.front()->onBackPressed();
BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__);
if (m_webEngine->tabsCount() >= m_tabLimit) {
- if (m_storageService->getSettingsStorage().getSettingsBool(
- TAB_LIMIT_DECISION, false)) {
+ if (!(m_storageService->getSettingsStorage().getSettingsBool(
+ TAB_LIMIT_DECISION, true))) {
closeOldestTab();
return true;
}
BROWSER_LOGD("[%s:%d]", __PRETTY_FUNCTION__, __LINE__);
if (data && obj) {
auto self = static_cast<TabUI*>(data);
- self->m_popup_decision = elm_check_state_get(obj) == EINA_TRUE;
- } else
+ self->m_popup_decision = elm_check_state_get(obj) == EINA_FALSE;
+ } else {
BROWSER_LOGW("[%s] data or obj = nullptr", __PRETTY_FUNCTION__);
+ }
}
void TabUI::_close_clicked(void* data, Evas_Object*, void*)
TabUI *self = static_cast<TabUI*>(data);
auto checkbox = elm_check_add(obj);
evas_object_smart_callback_add(checkbox, "changed", self->_decision_check_changed, self);
- elm_check_state_set(checkbox, EINA_TRUE);
+ elm_check_state_set(checkbox, EINA_FALSE);
evas_object_show(checkbox);
return checkbox;
}
/// \todo: Choose newly created tab.
TabId id(TabId::NONE);
TabId currentTabId = m_webEngine->currentTabId();
+
+ // Some sites may request for multiple window.open, in that case, if already max TAB_LIMIT is
+ // reached then only one additional tab should be allowed to create if user chooses to close
+ // oldest tab.
+ auto tabLimit = boost::any_cast<int>(Config::getInstance().get("TAB_LIMIT"));
+ if (m_webEngine->tabsCount() >= tabLimit + 1)
+ return;
+
if (currentTabId != (id = m_webEngine->addTab(std::string(),
boost::none,
std::string(),