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 OHOS_ABILITY_RUNTIME_INSIGHT_INTENT_EXECUTOR_H 17 #define OHOS_ABILITY_RUNTIME_INSIGHT_INTENT_EXECUTOR_H 18 19 #include <memory> 20 #include <napi/native_api.h> 21 #include <string> 22 #include "insight_intent_constant.h" 23 #include "insight_intent_context.h" 24 #include "insight_intent_executor_info.h" 25 26 namespace OHOS { 27 namespace AAFwk { 28 class WantParams; 29 } // namespace AAFwk 30 namespace AppExecFwk { 31 struct InsightIntentExecuteResult; 32 template <typename> class AbilityTransactionCallbackInfo; 33 } // namespace AppExecFwk 34 namespace AbilityRuntime { 35 class Runtime; 36 using InsightIntentExecutorAsyncCallback = 37 AppExecFwk::AbilityTransactionCallbackInfo<AppExecFwk::InsightIntentExecuteResult>; 38 class InsightIntentExecutor { 39 public: 40 static std::shared_ptr<InsightIntentExecutor> Create(Runtime& runtime); 41 protected: 42 InsightIntentExecutor() = default; 43 public: 44 InsightIntentExecutor(const InsightIntentExecutor&) = delete; 45 InsightIntentExecutor(const InsightIntentExecutor&&) = delete; 46 InsightIntentExecutor& operator=(const InsightIntentExecutor&) = delete; 47 InsightIntentExecutor& operator=(const InsightIntentExecutor&&) = delete; 48 virtual ~InsightIntentExecutor() = default; 49 50 /** 51 * @brief Init the insight intent executor and insight intent context. 52 * 53 * @param 54 */ 55 virtual bool Init(const InsightIntentExecutorInfo& intentInfo) = 0; 56 57 /** 58 * @brief Handling the life cycle execute insight intent. 59 * 60 * @param 61 * 62 */ 63 virtual bool HandleExecuteIntent( 64 InsightIntentExecuteMode mode, 65 const std::string& name, 66 const AAFwk::WantParams& params, 67 const std::shared_ptr<NativeReference>& pageLoader, 68 std::unique_ptr<InsightIntentExecutorAsyncCallback> callback, 69 bool& isAsync) = 0; 70 71 /** 72 * @brief Get current insight intent context. 73 * 74 * @return std::shared_ptr<InsightIntentContext> 75 */ 76 std::shared_ptr<InsightIntentContext> GetContext(); 77 78 private: 79 std::shared_ptr<InsightIntentContext> context_ = nullptr; 80 }; 81 } // namespace AbilityRuntime 82 } // namespace OHOS 83 #endif // OHOS_ABILITY_RUNTIME_INSIGHT_INTENT_EXECUTOR_H 84