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_IMPL_H_ 17 #define ARK_WEB_URL_RESOURCE_REQUEST_IMPL_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 ArkWebUrlResourceRequestImpl : public ArkWebUrlResourceRequest { 26 IMPLEMENT_REFCOUNTING(ArkWebUrlResourceRequestImpl); 27 28 public: 29 ArkWebUrlResourceRequestImpl(std::shared_ptr<OHOS::NWeb::NWebUrlResourceRequest> nweb_url_resource_request); 30 ~ArkWebUrlResourceRequestImpl() = default; 31 32 /** 33 * @brief Gets the URL for which the resource request was made. 34 * 35 * @return URL url string 36 */ 37 ArkWebString Url() override; 38 39 /** 40 * @brief Gets the method associated with the request, for example "GET". 41 * 42 * @return method the method associated with the request. 43 */ 44 ArkWebString Method() override; 45 46 /** 47 * @brief Gets whether a gesture (such as a click) was associated with the 48 * request. 49 * 50 * @return gesture whether was associated with the request. 51 */ 52 bool FromGesture() override; 53 54 /** 55 * @brief Gets the headers associated with the request. 56 * 57 * @return the headers associated with the request. 58 */ 59 ArkWebStringMap RequestHeaders() override; 60 61 /** 62 * @brief Gets whether the request was made in order to fetch the main frame's 63 * document. 64 * 65 * @return Is main frame 66 */ 67 bool IsAboutMainFrame() override; 68 69 /** 70 * @brief Gets whether the request was a result of a server-side redirect. 71 * 72 * @return is redirect 73 */ 74 bool IsRequestRedirect() override; 75 76 private: 77 std::shared_ptr<OHOS::NWeb::NWebUrlResourceRequest> nweb_url_resource_request_; 78 }; 79 80 } // namespace OHOS::ArkWeb 81 82 #endif // ARK_WEB_URL_RESOURCE_REQUEST_IMPL_H_ 83