EMMA Coverage Report (generated Fri Aug 23 16:39:17 PDT 2013)
[all classes][org.chromium.android_webview]

COVERAGE SUMMARY FOR SOURCE FILE [AwCookieManager.java]

nameclass, %method, %block, %line, %
AwCookieManager.java100% (1/1)100% (12/12)100% (52/52)100% (20/20)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class AwCookieManager100% (1/1)100% (12/12)100% (52/52)100% (20/20)
AwCookieManager (): void 100% (1/1)100% (3/3)100% (1/1)
acceptCookie (): boolean 100% (1/1)100% (3/3)100% (1/1)
allowFileSchemeCookies (): boolean 100% (1/1)100% (3/3)100% (1/1)
flushCookieStore (): void 100% (1/1)100% (3/3)100% (2/2)
getCookie (String): String 100% (1/1)100% (15/15)100% (2/2)
hasCookies (): boolean 100% (1/1)100% (3/3)100% (1/1)
removeAllCookie (): void 100% (1/1)100% (3/3)100% (2/2)
removeExpiredCookie (): void 100% (1/1)100% (3/3)100% (2/2)
removeSessionCookie (): void 100% (1/1)100% (3/3)100% (2/2)
setAcceptCookie (boolean): void 100% (1/1)100% (4/4)100% (2/2)
setAcceptFileSchemeCookies (boolean): void 100% (1/1)100% (4/4)100% (2/2)
setCookie (String, String): void 100% (1/1)100% (5/5)100% (2/2)

1// Copyright (c) 2012 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 
5package org.chromium.android_webview;
6 
7import android.net.ParseException;
8import android.util.Log;
9 
10import org.chromium.base.JNINamespace;
11import org.chromium.base.ThreadUtils;
12 
13import java.util.concurrent.Callable;
14 
15/**
16 * AwCookieManager manages cookies according to RFC2109 spec.
17 *
18 * Methods in this class are thread safe.
19 */
20@JNINamespace("android_webview")
21public final class AwCookieManager {
22    /**
23     * Control whether cookie is enabled or disabled
24     * @param accept TRUE if accept cookie
25     */
26    public void setAcceptCookie(boolean accept) {
27        nativeSetAcceptCookie(accept);
28    }
29 
30    /**
31     * Return whether cookie is enabled
32     * @return TRUE if accept cookie
33     */
34    public boolean acceptCookie() {
35        return nativeAcceptCookie();
36    }
37 
38    /**
39     * Set cookie for a given url. The old cookie with same host/path/name will
40     * be removed. The new cookie will be added if it is not expired or it does
41     * not have expiration which implies it is session cookie.
42     * @param url The url which cookie is set for
43     * @param value The value for set-cookie: in http response header
44     */
45    public void setCookie(final String url, final String value) {
46        nativeSetCookie(url, value);
47    }
48 
49    /**
50     * Get cookie(s) for a given url so that it can be set to "cookie:" in http
51     * request header.
52     * @param url The url needs cookie
53     * @return The cookies in the format of NAME=VALUE [; NAME=VALUE]
54     */
55    public String getCookie(final String url) {
56        String cookie = nativeGetCookie(url.toString());
57        // Return null if the string is empty to match legacy behavior
58        return cookie == null || cookie.trim().isEmpty() ? null : cookie;
59    }
60 
61    /**
62     * Remove all session cookies, which are cookies without expiration date
63     */
64    public void removeSessionCookie() {
65        nativeRemoveSessionCookie();
66    }
67 
68    /**
69     * Remove all cookies
70     */
71    public void removeAllCookie() {
72        nativeRemoveAllCookie();
73    }
74 
75    /**
76     *  Return true if there are stored cookies.
77     */
78    public boolean hasCookies() {
79        return nativeHasCookies();
80    }
81 
82    /**
83     * Remove all expired cookies
84     */
85    public void removeExpiredCookie() {
86        nativeRemoveExpiredCookie();
87    }
88 
89    public void flushCookieStore() {
90        nativeFlushCookieStore();
91    }
92 
93    /**
94     * Whether cookies are accepted for file scheme URLs.
95     */
96    public boolean allowFileSchemeCookies() {
97        return nativeAllowFileSchemeCookies();
98    }
99 
100    /**
101     * Sets whether cookies are accepted for file scheme URLs.
102     *
103     * Use of cookies with file scheme URLs is potentially insecure. Do not use this feature unless
104     * you can be sure that no unintentional sharing of cookie data can take place.
105     * <p>
106     * Note that calls to this method will have no effect if made after a WebView or CookieManager
107     * instance has been created.
108     */
109    public void setAcceptFileSchemeCookies(boolean accept) {
110        nativeSetAcceptFileSchemeCookies(accept);
111    }
112 
113    private native void nativeSetAcceptCookie(boolean accept);
114    private native boolean nativeAcceptCookie();
115 
116    private native void nativeSetCookie(String url, String value);
117    private native String nativeGetCookie(String url);
118 
119    private native void nativeRemoveSessionCookie();
120    private native void nativeRemoveAllCookie();
121    private native void nativeRemoveExpiredCookie();
122    private native void nativeFlushCookieStore();
123 
124    private native boolean nativeHasCookies();
125 
126    private native boolean nativeAllowFileSchemeCookies();
127    private native void nativeSetAcceptFileSchemeCookies(boolean accept);
128}

[all classes][org.chromium.android_webview]
EMMA 2.0.5312 (C) Vladimir Roubtsov