boost::signals2::signal<void (TabId)> currentTabChanged;
/**
- * New tab was creted. It could be explicit call (by user) or tab could be opened from JavaScript.
+ * New tab was created. It could be explicit call (by user) or tab could be opened from JavaScript.
*/
boost::signals2::signal<void ()> tabCreated;
/**
+ * Checks if tab can be created.
+ */
+ boost::signals2::signal<bool ()> checkIfCreate;
+
+ /**
* Tab closed
* \param TabId of closed tab
*/
m_data["TOOLTIP_DELAY"] = 0.05; // time from mouse in to tooltip show
m_data["TOOLTIP_HIDE_TIMEOUT"] = 2.0; // time from tooltip show to tooltip hide
- m_data["TAB_LIMIT"] = 20; // max number of open tabs
+ m_data["TAB_LIMIT"] = 10; // max number of open tabs
m_data["FAVORITES_LIMIT"] = 40; // max number of added favorites
# include "ConfigValues.h"
m_webEngine->loadError.connect(boost::bind(&SimpleUI::loadError, this));
m_webEngine->confirmationRequest.connect(boost::bind(&SimpleUI::handleConfirmationRequest, this, _1));
m_webEngine->tabCreated.connect(boost::bind(&SimpleUI::tabCreated, this));
+ m_webEngine->checkIfCreate.connect(boost::bind(&SimpleUI::checkIfCreate, this));
m_webEngine->tabClosed.connect(boost::bind(&SimpleUI::tabClosed,this,_1));
m_webEngine->IMEStateChanged.connect(boost::bind(&SimpleUI::setwvIMEStatus, this, _1));
m_webEngine->favIconChanged.connect(boost::bind(&MoreMenuUI::setFavIcon, m_moreMenuUI.get(), _1));
//check if url is in blocked
//no filtering
+
if (m_webPageUI->isHomePageActive())
openNewTab(url);
else
void SimpleUI::newTabClicked()
{
+ if (!checkIfCreate())
+ return;
+
BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__);
switchViewToQuickAccess();
}
void SimpleUI::tabCreated()
{
int tabs = m_webEngine->tabsCount();
+ m_webPageUI->setTabsNumber(tabs);
+}
- if (tabs > m_tabLimit)
- {
+bool SimpleUI::checkIfCreate()
+{
+ int tabs = m_webEngine->tabsCount();
+
+ if (tabs >= m_tabLimit) {
SimplePopup *popup = SimplePopup::createPopup();
- popup->setTitle("Too many tabs open");
- popup->addButton(CONTINUE);
- popup->addButton(CLOSE_TAB);
- popup->setMessage("Browser might slow down. Are you sure you want to continue?");
+ popup->setTitle("Maximum tab count reached.");
+ popup->addButton(OK);
+ popup->setMessage("Close other tabs to open another new tab");
popup->buttonClicked.connect(boost::bind(&SimpleUI::tabLimitPopupButtonClicked, this, _1, _2));
popup->show();
+ return false;
}
- m_webPageUI->setTabsNumber(tabs);
+ else
+ return true;
}
void SimpleUI::updateView() {
void tabClicked(const tizen_browser::basic_webengine::TabId& tabId);
void closeTabsClicked(const tizen_browser::basic_webengine::TabId& tabId);
void tabCreated();
+ bool checkIfCreate();
void tabClosed(const tizen_browser::basic_webengine::TabId& id);
std::vector<std::shared_ptr<tizen_browser::services::BookmarkItem> > getBookmarks(int folder_id = -1);
TabId WebKitEngineService::addTab(const std::string & uri, const TabId * openerId, bool desktopMode)
{
+ AbstractWebEngine::checkIfCreate();
+
+ config::DefaultConfig config;
+ config.load("");
+
+ if (tabsCount() >= boost::any_cast<int>(config.get("TAB_LIMIT")))
+ return currentTabId();
+
BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__);
// searching for next available tabId
M_ASSERT(m_webEngine);
/// \todo: Choose newly created tab.
- TabId id = m_webEngine->addTab(std::string(), &self->getTabId());
- BROWSER_LOGD("Created tab: %s", id.toString().c_str());
-
- Evas_Object* tab_ewk_view = m_webEngine->getTabView(id);
- *static_cast<Evas_Object**>(out) = tab_ewk_view;
+ TabId id;
+ if (m_webEngine->currentTabId() != (id = m_webEngine->addTab(std::string(), &self->getTabId()))) {
+ BROWSER_LOGD("Created tab: %s", id.toString().c_str());
+ Evas_Object* tab_ewk_view = m_webEngine->getTabView(id);
+ *static_cast<Evas_Object**>(out) = tab_ewk_view;
+ }
}
void WebView::__closeWindowRequest(void *data, Evas_Object *, void *)
BROWSER_LOGD("%s:%d %s", __FILE__, __LINE__, __func__);
WebView * self = reinterpret_cast<WebView *>(data);
+
self->m_isLoading = false;
self->m_loadProgress = 1;
WebView * self = reinterpret_cast<WebView *>(data);
self->m_loadProgress = *(double *)event_info;
-
self->loadProgress(self->m_loadProgress);
}
WebView * self = reinterpret_cast<WebView *>(data);
self->m_title = fromChar(ewk_view_title_get(obj));
-
self->titleChanged(self->m_title);
}
double WebView::getZoomFactor() const
{
- if(EINA_UNLIKELY(m_ewkView == nullptr)){
+ if(EINA_UNLIKELY(m_ewkView == nullptr)) {
return 1.0;
}
void WebView::setZoomFactor(double zoomFactor)
{
#if defined(USE_EWEBKIT)
- if(m_ewkView){
+ if(m_ewkView) {
//using zoomFactor = 0 sets zoom "fit to screen"
if(zoomFactor != getZoomFactor())
ewk_view_scroll_by(m_ewkView, dx, dy);
}
-const TabId& WebView::getTabId(){
+const TabId& WebView::getTabId() {
return m_tabId;
}