Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(193)

Side by Side Diff: Source/modules/notifications/Notification.h

Issue 789643003: The Service Worker notificationclick event should carry a notification. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: add missing file Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 29 matching lines...) Expand all
40 #include "public/platform/WebNotificationDelegate.h" 40 #include "public/platform/WebNotificationDelegate.h"
41 #include "public/platform/WebNotificationPermission.h" 41 #include "public/platform/WebNotificationPermission.h"
42 #include "wtf/PassOwnPtr.h" 42 #include "wtf/PassOwnPtr.h"
43 #include "wtf/RefCounted.h" 43 #include "wtf/RefCounted.h"
44 44
45 namespace blink { 45 namespace blink {
46 46
47 class ExecutionContext; 47 class ExecutionContext;
48 class NotificationOptions; 48 class NotificationOptions;
49 class NotificationPermissionCallback; 49 class NotificationPermissionCallback;
50 struct WebNotificationData;
50 51
51 class Notification : public RefCountedGarbageCollectedWillBeGarbageCollectedFina lized<Notification>, public ActiveDOMObject, public EventTargetWithInlineData, p ublic WebNotificationDelegate { 52 class Notification : public RefCountedGarbageCollectedWillBeGarbageCollectedFina lized<Notification>, public ActiveDOMObject, public EventTargetWithInlineData, p ublic WebNotificationDelegate {
52 DEFINE_EVENT_TARGET_REFCOUNTING_WILL_BE_REMOVED(RefCountedGarbageCollected<N otification>); 53 DEFINE_EVENT_TARGET_REFCOUNTING_WILL_BE_REMOVED(RefCountedGarbageCollected<N otification>);
53 DEFINE_WRAPPERTYPEINFO(); 54 DEFINE_WRAPPERTYPEINFO();
54 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(Notification); 55 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(Notification);
55 public: 56 public:
56 static Notification* create(ExecutionContext*, const String& title, const No tificationOptions&); 57 static Notification* create(ExecutionContext*, const String& title, const No tificationOptions&);
58 static Notification* create(ExecutionContext*, const String& persistentId, c onst WebNotificationData&);
Michael van Ouwerkerk 2014/12/09 19:49:21 It would be nice to document the different types b
Peter Beverloo 2014/12/10 14:11:09 Done.
57 59
58 virtual ~Notification(); 60 virtual ~Notification();
59 61
60 void close(); 62 void close();
61 63
62 DEFINE_ATTRIBUTE_EVENT_LISTENER(click); 64 DEFINE_ATTRIBUTE_EVENT_LISTENER(click);
63 DEFINE_ATTRIBUTE_EVENT_LISTENER(show); 65 DEFINE_ATTRIBUTE_EVENT_LISTENER(show);
64 DEFINE_ATTRIBUTE_EVENT_LISTENER(error); 66 DEFINE_ATTRIBUTE_EVENT_LISTENER(error);
65 DEFINE_ATTRIBUTE_EVENT_LISTENER(close); 67 DEFINE_ATTRIBUTE_EVENT_LISTENER(close);
66 68
(...skipping 23 matching lines...) Expand all
90 virtual bool dispatchEvent(PassRefPtrWillBeRawPtr<Event>) override final; 92 virtual bool dispatchEvent(PassRefPtrWillBeRawPtr<Event>) override final;
91 virtual const AtomicString& interfaceName() const override; 93 virtual const AtomicString& interfaceName() const override;
92 94
93 // ActiveDOMObject interface. 95 // ActiveDOMObject interface.
94 virtual void stop() override; 96 virtual void stop() override;
95 virtual bool hasPendingActivity() const override; 97 virtual bool hasPendingActivity() const override;
96 98
97 private: 99 private:
98 Notification(const String& title, ExecutionContext*); 100 Notification(const String& title, ExecutionContext*);
99 101
102 void scheduleShow();
103
100 // Calling show() may start asynchronous operation. If this object has 104 // Calling show() may start asynchronous operation. If this object has
101 // a V8 wrapper, hasPendingActivity() prevents the wrapper from being 105 // a V8 wrapper, hasPendingActivity() prevents the wrapper from being
102 // collected while m_state is Showing, and so this instance stays alive 106 // collected while m_state is Showing, and so this instance stays alive
103 // until the operation completes. Otherwise, you need to hold a ref on this 107 // until the operation completes. Otherwise, you need to hold a ref on this
104 // instance until the operation completes. 108 // instance until the operation completes.
105 void show(); 109 void show();
106 110
107 void setDir(const String& dir) { m_dir = dir; } 111 void setDir(const String& dir) { m_dir = dir; }
108 void setLang(const String& lang) { m_lang = lang; } 112 void setLang(const String& lang) { m_lang = lang; }
109 void setBody(const String& body) { m_body = body; } 113 void setBody(const String& body) { m_body = body; }
110 void setIconUrl(KURL iconUrl) { m_iconUrl = iconUrl; } 114 void setIconUrl(KURL iconUrl) { m_iconUrl = iconUrl; }
111 void setTag(const String& tag) { m_tag = tag; } 115 void setTag(const String& tag) { m_tag = tag; }
112 116
117 void setPersistentId(const String& persistentId) { m_persistentId = persiste ntId; }
118
113 private: 119 private:
114 String m_title; 120 String m_title;
115 String m_dir; 121 String m_dir;
116 String m_lang; 122 String m_lang;
117 String m_body; 123 String m_body;
118 String m_tag; 124 String m_tag;
119 125
120 KURL m_iconUrl; 126 KURL m_iconUrl;
121 127
128 // Notifications can either be bound to the page, which means they're identi fied by
129 // their delegate, or persistent, which means they're identified by a persis tent Id
130 // given to us by the embedder. This influences how we close the notificatio n.
131 String m_persistentId;
132
122 enum NotificationState { 133 enum NotificationState {
123 NotificationStateIdle, 134 NotificationStateIdle,
124 NotificationStateShowing, 135 NotificationStateShowing,
125 NotificationStateClosed 136 NotificationStateClosed
126 }; 137 };
127 138
139 // Only to be used by the Notification::create() method when notifications w ere created
140 // by the embedder rather than by Blink.
141 void setState(NotificationState state) { m_state = state; }
142
128 NotificationState m_state; 143 NotificationState m_state;
129 144
130 AsyncMethodRunner<Notification> m_asyncRunner; 145 AsyncMethodRunner<Notification> m_asyncRunner;
131 }; 146 };
132 147
133 } // namespace blink 148 } // namespace blink
134 149
135 #endif // Notification_h 150 #endif // Notification_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698