Initial secret mode implementation 09/85909/8
authorMaciej Skrzypkowski <m.skrzypkows@samsung.com>
Wed, 31 Aug 2016 13:11:02 +0000 (15:11 +0200)
committerHye Kyoung Hwang <cookie@samsung.com>
Thu, 1 Sep 2016 06:32:55 +0000 (23:32 -0700)
[Issue]    http://suprem.sec.samsung.net/jira/browse/TWF-1897
[Problem]  No secret mode
[Solution] Added secret mode switch in TabUI, added two list of
           tabs in WebEngineService, changed colors in WebPageUI
[Verify]   Open few tabs, switch to secret mode in tab manager, open
           few tabs in secret mode, switch again to normal mode,
           check if previous tabs list appear.

Change-Id: I82a143428275416ca381b9b868245e25a181dc07
Signed-off-by: Maciej Skrzypkowski <m.skrzypkows@samsung.com>
22 files changed:
core/AbstractWebEngine/AbstractWebEngine.h
core/AbstractWebEngine/State.h [new file with mode: 0644]
core/BasicUI/NaviframeWrapper.cpp
core/BasicUI/NaviframeWrapper.h
core/Tools/edc/ColorClasses.edc
services/SimpleUI/ContentPopup_mob.h
services/SimpleUI/SimpleUI.cpp
services/SimpleUI/SimpleUI.h
services/TabService/TabService.h
services/TabUI/TabUI.cpp
services/TabUI/TabUI.h
services/WebEngineService/WebEngineService.cpp
services/WebEngineService/WebEngineService.h
services/WebEngineService/WebView.cpp
services/WebEngineService/WebView.h
services/WebPageUI/ButtonBar.cpp
services/WebPageUI/ButtonBar.h
services/WebPageUI/WebPageUI.cpp
services/WebPageUI/WebPageUI.h
services/WebPageUI/edc/ImageButton.edc
services/WebPageUI/edc/WebPageUI.edc
unit_tests/ut_WebEngineService.cpp

index b9095b6d20ccd1639d894be709e3e068e6d8e621..f1aebe678c127474ce4989cbbec8340f9daeee5d 100644 (file)
@@ -32,6 +32,7 @@
 #include "TabOrigin.h"
 #include "WebConfirmation.h"
 #include "WebEngineSettings.h"
+#include "State.h"
 
 namespace tizen_browser {
 namespace basic_webengine {
@@ -40,9 +41,8 @@ namespace basic_webengine {
  * It is designed for multiple tabs operations.
  * It is designed to be only way for communication with WebEngine. It should NOT return WebEngine object.
  */
-template<typename T>
 #ifndef NDEBUG
-class AbstractWebEngine : public tizen_browser::core::AbstractService, ShowLifeCycle<AbstractWebEngine<T>>
+class AbstractWebEngine: public tizen_browser::core::AbstractService, ShowLifeCycle<AbstractWebEngine>
 #else
 class AbstractWebEngine: public tizen_browser::core::AbstractService
 #endif
@@ -53,14 +53,13 @@ public:
      * Remember that there must be at least 1 tab created to return layout
      * @return pointer Evas_Object for current WebView.
      */
-    virtual * getLayout() = 0;
+    virtual Evas_Object* getLayout() = 0;
 
     /**
      * Initialize WebEngine.
-     * @param guiParent GUI parent object (now should pass Evas_Object)
-     * \todo make guiParent nonEFL object
+     * @param guiParent GUI parent object
      */
-    virtual void init(void * guiParent) = 0;
+    virtual void init(Evas_Object* guiParent) = 0;
 
     /**
      * Preinitialize WebView parameters.
@@ -176,23 +175,20 @@ public:
      * @param tabId Tab id of the new tab. If boost::none, tab's id will be
      * generated
      * @param desktopMode true if desktop mode, false if mobile mode
-     * @param incognitoMode true if incognito mode, false if not
      * @return TabId of created tab
      */
     virtual TabId addTab(
             const std::string& uri = std::string(),
-            const TabId* openerId = NULL,
             const boost::optional<int> tabId = boost::none,
             const std::string& title = std::string(),
             bool desktopMode = true,
-            bool incognitoMode = false,
             TabOrigin origin = TabOrigin::UNKNOWN) = 0;
 
     /**
      * @param tab id
      * @return returns underlaying UI component
      */
-    virtual T* getTabView(TabId id) = 0;
+    virtual Evas_Object* getTabView(TabId id) = 0;
 
     /**
      * Switch current tab for tab with tabId
@@ -234,12 +230,12 @@ public:
             bool async, tizen_browser::tools::SnapshotType snapshot_type) = 0;
 
     /**
-     * Get the state of private mode for a specific tab
+     * Get the state of secret mode
      *
      * /param id of snapshot
      * /return state of private mode
      */
-    virtual bool isPrivateMode(const TabId&) = 0;
+    virtual bool isSecretMode() = 0;
 
     virtual bool isLoadError() const = 0;
 
@@ -366,7 +362,6 @@ public:
      */
     virtual void onTabIdCreated(int tabId) = 0;
 
-#if PROFILE_MOBILE
     /**
      * @brief Searches for word in the current page.
      *
@@ -396,7 +391,16 @@ public:
      * @brief Informs WebEngine that device orientation is changed.
      */
     virtual void orientationChanged() = 0;
-#endif
+
+    /**
+     * @brief set next state
+     */
+    virtual void changeState() = 0;
+
+    /**
+     * @brief Get current state of the engine
+     */
+    virtual State getState() = 0;
 
     /**
      * Ask browser to minimize itself
diff --git a/core/AbstractWebEngine/State.h b/core/AbstractWebEngine/State.h
new file mode 100644 (file)
index 0000000..f5e1579
--- /dev/null
@@ -0,0 +1,31 @@
+/*
+ * Copyright (c) 2014 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 __STATE_H__
+#define __STATE_H__
+
+namespace tizen_browser {
+namespace basic_webengine {
+
+enum class State {
+    NORMAL,
+    SECRET
+};
+
+}
+}
+
+#endif  // __STATE_H__
\ No newline at end of file
index 733d5e37ada720922efd97538f27ef197e94ec42..21864d3710e6de6ac90f5a27a78bd389ebbcad8e 100644 (file)
@@ -207,17 +207,23 @@ void NaviframeWrapper::addButtonToBottomBar(std::string text, Evas_Smart_Cb call
     evas_object_smart_callback_add(button, "clicked", callback, data);
 
     elm_box_pack_end(m_bottom_box, button);
-    m_map_bottom_box.insert(std::pair<std::string, Evas_Object*>(text, button));
+    m_bottom_buttons.push_back(button);
     evas_object_show(button);
 
 }
 
-void NaviframeWrapper::setEnableButtonInBottomBar(std::string text, bool enabled)
+void NaviframeWrapper::setEnableButtonInBottomBar(int number, bool enabled)
 {
     if (enabled)
-        elm_object_signal_emit(m_map_bottom_box[text], "elm,state,enabled", "elm");
+        elm_object_signal_emit(m_bottom_buttons[number], "elm,state,enabled", "elm");
     else
-        elm_object_signal_emit(m_map_bottom_box[text], "elm,state,disabled", "elm");
+        elm_object_signal_emit(m_bottom_buttons[number], "elm,state,disabled", "elm");
+}
+
+void NaviframeWrapper::setBottomButtonText(int number, const std::string& text)
+{
+    BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__);
+    elm_object_part_text_set(m_bottom_buttons[number], "elm.text", text.c_str());
 }
 
 void NaviframeWrapper::setVisibleBottomBar(bool visible)
index f907e7d325eca2946807547c504d0e45c31b0a7c..065e4bab5765cdecfc926ea12f5b188c349d5f34 100644 (file)
@@ -64,14 +64,15 @@ public:
     void createBottomBar(Evas_Object* layout = nullptr,
         std::string swallow_name = "elm.swallow.content");
     void addButtonToBottomBar(std::string text, Evas_Smart_Cb callback, void* data);
-    void setEnableButtonInBottomBar(std::string text, bool enabled);
+    void setEnableButtonInBottomBar(int number, bool enabled);
+    void setBottomButtonText(int number, const std::string& text);
     void setVisibleBottomBar(bool visible);
 
 protected:
     Evas_Object *m_parent;
     Evas_Object *m_layout;
     Evas_Object *m_bottom_box;
-    std::map<std::string, Evas_Object*> m_map_bottom_box;
+    std::vector<Evas_Object*> m_bottom_buttons;
 };
 
 using SharedNaviframeWrapper = std::shared_ptr<NaviframeWrapper>;
index 48925d385375d2866ef6681837233f338ef8b829..16d80345a7e7a0a6980d86f7e32067a7425a06b7 100644 (file)
@@ -29,7 +29,10 @@ color_classes {
         name: "AO035";
         color: 255 255 255 230;
     }
-
+    color_class {
+        name: "secret";
+        color: 97 97 97 255;
+    }
 //Font colors
     color_class {
         name: "ATO015";
index 708c7580b3f4e065ed768e95fe44d89c11db9518..953cf238b85880e34d614e15d4fa05177a75c3c3 100644 (file)
@@ -20,8 +20,6 @@
 #include <Evas.h>
 #include <Elementary.h>
 #include <string>
-#include <list>
-#include <memory>
 
 #include "AbstractPopup.h"
 #include "PopupButtons.h"
index 32cb38faa2a093067d5a28e24e03e3a65b3fc1dc..6f475d68e69bea62f57ae31777b3ac367bc10006 100755 (executable)
@@ -295,16 +295,16 @@ void SimpleUI::connectUISignals()
 //    m_webPageUI->getUrlHistoryList()->openURL.connect(boost::bind(&SimpleUI::onOpenURL, this, _1));
 //    m_webPageUI->getUrlHistoryList()->uriChanged.connect(boost::bind(&SimpleUI::filterURL, this, _1));
     m_webPageUI->backPage.connect(boost::bind(&SimpleUI::switchViewToWebPage, this));
-    m_webPageUI->backPage.connect(boost::bind(&tizen_browser::basic_webengine::AbstractWebEngine<Evas_Object>::back, m_webEngine.get()));
+    m_webPageUI->backPage.connect(boost::bind(&basic_webengine::AbstractWebEngine::back, m_webEngine.get()));
     m_webPageUI->showTabUI.connect(boost::bind(&SimpleUI::showTabUI, this));
     m_webPageUI->showBookmarksUI.connect(boost::bind(&SimpleUI::showBookmarkManagerUI, this,
         m_favoriteService->getRoot(), BookmarkManagerState::Default));
     m_webPageUI->showHomePage.connect(boost::bind(&SimpleUI::showHomePage, this));
-    m_webPageUI->forwardPage.connect(boost::bind(&tizen_browser::basic_webengine::AbstractWebEngine<Evas_Object>::forward, m_webEngine.get()));
+    m_webPageUI->forwardPage.connect(boost::bind(&basic_webengine::AbstractWebEngine::forward, m_webEngine.get()));
     m_webPageUI->showQuickAccess.connect(boost::bind(&SimpleUI::showQuickAccess, this));
     m_webPageUI->hideQuickAccess.connect(boost::bind(&QuickAccess::hideUI, m_quickAccess));
-    m_webPageUI->focusWebView.connect(boost::bind(&tizen_browser::basic_webengine::AbstractWebEngine<Evas_Object>::setFocus, m_webEngine.get()));
-    m_webPageUI->unfocusWebView.connect(boost::bind(&tizen_browser::basic_webengine::AbstractWebEngine<Evas_Object>::clearFocus, m_webEngine.get()));
+    m_webPageUI->focusWebView.connect(boost::bind(&basic_webengine::AbstractWebEngine::setFocus, m_webEngine.get()));
+    m_webPageUI->unfocusWebView.connect(boost::bind(&basic_webengine::AbstractWebEngine::clearFocus, m_webEngine.get()));
     m_webPageUI->bookmarkManagerClicked.connect(boost::bind(&SimpleUI::showBookmarkManagerUI, this,
         m_favoriteService->getRoot(), BookmarkManagerState::Default));
     m_webPageUI->getWindow.connect(boost::bind(&SimpleUI::getMainWindow, this));
@@ -320,12 +320,13 @@ void SimpleUI::connectUISignals()
     m_webPageUI->getURIEntry().secureIconClicked.connect(boost::bind(&SimpleUI::showCertificatePopup, this));
     m_webPageUI->getURIEntry().isValidCert.connect(boost::bind(&services::CertificateContents::isValidCertificate, m_certificateContents, _1));
     m_webPageUI->getURIEntry().reloadPage.connect(
-        boost::bind(&tizen_browser::basic_webengine::AbstractWebEngine<Evas_Object>::reload, m_webEngine.get()));
+        boost::bind(&basic_webengine::AbstractWebEngine::reload, m_webEngine.get()));
     m_webPageUI->getURIEntry().stopLoadingPage.connect(
-        boost::bind(&tizen_browser::basic_webengine::AbstractWebEngine<Evas_Object>::stopLoading, m_webEngine.get()));
+        boost::bind(&basic_webengine::AbstractWebEngine::stopLoading, m_webEngine.get()));
     m_webPageUI->isLandscape.connect(boost::bind(&SimpleUI::isLandscape, this));
     m_webPageUI->switchToMobileMode.connect(boost::bind(&SimpleUI::switchToMobileMode, this));
     m_webPageUI->switchToDesktopMode.connect(boost::bind(&SimpleUI::switchToDesktopMode, this));
+    m_webPageUI->getEngineState.connect(boost::bind(&basic_webengine::AbstractWebEngine::getState, m_webEngine.get()));
     // WPA
     m_webPageUI->requestCurrentPageForWebPageUI.connect(boost::bind(&SimpleUI::requestSettingsCurrentPage, this));
 
@@ -345,6 +346,9 @@ void SimpleUI::connectUISignals()
     m_tabUI->closeTabsClicked.connect(boost::bind(&SimpleUI::closeTabsClicked, this,_1));
     m_tabUI->getWindow.connect(boost::bind(&SimpleUI::getMainWindow, this));
     m_tabUI->isLandscape.connect(boost::bind(&SimpleUI::isLandscape, this));
+    m_tabUI->changeEngineState.connect(boost::bind(&basic_webengine::AbstractWebEngine::changeState, m_webEngine.get()));
+    m_tabUI->changeEngineState.connect(boost::bind(&SimpleUI::changeEngineState, this));
+    m_tabUI->refetchTabUIData.connect(boost::bind(&SimpleUI::refetchTabUIData, this));
 
     M_ASSERT(m_historyUI.get());
     m_historyUI->clearHistoryClicked.connect(boost::bind(&SimpleUI::onClearHistoryAllClicked, this));
@@ -394,7 +398,7 @@ void SimpleUI::loadModelServices()
 
     m_webEngine =
         std::dynamic_pointer_cast
-        <basic_webengine::AbstractWebEngine<Evas_Object>,tizen_browser::core::AbstractService>
+        <basic_webengine::AbstractWebEngine,tizen_browser::core::AbstractService>
         (tizen_browser::core::ServiceManager::getInstance().getService("org.tizen.browser.webengineservice"));
 
     m_storageService =
@@ -442,7 +446,7 @@ void SimpleUI::connectSettingsSignals()
         boost::bind(&SimpleUI::showSettings, this,_1));
     SPSC.getWebEngineSettingsParam.connect(
         boost::bind(
-            &basic_webengine::AbstractWebEngine<Evas_Object>::getSettingsParam,
+            &basic_webengine::AbstractWebEngine::getSettingsParam,
             m_webEngine.get(),
             _1));
     SPSC. getWebEngineSettingsParamString.connect(
@@ -453,7 +457,7 @@ void SimpleUI::connectSettingsSignals()
 
     SPSC.setWebEngineSettingsParam.connect(
         boost::bind(
-            &basic_webengine::AbstractWebEngine<Evas_Object>::setSettingsParam,
+            &basic_webengine::AbstractWebEngine::setSettingsParam,
             m_webEngine.get(),
             _1,
             _2));
@@ -559,7 +563,6 @@ void SimpleUI::connectModelSignals()
     m_webEngine->loadProgress.connect(boost::bind(&SimpleUI::progressChanged,this,_1));
     m_webEngine->loadFinished.connect(boost::bind(&SimpleUI::loadFinished, this));
     m_webEngine->loadStop.connect(boost::bind(&SimpleUI::loadFinished, this));
-    m_webEngine->loadError.connect(boost::bind(&SimpleUI::loadError, this));
     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));
@@ -597,7 +600,7 @@ void SimpleUI::connectModelSignals()
     m_certificateContents->addOrUpdateCertificateEntry.connect(boost::bind(&storage::CertificateStorage::addOrUpdateCertificateEntry, &m_storageService->getCertificateStorage(), _1, _2, _3));
 
 #if PROFILE_MOBILE
-    m_storageService->getSettingsStorage().setWebEngineSettingsParam.connect(boost::bind(&basic_webengine::AbstractWebEngine<Evas_Object>::setSettingsParam, m_webEngine.get(), _1, _2));
+    m_storageService->getSettingsStorage().setWebEngineSettingsParam.connect(boost::bind(&basic_webengine::AbstractWebEngine::setSettingsParam, m_webEngine.get(), _1, _2));
     m_platformInputManager->menuButtonPressed.connect(boost::bind(&SimpleUI::onMenuButtonPressed, this));
     m_platformInputManager->XF86BackPressed.connect(boost::bind(&SimpleUI::onXF86BackPressed, this));
     m_webEngine->registerHWKeyCallback.connect(boost::bind(&SimpleUI::registerHWKeyCallback, this));
@@ -627,22 +630,14 @@ void SimpleUI::switchViewToWebPage()
         m_webEngine->resume();
     m_webEngine->connectCurrentWebViewSignals();
     m_webPageUI->switchViewToWebPage(m_webEngine->getLayout(), m_webEngine->getURI(), m_webEngine->isLoading());
-    m_webPageUI->toIncognito(m_webEngine->isPrivateMode(m_webEngine->currentTabId()));
 }
 
 void SimpleUI::switchToTab(const tizen_browser::basic_webengine::TabId& tabId)
 {
     BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__);
     if(m_webEngine->currentTabId() != tabId) {
-        BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__);
         m_webEngine->switchToTab(tabId);
     }
-    if(m_webEngine->isLoadError()){
-        BROWSER_LOGD("[%s:%d] LOAD ERROR!", __PRETTY_FUNCTION__, __LINE__);
-        loadError();
-    return;
-    }
-    BROWSER_LOGD("[%s:%d] swiching to web_view ", __PRETTY_FUNCTION__, __LINE__);
     switchViewToWebPage();
 }
 
@@ -674,13 +669,12 @@ void SimpleUI::openNewTab(const std::string &uri, const std::string& title,
 {
     BROWSER_LOGD("[%s:%d] uri =%s", __PRETTY_FUNCTION__, __LINE__, uri.c_str());
     tizen_browser::basic_webengine::TabId tab = m_webEngine->addTab(uri,
-            nullptr, adaptorId, title, desktopMode, incognitoMode, origin);
+            adaptorId, title, desktopMode, origin);
     if (tab == basic_webengine::TabId::NONE) {
         BROWSER_LOGW("[%s:%d] New tab is not created!", __PRETTY_FUNCTION__, __LINE__);
         return;
     }
     switchToTab(tab);
-    m_webPageUI->toIncognito(incognitoMode);
     if (incognitoMode)
         switchViewToIncognitoPage();
 }
@@ -929,8 +923,12 @@ void SimpleUI::onSnapshotCaptured(std::shared_ptr<tools::BrowserImage> snapshot,
     BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__);
     switch (snapshot_type) {
     case tools::SnapshotType::ASYNC_LOAD_FINISHED:
-        m_historyService->updateHistoryItemSnapshot(m_webEngine->getURI(), snapshot);
-        m_tabService->updateTabItemSnapshot(m_webEngine->currentTabId(), snapshot);
+        if (m_webEngine->isSecretMode()) {
+            m_tabService->saveThumbCache(m_webEngine->currentTabId(), snapshot);
+        } else {
+            m_historyService->updateHistoryItemSnapshot(m_webEngine->getURI(), snapshot);
+            m_tabService->updateTabItemSnapshot(m_webEngine->currentTabId(), snapshot);
+        }
         break;
     case tools::SnapshotType::ASYNC_TAB:
         m_tabService->updateTabItemSnapshot(m_webEngine->currentTabId(), snapshot);
@@ -1157,7 +1155,7 @@ void SimpleUI::loadFinished()
     BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__);
     m_webPageUI->loadFinished();
 #if PROFILE_MOBILE
-    if (!m_webEngine->isPrivateMode(m_webEngine->currentTabId())) {
+    if (!m_webEngine->isSecretMode()) {
         m_tabService->updateTabItem(m_webEngine->currentTabId(),
                 m_webEngine->getURI(),
                 m_webEngine->getTitle(),
@@ -1169,14 +1167,6 @@ void SimpleUI::loadFinished()
 #endif
 }
 
-void SimpleUI::loadError()
-{
-    BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__);
-#if !PROFILE_MOBILE
-    m_webPageUI->switchViewToErrorPage();
-#endif
-}
-
 void SimpleUI::filterURL(const std::string& url)
 {
     BROWSER_LOGD("[%s:%d] url=%s", __PRETTY_FUNCTION__, __LINE__, url.c_str());
@@ -1199,7 +1189,7 @@ void SimpleUI::filterURL(const std::string& url)
         else
             m_webEngine->setURI(url);
 
-        if (m_webEngine->isPrivateMode(m_webEngine->currentTabId()) ||
+        if (m_webEngine->isSecretMode() ||
                 m_webPageUI->stateEquals(WPUState::MAIN_ERROR_PAGE))
             switchViewToWebPage();
     }
@@ -1309,6 +1299,14 @@ void SimpleUI::closeTabUI()
         m_viewManager.popTheStack();
 }
 
+void SimpleUI::refetchTabUIData() {
+    m_tabUI->setState(m_webEngine->getState());
+    std::vector<basic_webengine::TabContentPtr> tabsContents =
+            m_webEngine->getTabContents();
+    m_tabService->fillThumbs(tabsContents);
+    m_tabUI->addTabItems(tabsContents);
+}
+
 void SimpleUI::newTabClicked()
 {
     BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__);
@@ -1321,9 +1319,8 @@ void SimpleUI::newTabClicked()
 void SimpleUI::tabClicked(const tizen_browser::basic_webengine::TabId& tabId)
 {
     BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__);
-    m_viewManager.popStackTo(m_webPageUI.get());
-    m_webPageUI->toIncognito(m_webEngine->isPrivateMode(tabId));
     switchToTab(tabId);
+    m_viewManager.popStackTo(m_webPageUI.get());
 }
 
 void SimpleUI::closeTabsClicked(const tizen_browser::basic_webengine::TabId& tabId)
@@ -1790,6 +1787,13 @@ void SimpleUI::updateView()
     m_webPageUI->setTabsNumber(tabs);
 }
 
+void SimpleUI::changeEngineState()
+{
+    m_webEngine->disconnectCurrentWebViewSignals();
+    m_webPageUI->switchViewToQuickAccess(m_quickAccess->getContent());
+    updateView();
+}
+
 void SimpleUI::windowCreated()
 {
     BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__);
index 57770c524ac0011e2f00dbc87529ce9466df9369..9c037b585ba55b8062226dc1027bc5f611ee7b20 100644 (file)
@@ -104,7 +104,6 @@ private:
     void loadFinished();
     void progressChanged(double progress);
     void loadStarted();
-    void loadError();
 
     void setErrorButtons();
 
@@ -116,6 +115,7 @@ private:
     void switchViewToIncognitoPage();
     void switchViewToWebPage();
     void updateView();
+    void changeEngineState();
     void windowCreated();
     void minimizeBrowser();
 
@@ -252,6 +252,7 @@ private:
 
     void showTabUI();
     void closeTabUI();
+    void refetchTabUIData();
     void switchToMobileMode();
     void switchToDesktopMode();
     Evas_Object* showHistoryUI(Evas_Object* parent, SharedNaviframeWrapper naviframe, bool removeMode = false);
@@ -322,7 +323,7 @@ private:
     std::vector<interfaces::AbstractPopup*> m_popupVector;
 
     std::shared_ptr<WebPageUI> m_webPageUI;
-    std::shared_ptr<basic_webengine::AbstractWebEngine<Evas_Object>>  m_webEngine;
+    std::shared_ptr<basic_webengine::AbstractWebEngine>  m_webEngine;
     std::shared_ptr<interfaces::AbstractFavoriteService> m_favoriteService;
     std::shared_ptr<services::HistoryService> m_historyService;
     services::TabServicePtr m_tabService;
index 0259d2df083207d919c5a06cce06606d61e1e956..6b42b04085eaff9116288447f0579833fe27f486 100644 (file)
@@ -92,7 +92,11 @@ public:
 
     void updateTabItemSnapshot(const basic_webengine::TabId& tabId,
             tools::BrowserImagePtr imagePtr);
-
+    /**
+     * Cache given thumb image with given tab id.
+     */
+    void saveThumbCache(const basic_webengine::TabId& tabId,
+        tools::BrowserImagePtr imagePtr);
 private:
     /**
      * Help method printing last bp_tab_error_defs error.
@@ -112,11 +116,6 @@ private:
      */
     boost::optional<tools::BrowserImagePtr> getThumbCache(
             const basic_webengine::TabId& tabId);
-    /**
-     * Cache given thumb image with given tab id.
-     */
-    void saveThumbCache(const basic_webengine::TabId& tabId,
-            tools::BrowserImagePtr imagePtr);
     /**
      * Check if thumb for given id is in a map.
      */
index cd832435df711dd397f7c4993c666c6ec55a418d..6439086b52b4f9c15261b528a9ae3abb7433bfc8 100644 (file)
@@ -137,10 +137,10 @@ void TabUI::createBottomContent()
     m_naviframe->setVisibleBottomBar(true);
     //TODO: Missing translation
     m_naviframe->addButtonToBottomBar("Enable Secret", _enable_secret_clicked, this);
-    m_naviframe->setEnableButtonInBottomBar("Enable Secret", true);
+    m_naviframe->setEnableButtonInBottomBar(0, true);
     //TODO: _("IDS_BR_OPT_NEW_TAB") when it works
     m_naviframe->addButtonToBottomBar("New tab", _new_tab_clicked, this);
-    m_naviframe->setEnableButtonInBottomBar("New tab", true);
+    m_naviframe->setEnableButtonInBottomBar(1, true);
 }
 
 void TabUI::createEmptyLayout()
@@ -235,6 +235,20 @@ void TabUI::showContextMenu()
     }
 }
 
+void TabUI::setState(basic_webengine::State state)
+{
+    switch(state) {
+        case basic_webengine::State::NORMAL:
+            m_naviframe->setBottomButtonText(0, "Enable Secret");
+            break;
+        case basic_webengine::State::SECRET:
+            m_naviframe->setBottomButtonText(0, "Disable Secret");
+            break;
+        default:
+            BROWSER_LOGE("[%s:%d] Unknown state!", __PRETTY_FUNCTION__, __LINE__);
+    }
+}
+
 void TabUI::_cm_sync_clicked(void* data, Evas_Object*, void* )
 {
     BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__);
@@ -309,6 +323,9 @@ void TabUI::_enable_secret_clicked(void* data, Evas_Object*, void*)
 {
     BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__);
     if (data) {
+        auto self = static_cast<TabUI*>(data);
+        self->changeEngineState();
+        self->refetchTabUIData();
     } else {
         BROWSER_LOGW("[%s] data = nullptr", __PRETTY_FUNCTION__);
     }
@@ -344,6 +361,7 @@ void TabUI::addTabItem(basic_webengine::TabContentPtr hi)
 void TabUI::addTabItems(std::vector<basic_webengine::TabContentPtr>& items)
 {
     BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__);
+    elm_gengrid_clear(m_gengrid);
     for (auto it = items.begin(); it < items.end(); ++it)
         addTabItem(*it);
     updateNoTabsText();
index 1008e11327249bb287383e53f0d0567529dcccbc..daaae841084cadf57527f323d90e37d6498b57e5 100644 (file)
@@ -23,6 +23,7 @@
 #include "AbstractContextMenu.h"
 #include "AbstractUIComponent.h"
 #include "AbstractService.h"
+#include "AbstractWebEngine/State.h"
 #include "ServiceFactory.h"
 #include "service_macros.h"
 #include "TabIdTypedef.h"
@@ -55,10 +56,14 @@ public:
     //AbstractContextMenu interface implementation
     virtual void showContextMenu() override;
 
+    void setState(basic_webengine::State state);
+
     boost::signals2::signal<void (const tizen_browser::basic_webengine::TabId&)> tabClicked;
     boost::signals2::signal<void ()> newTabClicked;
     boost::signals2::signal<void (const tizen_browser::basic_webengine::TabId&)> closeTabsClicked;
     boost::signals2::signal<void ()> closeTabUIClicked;
+    boost::signals2::signal<void ()> changeEngineState;
+    boost::signals2::signal<void ()> refetchTabUIData;
 
 private:
     struct TabData
index 7295dc0bb5ea1baa2532c83028d96aa2448e074d..c617faecc1caf5cff20451656b8035470a6d9af5 100755 (executable)
@@ -35,19 +35,20 @@ namespace webengine_service {
 EXPORT_SERVICE(WebEngineService, "org.tizen.browser.webengineservice")
 
 WebEngineService::WebEngineService()
-    : m_initialised(false)
+    : m_state(State::NORMAL)
+    , m_initialised(false)
     , m_guiParent(nullptr)
     , m_stopped(false)
     , m_webViewCacheInitialized(false)
     , m_currentTabId(TabId::NONE)
     , m_currentWebView(nullptr)
+    , m_stateStruct(&m_normalStateStruct)
     , m_tabIdCreated(-1)
-    #if PROFILE_MOBILE
+    , m_tabIdSecret(0)
     , m_downloadControl(nullptr)
-    #endif
 {
-    m_mostRecentTab.clear();
-    m_tabs.clear();
+    m_stateStruct->mostRecentTab.clear();
+    m_stateStruct->tabs.clear();
 
 #if PROFILE_MOBILE
     // init settings
@@ -72,7 +73,7 @@ WebEngineService::~WebEngineService()
 void WebEngineService::destroyTabs()
 {
     BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__);
-    m_tabs.clear();
+    m_stateStruct->tabs.clear();
     if (m_currentWebView)
         m_currentWebView.reset();
 }
@@ -88,7 +89,7 @@ Evas_Object * WebEngineService::getLayout()
     return m_currentWebView->getLayout();
 }
 
-void WebEngineService::init(void * guiParent)
+void WebEngineService::init(Evas_Object* guiParent)
 {
     BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__);
     if (!m_initialised) {
@@ -109,8 +110,7 @@ void WebEngineService::preinitializeWebViewCache()
     if (!m_webViewCacheInitialized) {
         m_webViewCacheInitialized = true;
         Ewk_Context* context = ewk_context_default_get();
-        Evas_Object* ewk_view = ewk_view_add_with_context(evas_object_evas_get(
-                reinterpret_cast<Evas_Object *>(m_guiParent)), context);
+        Evas_Object* ewk_view = ewk_view_add_with_context(evas_object_evas_get(m_guiParent), context);
         ewk_context_cache_model_set(context, EWK_CACHE_MODEL_PRIMARY_WEBBROWSER);
         ewk_view_orientation_send(ewk_view, 0);
         evas_object_del(ewk_view);
@@ -145,6 +145,7 @@ void WebEngineService::connectSignals(std::shared_ptr<WebView> webView)
 
 void WebEngineService::disconnectSignals(std::shared_ptr<WebView> webView)
 {
+    BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__);
     M_ASSERT(webView);
     webView->favIconChanged.disconnect(boost::bind(&WebEngineService::_favIconChanged, this));
     webView->titleChanged.disconnect(boost::bind(&WebEngineService::_titleChanged, this, _1));
@@ -276,12 +277,10 @@ void WebEngineService::suspend()
         BROWSER_LOGD("[%s:%d:%s] ", __PRETTY_FUNCTION__, __LINE__,"m_currentWebView is null");
         return;
     }
-    if (tabsCount()>0) {
-        m_currentWebView->suspend();
+    m_currentWebView->suspend();
 #if PROFILE_MOBILE
         unregisterHWKeyCallback();
 #endif
-    }
 }
 
 void WebEngineService::resume()
@@ -292,13 +291,10 @@ void WebEngineService::resume()
         BROWSER_LOGD("[%s:%d:%s] ", __PRETTY_FUNCTION__, __LINE__,"m_currentWebView is null");
         return;
     }
-    if (tabsCount()>0) {
-        M_ASSERT(m_currentWebView);
-        m_currentWebView->resume();
+    m_currentWebView->resume();
 #if PROFILE_MOBILE
         registerHWKeyCallback();
 #endif
-    }
 }
 
 bool WebEngineService::isSuspended() const
@@ -458,7 +454,7 @@ void WebEngineService::_confirmationRequest(WebConfirmationPtr c)
 
 int WebEngineService::tabsCount() const
 {
-    return m_tabs.size();
+    return m_stateStruct->tabs.size();
 }
 
 TabId WebEngineService::currentTabId() const
@@ -468,41 +464,43 @@ TabId WebEngineService::currentTabId() const
 
 std::vector<TabContentPtr> WebEngineService::getTabContents() const {
     std::vector<TabContentPtr> result;
-    for (auto const& tab : m_tabs) {
+    for (auto const& tab : m_stateStruct->tabs) {
         auto tabContent = std::make_shared<TabContent>(tab.first, tab.second->getURI(), tab.second->getTitle(), tab.second->getOrigin());
         result.push_back(tabContent);
     }
     return result;
 }
 
-TabId WebEngineService::addTab(const std::string & uri,
-        const TabId * tabInitId, const boost::optional<int> tabId,
-        const std::string& title, bool desktopMode, bool incognitoMode, TabOrigin origin)
+TabId WebEngineService::addTab(const std::string & uri, const boost::optional<int> tabId,
+        const std::string& title, bool desktopMode, TabOrigin origin)
 {
     if (!(*AbstractWebEngine::checkIfCreate()))
         return currentTabId();
 
     BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__);
 
-    int newAdaptorId = -1;
-    if (tabId) {
-        newAdaptorId = *tabId;
+    TabId newTabId(0);
+    if (m_state == State::NORMAL) {
+        int newAdaptorId = -1;
+        if (tabId) {
+            newAdaptorId = *tabId;
+        } else {
+            // searching for next available tabId
+            newAdaptorId = createTabId();
+            if (newAdaptorId < 0)
+                return TabId(TabId::NONE);
+        }
+        newTabId = TabId(newAdaptorId);
     } else {
-        // searching for next available tabId
-        newAdaptorId = createTabId();
-        if (newAdaptorId < 0)
-            return TabId(TabId::NONE);
+        ++m_tabIdSecret;
+        newTabId = TabId(m_tabIdSecret);
     }
-    TabId newTabId(newAdaptorId);
 
     m_webViewCacheInitialized = true;
-    WebViewPtr p = std::make_shared<WebView>(reinterpret_cast<Evas_Object *>(m_guiParent), newTabId, title, incognitoMode);
-    if (tabInitId)
-        p->init(desktopMode, origin, getTabView(*tabInitId));
-    else
-        p->init(desktopMode, origin);
+    WebViewPtr p = std::make_shared<WebView>(m_guiParent, newTabId, title, m_state == State::SECRET);
+    p->init(desktopMode, origin);
 
-    m_tabs[newTabId] = p;
+    m_stateStruct->tabs[newTabId] = p;
 
 #if PROFILE_MOBILE
     setWebViewSettings(p);
@@ -518,11 +516,11 @@ TabId WebEngineService::addTab(const std::string & uri,
 }
 
 Evas_Object* WebEngineService::getTabView(TabId id){
-    if (m_tabs.find(id) == m_tabs.end()) {
+    if (m_stateStruct->tabs.find(id) == m_stateStruct->tabs.end()) {
         BROWSER_LOGW("[%s:%d] there is no tab of id %d", __PRETTY_FUNCTION__, __LINE__, id.get());
         return nullptr;
     }
-    return m_tabs[id]->getLayout();
+    return m_stateStruct->tabs[id]->getLayout();
 }
 
 bool WebEngineService::switchToTab(tizen_browser::basic_webengine::TabId newTabId)
@@ -535,17 +533,21 @@ bool WebEngineService::switchToTab(tizen_browser::basic_webengine::TabId newTabI
         suspend();
     }
 
-    if (m_tabs.find(newTabId) == m_tabs.end()) {
+    if (m_stateStruct->tabs.find(newTabId) == m_stateStruct->tabs.end()) {
         BROWSER_LOGW("[%s:%d] there is no tab of id %d", __PRETTY_FUNCTION__, __LINE__, newTabId.get());
         return false;
     }
 #if PROFILE_MOBILE
     closeFindOnPage();
 #endif
-    m_currentWebView = m_tabs[newTabId];
+    m_currentWebView = m_stateStruct->tabs[newTabId];
     m_currentTabId = newTabId;
-    m_mostRecentTab.erase(std::remove(m_mostRecentTab.begin(), m_mostRecentTab.end(), newTabId), m_mostRecentTab.end());
-    m_mostRecentTab.push_back(newTabId);
+    m_stateStruct->mostRecentTab.erase(
+        std::remove(m_stateStruct->mostRecentTab.begin(),
+            m_stateStruct->mostRecentTab.end(),
+            newTabId),
+        m_stateStruct->mostRecentTab.end());
+    m_stateStruct->mostRecentTab.push_back(newTabId);
 
     connectSignals(m_currentWebView);
     resume();
@@ -577,18 +579,22 @@ bool WebEngineService::closeTab(TabId id) {
     if (closingTabId == TabId::NONE){
         return res;
     }
-    m_tabs.erase(closingTabId);
-    m_mostRecentTab.erase(std::remove(m_mostRecentTab.begin(), m_mostRecentTab.end(), closingTabId), m_mostRecentTab.end());
+    m_stateStruct->tabs.erase(closingTabId);
+    m_stateStruct->mostRecentTab.erase(
+        std::remove(m_stateStruct->mostRecentTab.begin(),
+            m_stateStruct->mostRecentTab.end(),
+            closingTabId),
+        m_stateStruct->mostRecentTab.end());
 
     if (closingTabId == m_currentTabId) {
         if (m_currentWebView)
             m_currentWebView.reset();
     }
-    if (m_tabs.size() == 0) {
+    if (m_stateStruct->tabs.size() == 0) {
         m_currentTabId = TabId::NONE;
     }
-    else if (closingTabId == m_currentTabId && m_mostRecentTab.size()){
-        res = switchToTab(m_mostRecentTab.back());
+    else if (closingTabId == m_currentTabId && m_stateStruct->mostRecentTab.size()){
+        res = switchToTab(m_stateStruct->mostRecentTab.back());
     }
 
     tabClosed(closingTabId);
@@ -602,21 +608,17 @@ void WebEngineService::confirmationResult(WebConfirmationPtr c)
     M_ASSERT(c && c->getTabId() != TabId());
 
     // check if still exists
-    if (m_tabs.find(c->getTabId()) == m_tabs.end()) {
+    if (m_stateStruct->tabs.find(c->getTabId()) == m_stateStruct->tabs.end()) {
         return;
     }
 
-    m_tabs[c->getTabId()]->confirmationResult(c);
+    m_stateStruct->tabs[c->getTabId()]->confirmationResult(c);
 }
 
-bool WebEngineService::isPrivateMode(const TabId& id)
+bool WebEngineService::isSecretMode()
 {
     BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__);
-    if (m_tabs.find(id) == m_tabs.end()) {
-        BROWSER_LOGW("[%s:%d] there is no tab of id %d", __PRETTY_FUNCTION__, __LINE__, id.get());
-        return false;
-    }
-    return m_tabs[id]->isPrivateMode();
+    return m_state == State::SECRET;
 }
 
 std::shared_ptr<tizen_browser::tools::BrowserImage> WebEngineService::getSnapshotData(int width, int height,
@@ -631,11 +633,11 @@ std::shared_ptr<tizen_browser::tools::BrowserImage> WebEngineService::getSnapsho
 
 std::shared_ptr<tizen_browser::tools::BrowserImage> WebEngineService::getSnapshotData(TabId id, int width, int height, bool async,
         tizen_browser::tools::SnapshotType snapshot_type){
-    if (m_tabs.find(id) == m_tabs.end()) {
+    if (m_stateStruct->tabs.find(id) == m_stateStruct->tabs.end()) {
         BROWSER_LOGW("[%s:%d] there is no tab of id %d", __PRETTY_FUNCTION__, __LINE__, id.get());
         return std::shared_ptr<tizen_browser::tools::BrowserImage>();
     }
-   return m_tabs[id]->captureSnapshot(width, height, async, snapshot_type);
+   return m_stateStruct->tabs[id]->captureSnapshot(width, height, async, snapshot_type);
 }
 
 void WebEngineService::setFocus()
@@ -734,29 +736,29 @@ void WebEngineService::setZoomFactor(int zoomFactor)
 
 void WebEngineService::clearCache()
 {
-    for(std::map<TabId, WebViewPtr>::const_iterator it = m_tabs.begin(); it != m_tabs.end(); ++it){
-            it->second->clearCache();
-        }
+    for(const auto& it: m_stateStruct->tabs) {
+        it.second->clearCache();
+    }
 }
 
 void WebEngineService::clearCookies()
 {
-    for(std::map<TabId, WebViewPtr>::const_iterator it = m_tabs.begin(); it != m_tabs.end(); ++it){
-            it->second->clearCookies();
-        }
+    for(const auto& it: m_stateStruct->tabs) {
+        it.second->clearCookies();
+    }
 }
 
 void WebEngineService::clearPrivateData()
 {
-    for(std::map<TabId, WebViewPtr>::const_iterator it = m_tabs.begin(); it != m_tabs.end(); ++it){
-            it->second->clearPrivateData();
-        }
+    for(const auto& it: m_stateStruct->tabs) {
+        it.second->clearPrivateData();
+    }
 }
 void WebEngineService::clearPasswordData()
 {
-    for(std::map<TabId, WebViewPtr>::const_iterator it = m_tabs.begin(); it != m_tabs.end(); ++it){
-            it->second->clearPasswordData();
-        }
+    for(const auto& it: m_stateStruct->tabs) {
+        it.second->clearPasswordData();
+    }
 }
 
 void WebEngineService::clearFormData()
@@ -773,8 +775,8 @@ void WebEngineService::clearFormData()
         }
     }
     ewk_context_form_candidate_data_delete_all(ewk_context_default_get());
-    for (std::map<TabId, WebViewPtr>::const_iterator it = m_tabs.begin(); it != m_tabs.end(); ++it)
-        it->second->clearFormData();
+    for(const auto& it: m_stateStruct->tabs)
+        it.second->clearFormData();
 }
 
 void WebEngineService::searchOnWebsite(const std::string & searchString, int flags)
@@ -893,9 +895,8 @@ void WebEngineService::backButtonClicked()
 
     if (isBackEnabled()) {
         m_currentWebView->back();
-    } else if (m_currentWebView->isPrivateMode()) {
-        closeTab();
-    } else if (m_currentWebView->getOrigin().isFromWebView() && m_tabs.find(m_currentWebView->getOrigin().getValue()) != m_tabs.end()) {
+    } else if (m_currentWebView->getOrigin().isFromWebView() &&
+        m_stateStruct->tabs.find(m_currentWebView->getOrigin().getValue()) != m_stateStruct->tabs.end()) {
         int switchTo = m_currentWebView->getOrigin().getValue();
         closeTab();
         switchToTab(switchTo);
@@ -951,7 +952,6 @@ void WebEngineService::scrollView(const int& dx, const int& dy)
     m_currentWebView->scrollView(dx, dy);
 }
 
-#if PROFILE_MOBILE
 void WebEngineService::findWord(const char *word, Eina_Bool forward, Evas_Smart_Cb found_cb, void *data)
 {
     if (m_currentWebView)
@@ -964,7 +964,7 @@ bool WebEngineService::getSettingsParam(WebEngineSettings param) {
 
 void WebEngineService::setSettingsParam(WebEngineSettings param, bool value) {
     m_settings[param] = value;
-    for(auto it = m_tabs.cbegin(); it != m_tabs.cend(); ++it) {
+    for(auto it = m_stateStruct->tabs.cbegin(); it != m_stateStruct->tabs.cend(); ++it) {
         switch (param) {
         case WebEngineSettings::PAGE_OVERVIEW:
             it->second->ewkSettingsAutoFittingSet(value);
@@ -1010,7 +1010,17 @@ void WebEngineService::resetSettingsParam()
     setSettingsParam(WebEngineSettings::SCRIPTS_CAN_OPEN_PAGES, boost::any_cast<bool>(
             tizen_browser::config::Config::getInstance().get(CONFIG_KEY::WEB_ENGINE_SCRIPTS_CAN_OPEN_PAGES)));
 }
-#endif
+
+void WebEngineService::changeState()
+{
+    if (m_state == State::NORMAL) {
+        m_state = State::SECRET;
+        m_stateStruct = &m_secretStateStruct;
+    } else {
+        m_state = State::NORMAL;
+        m_stateStruct = &m_normalStateStruct;
+    }
+}
 
 } /* end of webengine_service */
 } /* end of basic_webengine */
index b772643fb02608dc585ed40d78307b3b8bc31c05..484ab5c1fce9c4d7f2d5fd0b942a1f5ee8d4c53c 100644 (file)
@@ -29,6 +29,7 @@
 #include "AbstractWebEngine/TabIdTypedef.h"
 #include "AbstractWebEngine/WebConfirmation.h"
 #include "AbstractWebEngine/TabOrigin.h"
+#include "AbstractWebEngine/State.h"
 #include "SnapshotType.h"
 #include "BrowserImage.h"
 #include "DownloadControl/DownloadControl.h"
@@ -39,9 +40,10 @@ namespace webengine_service {
 
 class WebView;
 
-typedef std::shared_ptr<WebView> WebViewPtr;
+using WebViewPtr = std::shared_ptr<WebView>;
+using TabsMapPtr = std::shared_ptr<std::map<TabId, WebViewPtr > >;
 
-class BROWSER_EXPORT WebEngineService : public AbstractWebEngine<Evas_Object>, boost::noncopyable
+class BROWSER_EXPORT WebEngineService : public AbstractWebEngine, boost::noncopyable
 {
 public:
     WebEngineService();
@@ -49,7 +51,7 @@ public:
     virtual std::string getName();
 
     Evas_Object * getLayout();
-    void init(void * guiParent);
+    void init(Evas_Object* guiParent);
     void preinitializeWebViewCache();
 
     void setURI(const std::string &);
@@ -97,11 +99,9 @@ public:
      */
     TabId addTab(
             const std::string & uri = std::string(),
-            const TabId* tabInitId = NULL,
             const boost::optional<int> tabId = boost::none,
             const std::string& title = std::string(),
             bool desktopMode = true,
-            bool incognitoMode = false,
             TabOrigin origin = TabOrigin::UNKNOWN);
     Evas_Object* getTabView(TabId id);
     bool switchToTab(TabId);
@@ -122,15 +122,10 @@ public:
     std::shared_ptr<tizen_browser::tools::BrowserImage> getSnapshotData(TabId id, int width, int height, bool async, tizen_browser::tools::SnapshotType snapshot_type);
 
     /**
-     * @brief Get the state of private mode for a specific tab
+     * @brief Get the state of secret mode
      *
-     * @param id of snapshot
-     * @return state of private mode where:
-     *     -1 is "Not set"
-     *      0 is "False"
-     *      1 is "True"
      */
-    bool isPrivateMode(const TabId& id);
+    bool isSecretMode();
 
 
     /**
@@ -194,7 +189,6 @@ public:
 
     void onTabIdCreated(int tabId) override;
 
-#if PROFILE_MOBILE
     /**
      * @brief Searches for word in the current page.
      *
@@ -219,7 +213,16 @@ public:
      * @brief Reset WebView settings
      */
     virtual void resetSettingsParam() override;
-#endif
+
+    /**
+     * @brief set next state
+     */
+    void changeState() override;
+
+    /**
+     * @brief Get current state of the engine
+     */
+    State getState() override { return m_state; }
 private:
     // callbacks from WebView
     void _favIconChanged(std::shared_ptr<tizen_browser::tools::BrowserImage> bi);
@@ -264,8 +267,14 @@ private:
     int createTabId();
 
 private:
+    struct StateStruct {
+        std::map<TabId, WebViewPtr > tabs;
+        std::vector<TabId> mostRecentTab;
+    };
+
+    State m_state;
     bool m_initialised;
-    void* m_guiParent;
+    Evas_Object* m_guiParent;
     bool m_stopped;
     bool m_webViewCacheInitialized;
 
@@ -273,16 +282,14 @@ private:
     TabId m_currentTabId;
     // current WebView
     WebViewPtr m_currentWebView;
-
-    // map of all tabs (WebViews)
-    std::map<TabId, WebViewPtr > m_tabs;
-    // Most recent tab list
-    std::vector<TabId> m_mostRecentTab;
+    StateStruct m_normalStateStruct;
+    StateStruct m_secretStateStruct;
+    StateStruct* m_stateStruct;
     int m_tabIdCreated;
-#if PROFILE_MOBILE
+    int m_tabIdSecret;
+
     std::map<WebEngineSettings, bool>  m_settings;
     DownloadControl *m_downloadControl;
-#endif
 };
 
 } /* end of webengine_service */
index eed0fdf7837b0786e229c1e1cb6c4d3c060e4a8c..374afed3b65c66ce9a84b8ae6d10d11e08cdf1c8 100755 (executable)
@@ -108,7 +108,7 @@ WebView::~WebView()
 #endif
 }
 
-void WebView::init(bool desktopMode, TabOrigin origin, Evas_Object*)
+void WebView::init(bool desktopMode, TabOrigin origin)
 {
     m_ewkView = m_private ? ewk_view_add_in_incognito_mode(evas_object_evas_get(m_parent)) :
                             ewk_view_add_with_context(evas_object_evas_get(m_parent), ewk_context_default_get());
@@ -849,10 +849,10 @@ void WebView::__newWindowRequest(void *data, Evas_Object *, void *out)
     WebView * self = reinterpret_cast<WebView *>(data);
     BROWSER_LOGD("[%s:%d] self=%p", __PRETTY_FUNCTION__, __LINE__, self);
     BROWSER_LOGD("Window creating in tab: %s", self->getTabId().toString().c_str());
-    std::shared_ptr<basic_webengine::AbstractWebEngine<Evas_Object>>  m_webEngine;
+    std::shared_ptr<basic_webengine::AbstractWebEngine>  m_webEngine;
     m_webEngine = std::dynamic_pointer_cast
     <
-        basic_webengine::AbstractWebEngine<Evas_Object>,tizen_browser::core::AbstractService
+        basic_webengine::AbstractWebEngine,tizen_browser::core::AbstractService
     >
     (tizen_browser::core::ServiceManager::getInstance().getService("org.tizen.browser.webengineservice"));
     M_ASSERT(m_webEngine);
@@ -861,11 +861,9 @@ void WebView::__newWindowRequest(void *data, Evas_Object *, void *out)
     TabId id(TabId::NONE);
     TabId currentTabId = m_webEngine->currentTabId();
     if (currentTabId != (id = m_webEngine->addTab(std::string(),
-                                                                 &self->getTabId(),
                                                                  boost::none,
                                                                  std::string(),
                                                                  self->isDesktopMode(),
-                                                                 self->isPrivateMode(),
                                                                  currentTabId.get()))) {
         BROWSER_LOGD("Created tab: %s", id.toString().c_str());
         Evas_Object* tab_ewk_view = m_webEngine->getTabView(id);
@@ -881,9 +879,9 @@ void WebView::__closeWindowRequest(void *data, Evas_Object *, void *)
 {
     BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__);
     WebView * self = reinterpret_cast<WebView *>(data);
-    std::shared_ptr<AbstractWebEngine<Evas_Object>> m_webEngine =
+    std::shared_ptr<AbstractWebEngine> m_webEngine =
                 std::dynamic_pointer_cast
-                <basic_webengine::AbstractWebEngine<Evas_Object>,tizen_browser::core::AbstractService>
+                <basic_webengine::AbstractWebEngine,tizen_browser::core::AbstractService>
                 (tizen_browser::core::ServiceManager::getInstance().getService("org.tizen.browser.webengineservice"));
     m_webEngine->closeTab(self->getTabId());
 }
index cbbe55bfa2fc7206e7bac2774c9ea5a62e775259..3978538f854c59cdcf9f927389a62cb7903bbedf 100644 (file)
@@ -76,7 +76,7 @@ class WebView
 public:
     WebView(Evas_Object *, TabId, const std::string& title, bool incognitoMode);
     virtual ~WebView();
-    void init(bool desktopMode, TabOrigin origin, Evas_Object * view = NULL);
+    void init(bool desktopMode, TabOrigin origin);
 
 #if PROFILE_MOBILE
     virtual void orientationChanged() override;
@@ -112,13 +112,6 @@ public:
 
     void confirmationResult(WebConfirmationPtr);
 
-    /**
-     * @brief Get the state of private mode
-     *
-     * @return state of private mode
-     */
-    bool isPrivateMode() {return m_private;}
-
     std::shared_ptr<tizen_browser::tools::BrowserImage> captureSnapshot(int width, int height, bool async,
             tizen_browser::tools::SnapshotType snapshot_type);
      /**
index e8d5cd9bb2a357b53746894d7a083adcd85c442c..e8c9eb058aaa240eb4c981631e29518388c1c6db 100644 (file)
@@ -51,32 +51,25 @@ void ButtonBar::addAction(sharedAction action, const std::string& buttonName)
     actionButton.eAction = eAction;
     Evas_Object* button = elm_button_add(m_layout);
 
-    edje_color_class_set("elm/widget/button/default/bg-default", 240, 240, 240, 255,
-                        255, 255, 255, 255,
-                        255, 255, 255, 255);
-
-    edje_color_class_set("elm/widget/button/default/bg-disabled", 240, 240, 240, 255,
-                        255, 255, 255, 255,
-                        255, 255, 255, 255);
-
-    Evas_Object* m_box = elm_box_add(button);
-    evas_object_size_hint_weight_set(m_box, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
-    evas_object_size_hint_align_set(m_box, EVAS_HINT_FILL, EVAS_HINT_FILL);
-    elm_box_homogeneous_set(m_box, EINA_FALSE);
+    Evas_Object* box = elm_box_add(button);
+    evas_object_size_hint_weight_set(box, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+    evas_object_size_hint_align_set(box, EVAS_HINT_FILL, EVAS_HINT_FILL);
+    elm_box_homogeneous_set(box, EINA_FALSE);
 
     // Set a source file to fetch pixel data
-    Evas_Object *img = elm_image_add(m_box);
-    elm_image_file_set(img, m_edjFilePath.c_str(), action->getIcon().c_str());
+    Evas_Object *img = elm_layout_add(box);
+    elm_layout_file_set(img, m_edjFilePath.c_str(), action->getIcon().c_str());
     evas_object_size_hint_min_set(img, 0, BUTTON_WITH_ICON_HEIGHT);
-    elm_box_pack_end(m_box, img);
+    elm_box_pack_end(box, img);
     evas_object_show(img);
+    m_imgMap[buttonName] = img;
 
-    Evas_Object *label = elm_label_add(m_box);
+    Evas_Object *label = elm_label_add(box);
     elm_object_text_set(label, action->getText().c_str());
-    elm_box_pack_end(m_box, label);
+    elm_box_pack_end(box, label);
     evas_object_show(label);
-    evas_object_show(m_box);
-    elm_object_part_content_set(button, "elm.swallow.content", m_box);
+    evas_object_show(box);
+    elm_object_part_content_set(button, "elm.swallow.content", box);
 
     elm_object_disabled_set(button, action->isEnabled() ? EINA_FALSE : EINA_TRUE);
     evas_object_smart_callback_add(button, "clicked", EAction::callbackFunction, eAction.get());
@@ -109,8 +102,6 @@ void ButtonBar::setActionForButton(const std::string& buttonName, sharedAction n
     Evas_Object* button = m_buttonsMap[buttonName].button;
     std::shared_ptr<EAction> eAction = std::make_shared<EAction>(newAction);
 
-    elm_object_style_set(button, newAction->getIcon().c_str());
-
     evas_object_smart_callback_del(button, "clicked", EAction::callbackFunction);
     evas_object_smart_callback_add(button, "clicked", EAction::callbackFunction, eAction.get());
 
@@ -157,5 +148,20 @@ void ButtonBar::setDisabled(bool disabled)
     elm_object_disabled_set(getContent(), disabled ? EINA_TRUE : EINA_FALSE);
 }
 
+void ButtonBar::setButtonsColor(bool secretMode)
+{
+    for (const auto& it : m_buttonsMap) {
+        if (secretMode) {
+            //TODO works, state is changed but get gray scale only, why?
+            //elm_object_signal_emit(m_imgMap[it.first], "set_secret_mode", "ui");
+            evas_object_color_set(it.second.button, 97, 97, 97, 255);
+        } else {
+            evas_object_color_set(it.second.button, 240, 240, 240, 255);
+            elm_object_signal_emit(m_imgMap[it.first], "set_normal_mode", "ui");
+        }
+    }
+
+}
+
 }
 }
index 6e93b77caaea4303362920e5d900b127b1144053..75fbe60889d729427f442b5108cf3c3fdff6a145 100644 (file)
@@ -51,6 +51,7 @@ public:
     Evas_Object* getButton(const std::string& buttonName);
     void clearFocus();
     void setDisabled(bool disabled);
+    void setButtonsColor(bool secretMode);
 
 private:
     std::string m_edjFilePath;
@@ -58,6 +59,7 @@ private:
     std::map<std::string, sharedAction> m_actionsMap;
     //map button name to struct ActionButton which contains Evas_Object of button
     std::map<std::string, ActionButton> m_buttonsMap;
+    std::map<std::string, Evas_Object*> m_imgMap;
     Evas_Object* m_layout;
     void refreshButton(const std::string& buttonName);
     void onEnabledChanged(const std::string& buttonName, sharedAction action);
index d61b9f1d3a3263f7486ff8b1ee1fe068c06eb272..e6de84c649cb367668d50775762013a13ada720a 100755 (executable)
@@ -90,6 +90,25 @@ UrlHistoryPtr WebPageUI::getUrlHistoryList()
 void WebPageUI::showUI()
 {
     BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__);
+
+    auto state = getEngineState();
+    if (state) {
+        switch (*state) {
+            case basic_webengine::State::NORMAL:
+                elm_object_signal_emit(m_mainLayout, "set_normal_mode", "ui");
+                break;
+            case basic_webengine::State::SECRET:
+                elm_object_signal_emit(m_mainLayout, "set_secret_mode", "ui");
+                break;
+            default:
+                BROWSER_LOGE("[%s:%d] Unknown state!", __PRETTY_FUNCTION__, __LINE__);
+        }
+        m_bottomButtonBar->setButtonsColor(*state == basic_webengine::State::SECRET);
+        m_rightButtonBar->setButtonsColor(*state == basic_webengine::State::SECRET);
+    } else {
+        BROWSER_LOGE("[%s:%d] Wrong state value!", __PRETTY_FUNCTION__, __LINE__);
+    }
+
     M_ASSERT(m_mainLayout);
     evas_object_show(m_mainLayout);
 
@@ -568,6 +587,15 @@ void WebPageUI::createLayout()
 {
     BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__);
     M_ASSERT(m_parent);
+
+    // set white base background for button
+    edje_color_class_set("elm/widget/button/default/bg-default", 255, 255, 255, 255,
+                    255, 255, 255, 255,
+                    255, 255, 255, 255);
+    edje_color_class_set("elm/widget/button/default/bg-disabled", 255, 255, 255, 255,
+                        255, 255, 255, 255,
+                        255, 255, 255, 255);
+
     // create web layout
     m_mainLayout = elm_layout_add(m_parent);
     evas_object_size_hint_weight_set(m_mainLayout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
index 0dff63940e967ede898388089e92b5405073d7b1..8d9cdfb04cc47710763b227137a8035a074c8f6d 100755 (executable)
@@ -27,6 +27,7 @@
 #include "service_macros.h"
 #include "ButtonBar.h"
 #include "URIEntry.h"
+#include "AbstractWebEngine/State.h"
 
 namespace tizen_browser {
 namespace base_ui {
@@ -144,6 +145,7 @@ public:
     boost::signals2::signal<void ()> switchToDesktopMode;
 
     boost::signals2::signal<std::string ()> requestCurrentPageForWebPageUI;
+    boost::signals2::signal<basic_webengine::State ()> getEngineState;
 
 private:
     static void faviconClicked(void* data, Evas_Object* obj, const char* emission, const char* source);
index 7ece13d4b95b78fb648659ff6837fd163413c8f8..4ad45b44f8f40d67c085316141cb2febc1426010 100644 (file)
@@ -8,9 +8,8 @@
         name: NAME;                                                 \
         images.image: IMG COMP;                                     \
         parts {                                                     \
-            part {                                                  \
+            image {                                                 \
                 name: "image";                                      \
-                type: IMAGE;                                        \
                 mouse_events: 1;                                    \
                 repeat_events: 0;                                   \
                 description {                                       \
                     image.normal: IMG;                              \
                     color: 105 105 105 255;                         \
                 }                                                   \
+                description {                                       \
+                    state: "secret" 0.0;                            \
+                    inherit: "default" 0.0;                         \
+                    color: 250 250 250 255;                         \
+                }                                                   \
+            }                                                       \
+        }                                                           \
+        programs {                                                  \
+            program {                                               \
+                name: "set_normal_mode";                            \
+                signal: "set_normal_mode";                          \
+                source: "ui";                                       \
+                action: STATE_SET "default" 0.0;                    \
+                target: "image";                                    \
+            }                                                       \
+            program {                                               \
+                name: "set_secret_mode";                            \
+                signal: "set_secret_mode";                          \
+                source: "ui";                                       \
+                action: STATE_SET "secret" 0.0;                     \
+                target: "image";                                    \
             }                                                       \
         }                                                           \
     }
index e7bf2129a925e9860a1b0ef149cc374928383178..3aaf483bc4342dabf2b6b603aebee4857a64a049 100644 (file)
@@ -9,6 +9,7 @@
 #define FINDONPAGE_WIDTH 720
 #define SPACER_SIZE 16
 #include "../../../core/Tools/edc/Spacer.edc"
+#include "../../../core/Tools/edc/ColorClasses.edc"
 
 #define PROGRESS_DESCRIPTIONS\
     PROGRESS_DESCRIPTION(0.00)\
@@ -79,6 +80,12 @@ collections { base_scale: 2.6;
             image: PROGRESS_BG_IMAGE COMP;
             image: PROGRESS_BAR_IMAGE COMP;
         }
+        color_classes{
+            color_class{
+                name: "defaultBg";
+                color: 240 240 240 255;
+            }
+        }
         parts {
             part {
                 name: "bg";
@@ -101,12 +108,11 @@ collections { base_scale: 2.6;
                 scale: 1;
                 description {
                     state: "default" 0.0;
-                    visible: 1;
+                    visible: 0;
                     fixed: 0 1;
                     align: 0 0;
                     min: 0 URI_BG_HEIGHT;
                     max: -1 URI_BG_HEIGHT;
-                    color: 240 240 240 255;
                     rel1 {relative: 0.0 0.0; to:"bg";}
                     rel2 {relative: 1.0 1.0; to:"bg";}
                 }
@@ -121,6 +127,24 @@ collections { base_scale: 2.6;
                     rel1 {relative: 0.0 -URI_BG_HEIGHT/668; to:"bg";}
                 }
             }
+
+            rect {
+                name: "uri_bar_bg_color";
+                scale: 1;
+                description {
+                    state: "default" 0.0;
+                    visible: 1;
+                    align: 0 0;
+                    color_class: "defaultBg";
+                    rel1 {relative: 0.0 0.0; to:"uri_bar_bg";}
+                    rel2 {relative: 1.0 1.0; to:"uri_bar_bg";}
+                }
+                description {
+                    state: "secret" 0.0;
+                    inherit: "default" 0.0;
+                    color_class: "secret";
+                }
+            }
             ADD_SPACER_OVER("left_spacer", "uri_bar_bg", SPACER_SIZE, SPACER_SIZE)
 
             part {
@@ -223,11 +247,11 @@ collections { base_scale: 2.6;
                 scale: 1;
                 description {
                     state: "default" 0.0;
-                    visible: 1;
+                    visible: 0;
                     align: 0.0 1.0;
                     min: 0 0;
                     max: -1 BOTTOM_TOOLBAR_HEIGHT;
-                    color: 240 240 240 255;
+                    color_class: "defaultBg";
                     rel1 { relative: 0.0 0.0; to: "bg"; }
                     rel2 { relative: 1.0 1.0; to: "bg"; }
                 }
@@ -242,6 +266,23 @@ collections { base_scale: 2.6;
                     rel1 {relative: 0.0 1.0; to:"bg";}
                 }
             }
+            rect {
+                name: "bottom_toolbar_bg_color";
+                scale: 1;
+                description {
+                    state: "default" 0.0;
+                    visible: 1;
+                    align: 0.0 0.0;
+                    color_class: "defaultBg";
+                    rel1 { relative: 0.0 0.0; to: "bottom_toolbar"; }
+                    rel2 { relative: 1.0 1.0; to: "bottom_toolbar"; }
+                }
+                description {
+                    state: "secret" 0.0;
+                    inherit: "default" 0.0;
+                    color_class: "secret";
+                }
+            }
             part {
                 name: "bottom_swallow";
                 type: SWALLOW;
@@ -450,6 +491,22 @@ collections { base_scale: 2.6;
                 action: STATE_SET "visible" 0.0;
                 target: "findonpage";
             }
+            program {
+                name: "set_normal_mode";
+                signal: "set_normal_mode";
+                source: "ui";
+                action: STATE_SET "default" 0.0;
+                target: "uri_bar_bg_color";
+                target: "bottom_toolbar_bg_color";
+            }
+            program {
+                name: "set_secret_mode";
+                signal: "set_secret_mode";
+                source: "ui";
+                action: STATE_SET "secret" 0.0;
+                target: "uri_bar_bg_color";
+                target: "bottom_toolbar_bg_color";
+            }
         }
     }
 }
index b96ce7501077e184a3e1c5cdb09267763f04022c..35aa818bf29260a758001e902c2b4d024d222f1c 100644 (file)
@@ -245,15 +245,15 @@ BOOST_AUTO_TEST_CASE(PrivateModeOnOff)
 
     tizen_browser::basic_webengine::TabId parentTabId = webEngineService->addTab("www.test.com");
 
-    BOOST_CHECK(!(webEngineService->isPrivateMode()));
+    BOOST_CHECK(!(webEngineService->isSecretMode()));
 
     webEngineService->setPrivateMode(true);
 
-    BOOST_CHECK(webEngineService->isPrivateMode());
+    BOOST_CHECK(webEngineService->isSecretMode());
 
     webEngineService->setPrivateMode(false);
 
-    BOOST_CHECK(!(webEngineService->isPrivateMode()));
+    BOOST_CHECK(!(webEngineService->isSecretMode()));
 
     BOOST_TEST_MESSAGE(TAG "Print closeTab():" << webEngineService->closeTab());