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 #include "ohos_nweb/include/ark_web_proxy_changed_callback.h" 30 31 namespace OHOS::ArkWeb { 32 33 /*--ark web(source=webcore)--*/ 34 class ArkWebEngine : public virtual ArkWebBaseRefCounted { 35 public: 36 /*--ark web()--*/ 37 static ArkWebRefPtr<ArkWebEngine> GetInstance(); 38 39 /*--ark web()--*/ 40 virtual ArkWebRefPtr<ArkWebNWeb> CreateNWeb(ArkWebRefPtr<ArkWebNWebCreateInfo> create_info) = 0; 41 42 /*--ark web()--*/ 43 virtual ArkWebRefPtr<ArkWebNWeb> GetNWeb(int32_t nweb_id) = 0; 44 45 /*--ark web()--*/ 46 virtual ArkWebRefPtr<ArkWebDataBase> GetDataBase() = 0; 47 48 /*--ark web()--*/ 49 virtual ArkWebRefPtr<ArkWebWebStorage> GetWebStorage() = 0; 50 51 /*--ark web()--*/ 52 virtual ArkWebRefPtr<ArkWebCookieManager> GetCookieManager() = 0; 53 54 /*--ark web()--*/ 55 virtual ArkWebRefPtr<ArkWebDownloadManager> GetDownloadManager() = 0; 56 57 /*--ark web()--*/ 58 virtual void SetWebTag(int32_t nweb_id, const char* web_tag) = 0; 59 60 /*--ark web()--*/ 61 virtual void InitializeWebEngine(ArkWebRefPtr<ArkWebEngineInitArgs> init_args) = 0; 62 63 /*--ark web()--*/ 64 virtual void PrepareForPageLoad(const ArkWebString& url, bool preconnectable, int32_t num_sockets) = 0; 65 66 /*--ark web()--*/ 67 virtual void SetWebDebuggingAccess(bool isEnableDebug) = 0; 68 69 /*--ark web()--*/ 70 virtual void AddIntelligentTrackingPreventionBypassingList(const ArkWebStringVector& hosts) = 0; 71 72 /*--ark web()--*/ 73 virtual void RemoveIntelligentTrackingPreventionBypassingList(const ArkWebStringVector& hosts) = 0; 74 75 /*--ark web()--*/ 76 virtual void ClearIntelligentTrackingPreventionBypassingList() = 0; 77 78 /*--ark web()--*/ 79 virtual void PauseAllTimers() = 0; 80 81 /*--ark web()--*/ 82 virtual void ResumeAllTimers() = 0; 83 84 /*--ark web()--*/ 85 virtual void PrefetchResource(ArkWebRefPtr<ArkWebEnginePrefetchArgs>& pre_args, 86 const ArkWebStringMap& additional_http_headers, const ArkWebString& cache_key, 87 const uint32_t& cache_valid_time) = 0; 88 89 /*--ark web()--*/ 90 virtual void SetRenderProcessMode(int32_t mode) = 0; 91 92 /*--ark web()--*/ 93 virtual int32_t GetRenderProcessMode() = 0; 94 95 /*--ark web()--*/ 96 virtual void ClearPrefetchedResource(const ArkWebStringVector& cache_key_list) = 0; 97 98 /*--ark web()--*/ 99 virtual void WarmupServiceWorker(const ArkWebString& url) = 0; 100 101 /*--ark web()--*/ 102 virtual void SetHostIP(const ArkWebString& hostName, const ArkWebString& address, int32_t aliveTime) = 0; 103 104 /*--ark web()--*/ 105 virtual void ClearHostIP(const ArkWebString& hostName) = 0; 106 107 /*--ark web()--*/ 108 virtual void EnableWholeWebPageDrawing() = 0; 109 110 /*--ark web()--*/ 111 virtual ArkWebRefPtr<ArkWebAdsBlockManager> GetAdsBlockManager() = 0; 112 113 /*--ark web()--*/ 114 virtual void TrimMemoryByPressureLevel(int32_t memoryLevel) = 0; 115 116 /** 117 * @Description: set api level of rom to core 118 * @Input apiLevel: api level 119 * @Since: 12005 120 */ 121 /*--ark web()--*/ 122 virtual void SetArkWebRomApiLevel(int apiLevel) = 0; 123 124 /** 125 * @Description: get api level of core 126 * @Return: api level of core 127 * @Since: 12005 128 */ 129 /*--ark web()--*/ 130 virtual int GetArkWebCoreApiLevel() = 0; 131 132 /** 133 * @Description: get the default user agent 134 * @Return: the default user agent 135 * @Since: 14001 136 */ 137 /*--ark web()--*/ 138 virtual ArkWebString GetDefaultUserAgent() = 0; 139 140 /*--ark web()--*/ 141 virtual void RemoveAllCache(bool include_disk_files) = 0; 142 143 /** 144 * @Description: Set the proxy config used by arkweb. 145 * @Input proxy_urls: The proxy urls for construct proxy rule. 146 * @Input proxy_scheme_filters: The proxy scheme filters for construct proxy rule. 147 * @Input proxy_bypass_rules: The bypass rules. 148 * @Input reverse_bypass: Indicates whether reverse the bypass rules. 149 * @Since: 16001 150 */ 151 /*--ark web()--*/ 152 virtual void SetProxyOverride(const ArkWebStringVector& proxy_urls, 153 const ArkWebStringVector& proxy_scheme_filters, 154 const ArkWebStringVector& proxy_bypass_rules, 155 const bool& reverse_bypass, 156 ArkWebRefPtr<ArkWebProxyChangedCallback> callback) = 0; 157 158 /** 159 * @Description: Clear the proxy config used by arkweb. 160 * @Since: 16001 161 */ 162 /*--ark web()--*/ 163 virtual void RemoveProxyOverride(ArkWebRefPtr<ArkWebProxyChangedCallback> callback) = 0; 164 165 /*--ark web()--*/ 166 virtual void SetAppCustomUserAgent(const ArkWebString& userAgent) = 0; 167 168 /*--ark web()--*/ 169 virtual void SetUserAgentForHosts(const ArkWebString& userAgent, const ArkWebStringVector& hosts) = 0; 170 171 /*--ark web()--*/ 172 virtual void SetWebDebuggingAccessAndPort(bool isEnableDebug, int32_t port) = 0; 173 174 /*--ark web()--*/ 175 virtual uint32_t AddBlanklessLoadingUrls(const ArkWebStringVector& urls) = 0; 176 177 /*--ark web()--*/ 178 virtual void RemoveBlanklessLoadingUrls(const ArkWebStringVector& urls) = 0; 179 180 /*--ark web()--*/ 181 virtual void ClearBlanklessLoadingCache(const ArkWebStringVector& urls) = 0; 182 183 /*--ark web()--*/ 184 virtual ArkWebString CheckBlankOptEnable(const ArkWebString& url, int32_t nweb_id) = 0; 185 186 /*--ark web()--*/ 187 virtual void SetBlanklessLoadingCacheCapacity(int32_t capacity) = 0; 188 189 /*--ark web()--*/ 190 virtual void EnablePrivateNetworkAccess(bool enable) = 0; 191 192 /*--ark web()--*/ 193 virtual bool IsPrivateNetworkAccessEnabled() = 0; 194 195 /*--ark web()--*/ 196 virtual void SetWebDestroyMode(int32_t mode) = 0; 197 }; 198 199 } // namespace OHOS::ArkWeb 200 201 #endif // ARK_WEB_ENGINE_H_ 202