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