| 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 #ifndef PermissionsCallback_h | 5 #ifndef PermissionsCallback_h |
| 6 #define PermissionsCallback_h | 6 #define PermissionsCallback_h |
| 7 | 7 |
| 8 #include "platform/heap/Handle.h" | 8 #include "platform/heap/Handle.h" |
| 9 #include "public/platform/WebCallbacks.h" | 9 #include "public/platform/WebCallbacks.h" |
| 10 #include "public/platform/WebPassOwnPtr.h" | |
| 11 #include "public/platform/WebVector.h" | 10 #include "public/platform/WebVector.h" |
| 12 #include "public/platform/modules/permissions/WebPermissionStatus.h" | 11 #include "public/platform/modules/permissions/WebPermissionStatus.h" |
| 13 #include "public/platform/modules/permissions/WebPermissionType.h" | 12 #include "public/platform/modules/permissions/WebPermissionType.h" |
| 14 #include "wtf/Noncopyable.h" | 13 #include "wtf/Noncopyable.h" |
| 15 #include "wtf/PassRefPtr.h" | 14 #include "wtf/PassRefPtr.h" |
| 16 #include "wtf/RefPtr.h" | 15 #include "wtf/RefPtr.h" |
| 17 | 16 |
| 17 #include <memory> |
| 18 |
| 18 namespace blink { | 19 namespace blink { |
| 19 | 20 |
| 20 class ScriptPromiseResolver; | 21 class ScriptPromiseResolver; |
| 21 | 22 |
| 22 // PermissionQueryCallback is an implementation of WebPermissionCallbacks | 23 // PermissionQueryCallback is an implementation of WebPermissionCallbacks |
| 23 // that will resolve the underlying promise depending on the result passed to | 24 // that will resolve the underlying promise depending on the result passed to |
| 24 // the callback. It takes a WebPermissionType in its constructor and will pass | 25 // the callback. It takes a WebPermissionType in its constructor and will pass |
| 25 // it to the PermissionStatus. | 26 // it to the PermissionStatus. |
| 26 class PermissionsCallback final | 27 class PermissionsCallback final |
| 27 : public WebCallbacks<WebPassOwnPtr<WebVector<WebPermissionStatus>>, void> { | 28 : public WebCallbacks<std::unique_ptr<WebVector<WebPermissionStatus>>, void>
{ |
| 28 public: | 29 public: |
| 29 PermissionsCallback(ScriptPromiseResolver*, PassOwnPtr<Vector<WebPermissionT
ype>>, PassOwnPtr<Vector<int>>); | 30 PermissionsCallback(ScriptPromiseResolver*, PassOwnPtr<Vector<WebPermissionT
ype>>, PassOwnPtr<Vector<int>>); |
| 30 ~PermissionsCallback() = default; | 31 ~PermissionsCallback() = default; |
| 31 | 32 |
| 32 void onSuccess(WebPassOwnPtr<WebVector<WebPermissionStatus>>) override; | 33 void onSuccess(std::unique_ptr<WebVector<WebPermissionStatus>>) override; |
| 33 void onError() override; | 34 void onError() override; |
| 34 | 35 |
| 35 private: | 36 private: |
| 36 Persistent<ScriptPromiseResolver> m_resolver; | 37 Persistent<ScriptPromiseResolver> m_resolver; |
| 37 | 38 |
| 38 // The permission types which were passed to the client to be requested. | 39 // The permission types which were passed to the client to be requested. |
| 39 OwnPtr<Vector<WebPermissionType>> m_internalPermissions; | 40 OwnPtr<Vector<WebPermissionType>> m_internalPermissions; |
| 40 | 41 |
| 41 // Maps each index in the caller vector to the corresponding index in the | 42 // Maps each index in the caller vector to the corresponding index in the |
| 42 // internal vector (i.e. the vector passsed to the client) such that both | 43 // internal vector (i.e. the vector passsed to the client) such that both |
| 43 // indices have the same WebPermissionType. | 44 // indices have the same WebPermissionType. |
| 44 OwnPtr<Vector<int>> m_callerIndexToInternalIndex; | 45 OwnPtr<Vector<int>> m_callerIndexToInternalIndex; |
| 45 | 46 |
| 46 WTF_MAKE_NONCOPYABLE(PermissionsCallback); | 47 WTF_MAKE_NONCOPYABLE(PermissionsCallback); |
| 47 }; | 48 }; |
| 48 | 49 |
| 49 } // namespace blink | 50 } // namespace blink |
| 50 | 51 |
| 51 #endif // PermissionsCallback_h | 52 #endif // PermissionsCallback_h |
| OLD | NEW |