#include "common/web_contents_utils.h"
#include "content/browser/renderer_host/render_view_host_impl.h"
#include "content/public/browser/web_contents.h"
-#include "tizen_webview/public/tw_notification.h"
+#include "private/ewk_notification_private.h"
#include "tizen_webview/public/tw_security_origin.h"
#include "tizen_webview/tw_misc_utility.h"
-using tizen_webview::NotificationPermissionRequest;
using tizen_webview::Security_Origin;
using web_contents_utils::WebViewFromWebContents;
}
void NotificationControllerEfl::SetPermissionForNotification(
- NotificationPermissionRequest* notification, bool isAllowed) {
+ Ewk_Notification_Permission_Request* notification, bool isAllowed) {
EWebView* wv = EWebView::FromEvasObject(notification->GetWebviewEvasObject());
DCHECK(wv);
result_callback.Run(kDefaultResponse);
return;
}
- scoped_ptr<NotificationPermissionRequest> notification_permission(
- new NotificationPermissionRequest(web_view->evas_object(),
+ scoped_ptr<Ewk_Notification_Permission_Request> notification_permission(
+ new Ewk_Notification_Permission_Request(web_view->evas_object(),
result_callback, tizen_webview::GetURL(requesting_frame)));
if (!web_view->IsNotificationPermissionCallbackSet()) {
#include "tizen_webview/public/tw_url.h"
#include "url/gurl.h"
-
-namespace tizen_webview {
-class NotificationPermissionRequest;
-}
+class Ewk_Notification_Permission_Request;
namespace content {
class DesktopNotificationDelegate;
// sets the permission for a particular pending notification
void SetPermissionForNotification(
- tizen_webview::NotificationPermissionRequest* notification,
+ Ewk_Notification_Permission_Request* notification,
bool isAllowed);
// Sets the permissions for given origins
#include "browser/notification/notification_controller_efl.h"
-#include "tizen_webview/public/tw_notification.h"
+#include "private/ewk_notification_private.h"
#include "tizen_webview/public/tw_security_origin.h"
#include "tizen_webview/public/tw_url.h"
#include "tizen_webview/tw_misc_utility.h"
-using tizen_webview::NotificationPermissionRequest;
using tizen_webview::Security_Origin;
using tizen_webview::URL;
using web_contents_utils::WebContentsFromFrameID;
notification_controller_->NotificationAdd(notificationUniqueId,
render_process_id, params.replace_id, delegate.Pass());
- tizen_webview::Notification* notification =
- new tizen_webview::Notification(base::UTF16ToUTF8(params.body),
- base::UTF16ToUTF8(params.replace_id),
- base::UTF16ToUTF8(params.title),
- params.icon,
- notificationUniqueId,
- URL(params.origin.host(),
- params.origin.scheme(),
- atoi(params.origin.port().c_str())));
+ Ewk_Notification* notification =
+ new Ewk_Notification(base::UTF16ToUTF8(params.body),
+ base::UTF16ToUTF8(params.replace_id),
+ base::UTF16ToUTF8(params.title),
+ params.icon,
+ notificationUniqueId,
+ URL(params.origin.host(),
+ params.origin.scheme(),
+ atoi(params.origin.port().c_str())));
notification_show_callback_(notification, notification_callback_user_data_);
delete notification;
class CommandLine;
}
-namespace tizen_webview {
-class Notification;
-}
-
class EWebContext;
+class Ewk_Notification;
namespace content {
class BrowserMainPartsEfl;
class ContentBrowserClientEfl: public ContentBrowserClient {
public:
- typedef void (*Notification_Show_Callback)(tizen_webview::Notification*, void*);
+ typedef void (*Notification_Show_Callback)(Ewk_Notification*, void*);
typedef void (*Notification_Cancel_Callback)(uint64_t, void*);
ContentBrowserClientEfl();
'tizen_webview/public/tw_frame.h',
'tizen_webview/public/tw_url.cc',
'tizen_webview/public/tw_webview_delegate.h',
- 'tizen_webview/public/tw_notification.h',
'tizen_webview/public/tw_context_menu_controller.h',
- 'tizen_webview/public/tw_notification.cc',
'tizen_webview/public/tw_security_origin.cc',
'tizen_webview/public/tw_selection_controller.h',
'tizen_webview/public/tw_selection_controller.cc',
}
bool EWebView::InvokeNotificationPermissionCallback(
- NotificationPermissionRequest *request) {
+ Ewk_Notification_Permission_Request *request) {
if (!notification_permission_callback_) {
return false;
}
tizen_webview::View_Notification_Permission_Callback func,
void* user_data)
: obj_(obj), func_(func), user_data_(user_data) {}
- bool Run(tizen_webview::NotificationPermissionRequest* request) {
+ bool Run(Ewk_Notification_Permission_Request* request) {
if (func_) {
return (func_)(obj_, request, user_data_) == EINA_TRUE;
}
void InvokeWebAppIconUrlsGetCallback(const std::map<std::string, std::string> &iconUrls, int callbackId);
void SetNotificationPermissionCallback(tizen_webview::View_Notification_Permission_Callback callback, void* user_data);
bool IsNotificationPermissionCallbackSet() const;
- bool InvokeNotificationPermissionCallback(tizen_webview::NotificationPermissionRequest* request);
+ bool InvokeNotificationPermissionCallback(Ewk_Notification_Permission_Request* request);
bool GetMHTMLData(tizen_webview::View_MHTML_Data_Get_Callback callback, void* user_data);
void OnMHTMLContentGet(const std::string& mhtml_content, int callback_id);
class Ewk_Wrt_Message_Data;
-namespace tizen_webview {
-class Notification;
-class NotificationPermissionRequest;
-}
-
namespace EWebViewCallbacks {
enum CallbackType {
#include "ewk_notification_private.h"
+#include "content/public/browser/browser_thread.h"
-// Use compiler generated constructor and destructor
-// No significant implementation is required.
+using content::BrowserThread;
-Ewk_Notification* chromium_glue::from(tizen_webview::Notification* val) {
- // Down-casting is safe because it is the only class that inherits
- // tizen_webview::Notification
- return static_cast<Ewk_Notification*>(val);
+Ewk_Notification::Ewk_Notification(
+ const std::string& body,
+ const std::string& replaceID,
+ const std::string& title,
+ const SkBitmap& icon,
+ uint64_t notificationID,
+ const tizen_webview::URL& origin)
+ : body_(body)
+ , icon_(icon)
+ , replaceID_(replaceID)
+ , title_(title)
+ , notificationID_(notificationID)
+ , origin_(new tizen_webview::Security_Origin(origin)) {
}
+
+Ewk_Notification::~Ewk_Notification() {
+}
+
+const char* Ewk_Notification::GetBody() const {
+ return body_.c_str();
+}
+
+const char* Ewk_Notification::GetReplaceId() const {
+ return replaceID_.c_str();
+}
+
+const char* Ewk_Notification::GetTitle() const {
+ return title_.c_str();
+}
+
+Evas_Object* Ewk_Notification::GetIcon(Evas* evas) const {
+ if (icon_.isNull()) {
+ return nullptr;
+ }
+
+ Evas_Object* icon = evas_object_image_filled_add(evas);
+ evas_object_image_size_set(icon, icon_.width(), icon_.height());
+ evas_object_image_colorspace_set(icon, EVAS_COLORSPACE_ARGB8888);
+ evas_object_image_alpha_set(icon, EINA_TRUE);
+ void* pixels = evas_object_image_data_get(icon, EINA_TRUE);
+ if (pixels) {
+ icon_.copyPixelsTo(pixels, icon_.getSize());
+ evas_object_image_data_set(icon, pixels);
+ }
+
+ return icon;
+}
+
+int Ewk_Notification::GetID() const {
+ return notificationID_;
+}
+
+const tizen_webview::Security_Origin* Ewk_Notification::GetSecurityOrigin() const {
+ return origin_.get();
+}
+
+
+Ewk_Notification_Permission_Request::Ewk_Notification_Permission_Request(
+ Evas_Object* webview,
+ const base::Callback<void(bool)>& callback,
+ const tizen_webview::URL& source_origin)
+ : webview_(webview)
+ , origin_(new tizen_webview::Security_Origin(source_origin))
+ , callback_(callback)
+ , decided_(false)
+ , suspended_(false)
+{
+}
+
+Ewk_Notification_Permission_Request::~Ewk_Notification_Permission_Request() {
+}
+
+Evas_Object* Ewk_Notification_Permission_Request::GetWebviewEvasObject() const {
+ return webview_;
+}
+
+const tizen_webview::Security_Origin* Ewk_Notification_Permission_Request::GetSecurityOrigin() const {
+ return origin_.get();
+}
+
+bool Ewk_Notification_Permission_Request::IsDecided() const {
+ return decided_;
+}
+
+bool Ewk_Notification_Permission_Request::IsSuspended() const {
+ return suspended_;
+}
+
+bool Ewk_Notification_Permission_Request::SetSuspend(bool suspend) const {
+ if (suspend != suspended_) {
+ suspended_ = suspend;
+ return true;
+ }
+
+ return false;
+}
+
+bool Ewk_Notification_Permission_Request::Reply(bool allow) {
+ if (decided_)
+ return false;
+
+ decided_ = true;
+ callback_.Run(allow);
+
+ if (suspended_) {
+ // If decision was suspended, then it was not deleted by the creator
+ // Deletion of this object must be done after decision was made, as
+ // this object will no longer be valid. But if decision was not suspended
+ // it will be deleted right after permission callbacks are executed.
+ BrowserThread::DeleteSoon(BrowserThread::UI, FROM_HERE, this);
+ }
+
+ return true;
+}
+
+
#ifndef ewk_notification_private_h
#define ewk_notification_private_h
-#include <tizen_webview/public/tw_notification.h>
+#include <Evas.h>
+#include <string>
-struct Ewk_Notification : public tizen_webview::Notification {
-};
+#include "base/callback.h"
+#include "base/memory/scoped_ptr.h"
+#include "third_party/skia/include/core/SkBitmap.h"
+
+#include "tizen_webview/public/tw_macro.h"
+#include "tizen_webview/public/tw_security_origin.h"
+
+struct Ewk_Notification {
+ public:
+ Ewk_Notification(const std::string& body,
+ const std::string& replaceID,
+ const std::string& title,
+ const SkBitmap& icon,
+ uint64_t notificationID,
+ const tizen_webview::URL& securityOrigin);
+ ~Ewk_Notification();
+
+ const char* GetBody() const;
+ const char* GetReplaceId() const;
+ const char* GetTitle() const;
+ Evas_Object* GetIcon(Evas* evas) const;
+ int GetID() const;
+ const tizen_webview::Security_Origin* GetSecurityOrigin() const;
+
+ private:
+ std::string body_;
+ SkBitmap icon_;
+ std::string replaceID_;
+ std::string title_;
+ uint64_t notificationID_;
+ scoped_ptr<tizen_webview::Security_Origin> origin_;
+
+ DISALLOW_COPY_AND_ASSIGN(Ewk_Notification);
-struct Ewk_Notification_Permission_Request
- : public tizen_webview::NotificationPermissionRequest {
};
-namespace chromium_glue {
- Ewk_Notification* from(tizen_webview::Notification*);
+struct Ewk_Notification_Permission_Request {
+ public:
+ Ewk_Notification_Permission_Request(Evas_Object* webview,
+ const base::Callback<void(bool)>& callback,
+ const tizen_webview::URL& source_origin);
+ ~Ewk_Notification_Permission_Request();
+
+ Evas_Object* GetWebviewEvasObject() const;
+ const tizen_webview::Security_Origin* GetSecurityOrigin() const;
+ bool IsDecided() const;
+ bool IsSuspended() const;
+ bool SetSuspend(bool suspend) const;
+ bool Reply(bool allow);
+
+ private:
+ Evas_Object* webview_;
+ scoped_ptr<tizen_webview::Security_Origin> origin_;
+ base::Callback<void(bool)> callback_;
+ bool decided_;
+ mutable bool suspended_;
+
+ DISALLOW_COPY_AND_ASSIGN(Ewk_Notification_Permission_Request);
+};
- //tizen_webview::NotificationPermissionRequest* to(tizen_webview::Notification*);
-}
#endif // ewk_notification_private_h
ContentBrowserClientEfl* cbce = GetContentBrowserClient();
EINA_SAFETY_ON_NULL_RETURN_VAL(cbce, EINA_FALSE);
- ContentBrowserClientEfl::Notification_Show_Callback scb =
- reinterpret_cast<ContentBrowserClientEfl::Notification_Show_Callback>(show_callback);
-
- ContentBrowserClientEfl::Notification_Cancel_Callback ccb =
- reinterpret_cast<ContentBrowserClientEfl::Notification_Cancel_Callback>(cancel_callback);
-
- cbce->SetNotificationCallbacks(scb, ccb, user_data);
+ cbce->SetNotificationCallbacks(show_callback, cancel_callback, user_data);
return EINA_TRUE;
}
#include <Evas.h>
+class Ewk_Notification_Permission_Request;
+
namespace tizen_webview {
class Hit_Test;
class Security_Origin;
-class NotificationPermissionRequest;
// from ewk_context.h
typedef void (*Local_File_System_Origins_Get_Callback)(Eina_List *origins, void *user_data);
* @param request Ewk_Notification_Permission_Request object to get the information about notification permission request.
* @param user_data user data
*/
-typedef Eina_Bool (*View_Notification_Permission_Callback)(Evas_Object *o, NotificationPermissionRequest *request, void *user_data);
+typedef Eina_Bool (*View_Notification_Permission_Callback)(Evas_Object *o, Ewk_Notification_Permission_Request *request, void *user_data);
/**
* Callback for ewk_view_script_execute
+++ /dev/null
-// Copyright (c) 2014 The Chromium Authors. All rights reserved.
-// Copyright 2014 Samsung Electronics. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "tw_notification.h"
-
-#include "content/public/browser/browser_thread.h"
-
-using content::BrowserThread;
-
-namespace tizen_webview {
-
-// tizen_webview::Notification ------------------------------------------------
-Notification::Notification(
- const std::string& body,
- const std::string& replaceID,
- const std::string& title,
- const SkBitmap& icon,
- uint64_t notificationID,
- const tizen_webview::URL& origin)
- : body_(body)
- , icon_(icon)
- , replaceID_(replaceID)
- , title_(title)
- , notificationID_(notificationID)
- , origin_(new Security_Origin(origin)) {
-}
-
-Notification::~Notification() {
-}
-
-const char* Notification::GetBody() const {
- return body_.c_str();
-}
-
-const char* Notification::GetReplaceId() const {
- return replaceID_.c_str();
-}
-
-const char* Notification::GetTitle() const {
- return title_.c_str();
-}
-
-Evas_Object* Notification::GetIcon(Evas* evas) const {
- if (icon_.isNull()) {
- return nullptr;
- }
-
- Evas_Object* icon = evas_object_image_filled_add(evas);
- evas_object_image_size_set(icon, icon_.width(), icon_.height());
- evas_object_image_colorspace_set(icon, EVAS_COLORSPACE_ARGB8888);
- evas_object_image_alpha_set(icon, EINA_TRUE);
- void* pixels = evas_object_image_data_get(icon, EINA_TRUE);
- if (pixels) {
- icon_.copyPixelsTo(pixels, icon_.getSize());
- evas_object_image_data_set(icon, pixels);
- }
-
- return icon;
-}
-
-int Notification::GetID() const {
- return notificationID_;
-}
-
-const Security_Origin* Notification::GetSecurityOrigin() const {
- return origin_.get();
-}
-
-// tizen_webview::NotificationPermissionRequest -------------------------------
-
-NotificationPermissionRequest::NotificationPermissionRequest(
- Evas_Object* webview,
- const base::Callback<void(bool)>& callback,
- const URL& source_origin)
- : webview_(webview)
- , origin_(new Security_Origin(source_origin))
- , callback_(callback)
- , decided_(false)
- , suspended_(false)
-{
-}
-
-NotificationPermissionRequest::~NotificationPermissionRequest() {
-}
-
-Evas_Object* NotificationPermissionRequest::GetWebviewEvasObject() const {
- return webview_;
-}
-
-const Security_Origin* NotificationPermissionRequest::GetSecurityOrigin() const {
- return origin_.get();
-}
-
-bool NotificationPermissionRequest::IsDecided() const {
- return decided_;
-}
-
-bool NotificationPermissionRequest::IsSuspended() const {
- return suspended_;
-}
-
-bool NotificationPermissionRequest::SetSuspend(bool suspend) const {
- if (suspend != suspended_) {
- suspended_ = suspend;
- return true;
- }
-
- return false;
-}
-
-bool NotificationPermissionRequest::Reply(bool allow) {
- if (decided_)
- return false;
-
- decided_ = true;
- callback_.Run(allow);
-
- if (suspended_) {
- // If decision was suspended, then it was not deleted by the creator
- // Deletion of this object must be done after decision was made, as
- // this object will no longer be valid. But if decision was not suspended
- // it will be deleted right after permission callbacks are executed.
- BrowserThread::DeleteSoon(BrowserThread::UI, FROM_HERE, this);
- }
-
- return true;
-}
-
-} // namespace tizen_webview
+++ /dev/null
-// Copyright (c) 2014 The Chromium Authors. All rights reserved.
-// Copyright 2014 Samsung Electronics. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef TIZEN_WEBVIEW_PUBLIC_TW_NOTIFICATION_H_
-#define TIZEN_WEBVIEW_PUBLIC_TW_NOTIFICATION_H_
-
-#include <Evas.h>
-#include <string>
-
-#include "base/callback.h"
-#include "base/memory/scoped_ptr.h"
-#include "third_party/skia/include/core/SkBitmap.h"
-
-#include "tizen_webview/public/tw_macro.h"
-#include "tizen_webview/public/tw_security_origin.h"
-
-struct _Ewk_Notification;
-struct _Ewk_Notification_Permission_Request;
-
-namespace content {
-class NotificationControllerEfl;
-class WebContents;
-}
-
-namespace tizen_webview {
-
-class URL;
-
-class Notification {
- public:
- Notification(const std::string& body,
- const std::string& replaceID,
- const std::string& title,
- const SkBitmap& icon,
- uint64_t notificationID,
- const tizen_webview::URL& securityOrigin);
- ~Notification();
-
- const char* GetBody() const;
- const char* GetReplaceId() const;
- const char* GetTitle() const;
- Evas_Object* GetIcon(Evas* evas) const;
- int GetID() const;
- const Security_Origin* GetSecurityOrigin() const;
-
- private:
- std::string body_;
- SkBitmap icon_;
- std::string replaceID_;
- std::string title_;
- uint64_t notificationID_;
- scoped_ptr<Security_Origin> origin_;
-
- DISALLOW_COPY_AND_ASSIGN(Notification);
-};
-
-class NotificationPermissionRequest {
- public:
- NotificationPermissionRequest(Evas_Object* webview,
- const base::Callback<void(bool)>& callback,
- const tizen_webview::URL& source_origin);
- ~NotificationPermissionRequest();
-
- Evas_Object* GetWebviewEvasObject() const;
- const Security_Origin* GetSecurityOrigin() const;
- bool IsDecided() const;
- bool IsSuspended() const;
- bool SetSuspend(bool suspend) const;
- bool Reply(bool allow);
-
- private:
- Evas_Object* webview_;
- scoped_ptr<Security_Origin> origin_;
- base::Callback<void(bool)> callback_;
- bool decided_;
- mutable bool suspended_;
-
- DISALLOW_COPY_AND_ASSIGN(NotificationPermissionRequest);
-};
-
-} // namespace tizen_webview
-
-#endif // TIZEN_WEBVIEW_PUBLIC_TW_NOTIFICATION_H_
'tizen_webview/public/tw_frame.cc',
'tizen_webview/public/tw_hit_test.h',
'tizen_webview/public/tw_hit_test.cc',
- 'tizen_webview/public/tw_notification.cc',
- 'tizen_webview/public/tw_notification.h',
'tizen_webview/public/tw_policy_decision.h',
'tizen_webview/public/tw_policy_decision.cc',
'tizen_webview/public/tw_security_origin.cc',