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 OHOS_MISCSERVICES_JS_KEYBOARD_DELEGATE_H 17 #define OHOS_MISCSERVICES_JS_KEYBOARD_DELEGATE_H 18 19 #include "js_runtime_utils.h" 20 #include "native_engine/native_engine.h" 21 #include "native_engine/native_value.h" 22 #include "js_keyboard_delegate_listener.h" 23 #include "event_handler.h" 24 #include "event_runner.h" 25 26 namespace OHOS { 27 namespace MiscServices { 28 class JsKeyboardDelegate { 29 public: 30 JsKeyboardDelegate(NativeEngine* engine); 31 ~JsKeyboardDelegate() = default; 32 static void Finalizer(NativeEngine* engine, void* data, void* hint); 33 static NativeValue* RegisterCallback(NativeEngine* engine, NativeCallbackInfo* info); 34 static NativeValue* UnRegisterCallback(NativeEngine* engine, NativeCallbackInfo* info); 35 private: 36 sptr<JsKeyboardDelegateListener> kdListener_; 37 std::mutex mtx_; 38 NativeValue* OnRegisterCallback(NativeEngine& engine, NativeCallbackInfo& info); 39 NativeValue* OnUnRegisterCallback(NativeEngine& engine, NativeCallbackInfo& info); 40 std::shared_ptr<AppExecFwk::EventHandler> GetMainHandler(); 41 std::shared_ptr<AppExecFwk::EventHandler> mainHandler_ = nullptr; 42 }; 43 } 44 } 45 #endif // OHOS_MISCSERVICES_JS_KEYBOARD_DELEGATE_H