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 FRAMEWORKS_BRIDGE_DECLARATIVE_FRONTEND_JS_VIEW_JS_XCOMPONENT_CONTROLLER_H 17 #define FRAMEWORKS_BRIDGE_DECLARATIVE_FRONTEND_JS_VIEW_JS_XCOMPONENT_CONTROLLER_H 18 19 #include "base/memory/referenced.h" 20 #include "bridge/declarative_frontend/engine/bindings.h" 21 #include "core/components/xcomponent/xcomponent_controller.h" 22 23 namespace OHOS::Ace::Framework { 24 class JSXComponentController : public Referenced { 25 public: 26 JSXComponentController() = default; 27 ~JSXComponentController() override = default; 28 29 static void JSBind(BindingTarget globalObj); 30 static void Constructor(const JSCallbackInfo& args); 31 static void Destructor(JSXComponentController* xcomponentController); 32 33 void GetSurfaceId(const JSCallbackInfo& args); 34 void SetSurfaceConfig(const JSCallbackInfo& args); 35 GetXComponentContext(const JSCallbackInfo & args)36 void GetXComponentContext(const JSCallbackInfo& args) 37 { 38 args.SetReturnValue(renderContext_); 39 } 40 SetXComponentContext(const JSRef<JSVal> & renderContext)41 void SetXComponentContext(const JSRef<JSVal> &renderContext) 42 { 43 renderContext_ = renderContext; 44 } 45 GetController()46 RefPtr<XComponentController> GetController() const 47 { 48 return xcomponentController_; 49 } 50 SetController(const RefPtr<XComponentController> & xcomponentController)51 void SetController(const RefPtr<XComponentController>& xcomponentController) 52 { 53 xcomponentController_ = xcomponentController; 54 } 55 56 private: 57 RefPtr<XComponentController> xcomponentController_; 58 JSRef<JSVal> renderContext_; 59 ACE_DISALLOW_COPY_AND_MOVE(JSXComponentController); 60 }; 61 } // namespace OHOS::Ace::Framework 62 #endif // FRAMEWORKS_BRIDGE_DECLARATIVE_FRONTEND_JS_VIEW_JS_XCOMPONENT_CONTROLLER_H