summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLeon Clarke <leonclarke@google.com>2010-03-23 18:35:04 +0000
committerLeon Clarke <leonclarke@google.com>2010-03-23 18:36:58 +0000
commit60708a75120c4469dc2683485301ff9ee3b022e0 (patch)
treebd8583d0cabcea879cad0b769801e62c706671b6
parentb83b556eadd73b0cbcd50664b1cc4fca51815cc2 (diff)
downloadframeworks_base-60708a75120c4469dc2683485301ff9ee3b022e0.zip
frameworks_base-60708a75120c4469dc2683485301ff9ee3b022e0.tar.gz
frameworks_base-60708a75120c4469dc2683485301ff9ee3b022e0.tar.bz2
Fix for when flash loads cached crossdomain.xml files.
Cache the x-permitted-cross-domain-policies header. http://b/issue?id=2519669
-rw-r--r--core/java/android/net/http/Headers.java21
-rw-r--r--core/java/android/webkit/CacheLoader.java4
-rw-r--r--core/java/android/webkit/CacheManager.java6
-rw-r--r--core/java/android/webkit/WebViewDatabase.java13
4 files changed, 40 insertions, 4 deletions
diff --git a/core/java/android/net/http/Headers.java b/core/java/android/net/http/Headers.java
index b0923d1..09f6f4f 100644
--- a/core/java/android/net/http/Headers.java
+++ b/core/java/android/net/http/Headers.java
@@ -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);
}
diff --git a/core/java/android/webkit/CacheLoader.java b/core/java/android/webkit/CacheLoader.java
index aeb537c..05c02b0 100644
--- a/core/java/android/webkit/CacheLoader.java
+++ b/core/java/android/webkit/CacheLoader.java
@@ -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);
+ }
}
}
diff --git a/core/java/android/webkit/CacheManager.java b/core/java/android/webkit/CacheManager.java
index 4f680e5..d19805e 100644
--- a/core/java/android/webkit/CacheManager.java
+++ b/core/java/android/webkit/CacheManager.java
@@ -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();
diff --git a/core/java/android/webkit/WebViewDatabase.java b/core/java/android/webkit/WebViewDatabase.java
index a75e6f0..b18419d 100644
--- a/core/java/android/webkit/WebViewDatabase.java
+++ b/core/java/android/webkit/WebViewDatabase.java
@@ -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();
}