| 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 23 matching lines...) Expand all Loading... |
| 34 #include "bindings/core/v8/ScriptState.h" | 34 #include "bindings/core/v8/ScriptState.h" |
| 35 #include "bindings/core/v8/SerializedScriptValueFactory.h" | 35 #include "bindings/core/v8/SerializedScriptValueFactory.h" |
| 36 #include "bindings/modules/v8/V8NotificationAction.h" | 36 #include "bindings/modules/v8/V8NotificationAction.h" |
| 37 #include "core/dom/Document.h" | 37 #include "core/dom/Document.h" |
| 38 #include "core/dom/DocumentUserGestureToken.h" | 38 #include "core/dom/DocumentUserGestureToken.h" |
| 39 #include "core/dom/ExecutionContext.h" | 39 #include "core/dom/ExecutionContext.h" |
| 40 #include "core/dom/ExecutionContextTask.h" | 40 #include "core/dom/ExecutionContextTask.h" |
| 41 #include "core/dom/ScopedWindowFocusAllowedIndicator.h" | 41 #include "core/dom/ScopedWindowFocusAllowedIndicator.h" |
| 42 #include "core/dom/TaskRunnerHelper.h" | 42 #include "core/dom/TaskRunnerHelper.h" |
| 43 #include "core/events/Event.h" | 43 #include "core/events/Event.h" |
| 44 #include "core/frame/Deprecation.h" |
| 44 #include "core/frame/UseCounter.h" | 45 #include "core/frame/UseCounter.h" |
| 45 #include "modules/notifications/NotificationAction.h" | 46 #include "modules/notifications/NotificationAction.h" |
| 46 #include "modules/notifications/NotificationData.h" | 47 #include "modules/notifications/NotificationData.h" |
| 47 #include "modules/notifications/NotificationManager.h" | 48 #include "modules/notifications/NotificationManager.h" |
| 48 #include "modules/notifications/NotificationOptions.h" | 49 #include "modules/notifications/NotificationOptions.h" |
| 49 #include "modules/notifications/NotificationResourcesLoader.h" | 50 #include "modules/notifications/NotificationResourcesLoader.h" |
| 50 #include "platform/RuntimeEnabledFeatures.h" | 51 #include "platform/RuntimeEnabledFeatures.h" |
| 51 #include "platform/UserGestureIndicator.h" | 52 #include "platform/UserGestureIndicator.h" |
| 52 #include "public/platform/Platform.h" | 53 #include "public/platform/Platform.h" |
| 53 #include "public/platform/WebSecurityOrigin.h" | 54 #include "public/platform/WebSecurityOrigin.h" |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 "ServiceWorkerRegistration.showNotification()."); | 92 "ServiceWorkerRegistration.showNotification()."); |
| 92 return nullptr; | 93 return nullptr; |
| 93 } | 94 } |
| 94 | 95 |
| 95 if (context->isSecureContext()) { | 96 if (context->isSecureContext()) { |
| 96 UseCounter::count(context, UseCounter::NotificationSecureOrigin); | 97 UseCounter::count(context, UseCounter::NotificationSecureOrigin); |
| 97 if (context->isDocument()) | 98 if (context->isDocument()) |
| 98 UseCounter::countCrossOriginIframe( | 99 UseCounter::countCrossOriginIframe( |
| 99 *toDocument(context), UseCounter::NotificationAPISecureOriginIframe); | 100 *toDocument(context), UseCounter::NotificationAPISecureOriginIframe); |
| 100 } else { | 101 } else { |
| 101 UseCounter::count(context, UseCounter::NotificationInsecureOrigin); | 102 Deprecation::countDeprecation(context, |
| 103 UseCounter::NotificationInsecureOrigin); |
| 102 if (context->isDocument()) | 104 if (context->isDocument()) |
| 103 UseCounter::countCrossOriginIframe( | 105 Deprecation::countDeprecationCrossOriginIframe( |
| 104 *toDocument(context), | 106 *toDocument(context), |
| 105 UseCounter::NotificationAPIInsecureOriginIframe); | 107 UseCounter::NotificationAPIInsecureOriginIframe); |
| 106 } | 108 } |
| 107 | 109 |
| 108 WebNotificationData data = | 110 WebNotificationData data = |
| 109 createWebNotificationData(context, title, options, exceptionState); | 111 createWebNotificationData(context, title, options, exceptionState); |
| 110 if (exceptionState.hadException()) | 112 if (exceptionState.hadException()) |
| 111 return nullptr; | 113 return nullptr; |
| 112 | 114 |
| 113 Notification* notification = | 115 Notification* notification = |
| (...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 351 } | 353 } |
| 352 | 354 |
| 353 String Notification::permission(ExecutionContext* context) { | 355 String Notification::permission(ExecutionContext* context) { |
| 354 return permissionString( | 356 return permissionString( |
| 355 NotificationManager::from(context)->permissionStatus(context)); | 357 NotificationManager::from(context)->permissionStatus(context)); |
| 356 } | 358 } |
| 357 | 359 |
| 358 ScriptPromise Notification::requestPermission( | 360 ScriptPromise Notification::requestPermission( |
| 359 ScriptState* scriptState, | 361 ScriptState* scriptState, |
| 360 NotificationPermissionCallback* deprecatedCallback) { | 362 NotificationPermissionCallback* deprecatedCallback) { |
| 361 return NotificationManager::from(scriptState->getExecutionContext()) | 363 ExecutionContext* context = scriptState->getExecutionContext(); |
| 362 ->requestPermission(scriptState, deprecatedCallback); | 364 if (!context->isSecureContext()) { |
| 365 Deprecation::countDeprecation( |
| 366 context, UseCounter::NotificationPermissionRequestedInsecureOrigin); |
| 367 } |
| 368 return NotificationManager::from(context)->requestPermission( |
| 369 scriptState, deprecatedCallback); |
| 363 } | 370 } |
| 364 | 371 |
| 365 size_t Notification::maxActions() { | 372 size_t Notification::maxActions() { |
| 366 return kWebNotificationMaxActions; | 373 return kWebNotificationMaxActions; |
| 367 } | 374 } |
| 368 | 375 |
| 369 DispatchEventResult Notification::dispatchEventInternal(Event* event) { | 376 DispatchEventResult Notification::dispatchEventInternal(Event* event) { |
| 370 DCHECK(getExecutionContext()->isContextThread()); | 377 DCHECK(getExecutionContext()->isContextThread()); |
| 371 return EventTarget::dispatchEventInternal(event); | 378 return EventTarget::dispatchEventInternal(event); |
| 372 } | 379 } |
| (...skipping 24 matching lines...) Expand all Loading... |
| 397 } | 404 } |
| 398 | 405 |
| 399 DEFINE_TRACE(Notification) { | 406 DEFINE_TRACE(Notification) { |
| 400 visitor->trace(m_prepareShowMethodRunner); | 407 visitor->trace(m_prepareShowMethodRunner); |
| 401 visitor->trace(m_loader); | 408 visitor->trace(m_loader); |
| 402 EventTargetWithInlineData::trace(visitor); | 409 EventTargetWithInlineData::trace(visitor); |
| 403 ContextLifecycleObserver::trace(visitor); | 410 ContextLifecycleObserver::trace(visitor); |
| 404 } | 411 } |
| 405 | 412 |
| 406 } // namespace blink | 413 } // namespace blink |
| OLD | NEW |