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 26 matching lines...) Expand all Loading... |
37 #include "core/dom/Document.h" | 37 #include "core/dom/Document.h" |
38 #include "core/dom/ExecutionContext.h" | 38 #include "core/dom/ExecutionContext.h" |
39 #include "core/dom/ExecutionContextTask.h" | 39 #include "core/dom/ExecutionContextTask.h" |
40 #include "core/dom/ScopedWindowFocusAllowedIndicator.h" | 40 #include "core/dom/ScopedWindowFocusAllowedIndicator.h" |
41 #include "core/events/Event.h" | 41 #include "core/events/Event.h" |
42 #include "core/frame/UseCounter.h" | 42 #include "core/frame/UseCounter.h" |
43 #include "modules/notifications/NotificationAction.h" | 43 #include "modules/notifications/NotificationAction.h" |
44 #include "modules/notifications/NotificationData.h" | 44 #include "modules/notifications/NotificationData.h" |
45 #include "modules/notifications/NotificationManager.h" | 45 #include "modules/notifications/NotificationManager.h" |
46 #include "modules/notifications/NotificationOptions.h" | 46 #include "modules/notifications/NotificationOptions.h" |
| 47 #include "modules/notifications/NotificationPermissionClient.h" |
47 #include "modules/notifications/NotificationResourcesLoader.h" | 48 #include "modules/notifications/NotificationResourcesLoader.h" |
48 #include "platform/RuntimeEnabledFeatures.h" | 49 #include "platform/RuntimeEnabledFeatures.h" |
49 #include "platform/UserGestureIndicator.h" | 50 #include "platform/UserGestureIndicator.h" |
50 #include "public/platform/Platform.h" | 51 #include "public/platform/Platform.h" |
51 #include "public/platform/WebSecurityOrigin.h" | 52 #include "public/platform/WebSecurityOrigin.h" |
| 53 #include "public/platform/WebString.h" |
52 #include "public/platform/modules/notifications/WebNotificationAction.h" | 54 #include "public/platform/modules/notifications/WebNotificationAction.h" |
53 #include "public/platform/modules/notifications/WebNotificationConstants.h" | 55 #include "public/platform/modules/notifications/WebNotificationConstants.h" |
54 #include "public/platform/modules/notifications/WebNotificationManager.h" | 56 #include "public/platform/modules/notifications/WebNotificationManager.h" |
| 57 #include "public/platform/modules/permissions/permission_status.mojom-blink.h" |
55 #include "wtf/Assertions.h" | 58 #include "wtf/Assertions.h" |
56 #include "wtf/Functional.h" | 59 #include "wtf/Functional.h" |
57 | 60 |
58 namespace blink { | 61 namespace blink { |
59 namespace { | 62 namespace { |
60 | 63 |
61 const int64_t kInvalidPersistentId = -1; | 64 const int64_t kInvalidPersistentId = -1; |
62 | 65 |
63 WebNotificationManager* notificationManager() | 66 WebNotificationManager* notificationManager() |
64 { | 67 { |
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
344 return "denied"; | 347 return "denied"; |
345 } | 348 } |
346 | 349 |
347 String Notification::permission(ExecutionContext* context) | 350 String Notification::permission(ExecutionContext* context) |
348 { | 351 { |
349 return permissionString(NotificationManager::from(context)->permissionStatus
()); | 352 return permissionString(NotificationManager::from(context)->permissionStatus
()); |
350 } | 353 } |
351 | 354 |
352 ScriptPromise Notification::requestPermission(ScriptState* scriptState, Notifica
tionPermissionCallback* deprecatedCallback) | 355 ScriptPromise Notification::requestPermission(ScriptState* scriptState, Notifica
tionPermissionCallback* deprecatedCallback) |
353 { | 356 { |
354 return NotificationManager::from(scriptState->getExecutionContext())->reques
tPermission(scriptState, deprecatedCallback); | 357 ExecutionContext* context = scriptState->getExecutionContext(); |
| 358 if (NotificationPermissionClient* permissionClient = NotificationPermissionC
lient::from(context)) |
| 359 return permissionClient->requestPermission(scriptState, deprecatedCallba
ck); |
| 360 |
| 361 // The context has been detached. Return a promise that will never settle. |
| 362 DCHECK(context->activeDOMObjectsAreStopped()); |
| 363 |
| 364 return ScriptPromise(); |
355 } | 365 } |
356 | 366 |
357 size_t Notification::maxActions() | 367 size_t Notification::maxActions() |
358 { | 368 { |
359 return kWebNotificationMaxActions; | 369 return kWebNotificationMaxActions; |
360 } | 370 } |
361 | 371 |
362 DispatchEventResult Notification::dispatchEventInternal(Event* event) | 372 DispatchEventResult Notification::dispatchEventInternal(Event* event) |
363 { | 373 { |
364 DCHECK(getExecutionContext()->isContextThread()); | 374 DCHECK(getExecutionContext()->isContextThread()); |
(...skipping 24 matching lines...) Expand all Loading... |
389 | 399 |
390 DEFINE_TRACE(Notification) | 400 DEFINE_TRACE(Notification) |
391 { | 401 { |
392 visitor->trace(m_prepareShowMethodRunner); | 402 visitor->trace(m_prepareShowMethodRunner); |
393 visitor->trace(m_loader); | 403 visitor->trace(m_loader); |
394 EventTargetWithInlineData::trace(visitor); | 404 EventTargetWithInlineData::trace(visitor); |
395 ActiveDOMObject::trace(visitor); | 405 ActiveDOMObject::trace(visitor); |
396 } | 406 } |
397 | 407 |
398 } // namespace blink | 408 } // namespace blink |
OLD | NEW |