-
Notifications
You must be signed in to change notification settings - Fork 39
/
Copy pathCefDownloadItem_N.cpp
178 lines (158 loc) · 6.62 KB
/
CefDownloadItem_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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
// 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 "CefDownloadItem_N.h"
#include "include/cef_download_item.h"
#include "jni_scoped_helpers.h"
#include "jni_util.h"
namespace {
CefRefPtr<CefDownloadItem> GetSelf(jlong self) {
return reinterpret_cast<CefDownloadItem*>(self);
}
} // namespace
JNIEXPORT jboolean JNICALL
Java_org_cef_callback_CefDownloadItem_1N_N_1IsValid(JNIEnv* env,
jobject obj,
jlong self) {
CefRefPtr<CefDownloadItem> downloadItem = GetSelf(self);
if (!downloadItem)
return JNI_FALSE;
return downloadItem->IsValid() ? JNI_TRUE : JNI_FALSE;
}
JNIEXPORT jboolean JNICALL
Java_org_cef_callback_CefDownloadItem_1N_N_1IsInProgress(JNIEnv* env,
jobject obj,
jlong self) {
CefRefPtr<CefDownloadItem> downloadItem = GetSelf(self);
if (!downloadItem)
return JNI_FALSE;
return downloadItem->IsInProgress() ? JNI_TRUE : JNI_FALSE;
}
JNIEXPORT jboolean JNICALL
Java_org_cef_callback_CefDownloadItem_1N_N_1IsComplete(JNIEnv* env,
jobject obj,
jlong self) {
CefRefPtr<CefDownloadItem> downloadItem = GetSelf(self);
if (!downloadItem)
return JNI_FALSE;
return downloadItem->IsComplete() ? JNI_TRUE : JNI_FALSE;
}
JNIEXPORT jboolean JNICALL
Java_org_cef_callback_CefDownloadItem_1N_N_1IsCanceled(JNIEnv* env,
jobject obj,
jlong self) {
CefRefPtr<CefDownloadItem> downloadItem = GetSelf(self);
if (!downloadItem)
return JNI_FALSE;
return downloadItem->IsCanceled() ? JNI_TRUE : JNI_FALSE;
}
JNIEXPORT jlong JNICALL
Java_org_cef_callback_CefDownloadItem_1N_N_1GetCurrentSpeed(JNIEnv* env,
jobject obj,
jlong self) {
CefRefPtr<CefDownloadItem> downloadItem = GetSelf(self);
if (!downloadItem)
return 0;
return downloadItem->GetCurrentSpeed();
}
JNIEXPORT jint JNICALL
Java_org_cef_callback_CefDownloadItem_1N_N_1GetPercentComplete(JNIEnv* env,
jobject obj,
jlong self) {
CefRefPtr<CefDownloadItem> downloadItem = GetSelf(self);
if (!downloadItem)
return 0;
return downloadItem->GetPercentComplete();
}
JNIEXPORT jlong JNICALL
Java_org_cef_callback_CefDownloadItem_1N_N_1GetTotalBytes(JNIEnv* env,
jobject obj,
jlong self) {
CefRefPtr<CefDownloadItem> downloadItem = GetSelf(self);
if (!downloadItem)
return 0;
return downloadItem->GetTotalBytes();
}
JNIEXPORT jlong JNICALL
Java_org_cef_callback_CefDownloadItem_1N_N_1GetReceivedBytes(JNIEnv* env,
jobject obj,
jlong self) {
CefRefPtr<CefDownloadItem> downloadItem = GetSelf(self);
if (!downloadItem)
return 0;
return downloadItem->GetReceivedBytes();
}
JNIEXPORT jobject JNICALL
Java_org_cef_callback_CefDownloadItem_1N_N_1GetStartTime(JNIEnv* env,
jobject obj,
jlong self) {
CefRefPtr<CefDownloadItem> downloadItem = GetSelf(self);
if (!downloadItem)
return nullptr;
ScopedJNIDate jdate(env, downloadItem->GetStartTime());
return jdate.Release();
}
JNIEXPORT jobject JNICALL
Java_org_cef_callback_CefDownloadItem_1N_N_1GetEndTime(JNIEnv* env,
jobject obj,
jlong self) {
CefRefPtr<CefDownloadItem> downloadItem = GetSelf(self);
if (!downloadItem)
return nullptr;
ScopedJNIDate jdate(env, downloadItem->GetEndTime());
return jdate.Release();
}
JNIEXPORT jstring JNICALL
Java_org_cef_callback_CefDownloadItem_1N_N_1GetFullPath(JNIEnv* env,
jobject obj,
jlong self) {
CefRefPtr<CefDownloadItem> downloadItem = GetSelf(self);
if (!downloadItem)
return nullptr;
return NewJNIString(env, downloadItem->GetFullPath());
}
JNIEXPORT jint JNICALL
Java_org_cef_callback_CefDownloadItem_1N_N_1GetId(JNIEnv* env,
jobject obj,
jlong self) {
CefRefPtr<CefDownloadItem> downloadItem = GetSelf(self);
if (!downloadItem)
return -1;
return downloadItem->GetId();
}
JNIEXPORT jstring JNICALL
Java_org_cef_callback_CefDownloadItem_1N_N_1GetURL(JNIEnv* env,
jobject obj,
jlong self) {
CefRefPtr<CefDownloadItem> downloadItem = GetSelf(self);
if (!downloadItem)
return nullptr;
return NewJNIString(env, downloadItem->GetURL());
}
JNIEXPORT jstring JNICALL
Java_org_cef_callback_CefDownloadItem_1N_N_1GetSuggestedFileName(JNIEnv* env,
jobject obj,
jlong self) {
CefRefPtr<CefDownloadItem> downloadItem = GetSelf(self);
if (!downloadItem)
return nullptr;
return NewJNIString(env, downloadItem->GetSuggestedFileName());
}
JNIEXPORT jstring JNICALL
Java_org_cef_callback_CefDownloadItem_1N_N_1GetContentDisposition(JNIEnv* env,
jobject obj,
jlong self) {
CefRefPtr<CefDownloadItem> downloadItem = GetSelf(self);
if (!downloadItem)
return nullptr;
return NewJNIString(env, downloadItem->GetContentDisposition());
}
JNIEXPORT jstring JNICALL
Java_org_cef_callback_CefDownloadItem_1N_N_1GetMimeType(JNIEnv* env,
jobject obj,
jlong self) {
CefRefPtr<CefDownloadItem> downloadItem = GetSelf(self);
if (!downloadItem)
return nullptr;
return NewJNIString(env, downloadItem->GetMimeType());
}