#include "Tools/EflTools.h"
#include "BrowserImage.h"
#include "SimpleUI.h"
+#include "WebPageUIStatesManager.h"
#include "BookmarkItem.h"
#include "Tools/EflTools.h"
#include "BrowserImage.h"
m_zoomUI->showNavigation();
}
-bool SimpleUI::isErrorPageActive()
-{
- return m_webPageUI->isErrorPageActive();
-}
-
void SimpleUI::showQuickAccess()
{
BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__);
bool SimpleUI::checkBookmark()
{
BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__);
- if (m_webPageUI->isHomePageActive())
+ if(m_webPageUI->stateEquals(WPUState::QUICK_ACCESS))
return false;
if(m_favoriteService->bookmarkExists(m_webEngine->getURI())) {
m_zoomUI->escapeZoom();
} else if ((m_viewManager->topOfStack() == m_tabUI.get()) && m_tabUI->isEditMode()) {
m_tabUI->onBackKey();
- } else if (m_webPageUI->isHomePageActive()) {
+ } else if (m_webPageUI->stateEquals(WPUState::QUICK_ACCESS)) {
m_quickAccess->backButtonClicked();
} else if ((m_viewManager->topOfStack() == m_webPageUI.get()) && !m_webPageUI->getURIEntry().hasFocus() && !m_wvIMEStatus) {
m_webEngine->backButtonClicked();
//no filtering
- if (m_webPageUI->isHomePageActive())
+ if (m_webPageUI->stateEquals(WPUState::QUICK_ACCESS))
openNewTab(url);
else
m_webEngine->setURI(url);
void SimpleUI::showZoomUI()
{
BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__);
- if(! m_webPageUI->isHomePageActive()) {
+ if(! m_webPageUI->stateEquals(WPUState::QUICK_ACCESS)) {
M_ASSERT(m_viewManager);
m_viewManager->popStackTo(m_webPageUI.get());
m_webPageUI->showTabUI.connect(boost::bind(&SimpleUI::closeZoomUI, this));
BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__);
M_ASSERT(m_viewManager);
- bool desktopMode = m_webPageUI->isHomePageActive() ? m_quickAccess->isDesktopMode() : m_webEngine->isDesktopMode();
+ bool desktopMode = m_webPageUI->stateEquals(WPUState::QUICK_ACCESS) ? m_quickAccess->isDesktopMode() : m_webEngine->isDesktopMode();
m_moreMenuUI->setDesktopMode(desktopMode);
m_viewManager->pushViewToStack(m_moreMenuUI.get());
m_moreMenuUI->showCurrentTab();
- if (!m_webPageUI->isHomePageActive()) {
+ if (!m_webPageUI->stateEquals(WPUState::QUICK_ACCESS)) {
m_moreMenuUI->setFavIcon(m_webEngine->getFavicon());
m_moreMenuUI->setWebTitle(m_webEngine->getTitle());
m_moreMenuUI->setURL(m_webEngine->getURI());
void SimpleUI::switchToMobileMode()
{
BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__);
- if (!m_webPageUI->isHomePageActive()) {
+ if (!m_webPageUI->stateEquals(WPUState::QUICK_ACCESS)) {
m_webEngine->switchToMobileMode();
m_viewManager->popStackTo(m_webPageUI.get());
m_webEngine->reload();
void SimpleUI::switchToDesktopMode()
{
BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__);
- if (!m_webPageUI->isHomePageActive()) {
+ if (!m_webPageUI->stateEquals(WPUState::QUICK_ACCESS)) {
m_webEngine->switchToDesktopMode();
m_webEngine->reload();
} else {
BROWSER_LOGD("[%s] Opened tabs: %d", __func__, tabs);
if (tabs == 0) {
switchViewToQuickAccess();
- } else if (!m_webPageUI->isHomePageActive()) {
+ } else if (!m_webPageUI->stateEquals(WPUState::QUICK_ACCESS)) {
switchViewToWebPage();
}
m_webPageUI->setTabsNumber(tabs);
void loadError();
void setErrorButtons();
- bool isErrorPageActive();
void bookmarkAdded();
void bookmarkDeleted();
set(WebPageUI_SRCS
WebPageUI.cpp
+ WebPageUIStatesManager.cpp
ButtonBar.cpp
URIEntry.cpp
UrlHistoryList/UrlHistoryList.cpp
/*
- * GenlistItemsManager.cpp
+ * Copyright (c) 2015 Samsung Electronics Co., Ltd.
*
- * Created on: Oct 23, 2015
- * Author: a.skobodzins
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
*/
#include "GenlistItemsManager.h"
/*
- * GenlistItemsManager.h
+ * Copyright (c) 2015 Samsung Electronics Co., Ltd.
*
- * Created on: Oct 23, 2015
- * Author: a.skobodzins
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
*/
#ifndef GENLISTITEMSMANAGER_H_
#include "ServiceManager.h"
#include "BrowserAssert.h"
#include "UrlHistoryList/UrlHistoryList.h"
+#include "WebPageUIStatesManager.h"
namespace tizen_browser {
namespace base_ui {
, m_bookmarkManagerButton(nullptr)
, m_URIEntry(new URIEntry())
, m_urlHistoryList(std::make_shared<UrlHistoryList>())
- , m_homePageActive(false)
+ , m_statesMgr(std::make_shared<WebPageUIStatesManager>(WPUState::MAIN_WEB_PAGE))
, m_webviewLocked(false)
{
BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__);
evas_object_show(elm_object_part_content_get(m_mainLayout, "uri_bar_buttons_left"));
evas_object_show(elm_object_part_content_get(m_mainLayout, "uri_bar_buttons_right"));
- if (m_homePageActive)
+ if(m_statesMgr->equals(WPUState::QUICK_ACCESS))
showQuickAccess();
else
m_URIEntry->showPageTitle();
elm_object_focus_custom_chain_unset(m_mainLayout);
evas_object_hide(m_mainLayout);
- if (m_homePageActive)
+ if(m_statesMgr->equals(WPUState::QUICK_ACCESS))
hideQuickAccess();
evas_object_hide(elm_object_part_content_get(m_mainLayout, "web_view"));
}
}
+bool WebPageUI::stateEquals(WPUState state) const
+{
+ return m_statesMgr->equals(state);
+}
+
+bool WebPageUI::stateEquals(std::initializer_list<WPUState> states) const
+{
+ return m_statesMgr->equals(states);
+}
+
void WebPageUI::loadFinished()
{
BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__);
m_URIEntry->showPageTitle();
}
-bool WebPageUI::isErrorPageActive()
-{
- return elm_object_part_content_get(m_mainLayout, "web_view") == m_errorLayout;
-}
-
void WebPageUI::setPageTitle(const std::string& title)
{
BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__);
m_URIEntry->setPageTitle(title);
}
-bool WebPageUI::isIncognitoPageActive()
-{
- return elm_object_part_content_get(m_mainLayout, "web_view") == m_privateLayout;
-}
-
void WebPageUI::toIncognito(bool incognito)
{
BROWSER_LOGD("[%s:%d,%d] ", __PRETTY_FUNCTION__, __LINE__, incognito);
void WebPageUI::switchViewToErrorPage()
{
BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__);
- m_homePageActive = false;
+ m_statesMgr->set(WPUState::MAIN_ERROR_PAGE);
setMainContent(m_errorLayout);
evas_object_show(m_leftButtonBar->getContent());
elm_object_signal_emit(m_mainLayout, "shiftright_uri", "ui");
void WebPageUI::switchViewToIncognitoPage()
{
- BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__);
- m_homePageActive = false;
+ BROWSER_LOGD("@@ [%s:%d] ", __PRETTY_FUNCTION__, __LINE__);
+ m_statesMgr->set(WPUState::MAIN_INCOGNITO_PAGE);
setMainContent(m_privateLayout);
evas_object_show(m_leftButtonBar->getContent());
elm_object_signal_emit(m_mainLayout, "shiftright_uri", "ui");
void WebPageUI::switchViewToWebPage(Evas_Object* content, const std::string uri, const std::string title)
{
- BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__);
- if (m_homePageActive)
+ BROWSER_LOGD("@@ [%s:%d] ", __PRETTY_FUNCTION__, __LINE__);
+ if(m_statesMgr->equals(WPUState::QUICK_ACCESS))
{
hideQuickAccess();
- m_homePageActive = false;
+ m_statesMgr->set(WPUState::MAIN_WEB_PAGE);
}
setMainContent(content);
updateURIBar(uri);
{
BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__);
- m_homePageActive = true;
+ m_statesMgr->set(WPUState::QUICK_ACCESS);
setMainContent(content);
evas_object_hide(m_leftButtonBar->getContent());
elm_object_signal_emit(m_mainLayout, "shiftback_uri", "ui");
{
BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__);
WebPageUI* self = reinterpret_cast<WebPageUI*>(data);
- if (!self->isHomePageActive() && !self->isErrorPageActive()) {
+ if(!self->stateEquals({ WPUState::QUICK_ACCESS, WPUState::MAIN_ERROR_PAGE })) {
self->getURIEntry().clearFocus();
}
}
{
BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__);
if(isWebPageUIvisible()) {
- if(!isHomePageActive() && !isErrorPageActive()) {
+ if(m_statesMgr->equals(WPUState::MAIN_WEB_PAGE)) {
elm_object_focus_custom_chain_unset(m_mainLayout);
elm_object_focus_custom_chain_append(m_mainLayout, elm_object_part_content_get(m_mainLayout, "web_view"), NULL);
m_webviewLocked = true;
{
BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__);
if(isWebPageUIvisible()) {
- if(!isHomePageActive()) {
+ if(m_statesMgr->equals(WPUState::MAIN_WEB_PAGE)) {
if(m_webviewLocked) {
refreshFocusChain();
m_URIEntry->setFocus();
// set custom focus chain
elm_object_focus_custom_chain_unset(m_mainLayout);
elm_object_focus_custom_chain_append(m_mainLayout, m_rightButtonBar->getContent(), NULL);
- if (!m_homePageActive) {
+ if(!m_statesMgr->equals(WPUState::QUICK_ACCESS)) {
elm_object_focus_custom_chain_append(m_mainLayout, m_leftButtonBar->getContent(), NULL);
elm_object_focus_custom_chain_append(m_mainLayout, m_bookmarkManagerButton, NULL);
} else {
namespace tizen_browser {
namespace base_ui {
+class WebPageUIStatesManager;
+enum class WPUState;
+typedef std::shared_ptr<WebPageUIStatesManager> WPUStatesManagerPtr;
+typedef std::shared_ptr<const WebPageUIStatesManager> WPUStatesManagerPtrConst;
class UrlHistoryList;
typedef std::shared_ptr<UrlHistoryList> UrlHistoryPtr;
void loadStarted();
void progressChanged(double progress);
void loadFinished();
- bool isErrorPageActive();
- bool isIncognitoPageActive();
- bool isHomePageActive() { return m_homePageActive; }
+ WPUStatesManagerPtrConst getStatesMgr() {return m_statesMgr;}
+ /**
+ * @param state The state to compare
+ * @returns True if manager's state equals to given state
+ */
+ bool stateEquals(WPUState state) const;
+ /**
+ * @param states The states to compare
+ * @returns True if one of the given states equals to the manager's state
+ */
+ bool stateEquals(std::initializer_list<WPUState> states) const;
bool isWebPageUIvisible() { return m_WebPageUIvisible; }
void toIncognito(bool);
void switchViewToErrorPage();
std::unique_ptr<ButtonBar> m_rightButtonBar;
std::unique_ptr<URIEntry> m_URIEntry;
UrlHistoryPtr m_urlHistoryList;
- bool m_homePageActive;
+ WPUStatesManagerPtr m_statesMgr;
bool m_webviewLocked;
bool m_WebPageUIvisible;
--- /dev/null
+/*
+ * Copyright (c) 2015 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "WebPageUIStatesManager.h"
+#include "BrowserLogger.h"
+
+namespace tizen_browser {
+namespace base_ui {
+
+WebPageUIStatesManager::WebPageUIStatesManager(WPUState initialState) :
+ m_state(initialState)
+{
+ namesMap = {
+ { WPUState::QUICK_ACCESS, "QUICK_ACCESS" },
+ { WPUState::MAIN_WEB_PAGE, "MAIN_WEB_PAGE" },
+ { WPUState::MAIN_ERROR_PAGE, "MAIN_ERROR_PAGE" },
+ { WPUState::MAIN_INCOGNITO_PAGE, "MAIN_INCOGNITO_PAGE" }
+ };
+}
+
+void WebPageUIStatesManager::set(WPUState state) {
+ m_state = state;
+}
+
+bool WebPageUIStatesManager::equals(WPUState state) const
+{
+ return (m_state == state);
+}
+
+bool WebPageUIStatesManager::equals(std::initializer_list<WPUState> states) const
+{
+ for (auto s : states) {
+ if (equals(s))
+ return true;
+ }
+ return false;
+}
+
+std::string WebPageUIStatesManager::toString(WPUState state) const
+{
+ return namesMap.find(state)->second;
+}
+
+} /* namespace base_ui */
+} /* namespace tizen_browser */
--- /dev/null
+/*
+ * Copyright (c) 2015 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef WEBPAGEUISTATESMANAGER_H_
+#define WEBPAGEUISTATESMANAGER_H_
+
+#include <map>
+#include <string>
+#include <initializer_list>
+
+namespace tizen_browser {
+namespace base_ui {
+
+enum class WPUState {
+ QUICK_ACCESS,
+ // displaying web page content
+ MAIN_WEB_PAGE,
+ MAIN_ERROR_PAGE,
+ // displaying incognito message page
+ MAIN_INCOGNITO_PAGE
+};
+
+class WebPageUIStatesManager
+{
+public:
+ WebPageUIStatesManager(WPUState initialState);
+ virtual ~WebPageUIStatesManager() {}
+
+ void set(WPUState state);
+
+ /**
+ * @param state The state to compare.
+ * @return True if current state equals the passed state
+ */
+ bool equals(WPUState state) const;
+
+ /**
+ * @param states The states to compare.
+ * @return True if current state is included in states to compare
+ */
+ bool equals(std::initializer_list<WPUState> states) const;
+
+private:
+ std::string toString(WPUState state) const;
+ WPUState m_state;
+ std::map<WPUState, std::string> namesMap;
+
+};
+
+} /* namespace base_ui */
+} /* namespace tizen_browser */
+
+#endif /* WEBPAGEUISTATESMANAGER_H_ */