forked from chromiumembedded/java-cef
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCefRequestContext_N.cpp
More file actions
64 lines (54 loc) · 2.2 KB
/
CefRequestContext_N.cpp
File metadata and controls
64 lines (54 loc) · 2.2 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
60
61
62
63
64
// 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 "CefRequestContext_N.h"
#include "include/cef_request_context.h"
#include "jni_util.h"
#include "request_context_handler.h"
JNIEXPORT jobject JNICALL
Java_org_cef_browser_CefRequestContext_1N_N_1GetGlobalContext(JNIEnv* env,
jclass cls) {
CefRefPtr<CefRequestContext> context = CefRequestContext::GetGlobalContext();
if (!context.get())
return nullptr;
ScopedJNIObjectLocal jContext(env, NewJNIObject(env, cls));
if (!jContext)
return nullptr;
SetCefForJNIObject(env, jContext, context.get(), "CefRequestContext");
return jContext.Release();
}
JNIEXPORT jobject JNICALL
Java_org_cef_browser_CefRequestContext_1N_N_1CreateContext(JNIEnv* env,
jclass cls,
jobject jhandler) {
CefRefPtr<CefRequestContextHandler> handler = nullptr;
if (jhandler != nullptr) {
handler = new RequestContextHandler(env, jhandler);
}
// TODO(JCEF): Expose CefRequestContextSettings.
CefRequestContextSettings settings;
CefRefPtr<CefRequestContext> context =
CefRequestContext::CreateContext(settings, handler);
if (!context.get())
return nullptr;
ScopedJNIObjectLocal jContext(env, NewJNIObject(env, cls));
if (!jContext)
return nullptr;
SetCefForJNIObject(env, jContext, context.get(), "CefRequestContext");
return jContext.Release();
}
JNIEXPORT jboolean JNICALL
Java_org_cef_browser_CefRequestContext_1N_N_1IsGlobal(JNIEnv* env,
jobject obj) {
CefRefPtr<CefRequestContext> context =
GetCefFromJNIObject<CefRequestContext>(env, obj, "CefRequestContext");
if (!context.get())
return JNI_FALSE;
return context->IsGlobal() ? JNI_TRUE : JNI_FALSE;
}
JNIEXPORT void JNICALL
Java_org_cef_browser_CefRequestContext_1N_N_1CefRequestContext_1DTOR(
JNIEnv* env,
jobject obj) {
SetCefForJNIObject<CefRequestContext>(env, obj, nullptr, "CefRequestContext");
}