1 /* 2 * Copyright (c) 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 #ifndef OHOS_JS_EMBEDDABLE_WINDOW_STAGE_H 17 #define OHOS_JS_EMBEDDABLE_WINDOW_STAGE_H 18 #include <map> 19 #include <refbase.h> 20 #include "native_engine/native_engine.h" 21 #include "native_engine/native_reference.h" 22 #include "native_engine/native_value.h" 23 #include "js_extension_window_register_manager.h" 24 #include "session_info.h" 25 #include "window.h" 26 namespace OHOS { 27 namespace Rosen { 28 class JsEmbeddableWindowStage { 29 public: 30 JsEmbeddableWindowStage(sptr<Rosen::Window> window, sptr<AAFwk::SessionInfo> sessionInfo); 31 ~JsEmbeddableWindowStage(); 32 static void Finalizer(napi_env env, void* data, void* hint); 33 static napi_value CreateJsEmbeddableWindowStage(napi_env env, sptr<Rosen::Window> window, 34 sptr<AAFwk::SessionInfo> sessionInfo); 35 static napi_value GetMainWindow(napi_env env, napi_callback_info info); 36 static napi_value GetMainWindowSync(napi_env env, napi_callback_info info); 37 static napi_value On(napi_env env, napi_callback_info info); 38 static napi_value Off(napi_env env, napi_callback_info info); 39 static napi_value LoadContent(napi_env env, napi_callback_info info); 40 static napi_value LoadContentByName(napi_env env, napi_callback_info info); 41 static napi_value CreateSubWindow(napi_env env, napi_callback_info info); 42 static napi_value GetSubWindow(napi_env env, napi_callback_info info); 43 44 private: 45 napi_value OnGetMainWindow(napi_env env, napi_callback_info info); 46 napi_value OnGetMainWindowSync(napi_env env, napi_callback_info info); 47 napi_value OnEvent(napi_env env, napi_callback_info info); 48 napi_value OffEvent(napi_env env, napi_callback_info info); 49 napi_value OnLoadContent(napi_env env, napi_callback_info info, bool isLoadedByName); 50 napi_value OnCreateSubWindow(napi_env env, napi_callback_info info); 51 napi_value OnGetSubWindow(napi_env env, napi_callback_info info); 52 53 sptr<Window> windowExtensionSessionImpl_; 54 sptr<AAFwk::SessionInfo> sessionInfo_ = nullptr; 55 std::unique_ptr<JsExtensionWindowRegisterManager> extwinRegisterManager_ = nullptr; 56 }; 57 } // namespace Rosen 58 } // namespace OHOS 59 #endif // OHOS_JS_EMBEDDABLE_WINDOW_STAGE_H 60