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_ENGINE_H_ 17 #define ARK_WEB_ENGINE_H_ 18 #pragma once 19 20 #include "ohos_nweb/include/ark_web_adsblock_manager.h" 21 #include "ohos_nweb/include/ark_web_cookie_manager.h" 22 #include "ohos_nweb/include/ark_web_data_base.h" 23 #include "ohos_nweb/include/ark_web_download_manager.h" 24 #include "ohos_nweb/include/ark_web_engine_init_args.h" 25 #include "ohos_nweb/include/ark_web_engine_prefetch_args.h" 26 #include "ohos_nweb/include/ark_web_nweb.h" 27 #include "ohos_nweb/include/ark_web_nweb_create_info.h" 28 #include "ohos_nweb/include/ark_web_web_storage.h" 29 30 namespace OHOS::ArkWeb { 31 32 /*--ark web(source=webcore)--*/ 33 class ArkWebEngine : public virtual ArkWebBaseRefCounted { 34 public: 35 /*--ark web()--*/ 36 static ArkWebRefPtr<ArkWebEngine> GetInstance(); 37 38 /*--ark web()--*/ 39 virtual ArkWebRefPtr<ArkWebNWeb> CreateNWeb(ArkWebRefPtr<ArkWebNWebCreateInfo> create_info) = 0; 40 41 /*--ark web()--*/ 42 virtual ArkWebRefPtr<ArkWebNWeb> GetNWeb(int32_t nweb_id) = 0; 43 44 /*--ark web()--*/ 45 virtual ArkWebRefPtr<ArkWebDataBase> GetDataBase() = 0; 46 47 /*--ark web()--*/ 48 virtual ArkWebRefPtr<ArkWebWebStorage> GetWebStorage() = 0; 49 50 /*--ark web()--*/ 51 virtual ArkWebRefPtr<ArkWebCookieManager> GetCookieManager() = 0; 52 53 /*--ark web()--*/ 54 virtual ArkWebRefPtr<ArkWebDownloadManager> GetDownloadManager() = 0; 55 56 /*--ark web()--*/ 57 virtual void SetWebTag(int32_t nweb_id, const char* web_tag) = 0; 58 59 /*--ark web()--*/ 60 virtual void InitializeWebEngine(ArkWebRefPtr<ArkWebEngineInitArgs> init_args) = 0; 61 62 /*--ark web()--*/ 63 virtual void PrepareForPageLoad(const ArkWebString& url, bool preconnectable, int32_t num_sockets) = 0; 64 65 /*--ark web()--*/ 66 virtual void SetWebDebuggingAccess(bool isEnableDebug) = 0; 67 68 /*--ark web()--*/ 69 virtual void AddIntelligentTrackingPreventionBypassingList(const ArkWebStringVector& hosts) = 0; 70 71 /*--ark web()--*/ 72 virtual void RemoveIntelligentTrackingPreventionBypassingList(const ArkWebStringVector& hosts) = 0; 73 74 /*--ark web()--*/ 75 virtual void ClearIntelligentTrackingPreventionBypassingList() = 0; 76 77 /*--ark web()--*/ 78 virtual void PauseAllTimers() = 0; 79 80 /*--ark web()--*/ 81 virtual void ResumeAllTimers() = 0; 82 83 /*--ark web()--*/ 84 virtual void PrefetchResource(ArkWebRefPtr<ArkWebEnginePrefetchArgs>& pre_args, 85 const ArkWebStringMap& additional_http_headers, const ArkWebString& cache_key, 86 const uint32_t& cache_valid_time) = 0; 87 88 /*--ark web()--*/ 89 virtual void SetRenderProcessMode(int32_t mode) = 0; 90 91 /*--ark web()--*/ 92 virtual int32_t GetRenderProcessMode() = 0; 93 94 /*--ark web()--*/ 95 virtual void ClearPrefetchedResource(const ArkWebStringVector& cache_key_list) = 0; 96 97 /*--ark web()--*/ 98 virtual void WarmupServiceWorker(const ArkWebString& url) = 0; 99 100 /*--ark web()--*/ 101 virtual void SetHostIP(const ArkWebString& hostName, const ArkWebString& address, int32_t aliveTime) = 0; 102 103 /*--ark web()--*/ 104 virtual void ClearHostIP(const ArkWebString& hostName) = 0; 105 106 /*--ark web()--*/ 107 virtual void SetWholeWebDrawing() = 0; 108 109 /*--ark web()--*/ 110 virtual ArkWebRefPtr<ArkWebAdsBlockManager> GetAdsBlockManager() = 0; 111 112 /*--ark web()--*/ 113 virtual void TrimMemoryByPressureLevel(int32_t memoryLevel) = 0; 114 115 /** 116 * @Description: get the default user agent 117 * @Return: the default user agent 118 * @Since: 14001 119 */ 120 /*--ark web()--*/ 121 virtual ArkWebString GetDefaultUserAgent() = 0; 122 }; 123 124 } // namespace OHOS::ArkWeb 125 126 #endif // ARK_WEB_ENGINE_H_ 127