Chromium Code Reviews| Index: Source/modules/notifications/Notification.h |
| diff --git a/Source/modules/notifications/Notification.h b/Source/modules/notifications/Notification.h |
| index 31735bfc09638301e01ed1731ef34223e6263b7f..88297f9a4bb9d9a887208f9444c37844c9dd031d 100644 |
| --- a/Source/modules/notifications/Notification.h |
| +++ b/Source/modules/notifications/Notification.h |
| @@ -43,7 +43,7 @@ |
| #include "platform/text/TextDirection.h" |
| #include "platform/weborigin/KURL.h" |
| #include "public/platform/WebVector.h" |
| -#include "public/platform/modules/notifications/WebNotificationAction.h" |
| +#include "public/platform/modules/notifications/WebNotificationData.h" |
| #include "public/platform/modules/notifications/WebNotificationDelegate.h" |
| #include "public/platform/modules/notifications/WebNotificationPermission.h" |
| #include "wtf/PassOwnPtr.h" |
| @@ -59,7 +59,6 @@ class NotificationPermissionCallback; |
| class ScriptState; |
| class ScriptValue; |
| class UnsignedLongOrUnsignedLongSequence; |
| -struct WebNotificationData; |
| class MODULES_EXPORT Notification final : public RefCountedGarbageCollectedEventTargetWithInlineData<Notification>, public ActiveDOMObject, public WebNotificationDelegate { |
| REFCOUNTED_GARBAGE_COLLECTED_EVENT_TARGET(Notification); |
| @@ -67,7 +66,7 @@ class MODULES_EXPORT Notification final : public RefCountedGarbageCollectedEvent |
| DEFINE_WRAPPERTYPEINFO(); |
| public: |
| // Used for JavaScript instantiations of the Notification object. Will automatically schedule for |
| - // the notification to be displayed to the user. |
| + // the notification to be displayed to the user when the developer-provided data is valid. |
| static Notification* create(ExecutionContext*, const String& title, const NotificationOptions&, ExceptionState&); |
| // Used for embedder-created Notification objects. Will initialize the Notification's state as showing. |
| @@ -88,20 +87,16 @@ public: |
| void dispatchErrorEvent() override; |
| void dispatchCloseEvent() override; |
| - String title() const { return m_title; } |
| - String dir() const { return m_dir; } |
| - String lang() const { return m_lang; } |
| - String body() const { return m_body; } |
| - String tag() const { return m_tag; } |
| - String icon() const { return m_iconUrl; } |
| - const NavigatorVibration::VibrationPattern& vibrate(bool& isNull) const; |
| - bool silent() const { return m_silent; } |
| - ScriptValue data(ScriptState*) const; |
| - const HeapVector<NotificationAction>& actions() const { return m_actions; } |
| - |
| - TextDirection direction() const; |
| - KURL iconURL() const { return m_iconUrl; } |
| - SerializedScriptValue* serializedData() const { return m_serializedData.get(); } |
| + String title() const; |
| + String dir() const; |
| + String lang() const; |
| + String body() const; |
| + String tag() const; |
| + String icon() const; |
| + NavigatorVibration::VibrationPattern vibrate(bool& isNull) const; |
| + bool silent() const; |
| + ScriptValue data(ScriptState*); |
| + HeapVector<NotificationAction> actions() const; |
|
johnme
2015/08/03 15:41:36
does returning a new HeapVector each time affect w
Peter Beverloo
2015/08/03 17:29:30
It affects whether it returns the same object. Sin
|
| static String permissionString(WebNotificationPermission); |
| static String permission(ExecutionContext*); |
| @@ -110,8 +105,6 @@ public: |
| static size_t maxActions(); |
| - static void actionsToWebActions(const HeapVector<NotificationAction>& actions, WebVector<WebNotificationAction>* webActions); |
| - |
| // EventTarget interface. |
| ExecutionContext* executionContext() const final { return ActiveDOMObject::executionContext(); } |
| const AtomicString& interfaceName() const override; |
| @@ -127,9 +120,7 @@ protected: |
| bool dispatchEventInternal(PassRefPtrWillBeRawPtr<Event>) final; |
| private: |
| - static void webActionsToActions(const WebVector<WebNotificationAction>& webActions, HeapVector<NotificationAction>* actions); |
| - |
| - Notification(const String& title, ExecutionContext*); |
| + Notification(ExecutionContext*, const WebNotificationData&); |
| void scheduleShow(); |
| @@ -140,29 +131,12 @@ private: |
| // instance until the operation completes. |
| void show(); |
| - void setDir(const String& dir) { m_dir = dir; } |
| - void setLang(const String& lang) { m_lang = lang; } |
| - void setBody(const String& body) { m_body = body; } |
| - void setIconUrl(KURL iconUrl) { m_iconUrl = iconUrl; } |
| - void setTag(const String& tag) { m_tag = tag; } |
| - void setVibrate(const NavigatorVibration::VibrationPattern& vibrate) { m_vibrate = vibrate; } |
| - void setSilent(bool silent) { m_silent = silent; } |
| - void setSerializedData(PassRefPtr<SerializedScriptValue> data) { m_serializedData = data; } |
| - void setActions(const HeapVector<NotificationAction>& actions) { m_actions = actions; } |
| - |
| void setPersistentId(int64_t persistentId) { m_persistentId = persistentId; } |
| - String m_title; |
| - String m_dir; |
| - String m_lang; |
| - String m_body; |
| - String m_tag; |
| - NavigatorVibration::VibrationPattern m_vibrate; |
| - bool m_silent; |
| - RefPtr<SerializedScriptValue> m_serializedData; |
| - HeapVector<NotificationAction> m_actions; |
| +private: |
| + WebNotificationData m_data; |
| - KURL m_iconUrl; |
| + RefPtr<SerializedScriptValue> m_serializedData; |
| // Notifications can either be bound to the page, which means they're identified by |
| // their delegate, or persistent, which means they're identified by a persistent Id |