1 /* 2 * Copyright (C) 2023-2023 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_CLIPBORD_CONTROLLER_H 17 #define WEB_CLIPBORD_CONTROLLER_H 18 19 #include <map> 20 #include <memory> 21 #include <mutex> 22 #include <string> 23 #include <vector> 24 25 #include "paste_data.h" 26 #include "paste_data_record.h" 27 #include "refbase.h" 28 29 namespace OHOS { 30 namespace MiscServices { 31 32 class API_EXPORT PasteboardWebController : public RefBase { 33 public: PasteboardWebController()34 PasteboardWebController() {}; ~PasteboardWebController()35 ~PasteboardWebController() {}; 36 37 static PasteboardWebController& GetInstance(); 38 39 std::shared_ptr<PasteData> SplitHtml(std::shared_ptr<std::string> html) noexcept; 40 std::shared_ptr<std::string> RebuildHtml(std::shared_ptr<PasteData> pasteData) noexcept; 41 42 private: 43 std::vector<std::pair<std::string, uint32_t>> SplitHtmlWithImgLabel( 44 const std::shared_ptr<std::string> html) noexcept; 45 std::map<std::string, std::vector<uint8_t>> SplitHtmlWithImgSrcLabel( 46 const std::vector<std::pair<std::string, uint32_t>>& matchVec) noexcept; 47 std::shared_ptr<PasteData> BuildPasteData( 48 std::shared_ptr<std::string> html, const std::map<std::string, std::vector<uint8_t>>& imgSrcMap) noexcept; 49 void RemoveAllRecord(std::shared_ptr<PasteData> pasteData) noexcept; 50 bool IsLocalURI(std::string& uri) noexcept; 51 }; 52 } // namespace MiscServices 53 } // namespace OHOS 54 55 #endif // WEB_CLIPBORD_CONTROLLER_H 56