| 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 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 162 #endif | 162 #endif |
| 163 | 163 |
| 164 const AtomicString& Notification::interfaceName() const | 164 const AtomicString& Notification::interfaceName() const |
| 165 { | 165 { |
| 166 return eventNames().interfaceForNotification; | 166 return eventNames().interfaceForNotification; |
| 167 } | 167 } |
| 168 | 168 |
| 169 void Notification::show() | 169 void Notification::show() |
| 170 { | 170 { |
| 171 // prevent double-showing | 171 // prevent double-showing |
| 172 if (m_state == Idle && m_notificationCenter->client() && m_notificationCente
r->client()->show(this)) { | 172 if (m_state == Idle && m_notificationCenter->client()) { |
| 173 m_state = Showing; | 173 #if ENABLE(NOTIFICATIONS) |
| 174 setPendingActivity(this); | 174 if (!static_cast<Document*>(scriptExecutionContext())->page()) |
| 175 return; |
| 176 if (NotificationController::from(static_cast<Document*>(scriptExecutionC
ontext())->page())->client()->checkPermission(scriptExecutionContext()) != Notif
icationClient::PermissionAllowed) { |
| 177 dispatchErrorEvent(); |
| 178 return; |
| 179 } |
| 180 #endif |
| 181 if (m_notificationCenter->client()->show(this)) { |
| 182 m_state = Showing; |
| 183 setPendingActivity(this); |
| 184 } |
| 175 } | 185 } |
| 176 } | 186 } |
| 177 | 187 |
| 178 void Notification::close() | 188 void Notification::close() |
| 179 { | 189 { |
| 180 switch (m_state) { | 190 switch (m_state) { |
| 181 case Idle: | 191 case Idle: |
| 182 break; | 192 break; |
| 183 case Showing: | 193 case Showing: |
| 184 if (m_notificationCenter->client()) | 194 if (m_notificationCenter->client()) |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 233 | 243 |
| 234 void Notification::dispatchErrorEvent() | 244 void Notification::dispatchErrorEvent() |
| 235 { | 245 { |
| 236 dispatchEvent(Event::create(eventNames().errorEvent, false, false)); | 246 dispatchEvent(Event::create(eventNames().errorEvent, false, false)); |
| 237 } | 247 } |
| 238 | 248 |
| 239 #if ENABLE(NOTIFICATIONS) | 249 #if ENABLE(NOTIFICATIONS) |
| 240 void Notification::taskTimerFired(Timer<Notification>* timer) | 250 void Notification::taskTimerFired(Timer<Notification>* timer) |
| 241 { | 251 { |
| 242 ASSERT(scriptExecutionContext()->isDocument()); | 252 ASSERT(scriptExecutionContext()->isDocument()); |
| 243 ASSERT(static_cast<Document*>(scriptExecutionContext())->page()); | |
| 244 ASSERT_UNUSED(timer, timer == m_taskTimer.get()); | 253 ASSERT_UNUSED(timer, timer == m_taskTimer.get()); |
| 245 if (NotificationController::from(static_cast<Document*>(scriptExecutionConte
xt())->page())->client()->checkPermission(scriptExecutionContext()) != Notificat
ionClient::PermissionAllowed) { | |
| 246 dispatchErrorEvent(); | |
| 247 return; | |
| 248 } | |
| 249 show(); | 254 show(); |
| 250 } | 255 } |
| 251 #endif | 256 #endif |
| 252 | 257 |
| 253 | 258 |
| 254 #if ENABLE(NOTIFICATIONS) | 259 #if ENABLE(NOTIFICATIONS) |
| 255 const String& Notification::permission(ScriptExecutionContext* context) | 260 const String& Notification::permission(ScriptExecutionContext* context) |
| 256 { | 261 { |
| 257 ASSERT(context->isDocument()); | 262 ASSERT(context->isDocument()); |
| 258 ASSERT(static_cast<Document*>(context)->page()); | 263 ASSERT(static_cast<Document*>(context)->page()); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 282 { | 287 { |
| 283 ASSERT(context->isDocument()); | 288 ASSERT(context->isDocument()); |
| 284 ASSERT(static_cast<Document*>(context)->page()); | 289 ASSERT(static_cast<Document*>(context)->page()); |
| 285 NotificationController::from(static_cast<Document*>(context)->page())->clien
t()->requestPermission(context, callback); | 290 NotificationController::from(static_cast<Document*>(context)->page())->clien
t()->requestPermission(context, callback); |
| 286 } | 291 } |
| 287 #endif | 292 #endif |
| 288 | 293 |
| 289 } // namespace WebCore | 294 } // namespace WebCore |
| 290 | 295 |
| 291 #endif // ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS) | 296 #endif // ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS) |
| OLD | NEW |