Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / android_webview / unittestjava / src / org / chromium / android_webview / unittest / MockAwContentsClientBridge.java
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.unittest;
6
7 import org.chromium.android_webview.AwContentsClientBridge;
8 import org.chromium.android_webview.ClientCertLookupTable;
9 import org.chromium.base.CalledByNative;
10 import org.chromium.net.AndroidKeyStore;
11 import org.chromium.net.AndroidPrivateKey;
12 import org.chromium.net.DefaultAndroidKeyStore;
13
14 class MockAwContentsClientBridge extends AwContentsClientBridge {
15
16     private int mId;
17     private String[] mKeyTypes;
18
19     public MockAwContentsClientBridge() {
20         super(new DefaultAndroidKeyStore(), new ClientCertLookupTable());
21     }
22
23     @Override
24     protected void selectClientCertificate(final int id, final String[] keyTypes,
25             byte[][] encodedPrincipals, final String host, final int port) {
26         mId = id;
27         mKeyTypes = keyTypes;
28     }
29
30     @CalledByNative
31     private static MockAwContentsClientBridge getAwContentsClientBridge() {
32         return new MockAwContentsClientBridge();
33     }
34
35     @CalledByNative
36     private String[] getKeyTypes() {
37         return mKeyTypes;
38     }
39
40     @CalledByNative
41     private int getRequestId() {
42         return mId;
43     }
44
45     @CalledByNative
46     private AndroidPrivateKey createTestPrivateKey() {
47         return new AndroidPrivateKey() {
48             @Override
49             public AndroidKeyStore getKeyStore() {
50                 return null;
51             }
52         };
53     }
54
55     @CalledByNative
56     private byte[][] createTestCertChain() {
57         return new byte[][]{{1}};
58     }
59 }