forked from chromiumembedded/java-cef
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdrag_handler.cpp
More file actions
41 lines (33 loc) · 1.27 KB
/
Copy pathdrag_handler.cpp
File metadata and controls
41 lines (33 loc) · 1.27 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
// 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 "drag_handler.h"
#include "client_handler.h"
#include "jni_util.h"
#include "util.h"
DragHandler::DragHandler(JNIEnv* env, jobject handler) {
jhandler_ = env->NewGlobalRef(handler);
}
DragHandler::~DragHandler() {
JNIEnv* env = GetJNIEnv();
env->DeleteGlobalRef(jhandler_);
}
bool DragHandler::OnDragEnter(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefDragData> dragData,
CefDragHandler::DragOperationsMask mask) {
JNIEnv* env = GetJNIEnv();
if (!env)
return false;
jobject jdragdata = NewJNIObject(env, "org/cef/callback/CefDragData_N");
if (!jdragdata)
return false;
SetCefForJNIObject(env, jdragdata, dragData.get(), "CefDragData");
jboolean result = JNI_FALSE;
JNI_CALL_METHOD(
env, jhandler_, "onDragEnter",
"(Lorg/cef/browser/CefBrowser;Lorg/cef/callback/CefDragData;I)Z", Boolean,
result, GetJNIBrowser(browser), jdragdata, (jint)mask);
// Remove native reference from java class
SetCefForJNIObject<CefDragData>(env, jdragdata, NULL, "CefDragData");
return (result != JNI_FALSE);
}