Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 | |
|
abarth-chromium
2013/10/22 18:46:51
supurious?
tyoshino (SeeGerritForStatus)
2013/10/23 06:02:30
oh, mistake. removed
| |
| 1 /* | 2 /* |
| 2 * Copyright (C) 2009 Google Inc. All rights reserved. | 3 * Copyright (C) 2009 Google Inc. All rights reserved. |
| 3 * Copyright (C) 2009, 2011, 2012 Apple Inc. All rights reserved. | 4 * Copyright (C) 2009, 2011, 2012 Apple Inc. All rights reserved. |
| 4 * | 5 * |
| 5 * Redistribution and use in source and binary forms, with or without | 6 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions are | 7 * modification, are permitted provided that the following conditions are |
| 7 * met: | 8 * met: |
| 8 * | 9 * |
| 9 * * Redistributions of source code must retain the above copyright | 10 * * Redistributions of source code must retain the above copyright |
| 10 * notice, this list of conditions and the following disclaimer. | 11 * notice, this list of conditions and the following disclaimer. |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 80 es.throwDOMException(SyntaxError, ExceptionMessages::failedToExecute("cr eateNotification", "NotificationCenter", "'" + iconURI + "' is not a valid icon URL.")); | 81 es.throwDOMException(SyntaxError, ExceptionMessages::failedToExecute("cr eateNotification", "NotificationCenter", "'" + iconURI + "' is not a valid icon URL.")); |
| 81 return; | 82 return; |
| 82 } | 83 } |
| 83 } | 84 } |
| 84 #endif | 85 #endif |
| 85 | 86 |
| 86 Notification::Notification(ExecutionContext* context, const String& title) | 87 Notification::Notification(ExecutionContext* context, const String& title) |
| 87 : ActiveDOMObject(context) | 88 : ActiveDOMObject(context) |
| 88 , m_title(title) | 89 , m_title(title) |
| 89 , m_state(Idle) | 90 , m_state(Idle) |
| 90 , m_taskTimer(adoptPtr(new Timer<Notification>(this, &Notification::taskTime rFired))) | 91 , m_asyncRunner(adoptPtr(new AsyncMethodRunner<Notification>(this, &Notifica tion::showSoon))) |
| 91 { | 92 { |
| 92 ScriptWrappable::init(this); | 93 ScriptWrappable::init(this); |
| 93 | 94 |
| 94 m_notificationClient = NotificationController::clientFrom(toDocument(context )->page()); | 95 m_notificationClient = NotificationController::clientFrom(toDocument(context )->page()); |
| 95 ASSERT(m_notificationClient); | 96 ASSERT(m_notificationClient); |
| 96 | 97 |
| 97 m_taskTimer->startOneShot(0); | 98 m_asyncRunner->runAsync(); |
| 98 } | 99 } |
| 99 | 100 |
| 100 Notification::~Notification() | 101 Notification::~Notification() |
| 101 { | 102 { |
| 102 } | 103 } |
| 103 | 104 |
| 104 #if ENABLE(LEGACY_NOTIFICATIONS) | 105 #if ENABLE(LEGACY_NOTIFICATIONS) |
| 105 PassRefPtr<Notification> Notification::create(const String& title, const String& body, const String& iconURI, ExecutionContext* context, ExceptionState& es, Pas sRefPtr<NotificationCenter> provider) | 106 PassRefPtr<Notification> Notification::create(const String& title, const String& body, const String& iconURI, ExecutionContext* context, ExceptionState& es, Pas sRefPtr<NotificationCenter> provider) |
| 106 { | 107 { |
| 107 RefPtr<Notification> notification(adoptRef(new Notification(title, body, ico nURI, context, es, provider))); | 108 RefPtr<Notification> notification(adoptRef(new Notification(title, body, ico nURI, context, es, provider))); |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 200 { | 201 { |
| 201 dispatchEvent(Event::create(EventTypeNames::close)); | 202 dispatchEvent(Event::create(EventTypeNames::close)); |
| 202 finalize(); | 203 finalize(); |
| 203 } | 204 } |
| 204 | 205 |
| 205 void Notification::dispatchErrorEvent() | 206 void Notification::dispatchErrorEvent() |
| 206 { | 207 { |
| 207 dispatchEvent(Event::create(EventTypeNames::error)); | 208 dispatchEvent(Event::create(EventTypeNames::error)); |
| 208 } | 209 } |
| 209 | 210 |
| 210 void Notification::taskTimerFired(Timer<Notification>* timer) | 211 void Notification::showSoon() |
| 211 { | 212 { |
| 212 ASSERT(executionContext()->isDocument()); | 213 ASSERT(executionContext()->isDocument()); |
| 213 ASSERT_UNUSED(timer, timer == m_taskTimer.get()); | |
| 214 show(); | 214 show(); |
| 215 } | 215 } |
| 216 | 216 |
| 217 bool Notification::dispatchEvent(PassRefPtr<Event> event) | 217 bool Notification::dispatchEvent(PassRefPtr<Event> event) |
| 218 { | 218 { |
| 219 // Do not dispatch if the context is gone. | 219 // Do not dispatch if the context is gone. |
| 220 if (!executionContext()) | 220 if (!executionContext()) |
| 221 return false; | 221 return false; |
| 222 | 222 |
| 223 return EventTarget::dispatchEvent(event); | 223 return EventTarget::dispatchEvent(event); |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 248 return deniedPermission; | 248 return deniedPermission; |
| 249 } | 249 } |
| 250 | 250 |
| 251 void Notification::requestPermission(ExecutionContext* context, PassRefPtr<Notif icationPermissionCallback> callback) | 251 void Notification::requestPermission(ExecutionContext* context, PassRefPtr<Notif icationPermissionCallback> callback) |
| 252 { | 252 { |
| 253 ASSERT(toDocument(context)->page()); | 253 ASSERT(toDocument(context)->page()); |
| 254 NotificationController::from(toDocument(context)->page())->client()->request Permission(context, callback); | 254 NotificationController::from(toDocument(context)->page())->client()->request Permission(context, callback); |
| 255 } | 255 } |
| 256 | 256 |
| 257 } // namespace WebCore | 257 } // namespace WebCore |
| OLD | NEW |