1 /*
2  * Copyright (c) 2024 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_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERNS_XCOMPONENT_XCOMPONENT_ACCESSIBILITY_PROVIDER_H
17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERNS_XCOMPONENT_XCOMPONENT_ACCESSIBILITY_PROVIDER_H
18 
19 #include "core/accessibility/accessibility_provider.h"
20 
21 namespace OHOS::Ace::NG {
22 class XComponentPattern;
23 
24 class XComponentAccessibilityProvider : public AccessibilityProvider {
25     DECLARE_ACE_TYPE(XComponentAccessibilityProvider, AccessibilityProvider);
26 public:
XComponentAccessibilityProvider(const WeakPtr<XComponentPattern> & xComponentPattern)27     XComponentAccessibilityProvider(const WeakPtr<XComponentPattern> &xComponentPattern)
28         : weakPattern_(xComponentPattern) {}
29     int32_t FindAccessibilityNodeInfosById(
30         const int64_t elementId, const int32_t mode, const int32_t requestId,
31         std::vector<ArkUI_AccessibilityElementInfo>& infos) override;
32     int32_t FindAccessibilityNodeInfosByText(
33         const int64_t elementId, std::string text, const int32_t requestId,
34         std::vector<ArkUI_AccessibilityElementInfo>& infos) override;
35     int32_t FindFocusedAccessibilityNode(
36         const int64_t elementId, int32_t focusType, const int32_t requestId,
37         ArkUI_AccessibilityElementInfo& elementInfo) override;
38     int32_t FindNextFocusAccessibilityNode(
39         const int64_t elementId, int32_t direction, const int32_t requestId,
40         ArkUI_AccessibilityElementInfo& elementInfo) override;
41     int32_t ExecuteAccessibilityAction(
42         const int64_t elementId, int32_t action, const int32_t requestId,
43         const std::map<std::string, std::string>& actionArguments) override;
44     int32_t ClearFocusedAccessibilityNode() override;
45     int32_t GetAccessibilityNodeCursorPosition(
46         const int64_t elementId, const int32_t requestId, int32_t &cursorPosition) override;
47     int32_t SendAccessibilityAsyncEvent(
48         const ArkUI_AccessibilityEventInfo& accessibilityEvent,
49         void (*callback)(int32_t errorCode)) override;
50     void SendThirdAccessibilityProvider(
51         const std::weak_ptr<ThirdAccessibilityManager>& thirdAccessibilityManager) override;
52 private:
53     WeakPtr<XComponentPattern> weakPattern_;
54     std::weak_ptr<ThirdAccessibilityManager> thirdAccessibilityManager_;
55 };
56 } // namespace OHOS::Ace
57 
58 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERNS_XCOMPONENT_XCOMPONENT_ACCESSIBILITY_PROVIDER_H
59