Below 2 APIs are missed in beta/m42.
So we need to migration from beta/m40
- ewk_context_notification_callbacks_set
- ewk_context_notification_callbacks_reset
Bug: http://web.sec.samsung.net/bugzilla/show_bug.cgi?id=11367
Original patch: http://web.sec.samsung.net/gerrit/#/c/75818/
Reviewed by: Hyunhak Kim, Karol Furmaniak
Change-Id: I858117f52a5e7ca67ded2b2651cbd23938f8cabb
Signed-off-by: DongJun Kim <djmix.kim@samsung.com>
scoped_ptr<DesktopNotificationDelegate> delegate,
base::Closure* cancel_callback) {
- if (!notification_show_callback_) {
+ BrowserContextEfl* browser_context_efl =
+ static_cast<BrowserContextEfl*>(browser_context);
+ CHECK(browser_context_efl);
+ EWebContext* ctx = browser_context_efl->WebContext();
+ CHECK(ctx);
+
+ bool has_callbacks = ctx->HasNotificationCallbacks()
+ || (notification_show_callback_ && notification_cancel_callback_);
+
+ if (!has_callbacks) {
delegate->NotificationClosed(false);
return;
}
if (!notification_data.tag.empty() &&
IsNotificationPresent(origin,
base::UTF8ToUTF16(notification_data.tag), replaceUniqueId)) {
- NotificationCancelled(replaceUniqueId);
+ if (!ctx->NotificationCancelCallback(replaceUniqueId))
+ NotificationCancelled(replaceUniqueId);
+ else
+ NotificationClosed(replaceUniqueId, false);
}
uint64_t notificationUniqueId = reinterpret_cast<uint64_t>(delegate.get());
notificationUniqueId,
origin);
- notification_show_callback_(notification, notification_callback_user_data_);
+ if (!ctx->NotificationShowCallback(notification))
+ notification_show_callback_(notification, notification_callback_user_data_);
+
delete notification;
}
EWebContext::EWebContext(bool incognito)
: m_pixmap(0),
inspector_server_(NULL),
- widget_scale_(0) {
+ widget_scale_(0),
+ notification_show_cb_(nullptr),
+ notification_cancel_cb_(nullptr),
+ notification_cb_user_data_(nullptr) {
CHECK(EwkGlobalData::GetInstance());
browser_context_.reset(new BrowserContextEfl(this, incognito));
EWebContext::EWebContext(const std::string& injectedBundlePath)
: injected_bundle_path_(injectedBundlePath),
m_pixmap(0),
- inspector_server_(NULL) {
+ inspector_server_(NULL),
+ notification_show_cb_(nullptr),
+ notification_cancel_cb_(nullptr),
+ notification_cb_user_data_(nullptr) {
CHECK(EwkGlobalData::GetInstance());
// WRT does not really care about incognito, so set it to false
inspector_server_ = NULL;
return true;
}
+
+void EWebContext::SetNotificationCallbacks(
+ Ewk_Notification_Show_Callback show_callback,
+ Ewk_Notification_Cancel_Callback cancel_callback,
+ void* user_data) {
+ notification_show_cb_ = show_callback;
+ notification_cancel_cb_ = cancel_callback;
+ notification_cb_user_data_ = user_data;
+}
+
+bool EWebContext::HasNotificationCallbacks() const {
+ return notification_show_cb_ && notification_cancel_cb_;
+}
+
+bool EWebContext::NotificationShowCallback(Ewk_Notification* notification) {
+ if (!HasNotificationCallbacks())
+ return false;
+
+ notification_show_cb_(notification, notification_cb_user_data_);
+ return true;
+}
+
+bool EWebContext::NotificationCancelCallback(uint64_t notification_id) {
+ if (!HasNotificationCallbacks())
+ return false;
+
+ notification_cancel_cb_(notification_id, notification_cb_user_data_);
+ return true;
+}
#include "browser/web_cache_efl/web_cache_manager_efl.h"
#include "private/ewk_cookie_manager_private.h"
#include "public/ewk_context.h"
+#include "public/ewk_notification.h"
#include "devtools_delegate_efl.h"
class CookieManager;
unsigned int InspectorServerStart(unsigned int port);
bool InspectorServerStop();
+ void SetNotificationCallbacks(
+ Ewk_Notification_Show_Callback show_callback,
+ Ewk_Notification_Cancel_Callback cancel_callback,
+ void* user_data);
+ bool HasNotificationCallbacks() const;
+ bool NotificationShowCallback(Ewk_Notification* notification);
+ bool NotificationCancelCallback(uint64_t notification_id);
+
const std::string& GetInjectedBundlePath() const { return injected_bundle_path_; }
const std::string& GetTizenId() const { return tizen_id_; }
const std::string& GetWidgetTheme() const { return widget_theme_; }
scoped_ptr<EwkMimeOverrideCallback> mime_override_callback_;
int m_pixmap;
content::DevToolsDelegateEfl* inspector_server_;
+ Ewk_Notification_Show_Callback notification_show_cb_;
+ Ewk_Notification_Cancel_Callback notification_cancel_cb_;
+ void* notification_cb_user_data_;
};
#endif
bool Ewk_Context::InspectorServerStop() const {
return impl->InspectorServerStop();
}
+
+void Ewk_Context::SetNotificationCallbacks(
+ Ewk_Notification_Show_Callback show_callback,
+ Ewk_Notification_Cancel_Callback cancel_callback,
+ void* user_data) {
+ impl->SetNotificationCallbacks(show_callback, cancel_callback, user_data);
+}
\ No newline at end of file
unsigned int InspectorServerStart(unsigned int port) const;
bool InspectorServerStop() const;
+ void SetNotificationCallbacks(
+ Ewk_Notification_Show_Callback show_callback,
+ Ewk_Notification_Cancel_Callback cancel_callback,
+ void* user_data);
+
private:
EWebContext* impl;
Ewk_Context_Notification_Show_Callback show_callback,
Ewk_Context_Notification_Cancel_Callback cancel_callback, void* user_data)
{
+ EINA_SAFETY_ON_NULL_RETURN_VAL(context, EINA_FALSE);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(show_callback, EINA_FALSE);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(cancel_callback, EINA_FALSE);
+
+ Ewk_Notification_Show_Callback scb =
+ reinterpret_cast<Ewk_Notification_Show_Callback>(show_callback);
+
+ Ewk_Notification_Cancel_Callback ccb =
+ reinterpret_cast<Ewk_Notification_Cancel_Callback>(cancel_callback);
+
+ context->SetNotificationCallbacks(scb, ccb, user_data);
return EINA_TRUE;
}
Eina_Bool ewk_context_notification_callbacks_reset(Ewk_Context* context)
{
+ EINA_SAFETY_ON_NULL_RETURN_VAL(context, EINA_FALSE);
+
+ context->SetNotificationCallbacks(nullptr, nullptr, nullptr);
return EINA_TRUE;
}
typedef struct Ewk_Context Ewk_Context;
typedef struct Ewk_Context_Exceeded_Quota Ewk_Context_Exceeded_Quota;
-typedef void (*Ewk_Context_Notification_Show_Callback)(Ewk_Context*,
- Ewk_Notification*, void*);
-typedef void (*Ewk_Context_Notification_Cancel_Callback)(Ewk_Context*,
- uint64_t, void*);
+typedef void (*Ewk_Context_Notification_Show_Callback)(Ewk_Notification*, void*);
+typedef void (*Ewk_Context_Notification_Cancel_Callback)(uint64_t, void*);
/**
* Deletes Ewk_Context.