mirror of
https://github.com/apache/cordova-android.git
synced 2025-02-20 23:56:20 +08:00
Make cookieManager a field in AndroidCookieManager rather than using getInstance() every time
This commit is contained in:
parent
11d6b8029f
commit
7be600d8e9
@ -24,38 +24,37 @@ import android.webkit.CookieManager;
|
||||
import android.webkit.WebView;
|
||||
|
||||
class AndroidCookieManager implements ICordovaCookieManager {
|
||||
|
||||
protected WebView webView;
|
||||
protected final WebView webView;
|
||||
private final CookieManager cookieManager;
|
||||
|
||||
public AndroidCookieManager(WebView webview) {
|
||||
webView = webview;
|
||||
cookieManager = CookieManager.getInstance();
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
|
||||
{
|
||||
CookieManager cookieManager = CookieManager.getInstance();
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||
cookieManager.setAcceptThirdPartyCookies(webView, true);
|
||||
}
|
||||
}
|
||||
|
||||
public void setCookiesEnabled(boolean accept) {
|
||||
CookieManager.getInstance().setAcceptCookie(accept);
|
||||
cookieManager.setAcceptCookie(accept);
|
||||
}
|
||||
|
||||
public void setCookie(final String url, final String value) {
|
||||
CookieManager.getInstance().setCookie(url, value);
|
||||
cookieManager.setCookie(url, value);
|
||||
}
|
||||
|
||||
public String getCookie(final String url) {
|
||||
return CookieManager.getInstance().getCookie(url);
|
||||
return cookieManager.getCookie(url);
|
||||
}
|
||||
|
||||
public void clearCookies() {
|
||||
CookieManager.getInstance().removeAllCookie();
|
||||
cookieManager.removeAllCookie();
|
||||
}
|
||||
|
||||
public void flush() {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||
CookieManager.getInstance().flush();
|
||||
cookieManager.flush();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user