const boost::optional<int> tabId = boost::none,
const std::string& title = std::string(),
bool desktopMode = true,
- bool incognitoMode = false) = 0;
+ bool incognitoMode = false,
+ int origin = 0) = 0;
/**
* @param tab id
--- /dev/null
+/*
+ * Copyright (c) 2016 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 ORIGIN_H_
+#define ORIGIN_H_
+
+
+namespace tizen_browser {
+namespace basic_webengine {
+namespace webengine_service {
+
+/*
+ * Container for webview origin id value
+ */
+class Origin
+{
+public:
+ static const int UNKNOWN = -1;
+ static const int QUICKACCESS = -2;
+ Origin() : m_value(UNKNOWN) { }
+ Origin(int from) : m_value(from) { }
+ int getValue() const { return m_value; }
+ void setValue(int value) { m_value = value; }
+ bool isFromWebView() const { return m_value >= 0; }
+private:
+ int m_value;
+
+};
+
+
+}
+}
+}
+
+#endif
\ No newline at end of file
TabId WebEngineService::addTab(const std::string & uri,
const TabId * tabInitId, const boost::optional<int> tabId,
- const std::string& title, bool desktopMode, bool incognitoMode)
+ const std::string& title, bool desktopMode, bool incognitoMode, int origin)
{
if (!(*AbstractWebEngine::checkIfCreate()))
return currentTabId();
m_webViewCacheInitialized = true;
WebViewPtr p = std::make_shared<WebView>(reinterpret_cast<Evas_Object *>(m_guiParent), newTabId, title, incognitoMode);
if (tabInitId)
- p->init(desktopMode, getTabView(*tabInitId));
+ p->init(desktopMode, origin, getTabView(*tabInitId));
else
- p->init(desktopMode);
+ p->init(desktopMode, origin);
m_tabs[newTabId] = p;
m_currentWebView->back();
} else if (m_currentWebView->isPrivateMode()) {
closeTab();
- switchToWebPage();
+ } else if (m_currentWebView->getOrigin().isFromWebView() && m_tabs.find(m_currentWebView->getOrigin().getValue()) != m_tabs.end()) {
+ int switchTo = m_currentWebView->getOrigin().getValue();
+ closeTab();
+ switchToTab(switchTo);
} else {
tools::ui_app_pause();
}
#include "AbstractWebEngine/WebConfirmation.h"
#include "SnapshotType.h"
#include "BrowserImage.h"
+#include "Origin.h"
namespace tizen_browser {
namespace basic_webengine {
const boost::optional<int> tabId = boost::none,
const std::string& title = std::string(),
bool desktopMode = true,
- bool incognitoMode = false);
+ bool incognitoMode = false,
+ int origin = Origin::UNKNOWN);
Evas_Object* getTabView(TabId id);
bool switchToTab(TabId);
bool closeTab();
#endif
}
-void WebView::init(bool desktopMode, Evas_Object*)
+void WebView::init(bool desktopMode, int origin, Evas_Object*)
{
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());
} else {
switchToMobileMode();
}
+ m_origin.setValue(origin);
ewk_context_cache_model_set(m_ewkContext, EWK_CACHE_MODEL_PRIMARY_WEBBROWSER);
std::string path = app_get_data_path() + COOKIES_PATH;
/// \todo: Choose newly created tab.
TabId id(TabId::NONE);
- if (m_webEngine->currentTabId() != (id = m_webEngine->addTab(std::string(),
+ TabId currentTabId = m_webEngine->currentTabId();
+ if (currentTabId != (id = m_webEngine->addTab(std::string(),
&self->getTabId(),
boost::none,
std::string(),
self->isDesktopMode(),
- self->isPrivateMode()))) {
+ self->isPrivateMode(),
+ currentTabId.get()))) {
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;
#include "SnapshotType.h"
#include "AbstractWebEngine/TabId.h"
#include "AbstractWebEngine/WebConfirmation.h"
+#include "Origin.h"
#if PROFILE_MOBILE
#include "DownloadControl/DownloadControl.h"
public:
WebView(Evas_Object *, TabId, const std::string& title, bool incognitoMode);
virtual ~WebView();
- void init(bool desktopMode, Evas_Object * view = NULL);
+ void init(bool desktopMode, int origin, Evas_Object * view = NULL);
#if PROFILE_MOBILE
virtual void orientationChanged() override;
*/
void scrollView(const int& dx, const int& dy);
+ Origin getOrigin() { return m_origin; }
+
#if PROFILE_MOBILE
/**
* @brief Searches for word in the current page.
bool m_suspended;
bool m_private;
bool m_fullscreen;
+ Origin m_origin;
std::map<CertificateConfirmationPtr, Ewk_Certificate_Policy_Decision *> m_confirmationCertificatenMap;