-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathDesktopWebView.java
More file actions
51 lines (38 loc) · 1.29 KB
/
DesktopWebView.java
File metadata and controls
51 lines (38 loc) · 1.29 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
package com.arn.scrobble;
// all params should be non null
// this class is just useed for testing
public class DesktopWebView {
private static native void startEventLoop();
static native void launchWebView(String url, String callbackPrefix, String cookiesUrl, String dataDir, String proxyHost, int proxyPort);
static native void deleteAndQuit();
static {
System.loadLibrary("native_webview");
}
public static void main(String[] args) {
launchWebView("https://fonts.google.com", "callbackPrefix", "/tmp/webview", "", 0);
new Thread(new Runnable() {
@Override
public void run() {
startEventLoop();
}
}).start();
try {
Thread.sleep(5000);
} catch (InterruptedException e) {
e.printStackTrace();
}
getWebViewCookiesFor("https://fonts.google.com");
try {
Thread.sleep(5000);
} catch (InterruptedException e) {
e.printStackTrace();
}
quitWebView();
}
public static void onCallback(String url, String[] cookies) {
System.out.println("onCallback: " + url);
for (String cookie : cookies) {
System.out.println("Cookie: " + cookie);
}
}
}