| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 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 29 matching lines...) Expand all Loading... |
| 40 #include "core/dom/ExecutionContext.h" | 40 #include "core/dom/ExecutionContext.h" |
| 41 #include "core/dom/ExecutionContextTask.h" | 41 #include "core/dom/ExecutionContextTask.h" |
| 42 #include "core/dom/ScopedWindowFocusAllowedIndicator.h" | 42 #include "core/dom/ScopedWindowFocusAllowedIndicator.h" |
| 43 #include "core/events/Event.h" | 43 #include "core/events/Event.h" |
| 44 #include "core/frame/UseCounter.h" | 44 #include "core/frame/UseCounter.h" |
| 45 #include "modules/notifications/NotificationOptions.h" | 45 #include "modules/notifications/NotificationOptions.h" |
| 46 #include "modules/notifications/NotificationPermissionClient.h" | 46 #include "modules/notifications/NotificationPermissionClient.h" |
| 47 #include "platform/RuntimeEnabledFeatures.h" | 47 #include "platform/RuntimeEnabledFeatures.h" |
| 48 #include "platform/UserGestureIndicator.h" | 48 #include "platform/UserGestureIndicator.h" |
| 49 #include "public/platform/Platform.h" | 49 #include "public/platform/Platform.h" |
| 50 #include "public/platform/WebSerializedOrigin.h" |
| 50 #include "public/platform/WebString.h" | 51 #include "public/platform/WebString.h" |
| 51 #include "public/platform/modules/notifications/WebNotificationData.h" | 52 #include "public/platform/modules/notifications/WebNotificationData.h" |
| 52 #include "public/platform/modules/notifications/WebNotificationManager.h" | 53 #include "public/platform/modules/notifications/WebNotificationManager.h" |
| 53 | 54 |
| 54 namespace blink { | 55 namespace blink { |
| 55 namespace { | 56 namespace { |
| 56 | 57 |
| 57 const int64_t kInvalidPersistentId = -1; | 58 const int64_t kInvalidPersistentId = -1; |
| 58 | 59 |
| 59 WebNotificationManager* notificationManager() | 60 WebNotificationManager* notificationManager() |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 184 ASSERT(origin); | 185 ASSERT(origin); |
| 185 | 186 |
| 186 // FIXME: Do CSP checks on the associated notification icon. | 187 // FIXME: Do CSP checks on the associated notification icon. |
| 187 WebNotificationData::Direction dir = m_dir == "rtl" ? WebNotificationData::D
irectionRightToLeft : WebNotificationData::DirectionLeftToRight; | 188 WebNotificationData::Direction dir = m_dir == "rtl" ? WebNotificationData::D
irectionRightToLeft : WebNotificationData::DirectionLeftToRight; |
| 188 | 189 |
| 189 // The lifetime and availability of non-persistent notifications is tied to
the page | 190 // The lifetime and availability of non-persistent notifications is tied to
the page |
| 190 // they were created by, and thus the data doesn't have to be known to the e
mbedder. | 191 // they were created by, and thus the data doesn't have to be known to the e
mbedder. |
| 191 Vector<char> emptyDataWireBytes; | 192 Vector<char> emptyDataWireBytes; |
| 192 | 193 |
| 193 WebNotificationData notificationData(m_title, dir, m_lang, m_body, m_tag, m_
iconUrl, m_vibrate, m_silent, emptyDataWireBytes); | 194 WebNotificationData notificationData(m_title, dir, m_lang, m_body, m_tag, m_
iconUrl, m_vibrate, m_silent, emptyDataWireBytes); |
| 194 notificationManager()->show(*origin, notificationData, this); | 195 notificationManager()->show(WebSerializedOrigin(*origin), notificationData,
this); |
| 195 | 196 |
| 196 m_state = NotificationStateShowing; | 197 m_state = NotificationStateShowing; |
| 197 } | 198 } |
| 198 | 199 |
| 199 void Notification::close() | 200 void Notification::close() |
| 200 { | 201 { |
| 201 if (m_state != NotificationStateShowing) | 202 if (m_state != NotificationStateShowing) |
| 202 return; | 203 return; |
| 203 | 204 |
| 204 if (m_persistentId == kInvalidPersistentId) { | 205 if (m_persistentId == kInvalidPersistentId) { |
| 205 // Fire the close event asynchronously. | 206 // Fire the close event asynchronously. |
| 206 executionContext()->postTask(FROM_HERE, createSameThreadTask(&Notificati
on::dispatchCloseEvent, this)); | 207 executionContext()->postTask(FROM_HERE, createSameThreadTask(&Notificati
on::dispatchCloseEvent, this)); |
| 207 | 208 |
| 208 m_state = NotificationStateClosing; | 209 m_state = NotificationStateClosing; |
| 209 notificationManager()->close(this); | 210 notificationManager()->close(this); |
| 210 } else { | 211 } else { |
| 211 m_state = NotificationStateClosed; | 212 m_state = NotificationStateClosed; |
| 212 | 213 |
| 213 SecurityOrigin* origin = executionContext()->securityOrigin(); | 214 SecurityOrigin* origin = executionContext()->securityOrigin(); |
| 214 ASSERT(origin); | 215 ASSERT(origin); |
| 215 | 216 |
| 216 notificationManager()->closePersistent(*origin, m_persistentId); | 217 notificationManager()->closePersistent(WebSerializedOrigin(*origin), m_p
ersistentId); |
| 217 } | 218 } |
| 218 } | 219 } |
| 219 | 220 |
| 220 void Notification::dispatchShowEvent() | 221 void Notification::dispatchShowEvent() |
| 221 { | 222 { |
| 222 dispatchEvent(Event::create(EventTypeNames::show)); | 223 dispatchEvent(Event::create(EventTypeNames::show)); |
| 223 } | 224 } |
| 224 | 225 |
| 225 void Notification::dispatchClickEvent() | 226 void Notification::dispatchClickEvent() |
| 226 { | 227 { |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 275 String Notification::permission(ExecutionContext* context) | 276 String Notification::permission(ExecutionContext* context) |
| 276 { | 277 { |
| 277 return permissionString(checkPermission(context)); | 278 return permissionString(checkPermission(context)); |
| 278 } | 279 } |
| 279 | 280 |
| 280 WebNotificationPermission Notification::checkPermission(ExecutionContext* contex
t) | 281 WebNotificationPermission Notification::checkPermission(ExecutionContext* contex
t) |
| 281 { | 282 { |
| 282 SecurityOrigin* origin = context->securityOrigin(); | 283 SecurityOrigin* origin = context->securityOrigin(); |
| 283 ASSERT(origin); | 284 ASSERT(origin); |
| 284 | 285 |
| 285 return notificationManager()->checkPermission(*origin); | 286 return notificationManager()->checkPermission(WebSerializedOrigin(*origin)); |
| 286 } | 287 } |
| 287 | 288 |
| 288 void Notification::requestPermission(ExecutionContext* context, NotificationPerm
issionCallback* callback) | 289 void Notification::requestPermission(ExecutionContext* context, NotificationPerm
issionCallback* callback) |
| 289 { | 290 { |
| 290 // FIXME: Assert that this code-path will only be reached for Document envir
onments | 291 // FIXME: Assert that this code-path will only be reached for Document envir
onments |
| 291 // when Blink supports [Exposed] annotations on class members in IDL definit
ions. | 292 // when Blink supports [Exposed] annotations on class members in IDL definit
ions. |
| 292 if (NotificationPermissionClient* permissionClient = NotificationPermissionC
lient::from(context)) | 293 if (NotificationPermissionClient* permissionClient = NotificationPermissionC
lient::from(context)) |
| 293 permissionClient->requestPermission(context, callback); | 294 permissionClient->requestPermission(context, callback); |
| 294 } | 295 } |
| 295 | 296 |
| (...skipping 30 matching lines...) Expand all Loading... |
| 326 return ScriptValue(scriptState, m_serializedData->deserialize(scriptState->i
solate())); | 327 return ScriptValue(scriptState, m_serializedData->deserialize(scriptState->i
solate())); |
| 327 } | 328 } |
| 328 | 329 |
| 329 DEFINE_TRACE(Notification) | 330 DEFINE_TRACE(Notification) |
| 330 { | 331 { |
| 331 RefCountedGarbageCollectedEventTargetWithInlineData<Notification>::trace(vis
itor); | 332 RefCountedGarbageCollectedEventTargetWithInlineData<Notification>::trace(vis
itor); |
| 332 ActiveDOMObject::trace(visitor); | 333 ActiveDOMObject::trace(visitor); |
| 333 } | 334 } |
| 334 | 335 |
| 335 } // namespace blink | 336 } // namespace blink |
| OLD | NEW |