1 /* 2 * Copyright (c) 2024 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 ARK_WEB_URL_RESOURCE_REQUEST_WRAPPER_H_ 17 #define ARK_WEB_URL_RESOURCE_REQUEST_WRAPPER_H_ 18 #pragma once 19 20 #include "include/nweb_url_resource_request.h" 21 #include "ohos_nweb/include/ark_web_url_resource_request.h" 22 23 namespace OHOS::ArkWeb { 24 25 class ArkWebUrlResourceRequestWrapper : public OHOS::NWeb::NWebUrlResourceRequest { 26 public: 27 ArkWebUrlResourceRequestWrapper(ArkWebRefPtr<ArkWebUrlResourceRequest> ark_web_url_resource_request); 28 ~ArkWebUrlResourceRequestWrapper() = default; 29 30 /** 31 * @brief Gets the URL for which the resource request was made. 32 * 33 * @return URL url string 34 */ 35 std::string Url() override; 36 37 /** 38 * @brief Gets the method associated with the request, for example "GET". 39 * 40 * @return method the method associated with the request. 41 */ 42 std::string Method() override; 43 44 /** 45 * @brief Gets whether a gesture (such as a click) was associated with the 46 * request. 47 * 48 * @return gesture whether was associated with the request. 49 */ 50 bool FromGesture() override; 51 52 /** 53 * @brief Gets the headers associated with the request. 54 * 55 * @return the headers associated with the request. 56 */ 57 std::map<std::string, std::string> RequestHeaders() override; 58 59 /** 60 * @brief Gets whether the request was made in order to fetch the main frame's 61 * document. 62 * 63 * @return Is main frame 64 */ 65 bool IsAboutMainFrame() override; 66 67 /** 68 * @brief Gets whether the request was a result of a server-side redirect. 69 * 70 * @return is redirect 71 */ 72 bool IsRequestRedirect() override; 73 74 private: 75 ArkWebRefPtr<ArkWebUrlResourceRequest> ark_web_url_resource_request_; 76 }; 77 78 } // namespace OHOS::ArkWeb 79 80 #endif // ARK_WEB_URL_RESOURCE_REQUEST_WRAPPER_H_ 81