Repository navigation
Expand file tree
/
Copy pathdialog_handler.cpp
More file actions
59 lines (51 loc) · 2.12 KB
/
Copy pathdialog_handler.cpp
File metadata and controls
59 lines (51 loc) · 2.12 KB
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
50
51
52
53
54
55
56
57
58
59
// 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 "dialog_handler.h"
#include "client_handler.h"
#include "jni_util.h"
#include "util.h"
DialogHandler::DialogHandler(JNIEnv* env, jobject handler) {
jhandler_ = env->NewGlobalRef(handler);
}
DialogHandler::~DialogHandler() {
JNIEnv* env = GetJNIEnv();
env->DeleteGlobalRef(jhandler_);
}
bool DialogHandler::OnFileDialog(CefRefPtr<CefBrowser> browser,
FileDialogMode mode,
const CefString& title,
const CefString& default_file_path,
const std::vector<CefString>& accept_filters,
int selected_accept_filter,
CefRefPtr<CefFileDialogCallback> callback) {
JNIEnv* env = GetJNIEnv();
if (!env)
return false;
jobject jmode = NULL;
switch (mode) {
default:
JNI_CASE(env, "org/cef/handler/CefDialogHandler$FileDialogMode",
FILE_DIALOG_OPEN, jmode);
JNI_CASE(env, "org/cef/handler/CefDialogHandler$FileDialogMode",
FILE_DIALOG_OPEN_MULTIPLE, jmode);
JNI_CASE(env, "org/cef/handler/CefDialogHandler$FileDialogMode",
FILE_DIALOG_SAVE, jmode);
}
jobject jcallback =
NewJNIObject(env, "org/cef/callback/CefFileDialogCallback_N");
if (!jcallback)
return false;
SetCefForJNIObject(env, jcallback, callback.get(), "CefFileDialogCallback");
jboolean jreturn = JNI_FALSE;
JNI_CALL_METHOD(
env, jhandler_, "onFileDialog",
"(Lorg/cef/browser/CefBrowser;Lorg/cef/handler/"
"CefDialogHandler$FileDialogMode;Ljava/lang/String;Ljava/lang/"
"String;Ljava/util/Vector;ILorg/cef/callback/CefFileDialogCallback;)Z",
Boolean, jreturn, GetJNIBrowser(browser), jmode, NewJNIString(env, title),
NewJNIString(env, default_file_path),
NewJNIStringVector(env, accept_filters), selected_accept_filter,
jcallback);
return (jreturn != JNI_FALSE);
}