Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 7f49b9e4 authored by Leon Clarke's avatar Leon Clarke Committed by Android (Google) Code Review
Browse files

Merge "Fix for when flash loads cached crossdomain.xml files. Cache the...

Merge "Fix for when flash loads cached crossdomain.xml files. Cache the x-permitted-cross-domain-policies header. http://b/issue?id=2519669"
parents 99e91114 60708a75
Loading
Loading
Loading
Loading
+19 −2
Original line number Diff line number Diff line
@@ -72,6 +72,7 @@ public final class Headers {
    public final static String SET_COOKIE = "set-cookie";
    public final static String PRAGMA = "pragma";
    public final static String REFRESH = "refresh";
    public final static String X_PERMITTED_CROSS_DOMAIN_POLICIES = "x-permitted-cross-domain-policies";

    // following hash are generated by String.hashCode()
    private final static int HASH_TRANSFER_ENCODING = 1274458357;
@@ -92,6 +93,7 @@ public final class Headers {
    private final static int HASH_SET_COOKIE = 1237214767;
    private final static int HASH_PRAGMA = -980228804;
    private final static int HASH_REFRESH = 1085444827;
    private final static int HASH_X_PERMITTED_CROSS_DOMAIN_POLICIES = -1345594014;

    // keep any headers that require direct access in a presized
    // string array
@@ -113,8 +115,9 @@ public final class Headers {
    private final static int IDX_SET_COOKIE = 15;
    private final static int IDX_PRAGMA = 16;
    private final static int IDX_REFRESH = 17;
    private final static int IDX_X_PERMITTED_CROSS_DOMAIN_POLICIES = 18;

    private final static int HEADER_COUNT = 18;
    private final static int HEADER_COUNT = 19;

    /* parsed values */
    private long transferEncoding;
@@ -141,7 +144,8 @@ public final class Headers {
        ETAG,
        SET_COOKIE,
        PRAGMA,
        REFRESH
        REFRESH,
        X_PERMITTED_CROSS_DOMAIN_POLICIES
    };

    // Catch-all for headers not explicitly handled
@@ -287,6 +291,11 @@ public final class Headers {
                mHeaders[IDX_REFRESH] = val;
            }
            break;
        case HASH_X_PERMITTED_CROSS_DOMAIN_POLICIES:
            if (name.equals(X_PERMITTED_CROSS_DOMAIN_POLICIES)) {
                mHeaders[IDX_X_PERMITTED_CROSS_DOMAIN_POLICIES] = val;
            }
            break;
        default:
            mExtraHeaderNames.add(name);
            mExtraHeaderValues.add(val);
@@ -361,6 +370,10 @@ public final class Headers {
        return mHeaders[IDX_REFRESH];
    }

    public String getXPermittedCrossDomainPolicies() {
        return mHeaders[IDX_X_PERMITTED_CROSS_DOMAIN_POLICIES];
    }

    public void setContentLength(long value) {
        this.contentLength = value;
    }
@@ -409,6 +422,10 @@ public final class Headers {
        mHeaders[IDX_ETAG] = value;
    }

    public void setXPermittedCrossDomainPolicies(String value) {
        mHeaders[IDX_X_PERMITTED_CROSS_DOMAIN_POLICIES] = value;
    }

    public interface HeaderCallback {
        public void header(String name, String value);
    }
+4 −0
Original line number Diff line number Diff line
@@ -67,5 +67,9 @@ class CacheLoader extends StreamLoader {
        if (!TextUtils.isEmpty(mCacheResult.contentdisposition)) {
            headers.setContentDisposition(mCacheResult.contentdisposition);
        }

        if (!TextUtils.isEmpty(mCacheResult.crossDomain)) {
            headers.setXPermittedCrossDomainPolicies(mCacheResult.crossDomain);
        }
    }
}
+6 −0
Original line number Diff line number Diff line
@@ -99,6 +99,7 @@ public final class CacheManager {
        String location;
        String encoding;
        String contentdisposition;
        String crossDomain;

        // these fields are NOT saved to the database
        InputStream inStream;
@@ -733,6 +734,11 @@ public final class CacheManager {
            ret.contentdisposition = contentDisposition;
        }

        String crossDomain = headers.getXPermittedCrossDomainPolicies();
        if (crossDomain != null) {
            ret.crossDomain = crossDomain;
        }

        // lastModified and etag may be set back to http header. So they can't
        // be empty string.
        String lastModified = headers.getLastModified();
+11 −2
Original line number Diff line number Diff line
@@ -51,9 +51,10 @@ public class WebViewDatabase {
    // 7 -> 8 Move cache to its own db
    // 8 -> 9 Store both scheme and host when storing passwords
    // 9 -> 10 Update httpauth table UNIQUE
    private static final int CACHE_DATABASE_VERSION = 3;
    private static final int CACHE_DATABASE_VERSION = 4;
    // 1 -> 2 Add expires String
    // 2 -> 3 Add content-disposition
    // 3 -> 4 Add crossdomain (For x-permitted-cross-domain-policies header)

    private static WebViewDatabase mInstance = null;

@@ -126,6 +127,8 @@ public class WebViewDatabase {

    private static final String CACHE_CONTENTDISPOSITION_COL = "contentdisposition";

    private static final String CACHE_CROSSDOMAIN_COL = "crossdomain";

    // column id strings for "password" table
    private static final String PASSWORD_HOST_COL = "host";

@@ -166,6 +169,7 @@ public class WebViewDatabase {
    private static int mCacheLocationColIndex;
    private static int mCacheContentLengthColIndex;
    private static int mCacheContentDispositionColIndex;
    private static int mCacheCrossDomainColIndex;

    private static int mCacheTransactionRefcount;

@@ -269,6 +273,8 @@ public class WebViewDatabase {
                        .getColumnIndex(CACHE_CONTENTLENGTH_COL);
                mCacheContentDispositionColIndex = mCacheInserter
                        .getColumnIndex(CACHE_CONTENTDISPOSITION_COL);
                mCacheCrossDomainColIndex = mCacheInserter
                        .getColumnIndex(CACHE_CROSSDOMAIN_COL);
            }
        }

@@ -378,6 +384,7 @@ public class WebViewDatabase {
                    + " TEXT," + CACHE_HTTP_STATUS_COL + " INTEGER, "
                    + CACHE_LOCATION_COL + " TEXT, " + CACHE_CONTENTLENGTH_COL
                    + " INTEGER, " + CACHE_CONTENTDISPOSITION_COL + " TEXT, "
                    + CACHE_CROSSDOMAIN_COL + " TEXT,"
                    + " UNIQUE (" + CACHE_URL_COL + ") ON CONFLICT REPLACE);");
            mCacheDatabase.execSQL("CREATE INDEX cacheUrlIndex ON cache ("
                    + CACHE_URL_COL + ")");
@@ -620,7 +627,7 @@ public class WebViewDatabase {
        Cursor cursor = null;
        final String query = "SELECT filepath, lastmodify, etag, expires, "
                + "expiresstring, mimetype, encoding, httpstatus, location, contentlength, "
                + "contentdisposition FROM cache WHERE url = ?";
                + "contentdisposition, crossdomain FROM cache WHERE url = ?";
        try {
            cursor = mCacheDatabase.rawQuery(query, new String[] { url });
            if (cursor.moveToFirst()) {
@@ -636,6 +643,7 @@ public class WebViewDatabase {
                ret.location = cursor.getString(8);
                ret.contentLength = cursor.getLong(9);
                ret.contentdisposition = cursor.getString(10);
                ret.crossDomain = cursor.getString(11);
                return ret;
            }
        } catch (IllegalStateException e) {
@@ -684,6 +692,7 @@ public class WebViewDatabase {
        mCacheInserter.bind(mCacheContentLengthColIndex, c.contentLength);
        mCacheInserter.bind(mCacheContentDispositionColIndex,
                c.contentdisposition);
        mCacheInserter.bind(mCacheCrossDomainColIndex, c.crossDomain);
        mCacheInserter.execute();
    }