10826e83eSopenharmony_ci/* 20826e83eSopenharmony_ci * Copyright (c) 2022 Huawei Device Co., Ltd. 30826e83eSopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 40826e83eSopenharmony_ci * you may not use this file except in compliance with the License. 50826e83eSopenharmony_ci * You may obtain a copy of the License at 60826e83eSopenharmony_ci * 70826e83eSopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 80826e83eSopenharmony_ci * 90826e83eSopenharmony_ci * Unless required by applicable law or agreed to in writing, software 100826e83eSopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 110826e83eSopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 120826e83eSopenharmony_ci * See the License for the specific language governing permissions and 130826e83eSopenharmony_ci * limitations under the License. 140826e83eSopenharmony_ci */ 150826e83eSopenharmony_ci 160826e83eSopenharmony_ci#ifndef NWEB_WEB_DOWNLOAD_MANAGER_H 170826e83eSopenharmony_ci#define NWEB_WEB_DOWNLOAD_MANAGER_H 180826e83eSopenharmony_ci 190826e83eSopenharmony_ci#include <string> 200826e83eSopenharmony_ci 210826e83eSopenharmony_ci#include "napi/native_api.h" 220826e83eSopenharmony_ci#include "napi/native_common.h" 230826e83eSopenharmony_ci#include "napi/native_node_api.h" 240826e83eSopenharmony_ci 250826e83eSopenharmony_ci#include "web_download_delegate.h" 260826e83eSopenharmony_ci#include "web_download_item.h" 270826e83eSopenharmony_ci 280826e83eSopenharmony_cinamespace OHOS { 290826e83eSopenharmony_cinamespace NWeb { 300826e83eSopenharmony_ciclass WebDownloadDelegate; 310826e83eSopenharmony_ci 320826e83eSopenharmony_ciclass WebDownloadManager { 330826e83eSopenharmony_cipublic: 340826e83eSopenharmony_ci static void SetDownloadDelegate(WebDownloadDelegate *delegate); 350826e83eSopenharmony_ci static void ResumeDownload(const WebDownloadItem *webDownload); 360826e83eSopenharmony_ci 370826e83eSopenharmony_ci static void AddDownloadDelegateForWeb(int32_t nwebId, WebDownloadDelegate *delegate); 380826e83eSopenharmony_ci static void RemoveDownloadDelegate(WebDownloadDelegate *delegate); 390826e83eSopenharmony_ci static void RemoveDownloadDelegateRef(int32_t nwebId); 400826e83eSopenharmony_ci 410826e83eSopenharmony_ci static bool HasValidDelegate(); 420826e83eSopenharmony_ci 430826e83eSopenharmony_ci WebDownloadManager() = default; 440826e83eSopenharmony_ci ~WebDownloadManager() = default; 450826e83eSopenharmony_ci 460826e83eSopenharmony_ciprivate: 470826e83eSopenharmony_ci static void RegisterDownloadCallback(); 480826e83eSopenharmony_ci}; 490826e83eSopenharmony_ci} // namespace NWeb 500826e83eSopenharmony_ci} // namespace OHOS 510826e83eSopenharmony_ci 520826e83eSopenharmony_ci#endif // NWEB_WEB_DOWNLOAD_MANAGER_H