• 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_FORM_RENDERER_GROUP_H
17 #define FOUNDATION_ACE_INTERFACE_INNERKITS_FORM_RENDERER_GROUP_H
18 
19 #include <memory>
20 #include <string>
21 #include <vector>
22 
23 #include "form_js_info.h"
24 #include "want.h"
25 
26 namespace OHOS {
27 namespace AbilityRuntime {
28 class Context;
29 class Runtime;
30 }
31 
32 namespace AppExecFwk {
33 class Configuration;
34 }
35 
36 namespace Ace {
37 #ifndef ACE_EXPORT
38 #define ACE_EXPORT __attribute__((visibility("default")))
39 #endif
40 
41 class FormRenderer;
42 
43 /**
44  * @class FormRendererGroup
45  * FormRendererGroup interface is used to form renderer group.
46  * Provider:FormRendererGroup:runtime = 1:1:1
47  * FormRendererGroup:FormRenderer = 1:1
48  */
49 class ACE_EXPORT FormRendererGroup {
50 public:
51     static std::shared_ptr<FormRendererGroup> Create(const std::shared_ptr<OHOS::AbilityRuntime::Context> context,
52                                                      const std::shared_ptr<OHOS::AbilityRuntime::Runtime> runtime);
53 
54     FormRendererGroup(const std::shared_ptr<OHOS::AbilityRuntime::Context> context,
55                       const std::shared_ptr<OHOS::AbilityRuntime::Runtime> runtime);
56     ~FormRendererGroup();
57 
58     void AddForm(const OHOS::AAFwk::Want& want, const OHOS::AppExecFwk::FormJsInfo& formJsInfo);
59     void UpdateForm(const OHOS::AppExecFwk::FormJsInfo& formJsInfo);
60     void DeleteForm();
61     void DeleteForm(const std::string& compId);
62     void ReloadForm();
63     void UpdateConfiguration(const std::shared_ptr<OHOS::AppExecFwk::Configuration>& config);
64 private:
65     struct FormRequest {
66         std::string compId;
67         OHOS::AAFwk::Want want;
68         OHOS::AppExecFwk::FormJsInfo formJsInfo;
69     };
70     std::shared_ptr<OHOS::AbilityRuntime::Context> context_;
71     std::shared_ptr<OHOS::AbilityRuntime::Runtime> runtime_;
72     std::shared_ptr<FormRenderer> formRenderer_;
73     std::vector<FormRequest> formRequests_;
74     std::string currentCompId_;
75 };
76 }  // namespace Ace
77 }  // namespace OHOS
78 #endif  // FOUNDATION_ACE_INTERFACE_INNERKITS_FORM_RENDERER_GROUP_H
79