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_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERN_SECURITY_COMPONENT_HANDLER_H 17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERN_SECURITY_COMPONENT_HANDLER_H 18 19 #include "core/components_ng/base/frame_node.h" 20 #include "core/components_ng/pattern/security_component/security_component_pattern.h" 21 #ifdef SECURITY_COMPONENT_ENABLE 22 #include "core/components_ng/pattern/security_component/security_component_probe.h" 23 #include "location_button.h" 24 #include "paste_button.h" 25 #include "save_button.h" 26 #include "sec_comp_err.h" 27 #include "sec_comp_kit.h" 28 #endif 29 30 namespace OHOS::Ace::NG { 31 class SecurityComponentHandler { 32 public: 33 static int32_t RegisterSecurityComponent(RefPtr<FrameNode>& node, int32_t& scId); 34 static int32_t UpdateSecurityComponent(RefPtr<FrameNode>& node, int32_t scId); 35 static int32_t UnregisterSecurityComponent(int32_t scId); 36 static int32_t ReportSecurityComponentClickEvent(int32_t scId, RefPtr<FrameNode>& node, GestureEvent& event); 37 #ifdef SECURITY_COMPONENT_ENABLE 38 static bool InitButtonInfo(std::string& componentInfo, RefPtr<FrameNode>& node); 39 static bool GetDisplayOffset(RefPtr<FrameNode>& node, double& offsetX, double& offsetY); 40 static bool GetWindowRect(RefPtr<FrameNode>& node, OHOS::Security::SecurityComponent::SecCompRect& winRect); 41 static OHOS::Security::SecurityComponent::SecCompUiRegister uiRegister; 42 static SecurityComponentProbe probe; 43 44 private: 45 static bool CheckOpacity(const RefPtr<FrameNode>& node, const RefPtr<RenderContext>& renderContext); 46 static bool CheckBrightness(const RefPtr<FrameNode>& node, const RefPtr<RenderContext>& renderContext); 47 static bool CheckVisibility(const RefPtr<FrameNode>& node, RefPtr<LayoutProperty>& layoutProperty); 48 static bool CheckBlur(const RefPtr<FrameNode>& node, const RefPtr<RenderContext>& renderContext); 49 static bool CheckGrayScale(const RefPtr<FrameNode>& node, const RefPtr<RenderContext>& renderContext); 50 static bool CheckSaturate(const RefPtr<FrameNode>& node, const RefPtr<RenderContext>& renderContext); 51 static bool CheckContrast(const RefPtr<FrameNode>& node, const RefPtr<RenderContext>& renderContext); 52 static bool CheckInvert(const RefPtr<FrameNode>& node, const RefPtr<RenderContext>& renderContext); 53 static bool CheckSepia(const RefPtr<FrameNode>& node, const RefPtr<RenderContext>& renderContext); 54 static bool CheckHueRotate(const RefPtr<FrameNode>& node, const RefPtr<RenderContext>& renderContext); 55 static bool CheckColorBlend(const RefPtr<FrameNode>& node, const RefPtr<RenderContext>& renderContext); 56 static bool CheckClipMask(const RefPtr<FrameNode>& node, const RefPtr<RenderContext>& renderContext); 57 static bool CheckForegroundColor(const RefPtr<FrameNode>& node, const RefPtr<RenderContext>& renderContext); 58 static bool CheckSphericalEffect(const RefPtr<FrameNode>& node, const RefPtr<RenderContext>& renderContext); 59 static bool CheckLightUpEffect(const RefPtr<FrameNode>& node, const RefPtr<RenderContext>& renderContext); 60 static bool CheckPixelStretchEffect(const RefPtr<FrameNode>& node, const RefPtr<RenderContext>& renderContext); 61 static bool CheckRenderEffect(RefPtr<FrameNode>& node); 62 static bool CheckParentNodesEffect(RefPtr<FrameNode>& node); 63 static void GetVisibleRect(RefPtr<FrameNode>& node, RectF& visibleRect); 64 static double CalculateCurrentVisibleRatio(const RectF& visibleRect, const RectF& renderRect); 65 static bool InitBaseInfo(OHOS::Security::SecurityComponent::SecCompBase& buttonInfo, RefPtr<FrameNode>& node); 66 static bool InitChildInfo(OHOS::Security::SecurityComponent::SecCompBase& buttonInfo, RefPtr<FrameNode>& node); 67 #endif 68 }; 69 } // namespace OHOS::Ace 70 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERN_SECURITY_COMPONENT_HANDLER_H 71