• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2024-2025 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 FOUNDATION_ACE_INTERFACE_UI_CONTENT_PROXY_H
17 #define FOUNDATION_ACE_INTERFACE_UI_CONTENT_PROXY_H
18 #include <functional>
19 #include "interfaces/inner_api/ui_session/ui_translate_manager.h"
20 
21 #include "frameworks/core/components_ng/base/frame_node.h"
22 namespace OHOS::Ace {
23 class ACE_FORCE_EXPORT UiTranslateManagerImpl : public UiTranslateManager {
24 public:
UiTranslateManagerImpl(const RefPtr<TaskExecutor> & taskExecutor)25     explicit UiTranslateManagerImpl(const RefPtr<TaskExecutor>& taskExecutor) : taskExecutor_(taskExecutor) {};
26     void AddTranslateListener(const WeakPtr<NG::FrameNode> node);
27     void RemoveTranslateListener(int32_t nodeId);
28     void GetWebViewCurrentLanguage() override;
29     void GetTranslateText(std::string extraData, bool isContinued) override;
30     void SendTranslateResult(int32_t nodeId, std::vector<std::string> results, std::vector<int32_t> ids) override;
31     void ResetTranslate(int32_t nodeId) override;
32     void SendTranslateResult(int32_t nodeId, std::string res) override;
33     void ClearMap() override;
34     void SendPixelMap();
35     void GetAllPixelMap(RefPtr<NG::FrameNode> pageNode);
36     void TravelFindPixelMap(RefPtr<NG::UINode> currentNode);
37     void AddPixelMap(int32_t nodeId, RefPtr<PixelMap> pixelMap);
38     void FindTopNavDestination(RefPtr<NG::UINode> currentNode, RefPtr<NG::FrameNode>& result);
39     void PostToUI(const std::function<void()>& task) override;
40 
41 private:
42     std::map<int32_t, WeakPtr<NG::FrameNode>> listenerMap_;
43     std::vector<std::pair<int32_t, std::shared_ptr<Media::PixelMap>>> pixelMap_;
44     const static std::set<std::string> layoutTags_;
45     RefPtr<TaskExecutor> taskExecutor_;
46 };
47 } // namespace OHOS::Ace
48 #endif // FOUNDATION_ACE_INTERFACE_UI_CONTENT_PROXY_H
49