1 /* 2 * Copyright (C) 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 "pasteboard_client.h" 28 #include "refbase.h" 29 30 namespace OHOS { 31 namespace NWeb { 32 33 class WebClipboardController : public RefBase { 34 public: WebClipboardController()35 WebClipboardController() {}; ~WebClipboardController()36 ~WebClipboardController() {}; 37 38 static WebClipboardController& GetInstance(); 39 40 std::shared_ptr<MiscServices::PasteData> SplitHtml(std::shared_ptr<std::string> html) noexcept; 41 std::shared_ptr<std::string> RebuildHtml(std::shared_ptr<MiscServices::PasteData> pasteData) noexcept; 42 43 private: 44 std::vector<std::pair<std::string, uint32_t>> SplitHtmlWithImgLabel( 45 const std::shared_ptr<std::string> html) noexcept; 46 std::map<std::string, std::vector<uint8_t>> SplitHtmlWithImgSrcLabel( 47 const std::vector<std::pair<std::string, uint32_t>>& matchVec) noexcept; 48 std::shared_ptr<MiscServices::PasteData> BuildPasteData( 49 std::shared_ptr<std::string> html, const std::map<std::string, std::vector<uint8_t>>& imgSrcMap) noexcept; 50 void RemoveAllRecord(std::shared_ptr<MiscServices::PasteData> pasteData) noexcept; 51 bool IsLocalURI(std::string& uri) noexcept; 52 }; 53 } // namespace NWeb 54 } // namespace OHOS 55 56 #endif // WEB_CLIPBORD_CONTROLLER_H 57