From: Przemyslaw Ciezkowski
Date: Tue, 11 Dec 2012 14:10:10 +0000 (+0100)
Subject: Custom handler popups
X-Git-Tag: 2.1b_release~22^2~174
X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=5a32bc6110cb9cc6217ac0cc5f8ea71f2dbab8fd;p=platform%2Fframework%2Fweb%2Fwrt.git
Custom handler popups
[Issue#] N/A
[Feature] Custom handler register callbacks should show popup.
[Problem] N/A
[Cause] N/A
[Solution] Popups added.
[Verification] Run manual test custom_handlers.wgt
1. Click register provider, check if popup appears.
2. Click again, popup should not appear.
3. Run widget again check if popup doesn't appear.
Repeat steps for content handler.
Change-Id: I0117dcaf098e5d5f98b9ccb5570a66ff315d07a9
---
diff --git a/src/view/webkit/CMakeLists.txt b/src/view/webkit/CMakeLists.txt
index 33b3325..7653370 100644
--- a/src/view/webkit/CMakeLists.txt
+++ b/src/view/webkit/CMakeLists.txt
@@ -25,7 +25,9 @@ PKG_CHECK_MODULES(VIEW_MODULE_DEP
dpl-popup-efl
dpl-utils-efl
dpl-wrt-dao-ro
+ wrt-commons-custom-handler-dao-rw
wrt-plugin-js-overlay
+ wrt-popup-wrt-runner
security-core
security-client
REQUIRED
diff --git a/src/view/webkit/view_logic.cpp b/src/view/webkit/view_logic.cpp
index 78de022..bef1544 100644
--- a/src/view/webkit/view_logic.cpp
+++ b/src/view/webkit/view_logic.cpp
@@ -34,6 +34,8 @@
#include
#include
#include
+#include
+#include
#include
#include
@@ -54,6 +56,7 @@
#include
#include
#include "bundles/plugin_module_support.h"
+#include
#include
#include
@@ -121,6 +124,11 @@ const char * const EWK_PROTOCOLHANDLER_UNREGISTRATION = "protocolhandler,unregis
const char * const EWK_CONTENTHANDLER_REGISTRATION = "contenthandler,registration,requested";
const char * const EWK_CONTENTHANDLER_ISREGISTERED = "contenthandler,isregistered";
const char * const EWK_CONTENTHANDLER_UNREGISTRATION = "contenthandler,unregistration,requested";
+
+const char PROTOCOL_HANDLER_ASK_MSG[] = "Add protocol?";
+const char PROTOCOL_HANDLER_ASK_TITLE[] = "Add protocol";
+const char CONTENT_HANDLER_ASK_MSG[] = "Add content?";
+const char CONTENT_HANDLER_ASK_TITLE[] = "Add content";
}
ViewLogic::ViewLogic():
@@ -130,12 +138,14 @@ ViewLogic::ViewLogic():
m_model(0),
m_cbs(new WRT::UserDelegates),
m_appsSupport(new ViewModule::AppsSupport()),
- m_vibrationSupport(NULL)
+ m_vibrationSupport(NULL),
+ m_attachedToCustomHandlerDao(false)
{
}
ViewLogic::~ViewLogic ()
{
+ detachFromCustomHandlersDao();
}
void ViewLogic::createWebView(Ewk_Context* context,
@@ -1660,26 +1670,46 @@ void ViewLogic::imeCloseCallback(
}
// helper method
-void ViewLogic::debugCustomHandlerData(void* data)
+CustomHandlerDB::CustomHandlerPtr getCustomHandlerFromData(void* data)
{
Assert(data);
Ewk_Custom_Handlers_Data* handler =
static_cast(data);
+ CustomHandlerDB::CustomHandlerPtr customHandler(new CustomHandlerDB::CustomHandler());
const char* base_url = ewk_custom_handlers_data_base_url_get(handler);
if (base_url) {
LogDebug("base url: " << base_url);
+ customHandler->base_url = DPL::FromASCIIString(string(base_url));
}
const char* url = ewk_custom_handlers_data_url_get(handler);
if (url) {
LogDebug("url: " << url);
+ customHandler->url = DPL::FromASCIIString(string(url));
}
const char* target = ewk_custom_handlers_data_target_get(handler);
if (target) {
LogDebug("target: " << target);
+ customHandler->target = DPL::FromASCIIString(string(target));
}
const char* title = ewk_custom_handlers_data_title_get(handler);
if (title) {
LogDebug("title: " << title);
+ customHandler->title = DPL::FromASCIIString(string(title));
+ }
+ return customHandler;
+}
+
+void ViewLogic::attachToCustomHandlersDao()
+{
+ if (!m_attachedToCustomHandlerDao) {
+ CustomHandlerDB::Interface::attachDatabaseRW();
+ }
+}
+
+void ViewLogic::detachFromCustomHandlersDao()
+{
+ if (m_attachedToCustomHandlerDao) {
+ CustomHandlerDB::Interface::detachDatabase();
}
}
@@ -1687,9 +1717,31 @@ void ViewLogic::protocolHandlerRegistrationCallback(void* data,
Evas_Object* obj,
void* eventInfo)
{
+ Assert(data);
LogDebug("enter");
- debugCustomHandlerData(eventInfo);
- // TODO to be continued...
+ CustomHandlerDB::CustomHandlerPtr customHandler =
+ getCustomHandlerFromData(eventInfo);
+ //TODO: whitelist/blacklist
+ ViewLogic* This = static_cast(data);
+ LogDebug("Creating handlers dao");
+ This->attachToCustomHandlersDao();
+ CustomHandlerDB::CustomHandlerDAO handlersDao(This->m_model->TizenId);
+ CustomHandlerDB::CustomHandlerPtr handler =
+ handlersDao.getProtocolHandler(customHandler->target, customHandler->url);
+ if (handler) {
+ LogDebug("Protocol already registered - nothing to do");
+ } else {
+ LogDebug("Protocol handler not found");
+ if (Wrt::Popup::PopupInvoker().askYesNo(PROTOCOL_HANDLER_ASK_TITLE, PROTOCOL_HANDLER_ASK_MSG)) {
+ LogDebug("User allowed");
+ customHandler->user_allowed = true;
+ } else {
+ LogDebug("User didn't allow");
+ customHandler->user_allowed = false;
+ }
+ handlersDao.registerProtocolHandler(*(customHandler.get()));
+ LogDebug("Protocal saved");
+ }
}
void ViewLogic::protocolHandlerIsRegisteredCallback(void* data,
@@ -1697,7 +1749,7 @@ void ViewLogic::protocolHandlerIsRegisteredCallback(void* data,
void* eventInfo)
{
LogDebug("enter");
- debugCustomHandlerData(eventInfo);
+ getCustomHandlerFromData(eventInfo);
// TODO to be continued...
}
@@ -1706,7 +1758,7 @@ void ViewLogic::protocolHandlerUnregistrationCallback(void* data,
void* eventInfo)
{
LogDebug("enter");
- debugCustomHandlerData(eventInfo);
+ getCustomHandlerFromData(eventInfo);
// TODO to be continued...
}
@@ -1714,9 +1766,31 @@ void ViewLogic::contentHandlerRegistrationCallback(void* data,
Evas_Object* obj,
void* eventInfo)
{
+ Assert(data);
LogDebug("enter");
- debugCustomHandlerData(eventInfo);
- // TODO to be continued...
+ CustomHandlerDB::CustomHandlerPtr customHandler =
+ getCustomHandlerFromData(eventInfo);
+ //TODO: whitelist/blacklist
+ ViewLogic* This = static_cast(data);
+ LogDebug("Creating handlers dao");
+ This->attachToCustomHandlersDao();
+ CustomHandlerDB::CustomHandlerDAO handlersDao(This->m_model->TizenId);
+ CustomHandlerDB::CustomHandlerPtr handler =
+ handlersDao.getContentHandler(customHandler->target, customHandler->url);
+ if (handler) {
+ LogDebug("Content already registered - nothing to do");
+ } else {
+ LogDebug("Content handler not found");
+ if (Wrt::Popup::PopupInvoker().askYesNo(CONTENT_HANDLER_ASK_TITLE, CONTENT_HANDLER_ASK_MSG)) {
+ LogDebug("User allowed");
+ customHandler->user_allowed = true;
+ } else {
+ LogDebug("User didn't allow");
+ customHandler->user_allowed = false;
+ }
+ handlersDao.registerContentHandler(*(customHandler.get()));
+ LogDebug("Content saved");
+ }
}
void ViewLogic::contentHandlerIsRegisteredCallback(void* data,
@@ -1724,7 +1798,7 @@ void ViewLogic::contentHandlerIsRegisteredCallback(void* data,
void* eventInfo)
{
LogDebug("enter");
- debugCustomHandlerData(eventInfo);
+ getCustomHandlerFromData(eventInfo);
// TODO to be continued...
}
@@ -1733,7 +1807,7 @@ void ViewLogic::contentHandlerUnregistrationCallback(void* data,
void* eventInfo)
{
LogDebug("enter");
- debugCustomHandlerData(eventInfo);
+ getCustomHandlerFromData(eventInfo);
// TODO to be continued...
}
diff --git a/src/view/webkit/view_logic.h b/src/view/webkit/view_logic.h
index 84fce92..b48e524 100644
--- a/src/view/webkit/view_logic.h
+++ b/src/view/webkit/view_logic.h
@@ -215,9 +215,9 @@ class ViewLogic : public ViewModule::IViewModule
Evas_Object* obj,
void* eventInfo);
- static void debugCustomHandlerData(void* data);
-
// custom content/scheme handlers
+ void attachToCustomHandlersDao();
+ void detachFromCustomHandlersDao();
static void protocolHandlerRegistrationCallback(void* data,
Evas_Object* obj,
void* eventInfo);
@@ -292,6 +292,7 @@ class ViewLogic : public ViewModule::IViewModule
std::unique_ptr m_appsSupport;
std::unique_ptr m_vibrationSupport;
std::unique_ptr m_securityOriginSupport;
+ bool m_attachedToCustomHandlerDao;
};
#endif //VIEW_LOGIC_H_