-
Notifications
You must be signed in to change notification settings - Fork 159
/
Copy pathCefDownloadItemCallback_N.cpp
63 lines (54 loc) · 2.17 KB
/
CefDownloadItemCallback_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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
// 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 "CefDownloadItemCallback_N.h"
#include "include/cef_download_handler.h"
#include "jni_scoped_helpers.h"
namespace {
CefRefPtr<CefDownloadItemCallback> GetSelf(jlong self) {
return reinterpret_cast<CefDownloadItemCallback*>(self);
}
void ClearSelf(JNIEnv* env, jobject obj) {
// Clear the reference added in DownloadHandler::OnDownloadUpdated.
SetCefForJNIObject<CefDownloadItemCallback>(env, obj, nullptr,
"CefDownloadItemCallback");
}
} // namespace
JNIEXPORT void JNICALL
Java_org_cef_callback_CefDownloadItemCallback_1N_N_1Cancel(JNIEnv* env,
jobject obj,
jlong self) {
CefRefPtr<CefDownloadItemCallback> callback = GetSelf(self);
if (!callback)
return;
callback->Cancel();
ClearSelf(env, obj);
}
JNIEXPORT void JNICALL
Java_org_cef_callback_CefDownloadItemCallback_1N_N_1Pause(JNIEnv* env,
jobject obj,
jlong self) {
CefRefPtr<CefDownloadItemCallback> callback = GetSelf(self);
if (!callback)
return;
callback->Pause();
}
JNIEXPORT void JNICALL
Java_org_cef_callback_CefDownloadItemCallback_1N_N_1Resume(JNIEnv* env,
jobject obj,
jlong self) {
CefRefPtr<CefDownloadItemCallback> callback = GetSelf(self);
if (!callback)
return;
callback->Resume();
}
JNIEXPORT void JNICALL
Java_org_cef_callback_CefDownloadItemCallback_1N_N_1Dispose(JNIEnv* env,
jobject obj,
jlong self) {
CefRefPtr<CefDownloadItemCallback> callback = GetSelf(self);
if (!callback)
return;
// Intentionally not executing any callback methods here.
ClearSelf(env, obj);
}