| 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" | 10 #include "public/platform/WebPassOwnPtr.h" |
| 11 #include "public/platform/WebVector.h" | 11 #include "public/platform/WebVector.h" |
| 12 #include "public/platform/modules/permissions/WebPermissionStatus.h" | 12 #include "public/platform/modules/permissions/WebPermissionStatus.h" |
| 13 #include "public/platform/modules/permissions/WebPermissionType.h" | 13 #include "public/platform/modules/permissions/WebPermissionType.h" |
| 14 #include "wtf/Noncopyable.h" | 14 #include "wtf/Noncopyable.h" |
| 15 #include "wtf/PassRefPtr.h" | 15 #include "wtf/PassRefPtr.h" |
| 16 #include "wtf/RefPtr.h" | 16 #include "wtf/RefPtr.h" |
| 17 | 17 |
| 18 namespace blink { | 18 namespace blink { |
| 19 | 19 |
| 20 class ScriptPromiseResolver; | 20 class ScriptPromiseResolver; |
| 21 | 21 |
| 22 // PermissionQueryCallback is an implementation of WebPermissionCallbacks | 22 // PermissionQueryCallback is an implementation of WebPermissionCallbacks |
| 23 // 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 |
| 24 // 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 |
| 25 // it to the PermissionStatus. | 25 // it to the PermissionStatus. |
| 26 class PermissionsCallback final | 26 class PermissionsCallback final |
| 27 : public WebCallbacks<WebPassOwnPtr<WebVector<WebPermissionStatus>>, void> { | 27 : public WebCallbacks<WebPassOwnPtr<WebVector<WebPermissionStatus>>, void> { |
| 28 public: | 28 public: |
| 29 PermissionsCallback(ScriptPromiseResolver*, PassOwnPtr<Vector<WebPermissionT
ype>>, PassOwnPtr<Vector<int>>); | 29 PermissionsCallback(ScriptPromiseResolver*, PassOwnPtr<WebVector<WebPermissi
onType>>); |
| 30 ~PermissionsCallback() = default; | 30 ~PermissionsCallback() = default; |
| 31 | 31 |
| 32 void onSuccess(WebPassOwnPtr<WebVector<WebPermissionStatus>>) override; | 32 void onSuccess(WebPassOwnPtr<WebVector<WebPermissionStatus>>) override; |
| 33 void onError() override; | 33 void onError() override; |
| 34 | 34 |
| 35 private: | 35 private: |
| 36 Persistent<ScriptPromiseResolver> m_resolver; | 36 Persistent<ScriptPromiseResolver> m_resolver; |
| 37 | 37 OwnPtr<WebVector<WebPermissionType>> m_permissionTypes; |
| 38 // The permission types which were passed to the client to be requested. | |
| 39 OwnPtr<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 OwnPtr<Vector<int>> m_callerIndexToInternalIndex; | |
| 45 | 38 |
| 46 WTF_MAKE_NONCOPYABLE(PermissionsCallback); | 39 WTF_MAKE_NONCOPYABLE(PermissionsCallback); |
| 47 }; | 40 }; |
| 48 | 41 |
| 49 } // namespace blink | 42 } // namespace blink |
| 50 | 43 |
| 51 #endif // PermissionsCallback_h | 44 #endif // PermissionsCallback_h |
| OLD | NEW |