| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2009 Google Inc. All rights reserved. | 2 * Copyright (C) 2009 Google Inc. All rights reserved. |
| 3 * Copyright (C) 2009, 2011, 2012 Apple Inc. All rights reserved. | 3 * Copyright (C) 2009, 2011, 2012 Apple Inc. All rights reserved. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions are | 6 * modification, are permitted provided that the following conditions are |
| 7 * met: | 7 * met: |
| 8 * | 8 * |
| 9 * * Redistributions of source code must retain the above copyright | 9 * * Redistributions of source code must retain the above copyright |
| 10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 REFCOUNTED_EVENT_TARGET(Notification); | 64 REFCOUNTED_EVENT_TARGET(Notification); |
| 65 public: | 65 public: |
| 66 Notification(); | 66 Notification(); |
| 67 #if ENABLE(LEGACY_NOTIFICATIONS) | 67 #if ENABLE(LEGACY_NOTIFICATIONS) |
| 68 static PassRefPtr<Notification> create(const String& title, const String& bo
dy, const String& iconURI, ExecutionContext*, ExceptionState&, PassRefPtr<Notifi
cationCenter> provider); | 68 static PassRefPtr<Notification> create(const String& title, const String& bo
dy, const String& iconURI, ExecutionContext*, ExceptionState&, PassRefPtr<Notifi
cationCenter> provider); |
| 69 #endif | 69 #endif |
| 70 static PassRefPtr<Notification> create(ExecutionContext*, const String& titl
e, const Dictionary& options); | 70 static PassRefPtr<Notification> create(ExecutionContext*, const String& titl
e, const Dictionary& options); |
| 71 | 71 |
| 72 virtual ~Notification(); | 72 virtual ~Notification(); |
| 73 | 73 |
| 74 // Calling show() may start asynchronous operation. If this object has |
| 75 // a V8 wrapper, hasPendingActivity() prevents the wrapper from being |
| 76 // collected while m_state is Showing, and so this instance stays alive |
| 77 // until the operation completes. Otherwise, you need to hold a ref on this |
| 78 // instance until the operation completes. |
| 74 void show(); | 79 void show(); |
| 75 #if ENABLE(LEGACY_NOTIFICATIONS) | 80 #if ENABLE(LEGACY_NOTIFICATIONS) |
| 76 void cancel() { close(); } | 81 void cancel() { close(); } |
| 77 #endif | 82 #endif |
| 78 void close(); | 83 void close(); |
| 79 | 84 |
| 80 String title() const { return m_title; } | 85 String title() const { return m_title; } |
| 81 String dir() const { return m_direction; } | 86 String dir() const { return m_direction; } |
| 82 String lang() const { return m_lang; } | 87 String lang() const { return m_lang; } |
| 83 String body() const { return m_body; } | 88 String body() const { return m_body; } |
| (...skipping 25 matching lines...) Expand all Loading... |
| 109 void dispatchShowEvent(); | 114 void dispatchShowEvent(); |
| 110 void dispatchErrorEvent(); | 115 void dispatchErrorEvent(); |
| 111 void dispatchCloseEvent(); | 116 void dispatchCloseEvent(); |
| 112 | 117 |
| 113 // EventTarget interface | 118 // EventTarget interface |
| 114 virtual const AtomicString& interfaceName() const OVERRIDE; | 119 virtual const AtomicString& interfaceName() const OVERRIDE; |
| 115 virtual ExecutionContext* executionContext() const OVERRIDE { return ActiveD
OMObject::executionContext(); } | 120 virtual ExecutionContext* executionContext() const OVERRIDE { return ActiveD
OMObject::executionContext(); } |
| 116 virtual bool dispatchEvent(PassRefPtr<Event>) OVERRIDE; | 121 virtual bool dispatchEvent(PassRefPtr<Event>) OVERRIDE; |
| 117 | 122 |
| 118 // ActiveDOMObject interface | 123 // ActiveDOMObject interface |
| 124 // Override to prevent this from being collected when in Showing state. |
| 125 virtual bool hasPendingActivity() const OVERRIDE; |
| 119 virtual void stop() OVERRIDE; | 126 virtual void stop() OVERRIDE; |
| 120 | 127 |
| 121 static const String& permission(ExecutionContext*); | 128 static const String& permission(ExecutionContext*); |
| 122 static const String& permissionString(NotificationClient::Permission); | 129 static const String& permissionString(NotificationClient::Permission); |
| 123 static void requestPermission(ExecutionContext*, PassRefPtr<NotificationPerm
issionCallback> = 0); | 130 static void requestPermission(ExecutionContext*, PassRefPtr<NotificationPerm
issionCallback> = 0); |
| 124 | 131 |
| 125 private: | 132 private: |
| 126 #if ENABLE(LEGACY_NOTIFICATIONS) | 133 #if ENABLE(LEGACY_NOTIFICATIONS) |
| 127 Notification(const String& title, const String& body, const String& iconURI,
ExecutionContext*, ExceptionState&, PassRefPtr<NotificationCenter>); | 134 Notification(const String& title, const String& body, const String& iconURI,
ExecutionContext*, ExceptionState&, PassRefPtr<NotificationCenter>); |
| 128 #endif | 135 #endif |
| 129 Notification(ExecutionContext*, const String& title); | 136 Notification(ExecutionContext*, const String& title); |
| 130 | 137 |
| 131 void finalize(); | |
| 132 | |
| 133 void setLang(const String& lang) { m_lang = lang; } | 138 void setLang(const String& lang) { m_lang = lang; } |
| 134 void setBody(const String& body) { m_body = body; } | 139 void setBody(const String& body) { m_body = body; } |
| 135 void setIcon(const KURL& url) { m_icon = url; } | 140 void setIcon(const KURL& url) { m_icon = url; } |
| 136 | 141 |
| 137 void showSoon(); | 142 void showSoon(); |
| 138 | 143 |
| 139 // Text notifications. | 144 // Text notifications. |
| 140 KURL m_icon; | 145 KURL m_icon; |
| 141 String m_title; | 146 String m_title; |
| 142 String m_body; | 147 String m_body; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 154 NotificationState m_state; | 159 NotificationState m_state; |
| 155 | 160 |
| 156 NotificationClient* m_notificationClient; | 161 NotificationClient* m_notificationClient; |
| 157 | 162 |
| 158 OwnPtr<AsyncMethodRunner<Notification> > m_asyncRunner; | 163 OwnPtr<AsyncMethodRunner<Notification> > m_asyncRunner; |
| 159 }; | 164 }; |
| 160 | 165 |
| 161 } // namespace WebCore | 166 } // namespace WebCore |
| 162 | 167 |
| 163 #endif // Notifications_h | 168 #endif // Notifications_h |
| OLD | NEW |