Skip to content

Commit 2caef5a

Browse files
OLSandermagreenblatt
authored andcommitted
Add CefDragData.getFilePaths
1 parent d048c6a commit 2caef5a

File tree

4 files changed

+47
-0
lines changed

4 files changed

+47
-0
lines changed

java/org/cef/callback/CefDragData.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,12 @@ public static final CefDragData create() {
127127
*/
128128
public abstract boolean getFileNames(Vector<String> names);
129129

130+
/**
131+
* Retrieve the list of file paths that are being dragged into the browser
132+
* window.
133+
*/
134+
public abstract boolean getFilePaths(Vector<String> paths);
135+
130136
/**
131137
* Set the link URL that is being dragged.
132138
* @param url The link URL to be set.

java/org/cef/callback/CefDragData_N.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,16 @@ public boolean getFileNames(Vector<String> names) {
179179
return false;
180180
}
181181

182+
@Override
183+
public boolean getFilePaths(Vector<String> paths) {
184+
try {
185+
return N_GetFilePaths(N_CefHandle, paths);
186+
} catch (UnsatisfiedLinkError ule) {
187+
ule.printStackTrace();
188+
}
189+
return false;
190+
}
191+
182192
public void setLinkURL(String url) {
183193
try {
184194
N_SetLinkURL(N_CefHandle, url);
@@ -259,6 +269,7 @@ public void addFile(String path, String displayName) {
259269
private final native int N_GetFileContents(long self, OutputStream writer);
260270
private final native String N_GetFileName(long self);
261271
private final native boolean N_GetFileNames(long self, Vector<String> names);
272+
private final native boolean N_GetFilePaths(long self, Vector<String> paths);
262273
private final native void N_SetLinkURL(long self, String url);
263274
private final native void N_SetLinkTitle(long self, String title);
264275
private final native void N_SetLinkMetadata(long self, String data);

native/CefDragData_N.cpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,25 @@ Java_org_cef_callback_CefDragData_1N_N_1GetFileNames(JNIEnv* env,
190190
return JNI_TRUE;
191191
}
192192

193+
JNIEXPORT jboolean JNICALL
194+
Java_org_cef_callback_CefDragData_1N_N_1GetFilePaths(JNIEnv* env,
195+
jobject obj,
196+
jlong self,
197+
jobject jfilePaths) {
198+
CefRefPtr<CefDragData> dragData = GetSelf(self);
199+
if (!dragData)
200+
return JNI_FALSE;
201+
202+
std::vector<CefString> filePaths;
203+
if (!dragData->GetFilePaths(filePaths))
204+
return JNI_FALSE;
205+
206+
for (size_t i = 0; i < filePaths.size(); ++i) {
207+
AddJNIStringToVector(env, jfilePaths, filePaths.at(i));
208+
}
209+
return JNI_TRUE;
210+
}
211+
193212
JNIEXPORT void JNICALL
194213
Java_org_cef_callback_CefDragData_1N_N_1SetLinkURL(JNIEnv* env,
195214
jobject obj,

native/CefDragData_N.h

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)