1 /*
2  * Copyright (c) 2021 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_HYPERLINK_HYPERLINK_RESOURCE_H
17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_HYPERLINK_HYPERLINK_RESOURCE_H
18 
19 #include <string>
20 
21 #include "base/memory/ace_type.h"
22 #include "core/pipeline/pipeline_context.h"
23 
24 namespace OHOS::Ace {
25 
26 constexpr int64_t INVALID_ID = -1;
27 
28 class HyperlinkResources : public virtual AceType {
29     DECLARE_ACE_TYPE(HyperlinkResources, AceType);
30 
31 public:
HyperlinkResources(const WeakPtr<PipelineContext> & context)32     explicit HyperlinkResources(const WeakPtr<PipelineContext>& context) : context_(context) {}
33     ~HyperlinkResources() override;
34     std::string CallResRegisterMethod(const std::string& method, const std::string& param);
35     void StartAbility(const std::string& address);
36     void CreatePlatformResource(const WeakPtr<PipelineContext>& context);
37 
38 protected:
39     std::string MakeResourceHash() const;
40     std::string MakeMethodHash(const std::string& method) const;
41     WeakPtr<PipelineContext> context_;
42 
43 private:
44     void CreatePluginResource(const WeakPtr<PipelineContext>& context);
45     void ReleasePluginResource();
46     int64_t id_ = INVALID_ID;
47     std::string hash_;
48 };
49 
50 } // namespace OHOS::Ace
51 
52 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_HYPERLINK_HYPERLINK_RESOURCE_H
53