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

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

Issue 184733002: Remove support for legacy WebKit Notifications (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Remove tests which no longer apply Created 6 years, 9 months 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) 2009 Google Inc. All rights reserved. 2 * Copyright (C) 2013 Google Inc. All rights reserved.
3 * Copyright (C) 2009, 2011, 2012 Apple Inc. All rights reserved.
4 * 3 *
5 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
7 * met: 6 * met:
8 * 7 *
9 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
11 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
12 * copyright notice, this list of conditions and the following disclaimer 11 * copyright notice, this list of conditions and the following disclaimer
13 * in the documentation and/or other materials provided with the 12 * in the documentation and/or other materials provided with the
(...skipping 11 matching lines...) Expand all
25 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */ 29 */
31 30
32 #ifndef Notification_h 31 #ifndef Notification_h
33 #define Notification_h 32 #define Notification_h
34 33
34 #include "bindings/v8/ScriptWrappable.h"
35 #include "core/dom/ActiveDOMObject.h"
36 #include "core/events/EventTarget.h"
35 #include "heap/Handle.h" 37 #include "heap/Handle.h"
36 #include "modules/notifications/NotificationBase.h" 38 #include "modules/notifications/NotificationClient.h"
37 #include "platform/AsyncMethodRunner.h" 39 #include "platform/AsyncMethodRunner.h"
40 #include "platform/text/TextDirection.h"
41 #include "platform/weborigin/KURL.h"
38 #include "wtf/OwnPtr.h" 42 #include "wtf/OwnPtr.h"
39 #include "wtf/PassRefPtr.h" 43 #include "wtf/PassRefPtr.h"
40 #include "wtf/RefCounted.h" 44 #include "wtf/RefCounted.h"
41 45
42 namespace WebCore { 46 namespace WebCore {
43 47
44 class Dictionary; 48 class Dictionary;
45 class ExecutionContext; 49 class ExecutionContext;
46 class NotificationClient;
47 class NotificationPermissionCallback; 50 class NotificationPermissionCallback;
48 51
49 class Notification FINAL : public RefCountedWillBeRefCountedGarbageCollected<Not ification>, public NotificationBase { 52 class Notification : public RefCountedWillBeRefCountedGarbageCollected<Notificat ion>, public ScriptWrappable, public ActiveDOMObject, public EventTargetWithInli neData {
50 DEFINE_EVENT_TARGET_REFCOUNTING(RefCountedWillBeRefCountedGarbageCollected<N otification>); 53 DEFINE_EVENT_TARGET_REFCOUNTING(RefCountedWillBeRefCountedGarbageCollected<N otification>);
51 54
52 public: 55 public:
53 static PassRefPtrWillBeRawPtr<Notification> create(ExecutionContext*, const String& title, const Dictionary& options); 56 static PassRefPtrWillBeRawPtr<Notification> create(ExecutionContext*, const String& title, const Dictionary& options);
54 57
55 virtual ~Notification(); 58 virtual ~Notification();
56 59
60 // Calling show() may start asynchronous operation. If this object has
61 // a V8 wrapper, hasPendingActivity() prevents the wrapper from being
62 // collected while m_state is Showing, and so this instance stays alive
63 // until the operation completes. Otherwise, you need to hold a ref on this
64 // instance until the operation completes.
65 void show();
66
67 void close();
68
69 DEFINE_ATTRIBUTE_EVENT_LISTENER(click);
70 DEFINE_ATTRIBUTE_EVENT_LISTENER(show);
71 DEFINE_ATTRIBUTE_EVENT_LISTENER(error);
72 DEFINE_ATTRIBUTE_EVENT_LISTENER(close);
73
74 void dispatchShowEvent();
75 void dispatchClickEvent();
76 void dispatchErrorEvent();
77 void dispatchCloseEvent();
78
79 String title() const { return m_title; }
80 String dir() const { return m_dir; }
81 String lang() const { return m_lang; }
82 String body() const { return m_body; }
83 String tag() const { return m_tag; }
84 String icon() const { return m_iconUrl; }
85
86 TextDirection direction() const;
87 KURL iconURL() const { return m_iconUrl; }
88
89 static const String& permissionString(NotificationClient::Permission);
57 static const String& permission(ExecutionContext*); 90 static const String& permission(ExecutionContext*);
58 static void requestPermission(ExecutionContext*, PassOwnPtr<NotificationPerm issionCallback> = nullptr); 91 static void requestPermission(ExecutionContext*, PassOwnPtr<NotificationPerm issionCallback> = nullptr);
59 92
60 // EventTarget interface 93 // EventTarget interface.
94 virtual ExecutionContext* executionContext() const OVERRIDE FINAL { return A ctiveDOMObject::executionContext(); }
95 virtual bool dispatchEvent(PassRefPtr<Event>) OVERRIDE FINAL;
61 virtual const AtomicString& interfaceName() const OVERRIDE; 96 virtual const AtomicString& interfaceName() const OVERRIDE;
62 97
63 // ActiveDOMObject interface 98 // ActiveDOMObject interface.
64 virtual void stop() OVERRIDE; 99 virtual void stop() OVERRIDE;
65 virtual bool hasPendingActivity() const OVERRIDE; 100 virtual bool hasPendingActivity() const OVERRIDE;
66 101
102 // RefCountedWillBeRefCountedGarbageCollected<Notification> interface.
67 void trace(Visitor*) { } 103 void trace(Visitor*) { }
68 104
69 private: 105 private:
70 Notification(ExecutionContext*, const String& title, NotificationClient*); 106 Notification(const String& title, ExecutionContext*, NotificationClient*);
107
108 void setDir(const String& dir) { m_dir = dir; }
109 void setLang(const String& lang) { m_lang = lang; }
110 void setBody(const String& body) { m_body = body; }
111 void setIconUrl(KURL iconUrl) { m_iconUrl = iconUrl; }
112 void setTag(const String& tag) { m_tag = tag; }
71 113
72 void showSoon(); 114 void showSoon();
73 115
116 private:
117 String m_title;
118 String m_dir;
119 String m_lang;
120 String m_body;
121 String m_tag;
122
123 KURL m_iconUrl;
124
125 enum NotificationState {
126 Idle = 0,
127 Showing = 1,
128 Closed = 2,
129 };
130
131 NotificationState m_state;
132
133 NotificationClient* m_client;
134
74 OwnPtr<AsyncMethodRunner<Notification> > m_asyncRunner; 135 OwnPtr<AsyncMethodRunner<Notification> > m_asyncRunner;
75 }; 136 };
76 137
77 } // namespace WebCore 138 } // namespace WebCore
78 139
79 #endif // Notifications_h 140 #endif // Notification_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698