mirror of
https://gitee.com/openharmony/window_window_manager
synced 2024-11-27 09:00:55 +00:00
add js interface bindDialogTarget
Signed-off-by: zhengjiangliang <zhengjiangliang@huawei.com> Change-Id: I66e3289a49120900a6a6c82ac813a7084286e599
This commit is contained in:
parent
8ddcc35b4b
commit
96b41b4a6b
@ -64,6 +64,7 @@ ohos_shared_library("window_native_kit") {
|
||||
|
||||
external_deps = [
|
||||
"ability_runtime:ability_manager",
|
||||
"ability_runtime:dialog_request_info",
|
||||
"ability_runtime:runtime",
|
||||
"access_token:libaccesstoken_sdk",
|
||||
"bundle_framework:appexecfwk_base",
|
||||
|
@ -32,6 +32,7 @@
|
||||
#include "pixel_map_napi.h"
|
||||
#include "napi_remote_object.h"
|
||||
#include "permission.h"
|
||||
#include "request_info.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace Rosen {
|
||||
@ -1267,6 +1268,12 @@ NativeValue* JsWindow::OnBindDialogTarget(NativeEngine& engine, NativeCallbackIn
|
||||
sptr<IRemoteObject> token = nullptr;
|
||||
token = NAPI_ohos_rpc_getNativeRemoteObject(
|
||||
reinterpret_cast<napi_env>(&engine), reinterpret_cast<napi_value>(info.argv[0]));
|
||||
if (token == nullptr) {
|
||||
std::shared_ptr<AbilityRuntime::RequestInfo> requestInfo = AbilityRuntime::RequestInfo::UnwrapRequestInfo(engine, info.argv[0]);
|
||||
if (requestInfo != nullptr) {
|
||||
token = requestInfo->GetToken();
|
||||
}
|
||||
}
|
||||
if (token == nullptr) {
|
||||
errCode = WmErrorCode::WM_ERROR_INVALID_PARAM;
|
||||
}
|
||||
|
38
previewer/mock/request_info.h
Normal file
38
previewer/mock/request_info.h
Normal file
@ -0,0 +1,38 @@
|
||||
/*
|
||||
* Copyright (c) 2023 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef OHOS_ABILITY_RUNTIME_REQUEST_INFO_H
|
||||
#define OHOS_ABILITY_RUNTIME_REQUEST_INFO_H
|
||||
|
||||
namespace OHOS {
|
||||
namespace AbilityRuntime {
|
||||
class RequestInfo {
|
||||
public:
|
||||
static NativeValue* WrapRequestInfo(NativeEngine &engine, RequestInfo *request) {
|
||||
return nullptr;
|
||||
};
|
||||
static std::shared_ptr<RequestInfo> UnwrapRequestInfo(NativeEngine &engine, NativeValue *jsParam) {
|
||||
return nullptr;
|
||||
};
|
||||
|
||||
sptr<IRemoteObject> GetToken() {
|
||||
return callerToken_;
|
||||
};
|
||||
private:
|
||||
sptr<IRemoteObject> callerToken_;
|
||||
};
|
||||
} // namespace AbilityRuntime
|
||||
} // namespace OHOS
|
||||
#endif // OHOS_ABILITY_RUNTIME_REQUEST_INFO_H
|
Loading…
Reference in New Issue
Block a user