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 #include "insight_intent_executor.h"
17 #include "js_insight_intent_executor.h"
18 
19 #include "hilog_tag_wrapper.h"
20 #include "js_runtime.h"
21 #include "runtime.h"
22 
23 namespace OHOS::AbilityRuntime {
Create(Runtime & runtime)24 std::shared_ptr<InsightIntentExecutor> InsightIntentExecutor::Create(Runtime& runtime)
25 {
26     TAG_LOGD(AAFwkTag::INTENT, "called");
27     switch (runtime.GetLanguage()) {
28         case Runtime::Language::JS:
29             return static_cast<std::shared_ptr<InsightIntentExecutor>>(JsInsightIntentExecutor::Create(
30                 static_cast<JsRuntime&>(runtime)));
31         default:
32             return nullptr;
33     }
34 }
35 
Init(const InsightIntentExecutorInfo & intentInfo)36 bool InsightIntentExecutor::Init(const InsightIntentExecutorInfo& intentInfo)
37 {
38     auto executeParam = intentInfo.executeParam;
39     if (executeParam == nullptr) {
40         TAG_LOGE(AAFwkTag::INTENT, "null executeParam");
41         return false;
42     }
43 
44     context_ = std::make_shared<InsightIntentContext>(intentInfo.token, executeParam->bundleName_,
45         intentInfo.windowMode, executeParam->insightIntentId_);
46     return true;
47 }
48 
GetContext()49 std::shared_ptr<InsightIntentContext> InsightIntentExecutor::GetContext()
50 {
51     return context_;
52 }
53 } // namespace OHOS::AbilityRuntime
54