• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 package org.chromium.android_webview;
6 
7 import org.chromium.base.CalledByNative;
8 import org.chromium.base.JNINamespace;
9 import org.chromium.base.ThreadUtils;
10 
11 import java.lang.Runnable;
12 
13 /**
14  * Implementations of various static methods, and also a home for static
15  * data structures that are meant to be shared between all webviews.
16  */
17 @JNINamespace("android_webview")
18 public class AwContentsStatics {
19 
20     private static ClientCertLookupTable sClientCertLookupTable;
21 
22     private static String sUnreachableWebDataUrl;
23 
24     /**
25      * Return the client certificate lookup table.
26      */
getClientCertLookupTable()27     public static ClientCertLookupTable getClientCertLookupTable() {
28         ThreadUtils.assertOnUiThread();
29         if (sClientCertLookupTable == null) {
30             sClientCertLookupTable = new ClientCertLookupTable();
31         }
32         return sClientCertLookupTable;
33     }
34 
35     /**
36      * Clear client cert lookup table. Should only be called from UI thread.
37      */
clearClientCertPreferences(Runnable callback)38     public static void clearClientCertPreferences(Runnable callback) {
39         ThreadUtils.assertOnUiThread();
40         getClientCertLookupTable().clear();
41         nativeClearClientCertPreferences(callback);
42     }
43 
44     @CalledByNative
clientCertificatesCleared(Runnable callback)45     private static void clientCertificatesCleared(Runnable callback) {
46         if (callback == null) return;
47         callback.run();
48     }
49 
50     /**
51      * Set Data Reduction Proxy key for authentication.
52      */
setDataReductionProxyKey(String key)53     public static void setDataReductionProxyKey(String key) {
54         ThreadUtils.assertOnUiThread();
55         nativeSetDataReductionProxyKey(key);
56     }
57 
58     /*
59      * Enable or disable data reduction proxy.
60      */
setDataReductionProxyEnabled(boolean enabled)61     public static void setDataReductionProxyEnabled(boolean enabled) {
62         ThreadUtils.assertOnUiThread();
63         nativeSetDataReductionProxyEnabled(enabled);
64     }
65 
getUnreachableWebDataUrl()66     public static String getUnreachableWebDataUrl() {
67         if (sUnreachableWebDataUrl == null) {
68             sUnreachableWebDataUrl = nativeGetUnreachableWebDataUrl();
69         }
70         return sUnreachableWebDataUrl;
71     }
72 
setRecordFullDocument(boolean recordFullDocument)73     public static void setRecordFullDocument(boolean recordFullDocument) {
74         nativeSetRecordFullDocument(recordFullDocument);
75     }
76 
77     //--------------------------------------------------------------------------------------------
78     //  Native methods
79     //--------------------------------------------------------------------------------------------
nativeClearClientCertPreferences(Runnable callback)80     private static native void nativeClearClientCertPreferences(Runnable callback);
nativeSetDataReductionProxyKey(String key)81     private static native void nativeSetDataReductionProxyKey(String key);
nativeSetDataReductionProxyEnabled(boolean enabled)82     private static native void nativeSetDataReductionProxyEnabled(boolean enabled);
nativeGetUnreachableWebDataUrl()83     private static native String nativeGetUnreachableWebDataUrl();
nativeSetRecordFullDocument(boolean recordFullDocument)84     private static native void nativeSetRecordFullDocument(boolean recordFullDocument);
85 }
86