1 /*
2  * Copyright (c) 2022 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 WINDOW_EXTENSION_H
17 #define WINDOW_EXTENSION_H
18 
19 #include <extension_base.h>
20 #include <service_extension.h>
21 
22 namespace OHOS {
23 namespace Rosen {
24 class WindowExtensionContext;
25 
26 class WindowExtension : public AbilityRuntime::ExtensionBase<WindowExtensionContext> {
27 public:
28     WindowExtension() = default;
29     virtual ~WindowExtension() = default;
30 
31     /**
32      * @brief Create and init context.
33      *
34      * @param record the extension record.
35      * @param application the application info.
36      * @param handler the extension handler.
37      * @param token the remote token.
38      * @return The created context.
39      */
40     virtual std::shared_ptr<WindowExtensionContext> CreateAndInitContext(
41         const std::shared_ptr<AbilityRuntime::AbilityLocalRecord>& record,
42         const std::shared_ptr<AbilityRuntime::OHOSApplication>& application,
43         std::shared_ptr<AbilityRuntime::AbilityHandler>& handler,
44         const sptr<IRemoteObject>& token) override;
45 
46     /**
47      * @brief Init the extension.
48      *
49      * @param record the extension record.
50      * @param application the application info.
51      * @param handler the extension handler.
52      * @param token the remote token.
53      */
54     virtual void Init(const std::shared_ptr<AbilityRuntime::AbilityLocalRecord>& record,
55         const std::shared_ptr<AbilityRuntime::OHOSApplication>& application,
56         std::shared_ptr<AbilityRuntime::AbilityHandler>& handler,
57         const sptr<IRemoteObject>& token) override;
58 
59     /**
60      * @brief Create Extension.
61      *
62      * @param runtime The runtime.
63      * @return The WindowExtension instance.
64      */
65     static WindowExtension* Create(const std::unique_ptr<AbilityRuntime::Runtime>& runtime);
66 };
67 } // namespace Rosen
68 } // namespace OHOS
69 #endif