| 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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 #include "modules/notifications/NotificationCenter.h" | 49 #include "modules/notifications/NotificationCenter.h" |
| 50 #include "modules/notifications/NotificationClient.h" | 50 #include "modules/notifications/NotificationClient.h" |
| 51 #include "modules/notifications/NotificationController.h" | 51 #include "modules/notifications/NotificationController.h" |
| 52 #include "modules/notifications/NotificationPermissionCallback.h" | 52 #include "modules/notifications/NotificationPermissionCallback.h" |
| 53 | 53 |
| 54 namespace WebCore { | 54 namespace WebCore { |
| 55 | 55 |
| 56 Notification::Notification() | 56 Notification::Notification() |
| 57 : ActiveDOMObject(0) | 57 : ActiveDOMObject(0) |
| 58 { | 58 { |
| 59 ScriptWrappable::init(this); |
| 59 } | 60 } |
| 60 | 61 |
| 61 #if ENABLE(LEGACY_NOTIFICATIONS) | 62 #if ENABLE(LEGACY_NOTIFICATIONS) |
| 62 Notification::Notification(const KURL& url, ScriptExecutionContext* context, Exc
eptionCode& ec, PassRefPtr<NotificationCenter> provider) | 63 Notification::Notification(const KURL& url, ScriptExecutionContext* context, Exc
eptionCode& ec, PassRefPtr<NotificationCenter> provider) |
| 63 : ActiveDOMObject(context) | 64 : ActiveDOMObject(context) |
| 64 , m_isHTML(true) | 65 , m_isHTML(true) |
| 65 , m_state(Idle) | 66 , m_state(Idle) |
| 66 , m_notificationCenter(provider) | 67 , m_notificationCenter(provider) |
| 67 { | 68 { |
| 69 ScriptWrappable::init(this); |
| 68 if (m_notificationCenter->checkPermission() != NotificationClient::Permissio
nAllowed) { | 70 if (m_notificationCenter->checkPermission() != NotificationClient::Permissio
nAllowed) { |
| 69 ec = SECURITY_ERR; | 71 ec = SECURITY_ERR; |
| 70 return; | 72 return; |
| 71 } | 73 } |
| 72 | 74 |
| 73 if (url.isEmpty() || !url.isValid()) { | 75 if (url.isEmpty() || !url.isValid()) { |
| 74 ec = SYNTAX_ERR; | 76 ec = SYNTAX_ERR; |
| 75 return; | 77 return; |
| 76 } | 78 } |
| 77 | 79 |
| 78 m_notificationURL = url; | 80 m_notificationURL = url; |
| 79 } | 81 } |
| 80 #endif | 82 #endif |
| 81 | 83 |
| 82 #if ENABLE(LEGACY_NOTIFICATIONS) | 84 #if ENABLE(LEGACY_NOTIFICATIONS) |
| 83 Notification::Notification(const String& title, const String& body, const String
& iconURI, ScriptExecutionContext* context, ExceptionCode& ec, PassRefPtr<Notifi
cationCenter> provider) | 85 Notification::Notification(const String& title, const String& body, const String
& iconURI, ScriptExecutionContext* context, ExceptionCode& ec, PassRefPtr<Notifi
cationCenter> provider) |
| 84 : ActiveDOMObject(context) | 86 : ActiveDOMObject(context) |
| 85 , m_isHTML(false) | 87 , m_isHTML(false) |
| 86 , m_title(title) | 88 , m_title(title) |
| 87 , m_body(body) | 89 , m_body(body) |
| 88 , m_state(Idle) | 90 , m_state(Idle) |
| 89 , m_notificationCenter(provider) | 91 , m_notificationCenter(provider) |
| 90 { | 92 { |
| 93 ScriptWrappable::init(this); |
| 91 if (m_notificationCenter->checkPermission() != NotificationClient::Permissio
nAllowed) { | 94 if (m_notificationCenter->checkPermission() != NotificationClient::Permissio
nAllowed) { |
| 92 ec = SECURITY_ERR; | 95 ec = SECURITY_ERR; |
| 93 return; | 96 return; |
| 94 } | 97 } |
| 95 | 98 |
| 96 m_icon = iconURI.isEmpty() ? KURL() : scriptExecutionContext()->completeURL(
iconURI); | 99 m_icon = iconURI.isEmpty() ? KURL() : scriptExecutionContext()->completeURL(
iconURI); |
| 97 if (!m_icon.isEmpty() && !m_icon.isValid()) { | 100 if (!m_icon.isEmpty() && !m_icon.isValid()) { |
| 98 ec = SYNTAX_ERR; | 101 ec = SYNTAX_ERR; |
| 99 return; | 102 return; |
| 100 } | 103 } |
| 101 } | 104 } |
| 102 #endif | 105 #endif |
| 103 | 106 |
| 104 #if ENABLE(NOTIFICATIONS) | 107 #if ENABLE(NOTIFICATIONS) |
| 105 Notification::Notification(ScriptExecutionContext* context, const String& title) | 108 Notification::Notification(ScriptExecutionContext* context, const String& title) |
| 106 : ActiveDOMObject(context) | 109 : ActiveDOMObject(context) |
| 107 , m_isHTML(false) | 110 , m_isHTML(false) |
| 108 , m_title(title) | 111 , m_title(title) |
| 109 , m_state(Idle) | 112 , m_state(Idle) |
| 110 , m_taskTimer(adoptPtr(new Timer<Notification>(this, &Notification::taskTime
rFired))) | 113 , m_taskTimer(adoptPtr(new Timer<Notification>(this, &Notification::taskTime
rFired))) |
| 111 { | 114 { |
| 115 ScriptWrappable::init(this); |
| 112 m_notificationCenter = DOMWindowNotifications::webkitNotifications(toDocumen
t(context)->domWindow()); | 116 m_notificationCenter = DOMWindowNotifications::webkitNotifications(toDocumen
t(context)->domWindow()); |
| 113 | 117 |
| 114 ASSERT(m_notificationCenter->client()); | 118 ASSERT(m_notificationCenter->client()); |
| 115 m_taskTimer->startOneShot(0); | 119 m_taskTimer->startOneShot(0); |
| 116 } | 120 } |
| 117 #endif | 121 #endif |
| 118 | 122 |
| 119 Notification::~Notification() | 123 Notification::~Notification() |
| 120 { | 124 { |
| 121 } | 125 } |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 284 void Notification::requestPermission(ScriptExecutionContext* context, PassRefPtr
<NotificationPermissionCallback> callback) | 288 void Notification::requestPermission(ScriptExecutionContext* context, PassRefPtr
<NotificationPermissionCallback> callback) |
| 285 { | 289 { |
| 286 ASSERT(toDocument(context)->page()); | 290 ASSERT(toDocument(context)->page()); |
| 287 NotificationController::from(toDocument(context)->page())->client()->request
Permission(context, callback); | 291 NotificationController::from(toDocument(context)->page())->client()->request
Permission(context, callback); |
| 288 } | 292 } |
| 289 #endif | 293 #endif |
| 290 | 294 |
| 291 } // namespace WebCore | 295 } // namespace WebCore |
| 292 | 296 |
| 293 #endif // ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS) | 297 #endif // ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS) |
| OLD | NEW |