| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef PermissionsCallback_h | |
| 6 #define PermissionsCallback_h | |
| 7 | |
| 8 #include "platform/heap/Handle.h" | |
| 9 #include "public/platform/WebCallbacks.h" | |
| 10 #include "public/platform/WebVector.h" | |
| 11 #include "public/platform/modules/permissions/WebPermissionStatus.h" | |
| 12 #include "public/platform/modules/permissions/WebPermissionType.h" | |
| 13 #include "wtf/Noncopyable.h" | |
| 14 #include "wtf/PassRefPtr.h" | |
| 15 #include "wtf/RefPtr.h" | |
| 16 #include <memory> | |
| 17 | |
| 18 namespace blink { | |
| 19 | |
| 20 class ScriptPromiseResolver; | |
| 21 | |
| 22 // PermissionQueryCallback is an implementation of WebPermissionCallbacks | |
| 23 // 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 // it to the PermissionStatus. | |
| 26 class PermissionsCallback final | |
| 27 : public WebCallbacks<std::unique_ptr<WebVector<WebPermissionStatus>>, void>
{ | |
| 28 public: | |
| 29 PermissionsCallback(ScriptPromiseResolver*, std::unique_ptr<Vector<WebPermis
sionType>>, std::unique_ptr<Vector<int>>); | |
| 30 ~PermissionsCallback() = default; | |
| 31 | |
| 32 void onSuccess(std::unique_ptr<WebVector<WebPermissionStatus>>) override; | |
| 33 void onError() override; | |
| 34 | |
| 35 private: | |
| 36 Persistent<ScriptPromiseResolver> m_resolver; | |
| 37 | |
| 38 // The permission types which were passed to the client to be requested. | |
| 39 std::unique_ptr<Vector<WebPermissionType>> m_internalPermissions; | |
| 40 | |
| 41 // 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 // indices have the same WebPermissionType. | |
| 44 std::unique_ptr<Vector<int>> m_callerIndexToInternalIndex; | |
| 45 | |
| 46 WTF_MAKE_NONCOPYABLE(PermissionsCallback); | |
| 47 }; | |
| 48 | |
| 49 } // namespace blink | |
| 50 | |
| 51 #endif // PermissionsCallback_h | |
| OLD | NEW |