| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2009 Google Inc. All rights reserved. | 2 * Copyright (C) 2009 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 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 return m_private->replaceId(); | 109 return m_private->replaceId(); |
| 110 } | 110 } |
| 111 | 111 |
| 112 void WebNotification::detachPresenter() | 112 void WebNotification::detachPresenter() |
| 113 { | 113 { |
| 114 m_private->detachPresenter(); | 114 m_private->detachPresenter(); |
| 115 } | 115 } |
| 116 | 116 |
| 117 void WebNotification::dispatchDisplayEvent() | 117 void WebNotification::dispatchDisplayEvent() |
| 118 { | 118 { |
| 119 RefPtr<Event> event = Event::create("display", false, true); | 119 dispatchEvent("display"); |
| 120 m_private->dispatchEvent(event.release()); | |
| 121 } | 120 } |
| 122 | 121 |
| 123 void WebNotification::dispatchErrorEvent(const WebKit::WebString& /* errorMessag
e */) | 122 void WebNotification::dispatchErrorEvent(const WebKit::WebString& /* errorMessag
e */) |
| 124 { | 123 { |
| 125 // FIXME: errorMessage not supported by WebCore yet | 124 // FIXME: errorMessage not supported by WebCore yet |
| 126 RefPtr<Event> event = Event::create(eventNames().errorEvent, false, true); | 125 dispatchEvent(eventNames().errorEvent); |
| 127 m_private->dispatchEvent(event.release()); | |
| 128 } | 126 } |
| 129 | 127 |
| 130 void WebNotification::dispatchCloseEvent(bool /* byUser */) | 128 void WebNotification::dispatchCloseEvent(bool /* byUser */) |
| 131 { | 129 { |
| 132 // FIXME: byUser flag not supported by WebCore yet | 130 // FIXME: byUser flag not supported by WebCore yet |
| 133 RefPtr<Event> event = Event::create(eventNames().closeEvent, false, true); | 131 dispatchEvent(eventNames().closeEvent); |
| 134 m_private->dispatchEvent(event.release()); | |
| 135 } | 132 } |
| 136 | 133 |
| 137 void WebNotification::dispatchClickEvent() | 134 void WebNotification::dispatchClickEvent() |
| 138 { | 135 { |
| 139 // Make sure clicks on notifications are treated as user gestures. | 136 // Make sure clicks on notifications are treated as user gestures. |
| 140 UserGestureIndicator gestureIndicator(DefinitelyProcessingUserGesture); | 137 UserGestureIndicator gestureIndicator(DefinitelyProcessingUserGesture); |
| 141 RefPtr<Event> event = Event::create(eventNames().clickEvent, false, true); | 138 dispatchEvent(eventNames().clickEvent); |
| 139 } |
| 140 |
| 141 void WebNotification::dispatchEvent(const WTF::AtomicString& type) |
| 142 { |
| 143 // Do not dispatch if the context is gone. |
| 144 if (!m_private->scriptExecutionContext()) |
| 145 return; |
| 146 |
| 147 RefPtr<Event> event = Event::create(type, false, true); |
| 142 m_private->dispatchEvent(event.release()); | 148 m_private->dispatchEvent(event.release()); |
| 143 } | 149 } |
| 144 | 150 |
| 145 WebNotification::WebNotification(const WTF::PassRefPtr<Notification>& notificati
on) | 151 WebNotification::WebNotification(const WTF::PassRefPtr<Notification>& notificati
on) |
| 146 : m_private(static_cast<WebNotificationPrivate*>(notification.releaseRef())) | 152 : m_private(static_cast<WebNotificationPrivate*>(notification.releaseRef())) |
| 147 { | 153 { |
| 148 } | 154 } |
| 149 | 155 |
| 150 WebNotification& WebNotification::operator=(const WTF::PassRefPtr<Notification>&
notification) | 156 WebNotification& WebNotification::operator=(const WTF::PassRefPtr<Notification>&
notification) |
| 151 { | 157 { |
| (...skipping 10 matching lines...) Expand all Loading... |
| 162 { | 168 { |
| 163 // p is already ref'd for us by the caller | 169 // p is already ref'd for us by the caller |
| 164 if (m_private) | 170 if (m_private) |
| 165 m_private->deref(); | 171 m_private->deref(); |
| 166 m_private = p; | 172 m_private = p; |
| 167 } | 173 } |
| 168 | 174 |
| 169 } // namespace WebKit | 175 } // namespace WebKit |
| 170 | 176 |
| 171 #endif // ENABLE(NOTIFICATIONS) | 177 #endif // ENABLE(NOTIFICATIONS) |
| OLD | NEW |