1 /* 2 * Copyright (c) 2023 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef OHOS_ABILITY_RUNTIME_REQUEST_INFO_H 17 #define OHOS_ABILITY_RUNTIME_REQUEST_INFO_H 18 19 #include "iremote_object.h" 20 #include "native_engine/native_engine.h" 21 22 namespace OHOS { 23 namespace AbilityRuntime { 24 class RequestInfo { 25 public: 26 RequestInfo(const sptr<IRemoteObject> &token, int32_t left, int32_t top, int32_t width, int32_t height); 27 ~RequestInfo(); 28 29 /** 30 * @brief Wrap request info to native value. 31 * 32 * @param env napi_env. 33 * @param request Request information. 34 * @return Native value wrapped from request. 35 */ 36 static napi_value WrapRequestInfo(napi_env env, RequestInfo *request); 37 38 /** 39 * @brief Unwrap native value to request information. 40 * 41 * @param env napi_env. 42 * @param jsParam napi_value. 43 * @return Request information unwrapped from native value. 44 */ 45 static std::shared_ptr<RequestInfo> UnwrapRequestInfo(napi_env env, napi_value jsParam); 46 47 /** 48 * @brief Get caller token. 49 * 50 * @return token. 51 */ 52 sptr<IRemoteObject> GetToken(); 53 54 /** 55 * @brief Create JsWindowRect. 56 * 57 * @param env napi_env. 58 * @param the left position of WindowRect. 59 * @param the top position of WindowRect. 60 * @param the width position of WindowRect. 61 * @param the height position of WindowRect. 62 * @return Native value Created from left, top, width, height. 63 */ 64 static napi_value CreateJsWindowRect( 65 napi_env env, int32_t left, int32_t top, int32_t width, int32_t height); 66 private: 67 sptr<IRemoteObject> callerToken_; 68 int32_t left_ = 0; 69 int32_t top_ = 0; 70 int32_t width_ = 0; 71 int32_t height_ = 0; 72 }; 73 } // namespace AbilityRuntime 74 } // namespace OHOS 75 #endif // OHOS_ABILITY_RUNTIME_REQUEST_INFO_H 76