Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "config.h" | 5 #include "config.h" |
| 6 #include "modules/push_messaging/PushManager.h" | 6 #include "modules/push_messaging/PushManager.h" |
| 7 | 7 |
| 8 #include "bindings/core/v8/CallbackPromiseAdapter.h" | 8 #include "bindings/core/v8/CallbackPromiseAdapter.h" |
| 9 #include "bindings/core/v8/ScriptPromise.h" | 9 #include "bindings/core/v8/ScriptPromise.h" |
| 10 #include "bindings/core/v8/ScriptPromiseResolver.h" | 10 #include "bindings/core/v8/ScriptPromiseResolver.h" |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 86 } | 86 } |
| 87 | 87 |
| 88 ScriptPromise PushManager::permissionState(ScriptState* scriptState, const PushS ubscriptionOptions& options) | 88 ScriptPromise PushManager::permissionState(ScriptState* scriptState, const PushS ubscriptionOptions& options) |
| 89 { | 89 { |
| 90 if (scriptState->executionContext()->isDocument()) { | 90 if (scriptState->executionContext()->isDocument()) { |
| 91 Document* document = toDocument(scriptState->executionContext()); | 91 Document* document = toDocument(scriptState->executionContext()); |
| 92 // FIXME: add test coverage for this condition - https://crbug.com/44043 1 | 92 // FIXME: add test coverage for this condition - https://crbug.com/44043 1 |
| 93 if (!document->domWindow() || !document->frame()) | 93 if (!document->domWindow() || !document->frame()) |
| 94 return ScriptPromise::rejectWithDOMException(scriptState, DOMExcepti on::create(InvalidStateError, "Document is detached from window.")); | 94 return ScriptPromise::rejectWithDOMException(scriptState, DOMExcepti on::create(InvalidStateError, "Document is detached from window.")); |
| 95 } | 95 } |
| 96 if (!options.userVisibleOnly()) { | |
| 97 return ScriptPromise::rejectWithDOMException(scriptState, DOMException:: create(NotSupportedError, | |
|
johnme
2015/05/08 15:48:22
To change the subject (since I think Peter and Mic
johnme
2015/05/08 15:57:07
Oh, it's rejecting the promise with an exception,
Miguel Garcia
2015/05/08 21:00:32
Yes, it feels more accurate than just denying. Tha
| |
| 98 "Chrome does not support push subscriptions that do not enable the u serVisibleOnly option.")); | |
| 99 } | |
| 96 | 100 |
| 97 RefPtrWillBeRawPtr<ScriptPromiseResolver> resolver = ScriptPromiseResolver:: create(scriptState); | 101 RefPtrWillBeRawPtr<ScriptPromiseResolver> resolver = ScriptPromiseResolver:: create(scriptState); |
| 98 ScriptPromise promise = resolver->promise(); | 102 ScriptPromise promise = resolver->promise(); |
| 99 | 103 |
| 100 pushProvider()->getPermissionStatus(m_registration->webRegistration(), toWeb PushSubscriptionOptions(options), new PushPermissionStatusCallbacks(resolver)); | 104 pushProvider()->getPermissionStatus(m_registration->webRegistration(), toWeb PushSubscriptionOptions(options), new PushPermissionStatusCallbacks(resolver)); |
| 101 return promise; | 105 return promise; |
| 102 } | 106 } |
| 103 | 107 |
| 104 DEFINE_TRACE(PushManager) | 108 DEFINE_TRACE(PushManager) |
| 105 { | 109 { |
| 106 visitor->trace(m_registration); | 110 visitor->trace(m_registration); |
| 107 } | 111 } |
| 108 | 112 |
| 109 } // namespace blink | 113 } // namespace blink |
| OLD | NEW |