• 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_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERN_UI_EXTENSION_UI_EXTENSION_MODEL_H
17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERN_UI_EXTENSION_UI_EXTENSION_MODEL_H
18 
19 #include <memory>
20 #include <mutex>
21 #include <string>
22 
23 #include "base/utils/macros.h"
24 #include "base/want/want_wrap.h"
25 
26 namespace OHOS::AAFwk {
27 class Want;
28 class WantParams;
29 }
30 
31 namespace OHOS::Ace {
32 namespace NG {
33 class UIExtensionProxy;
34 }
35 class ACE_EXPORT UIExtensionModel {
36 public:
37     static UIExtensionModel* GetInstance();
38     virtual ~UIExtensionModel() = default;
39 
40     virtual void Create(const RefPtr<OHOS::Ace::WantWrap>& wantWrap);
41     virtual void SetOnRemoteReady(std::function<void(const RefPtr<NG::UIExtensionProxy>&)>&& onRemoteReady);
42     virtual void SetOnRelease(std::function<void(int32_t)>&& onRelease);
43     virtual void SetOnResult(std::function<void(int32_t, const AAFwk::Want&)>&& onResult);
44     virtual void SetOnReceive(std::function<void(const AAFwk::WantParams&)>&& onReceive);
45     virtual void SetOnError(
46         std::function<void(int32_t code, const std::string& name, const std::string& message)>&& onError);
47 private:
48     static std::unique_ptr<UIExtensionModel> instance_;
49     static std::mutex mutex_;
50 };
51 } // namespace OHOS::Ace
52 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERN_UI_EXTENSION_UI_EXTENSION_MODEL_H
53