diff options
Diffstat (limited to 'core/java')
-rw-r--r-- | core/java/android/webkit/CacheManager.java | 9 | ||||
-rw-r--r-- | core/java/android/webkit/CookieManager.java | 30 | ||||
-rw-r--r-- | core/java/android/webkit/JniUtil.java | 18 | ||||
-rw-r--r-- | core/java/android/webkit/WebTextView.java | 51 |
4 files changed, 79 insertions, 29 deletions
diff --git a/core/java/android/webkit/CacheManager.java b/core/java/android/webkit/CacheManager.java index 821bcc6..f4ee238 100644 --- a/core/java/android/webkit/CacheManager.java +++ b/core/java/android/webkit/CacheManager.java @@ -181,6 +181,11 @@ public final class CacheManager { removeAllCacheFiles(); mClearCacheOnInit = false; } + // If we're using the Chrome HTTP stack, disable the cache. + // Chrome has its own cache, and we don't provide programmatic access to it. + if (JniUtil.useChromiumHttpStack()) { + setCacheDisabled(true); + } } /** @@ -233,6 +238,10 @@ public final class CacheManager { if (mDisabled) { removeAllCacheFiles(); } + if (!mDisabled && JniUtil.useChromiumHttpStack()) { + Log.w(LOGTAG, "CacheManager enabled, but it will not work as " + + "expected because the Chrome HTTP stack is in use."); + } } /** diff --git a/core/java/android/webkit/CookieManager.java b/core/java/android/webkit/CookieManager.java index 3ba7f81..ff9fe1c 100644 --- a/core/java/android/webkit/CookieManager.java +++ b/core/java/android/webkit/CookieManager.java @@ -99,10 +99,6 @@ public final class CookieManager { private boolean mAcceptCookie = true; - // TODO: Remove this if/when we permanently switch to the Chromium HTTP stack - // http:/b/3118772 - private static Boolean sUseChromiumHttpStack; - private int pendingCookieOperations = 0; /** @@ -264,19 +260,12 @@ public final class CookieManager { return sRef; } - private static boolean useChromiumHttpStack() { - if (sUseChromiumHttpStack == null) { - sUseChromiumHttpStack = nativeUseChromiumHttpStack(); - } - return sUseChromiumHttpStack; - } - /** * Control whether cookie is enabled or disabled * @param accept TRUE if accept cookie */ public synchronized void setAcceptCookie(boolean accept) { - if (useChromiumHttpStack()) { + if (JniUtil.useChromiumHttpStack()) { nativeSetAcceptCookie(accept); return; } @@ -289,7 +278,7 @@ public final class CookieManager { * @return TRUE if accept cookie */ public synchronized boolean acceptCookie() { - if (useChromiumHttpStack()) { + if (JniUtil.useChromiumHttpStack()) { return nativeAcceptCookie(); } @@ -304,7 +293,7 @@ public final class CookieManager { * @param value The value for set-cookie: in http response header */ public void setCookie(String url, String value) { - if (useChromiumHttpStack()) { + if (JniUtil.useChromiumHttpStack()) { nativeSetCookie(url, value); return; } @@ -435,7 +424,7 @@ public final class CookieManager { * @return The cookies in the format of NAME=VALUE [; NAME=VALUE] */ public String getCookie(String url) { - if (useChromiumHttpStack()) { + if (JniUtil.useChromiumHttpStack()) { return nativeGetCookie(url); } @@ -549,7 +538,7 @@ public final class CookieManager { */ public void removeSessionCookie() { signalCookieOperationsStart(); - if (useChromiumHttpStack()) { + if (JniUtil.useChromiumHttpStack()) { new AsyncTask<Void, Void, Void>() { protected Void doInBackground(Void... none) { nativeRemoveSessionCookie(); @@ -587,7 +576,7 @@ public final class CookieManager { * Remove all cookies */ public void removeAllCookie() { - if (useChromiumHttpStack()) { + if (JniUtil.useChromiumHttpStack()) { nativeRemoveAllCookie(); return; } @@ -608,7 +597,7 @@ public final class CookieManager { * Return true if there are stored cookies. */ public synchronized boolean hasCookies() { - if (useChromiumHttpStack()) { + if (JniUtil.useChromiumHttpStack()) { return nativeHasCookies(); } @@ -619,7 +608,7 @@ public final class CookieManager { * Remove all expired cookies */ public void removeExpiredCookie() { - if (useChromiumHttpStack()) { + if (JniUtil.useChromiumHttpStack()) { nativeRemoveExpiredCookie(); return; } @@ -655,7 +644,7 @@ public final class CookieManager { * Flush all cookies managed by the Chrome HTTP stack to flash. */ void flushCookieStore() { - if (useChromiumHttpStack()) { + if (JniUtil.useChromiumHttpStack()) { nativeFlushCookieStore(); } } @@ -1109,7 +1098,6 @@ public final class CookieManager { } // Native functions - private static native boolean nativeUseChromiumHttpStack(); private static native boolean nativeAcceptCookie(); private static native String nativeGetCookie(String url); private static native boolean nativeHasCookies(); diff --git a/core/java/android/webkit/JniUtil.java b/core/java/android/webkit/JniUtil.java index ef44d3a..8de30c5 100644 --- a/core/java/android/webkit/JniUtil.java +++ b/core/java/android/webkit/JniUtil.java @@ -19,9 +19,12 @@ package android.webkit; import android.content.Context; class JniUtil { + private JniUtil() {} // Utility class, do not instantiate. + // Used by the Chromium HTTP stack. private static String sDatabaseDirectory; private static String sCacheDirectory; + private static Boolean sUseChromiumHttpStack; private static boolean initialized = false; @@ -58,4 +61,19 @@ class JniUtil { checkIntialized(); return sCacheDirectory; } + + /** + * Returns true if we're using the Chromium HTTP stack. + * + * TODO: Remove this if/when we permanently switch to the Chromium HTTP stack + * http:/b/3118772 + */ + static boolean useChromiumHttpStack() { + if (sUseChromiumHttpStack == null) { + sUseChromiumHttpStack = nativeUseChromiumHttpStack(); + } + return sUseChromiumHttpStack; + } + + private static native boolean nativeUseChromiumHttpStack(); } diff --git a/core/java/android/webkit/WebTextView.java b/core/java/android/webkit/WebTextView.java index e1a5c2d..18a0bda 100644 --- a/core/java/android/webkit/WebTextView.java +++ b/core/java/android/webkit/WebTextView.java @@ -921,24 +921,59 @@ import junit.framework.Assert; * Private class used for the background of a password textfield. */ private static class OutlineDrawable extends Drawable { + private Paint mBackgroundPaint; + private Paint mOutlinePaint; + private float[] mLines; + public OutlineDrawable() { + mBackgroundPaint = new Paint(Paint.ANTI_ALIAS_FLAG); + mBackgroundPaint.setColor(Color.WHITE); + + mOutlinePaint = new Paint(Paint.ANTI_ALIAS_FLAG); + mOutlinePaint.setColor(Color.BLACK); + mOutlinePaint.setStyle(Paint.Style.STROKE); + + mLines = new float[16]; + } + @Override + public void setBounds(int left, int top, int right, int bottom) { + super.setBounds(left, top, right, bottom); + // Top line + mLines[0] = left; + mLines[1] = top + 1; + mLines[2] = right; + mLines[3] = top + 1; + // Right line + mLines[4] = right; + mLines[5] = top; + mLines[6] = right; + mLines[7] = bottom; + // Bottom line + mLines[8] = left; + mLines[9] = bottom; + mLines[10] = right; + mLines[11] = bottom; + // Left line + mLines[12] = left + 1; + mLines[13] = top; + mLines[14] = left + 1; + mLines[15] = bottom; + } + @Override public void draw(Canvas canvas) { - Rect bounds = getBounds(); - Paint paint = new Paint(); - paint.setAntiAlias(true); // Draw the background. - paint.setColor(Color.WHITE); - canvas.drawRect(bounds, paint); + canvas.drawRect(getBounds(), mBackgroundPaint); // Draw the outline. - paint.setStyle(Paint.Style.STROKE); - paint.setColor(Color.BLACK); - canvas.drawRect(bounds, paint); + canvas.drawLines(mLines, mOutlinePaint); } // Always want it to be opaque. + @Override public int getOpacity() { return PixelFormat.OPAQUE; } // These are needed because they are abstract in Drawable. + @Override public void setAlpha(int alpha) { } + @Override public void setColorFilter(ColorFilter cf) { } } |