-
Notifications
You must be signed in to change notification settings - Fork 159
/
Copy pathCefFileDialogCallback_N.cpp
49 lines (40 loc) · 1.6 KB
/
CefFileDialogCallback_N.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
// Copyright (c) 2014 The Chromium Embedded Framework Authors. All rights
// reserved. Use of this source code is governed by a BSD-style license that
// can be found in the LICENSE file.
#include "CefFileDialogCallback_N.h"
#include "include/cef_dialog_handler.h"
#include "jni_scoped_helpers.h"
#include "jni_util.h"
namespace {
CefRefPtr<CefFileDialogCallback> GetSelf(jlong self) {
return reinterpret_cast<CefFileDialogCallback*>(self);
}
void ClearSelf(JNIEnv* env, jobject obj) {
// Clear the reference added in DialogHandler::OnFileDialog.
SetCefForJNIObject<CefFileDialogCallback>(env, obj, nullptr,
"CefFileDialogCallback");
}
} // namespace
JNIEXPORT void JNICALL
Java_org_cef_callback_CefFileDialogCallback_1N_N_1Continue(JNIEnv* env,
jobject obj,
jlong self,
jobject jFilePaths) {
CefRefPtr<CefFileDialogCallback> callback = GetSelf(self);
if (!callback)
return;
std::vector<CefString> filePaths;
GetJNIStringVector(env, jFilePaths, filePaths);
callback->Continue(filePaths);
ClearSelf(env, obj);
}
JNIEXPORT void JNICALL
Java_org_cef_callback_CefFileDialogCallback_1N_N_1Cancel(JNIEnv* env,
jobject obj,
jlong self) {
CefRefPtr<CefFileDialogCallback> callback = GetSelf(self);
if (!callback)
return;
callback->Cancel();
ClearSelf(env, obj);
}