• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 FOUNDATION_ACE_INTERFACE_INNERKITS_ACE_UI_EVENT_OBSERVER_H
17 #define FOUNDATION_ACE_INTERFACE_INNERKITS_ACE_UI_EVENT_OBSERVER_H
18 
19 #include <functional>
20 #include <memory>
21 #include <string>
22 #include <unordered_map>
23 
24 #include "macros.h"
25 
26 namespace OHOS::Ace {
27 using OnInspectorTreeResult = std::function<void(const std::shared_ptr<std::string>)>;
28 using UICommandResult = std::function<void(const std::shared_ptr<std::string>)>;
29 
30 enum class InspectorInfoType: int32_t {
31     CONTENT = 0,
32     WINDOW_ID,
33     WEB_LANG,
34     PAGE_PARAM,
35 };
36 
37 enum class InspectorPageType: int32_t {
38     FOCUS = 0,
39     FOREGROUND,
40 };
41 
42 struct ACE_FORCE_EXPORT UICommandParams {
43     std::string params;
44 };
45 
46 struct ACE_FORCE_EXPORT TreeParams {
47     bool isNewVersion = true;
48     bool isVisibleOnly = false;
49     bool isContentOnly = false;
50     bool enableWeb = false;
51     std::string webContentJs;
52     bool isWindowIdOnly = false;
53     bool enableFullAttrs = false;
54     bool enableAllNodes = false;
55     bool enableBackground = false;
56     InspectorPageType inspectorType { InspectorPageType::FOCUS };
57     InspectorInfoType infoType { InspectorInfoType::CONTENT };
58     int32_t webId = 0;
59     bool enableCacheNode = false;
60     bool webAccessibility = false;
61 };
62 
63 class ACE_FORCE_EXPORT UIEventObserver {
64 public:
65     virtual ~UIEventObserver() = default;
66     virtual void NotifyUIEvent(int32_t eventType, const std::unordered_map<std::string, std::string>& eventParams) = 0;
67 
NotifyUIEvent(int32_t eventType,const std::shared_ptr<std::unordered_map<std::string,std::string>> & eventParams)68     virtual void NotifyUIEvent(
69         int32_t eventType, const std::shared_ptr<std::unordered_map<std::string, std::string>>& eventParams)
70     {}
71 };
72 } // namespace OHOS::Ace
73 #endif // FOUNDATION_ACE_INTERFACE_INNERKITS_ACE_UI_EVENT_OBSERVER_H
74