diff options
author | kristianm@chromium.org <kristianm@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-12-20 22:56:15 +0000 |
---|---|---|
committer | kristianm@chromium.org <kristianm@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-12-20 22:56:15 +0000 |
commit | af0fad0505b5e919f73da7d26855abe343fb8f7f (patch) | |
tree | b61447ff7fb359e895b095e319de7f0c6e5f66a0 /android_webview | |
parent | 82b781332bef747aff59589cc98109e920d93ebc (diff) | |
download | chromium_src-af0fad0505b5e919f73da7d26855abe343fb8f7f.zip chromium_src-af0fad0505b5e919f73da7d26855abe343fb8f7f.tar.gz chromium_src-af0fad0505b5e919f73da7d26855abe343fb8f7f.tar.bz2 |
Renaming org.chromium.android_webview.CookieManager to AwCookieManager
Final patch
BUG=
Review URL: https://chromiumcodereview.appspot.com/11640048
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@174262 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'android_webview')
5 files changed, 121 insertions, 138 deletions
diff --git a/android_webview/java/src/org/chromium/android_webview/AwCookieManager.java b/android_webview/java/src/org/chromium/android_webview/AwCookieManager.java index 0135208..53db5d8 100644 --- a/android_webview/java/src/org/chromium/android_webview/AwCookieManager.java +++ b/android_webview/java/src/org/chromium/android_webview/AwCookieManager.java @@ -4,11 +4,125 @@ package org.chromium.android_webview; +import android.net.ParseException; +import android.util.Log; + +import org.chromium.base.JNINamespace; +import org.chromium.base.ThreadUtils; + +import java.util.concurrent.Callable; + /** - * CookieManager manages cookies according to RFC2109 spec. + * AwCookieManager manages cookies according to RFC2109 spec. * * Methods in this class are thread safe. */ -public final class AwCookieManager extends CookieManager { - private native void nativeForJni(); +@JNINamespace("android_webview") +public final class AwCookieManager { + /** + * Control whether cookie is enabled or disabled + * @param accept TRUE if accept cookie + */ + public void setAcceptCookie(boolean accept) { + nativeSetAcceptCookie(accept); + } + + /** + * Return whether cookie is enabled + * @return TRUE if accept cookie + */ + public boolean acceptCookie() { + return nativeAcceptCookie(); + } + + /** + * Set cookie for a given url. The old cookie with same host/path/name will + * be removed. The new cookie will be added if it is not expired or it does + * not have expiration which implies it is session cookie. + * @param url The url which cookie is set for + * @param value The value for set-cookie: in http response header + */ + public void setCookie(final String url, final String value) { + nativeSetCookie(url, value); + } + + /** + * Get cookie(s) for a given url so that it can be set to "cookie:" in http + * request header. + * @param url The url needs cookie + * @return The cookies in the format of NAME=VALUE [; NAME=VALUE] + */ + public String getCookie(final String url) { + String cookie = nativeGetCookie(url.toString()); + // Return null if the string is empty to match legacy behavior + return cookie == null || cookie.trim().isEmpty() ? null : cookie; + } + + /** + * Remove all session cookies, which are cookies without expiration date + */ + public void removeSessionCookie() { + nativeRemoveSessionCookie(); + } + + /** + * Remove all cookies + */ + public void removeAllCookie() { + nativeRemoveAllCookie(); + } + + /** + * Return true if there are stored cookies. + */ + public boolean hasCookies() { + return nativeHasCookies(); + } + + /** + * Remove all expired cookies + */ + public void removeExpiredCookie() { + nativeRemoveExpiredCookie(); + } + + public void flushCookieStore() { + nativeFlushCookieStore(); + } + + /** + * Whether cookies are accepted for file scheme URLs. + */ + public boolean allowFileSchemeCookies() { + return nativeAllowFileSchemeCookies(); + } + + /** + * Sets whether cookies are accepted for file scheme URLs. + * + * Use of cookies with file scheme URLs is potentially insecure. Do not use this feature unless + * you can be sure that no unintentional sharing of cookie data can take place. + * <p> + * Note that calls to this method will have no effect if made after a WebView or CookieManager + * instance has been created. + */ + public void setAcceptFileSchemeCookies(boolean accept) { + nativeSetAcceptFileSchemeCookies(accept); + } + + private native void nativeSetAcceptCookie(boolean accept); + private native boolean nativeAcceptCookie(); + + private native void nativeSetCookie(String url, String value); + private native String nativeGetCookie(String url); + + private native void nativeRemoveSessionCookie(); + private native void nativeRemoveAllCookie(); + private native void nativeRemoveExpiredCookie(); + private native void nativeFlushCookieStore(); + + private native boolean nativeHasCookies(); + + private native boolean nativeAllowFileSchemeCookies(); + private native void nativeSetAcceptFileSchemeCookies(boolean accept); } diff --git a/android_webview/java/src/org/chromium/android_webview/CookieManager.java b/android_webview/java/src/org/chromium/android_webview/CookieManager.java deleted file mode 100644 index 696ff14..0000000 --- a/android_webview/java/src/org/chromium/android_webview/CookieManager.java +++ /dev/null @@ -1,130 +0,0 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -package org.chromium.android_webview; - -import android.net.ParseException; -import android.util.Log; - -import org.chromium.base.JNINamespace; -import org.chromium.base.ThreadUtils; - -import java.util.concurrent.Callable; - -/** - * CookieManager manages cookies according to RFC2109 spec. - * - * Methods in this class are thread safe. - */ -@JNINamespace("android_webview") -public class CookieManager { - private static final String LOGTAG = "CookieManager"; - - /** - * Control whether cookie is enabled or disabled - * @param accept TRUE if accept cookie - */ - public void setAcceptCookie(boolean accept) { - nativeSetAcceptCookie(accept); - } - - /** - * Return whether cookie is enabled - * @return TRUE if accept cookie - */ - public boolean acceptCookie() { - return nativeAcceptCookie(); - } - - /** - * Set cookie for a given url. The old cookie with same host/path/name will - * be removed. The new cookie will be added if it is not expired or it does - * not have expiration which implies it is session cookie. - * @param url The url which cookie is set for - * @param value The value for set-cookie: in http response header - */ - public void setCookie(final String url, final String value) { - nativeSetCookie(url, value); - } - - /** - * Get cookie(s) for a given url so that it can be set to "cookie:" in http - * request header. - * @param url The url needs cookie - * @return The cookies in the format of NAME=VALUE [; NAME=VALUE] - */ - public String getCookie(final String url) { - String cookie = nativeGetCookie(url.toString()); - // Return null if the string is empty to match legacy behavior - return cookie == null || cookie.trim().isEmpty() ? null : cookie; - } - - /** - * Remove all session cookies, which are cookies without expiration date - */ - public void removeSessionCookie() { - nativeRemoveSessionCookie(); - } - - /** - * Remove all cookies - */ - public void removeAllCookie() { - nativeRemoveAllCookie(); - } - - /** - * Return true if there are stored cookies. - */ - public boolean hasCookies() { - return nativeHasCookies(); - } - - /** - * Remove all expired cookies - */ - public void removeExpiredCookie() { - nativeRemoveExpiredCookie(); - } - - public void flushCookieStore() { - nativeFlushCookieStore(); - } - - /** - * Whether cookies are accepted for file scheme URLs. - */ - public boolean allowFileSchemeCookies() { - return nativeAllowFileSchemeCookies(); - } - - /** - * Sets whether cookies are accepted for file scheme URLs. - * - * Use of cookies with file scheme URLs is potentially insecure. Do not use this feature unless - * you can be sure that no unintentional sharing of cookie data can take place. - * <p> - * Note that calls to this method will have no effect if made after a WebView or CookieManager - * instance has been created. - */ - public void setAcceptFileSchemeCookies(boolean accept) { - nativeSetAcceptFileSchemeCookies(accept); - } - - private native void nativeSetAcceptCookie(boolean accept); - private native boolean nativeAcceptCookie(); - - private native void nativeSetCookie(String url, String value); - private native String nativeGetCookie(String url); - - private native void nativeRemoveSessionCookie(); - private native void nativeRemoveAllCookie(); - private native void nativeRemoveExpiredCookie(); - private native void nativeFlushCookieStore(); - - private native boolean nativeHasCookies(); - - private native boolean nativeAllowFileSchemeCookies(); - private native void nativeSetAcceptFileSchemeCookies(boolean accept); -} diff --git a/android_webview/javatests/src/org/chromium/android_webview/test/CookieManagerTest.java b/android_webview/javatests/src/org/chromium/android_webview/test/CookieManagerTest.java index 65435dd..0448855 100644 --- a/android_webview/javatests/src/org/chromium/android_webview/test/CookieManagerTest.java +++ b/android_webview/javatests/src/org/chromium/android_webview/test/CookieManagerTest.java @@ -10,7 +10,7 @@ import android.test.suitebuilder.annotation.SmallTest; import android.util.Pair; import org.chromium.android_webview.AwContents; -import org.chromium.android_webview.CookieManager; +import org.chromium.android_webview.AwCookieManager; import org.chromium.android_webview.test.util.JSUtils; import org.chromium.base.test.util.Feature; import org.chromium.content.browser.test.util.Criteria; @@ -31,7 +31,7 @@ import java.util.concurrent.atomic.AtomicInteger; */ public class CookieManagerTest extends AndroidWebViewTestBase { - private CookieManager mCookieManager; + private AwCookieManager mCookieManager; private TestAwContentsClient mContentsClient; private AwContents mAwContents; @@ -39,7 +39,7 @@ public class CookieManagerTest extends AndroidWebViewTestBase { protected void setUp() throws Exception { super.setUp(); - mCookieManager = new CookieManager(); + mCookieManager = new AwCookieManager(); mContentsClient = new TestAwContentsClient(); final AwTestContainerView testContainerView = createAwTestContainerViewOnMainSync(mContentsClient); diff --git a/android_webview/native/cookie_manager.cc b/android_webview/native/cookie_manager.cc index 868dcbe..33142ec 100644 --- a/android_webview/native/cookie_manager.cc +++ b/android_webview/native/cookie_manager.cc @@ -18,11 +18,11 @@ #include "content/public/browser/browser_context.h" #include "content/public/browser/browser_thread.h" #include "content/public/common/url_constants.h" +#include "jni/AwCookieManager_jni.h" #include "net/cookies/cookie_monster.h" #include "net/cookies/cookie_options.h" #include "net/cookies/cookie_store.h" #include "net/url_request/url_request_context.h" -#include "jni/CookieManager_jni.h" using base::android::ConvertJavaStringToUTF8; using base::android::ConvertJavaStringToUTF16; diff --git a/android_webview/native/webview_native.gyp b/android_webview/native/webview_native.gyp index 88f7fd9..3ecb1a6 100644 --- a/android_webview/native/webview_native.gyp +++ b/android_webview/native/webview_native.gyp @@ -76,7 +76,6 @@ '../java/src/org/chromium/android_webview/AwHttpAuthHandler.java', '../java/src/org/chromium/android_webview/AwResource.java', '../java/src/org/chromium/android_webview/AwWebContentsDelegate.java', - '../java/src/org/chromium/android_webview/CookieManager.java', '../java/src/org/chromium/android_webview/InterceptedRequestData.java', '../java/src/org/chromium/android_webview/JsResultHandler.java', ], |