| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "modules/permissions/PermissionsCallback.h" | 5 #include "modules/permissions/PermissionsCallback.h" |
| 6 | 6 |
| 7 #include "bindings/core/v8/ScriptPromiseResolver.h" | 7 #include "bindings/core/v8/ScriptPromiseResolver.h" |
| 8 #include "modules/permissions/PermissionStatus.h" | 8 #include "modules/permissions/PermissionStatus.h" |
| 9 | 9 |
| 10 namespace blink { | 10 namespace blink { |
| 11 | 11 |
| 12 PermissionsCallback::PermissionsCallback(ScriptPromiseResolver* resolver, PassOw
nPtr<Vector<WebPermissionType>> internalPermissions, PassOwnPtr<Vector<int>> cal
lerIndexToInternalIndex) | 12 PermissionsCallback::PermissionsCallback(ScriptPromiseResolver* resolver, PassOw
nPtr<Vector<WebPermissionType>> internalPermissions, PassOwnPtr<Vector<int>> cal
lerIndexToInternalIndex) |
| 13 : m_resolver(resolver), | 13 : m_resolver(resolver), |
| 14 m_internalPermissions(internalPermissions), | 14 m_internalPermissions(internalPermissions), |
| 15 m_callerIndexToInternalIndex(callerIndexToInternalIndex) | 15 m_callerIndexToInternalIndex(callerIndexToInternalIndex) |
| 16 { | 16 { |
| 17 ASSERT(m_resolver); | 17 ASSERT(m_resolver); |
| 18 } | 18 } |
| 19 | 19 |
| 20 void PermissionsCallback::onSuccess(WebPassOwnPtr<WebVector<WebPermissionStatus>
> permissionStatus) | 20 void PermissionsCallback::onSuccess(WebPassOwnPtr<WebVector<WebPermissionStatus>
> permissionStatus) |
| 21 { | 21 { |
| 22 if (!m_resolver->executionContext() || m_resolver->executionContext()->activ
eDOMObjectsAreStopped()) | 22 if (!m_resolver->getExecutionContext() || m_resolver->getExecutionContext()-
>activeDOMObjectsAreStopped()) |
| 23 return; | 23 return; |
| 24 | 24 |
| 25 OwnPtr<WebVector<WebPermissionStatus>> statusPtr = permissionStatus.release(
); | 25 OwnPtr<WebVector<WebPermissionStatus>> statusPtr = permissionStatus.release(
); |
| 26 HeapVector<Member<PermissionStatus>> result(m_callerIndexToInternalIndex->si
ze()); | 26 HeapVector<Member<PermissionStatus>> result(m_callerIndexToInternalIndex->si
ze()); |
| 27 | 27 |
| 28 // Create the response vector by finding the status for each index by | 28 // Create the response vector by finding the status for each index by |
| 29 // using the caller to internal index mapping and looking up the status | 29 // using the caller to internal index mapping and looking up the status |
| 30 // using the internal index obtained. | 30 // using the internal index obtained. |
| 31 for (size_t i = 0; i < m_callerIndexToInternalIndex->size(); ++i) { | 31 for (size_t i = 0; i < m_callerIndexToInternalIndex->size(); ++i) { |
| 32 int internalIndex = m_callerIndexToInternalIndex->operator[](i); | 32 int internalIndex = m_callerIndexToInternalIndex->operator[](i); |
| 33 result[i] = PermissionStatus::createAndListen(m_resolver->executionConte
xt(), statusPtr->operator[](internalIndex), m_internalPermissions->operator[](in
ternalIndex)); | 33 result[i] = PermissionStatus::createAndListen(m_resolver->getExecutionCo
ntext(), statusPtr->operator[](internalIndex), m_internalPermissions->operator[]
(internalIndex)); |
| 34 } | 34 } |
| 35 m_resolver->resolve(result); | 35 m_resolver->resolve(result); |
| 36 } | 36 } |
| 37 | 37 |
| 38 void PermissionsCallback::onError() | 38 void PermissionsCallback::onError() |
| 39 { | 39 { |
| 40 if (!m_resolver->executionContext() || m_resolver->executionContext()->activ
eDOMObjectsAreStopped()) | 40 if (!m_resolver->getExecutionContext() || m_resolver->getExecutionContext()-
>activeDOMObjectsAreStopped()) |
| 41 return; | 41 return; |
| 42 m_resolver->reject(); | 42 m_resolver->reject(); |
| 43 } | 43 } |
| 44 | 44 |
| 45 } // namespace blink | 45 } // namespace blink |
| OLD | NEW |