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 WEB_SCHEME_HANDLER_RESPONSE_H 17 #define WEB_SCHEME_HANDLER_RESPONSE_H 18 19 #include <cstdint> 20 #include <map> 21 #include <uv.h> 22 23 #include "arkweb_scheme_handler.h" 24 #include "ffi_remote_data.h" 25 #include "nweb.h" 26 #include "nweb_helper.h" 27 #include "nweb_log.h" 28 #include "web_errors.h" 29 #include "webview_javascript_result_callback.h" 30 31 namespace OHOS::Webview { 32 // WebSchemeHandlerResponse 33 class WebSchemeHandlerResponseImpl : public OHOS::FFI::FFIData { DECL_TYPE(WebSchemeHandlerResponseImpl,OHOS::FFI::FFIData)34 DECL_TYPE(WebSchemeHandlerResponseImpl, OHOS::FFI::FFIData) 35 public: 36 explicit WebSchemeHandlerResponseImpl() 37 { 38 OH_ArkWeb_CreateResponse(&response_); 39 }; WebSchemeHandlerResponseImpl(ArkWeb_Response * response)40 WebSchemeHandlerResponseImpl(ArkWeb_Response* response) 41 { 42 response_ = response; 43 }; 44 ~WebSchemeHandlerResponseImpl(); 45 46 char* GetUrl(); 47 int32_t SetUrl(const char* url); 48 int32_t GetStatus(); 49 int32_t SetStatus(int32_t status); 50 char* GetStatusText(); 51 int32_t SetStatusText(const char* statusText); 52 char* GetMimeType(); 53 int32_t SetMimeType(const char* mimeType); 54 char* GetEncoding(); 55 int32_t SetEncoding(const char* encoding); 56 char* GetHeaderByName(const char* name); 57 int32_t SetHeaderByName(const char* name, const char* value, bool overwrite); 58 int32_t GetErrorCode(); 59 int32_t SetErrorCode(int32_t code); GetArkWebResponse()60 ArkWeb_Response* GetArkWebResponse() 61 { 62 return response_; 63 } 64 65 private: 66 ArkWeb_Response* response_ = nullptr; 67 }; 68 } // namespace OHOS::Webview 69 #endif // WEB_SCHEME_HANDLER_RESPONSE_H