1 /* 2 * Copyright (c) 2023-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_PATTERN_UI_EXTENSION_UI_EXTENSION_MODEL_NG_H 17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERN_UI_EXTENSION_UI_EXTENSION_MODEL_NG_H 18 19 #include <memory> 20 #include <string> 21 22 #include "core/components_ng/base/frame_node.h" 23 #include "core/components_ng/pattern/ui_extension/ui_extension_model.h" 24 25 namespace OHOS::Ace { 26 struct ModalUIExtensionCallbacks; 27 } // namespace OHOS::Ace 28 29 namespace OHOS::Ace::NG { 30 class ACE_EXPORT UIExtensionModelNG : public UIExtensionModel { 31 public: 32 static RefPtr<FrameNode> Create(const std::string& bundleName, const std::string& abilityName, 33 const std::map<std::string, std::string>& params, std::function<void(int32_t)>&& onRelease, 34 std::function<void(int32_t, const std::string&, const std::string&)>&& onError); 35 static RefPtr<FrameNode> Create(const AAFwk::Want& want, const ModalUIExtensionCallbacks& callbacks, 36 const InnerModalUIExtensionConfig& config); 37 38 void Create(const RefPtr<OHOS::Ace::WantWrap>& wantWrap, 39 const std::map<NG::PlaceholderType, RefPtr<NG::FrameNode>>& placeholderMap, 40 bool transferringCaller = false, bool densityDpi = true) override; 41 // for Embedded Component 42 void Create(const RefPtr<OHOS::Ace::WantWrap>& wantWrap, SessionType sessionType) override; 43 // for dynamic component 44 void Create() override; 45 void Create(const UIExtensionConfig& config) override; 46 void InitializeDynamicComponent(const RefPtr<FrameNode>& frameNode, const std::string& hapPath, 47 const std::string& abcPath, const std::string& entryPoint, void* runtime) override; 48 void InitializeIsolatedComponent(const RefPtr<NG::FrameNode>& frameNode, 49 const RefPtr<OHOS::Ace::WantWrap>& wantWrap, void* runtime) override; 50 void SetPlatformOnError(std::function<void( 51 int32_t code, const std::string& name, const std::string& message)>&& onError) override; 52 void SetAdaptiveWidth(bool state) override; 53 void SetAdaptiveHeight(bool state) override; 54 55 void SetOnRemoteReady(std::function<void(const RefPtr<UIExtensionProxy>&)>&& onRemoteReady) override; 56 void SetOnRelease(std::function<void(int32_t)>&& onRelease) override; 57 void SetOnResult(std::function<void(int32_t, const AAFwk::Want&)>&& onResult) override; 58 void SetOnTerminated(std::function<void(int32_t, const RefPtr<WantWrap>&)>&& onTerminated, 59 NG::SessionType sessionType = NG::SessionType::UI_EXTENSION_ABILITY) override; 60 void SetOnReceive(std::function<void(const AAFwk::WantParams&)>&& onReceive, 61 NG::SessionType sessionType = NG::SessionType::UI_EXTENSION_ABILITY) override; 62 void SetSecurityOnRemoteReady( 63 std::function<void(const RefPtr<NG::SecurityUIExtensionProxy>&)>&& onRemoteReady) override; 64 void SetOnError( 65 std::function<void(int32_t code, const std::string& name, const std::string& message)>&& onError, 66 NG::SessionType sessionType = NG::SessionType::UI_EXTENSION_ABILITY) override; 67 68 private: 69 void CreateSecurityUIExtension(const UIExtensionConfig& config); 70 }; 71 } // namespace OHOS::Ace::NG 72 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERN_UI_EXTENSION_UI_EXTENSION_MODEL_NG_H 73