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 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
231 | 231 |
232 #if ENABLE(NOTIFICATIONS) | 232 #if ENABLE(NOTIFICATIONS) |
233 const String& Notification::permission(ScriptExecutionContext* context) | 233 const String& Notification::permission(ScriptExecutionContext* context) |
234 { | 234 { |
235 ASSERT(toDocument(context)->page()); | 235 ASSERT(toDocument(context)->page()); |
236 return permissionString(NotificationController::from(toDocument(context)->pa
ge())->client()->checkPermission(context)); | 236 return permissionString(NotificationController::from(toDocument(context)->pa
ge())->client()->checkPermission(context)); |
237 } | 237 } |
238 | 238 |
239 const String& Notification::permissionString(NotificationClient::Permission perm
ission) | 239 const String& Notification::permissionString(NotificationClient::Permission perm
ission) |
240 { | 240 { |
241 DEFINE_STATIC_LOCAL(const String, allowedPermission, (ASCIILiteral("granted"
))); | 241 DEFINE_STATIC_LOCAL(const String, allowedPermission, ("granted")); |
242 DEFINE_STATIC_LOCAL(const String, deniedPermission, (ASCIILiteral("denied"))
); | 242 DEFINE_STATIC_LOCAL(const String, deniedPermission, ("denied")); |
243 DEFINE_STATIC_LOCAL(const String, defaultPermission, (ASCIILiteral("default"
))); | 243 DEFINE_STATIC_LOCAL(const String, defaultPermission, ("default")); |
244 | 244 |
245 switch (permission) { | 245 switch (permission) { |
246 case NotificationClient::PermissionAllowed: | 246 case NotificationClient::PermissionAllowed: |
247 return allowedPermission; | 247 return allowedPermission; |
248 case NotificationClient::PermissionDenied: | 248 case NotificationClient::PermissionDenied: |
249 return deniedPermission; | 249 return deniedPermission; |
250 case NotificationClient::PermissionNotAllowed: | 250 case NotificationClient::PermissionNotAllowed: |
251 return defaultPermission; | 251 return defaultPermission; |
252 } | 252 } |
253 | 253 |
254 ASSERT_NOT_REACHED(); | 254 ASSERT_NOT_REACHED(); |
255 return deniedPermission; | 255 return deniedPermission; |
256 } | 256 } |
257 | 257 |
258 void Notification::requestPermission(ScriptExecutionContext* context, PassRefPtr
<NotificationPermissionCallback> callback) | 258 void Notification::requestPermission(ScriptExecutionContext* context, PassRefPtr
<NotificationPermissionCallback> callback) |
259 { | 259 { |
260 ASSERT(toDocument(context)->page()); | 260 ASSERT(toDocument(context)->page()); |
261 NotificationController::from(toDocument(context)->page())->client()->request
Permission(context, callback); | 261 NotificationController::from(toDocument(context)->page())->client()->request
Permission(context, callback); |
262 } | 262 } |
263 #endif | 263 #endif |
264 | 264 |
265 } // namespace WebCore | 265 } // namespace WebCore |
266 | 266 |
267 #endif // ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS) | 267 #endif // ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS) |
OLD | NEW |