diff options
author | Geremy Condra <gcondra@google.com> | 2013-04-01 14:02:22 -0700 |
---|---|---|
committer | Geremy Condra <gcondra@google.com> | 2013-04-04 10:40:04 -0700 |
commit | 3f5303ddcb298c49ae45ac90c74d56c448a2a302 (patch) | |
tree | e16b5028e8ff6742cf760359884813bd9711bc81 | |
parent | ce8dbedfc3319b9a49b60e8c5d82229e1d743347 (diff) | |
download | base-3f5303ddcb298c49ae45ac90c74d56c448a2a302.tar.gz |
DO NOT MERGE Add a delimiter between scheme and host
Bug: 6923539
Change-Id: Ibd6dce66cd63e14cc72a26710ae339ce089bee11
-rw-r--r-- | core/java/android/webkit/BrowserFrame.java | 14 | ||||
-rw-r--r-- | core/java/android/webkit/WebView.java | 16 | ||||
-rw-r--r-- | core/java/android/webkit/WebViewDatabase.java | 15 |
3 files changed, 35 insertions, 10 deletions
diff --git a/core/java/android/webkit/BrowserFrame.java b/core/java/android/webkit/BrowserFrame.java index 43e87960969a..0827d95de612 100644 --- a/core/java/android/webkit/BrowserFrame.java +++ b/core/java/android/webkit/BrowserFrame.java @@ -68,6 +68,7 @@ class BrowserFrame extends Handler { * request's LoadListener */ private final static int MAX_OUTSTANDING_REQUESTS = 300; + private final static String SCHEME_HOST_DELIMITER = "://"; private final CallbackProxy mCallbackProxy; private final WebSettings mSettings; @@ -514,9 +515,14 @@ class BrowserFrame extends Handler { .getCurrentItem(); if (item != null) { WebAddress uri = new WebAddress(item.getUrl()); - String schemePlusHost = uri.getScheme() + uri.getHost(); - String[] up = - mDatabase.getUsernamePassword(schemePlusHost); + String schemePlusHost = uri.getScheme() + SCHEME_HOST_DELIMITER + + uri.getHost(); + String[] up = mDatabase.getUsernamePassword( + schemePlusHost); + if (up == null) { // no row found, try again using the legacy method + schemePlusHost = uri.getScheme() + uri.getHost(); + up = mDatabase.getUsernamePassword(schemePlusHost); + } if (up != null && up[0] != null) { setUsernamePassword(up[0], up[1]); } @@ -927,7 +933,7 @@ class BrowserFrame extends Handler { } WebAddress uri = new WebAddress(mCallbackProxy .getBackForwardList().getCurrentItem().getUrl()); - String schemePlusHost = uri.getScheme() + uri.getHost(); + String schemePlusHost = uri.getScheme() + SCHEME_HOST_DELIMITER + uri.getHost(); // Check to see if the username & password appear in // the post data (there could be another form on the // page and that was posted instead. diff --git a/core/java/android/webkit/WebView.java b/core/java/android/webkit/WebView.java index bb029e6a9a75..b0c325b2de27 100644 --- a/core/java/android/webkit/WebView.java +++ b/core/java/android/webkit/WebView.java @@ -1604,11 +1604,17 @@ public class WebView extends AbsoluteLayout //------------------------------------------------------------------------- /** - * Save the username and password for a particular host in the WebView's - * internal database. - * @param host The host that required the credentials. - * @param username The username for the given host. - * @param password The password for the given host. + * Sets a username and password pair for the specified host. This data is + * used by the Webview to autocomplete username and password fields in web + * forms. Note that this is unrelated to the credentials used for HTTP + * authentication. + * + * @param host the host that required the credentials. It is recommended that + * the host is given using scheme://hostname format. + * @param username the username for the given host + * @param password the password for the given host + * @see WebViewDatabase#clearUsernamePassword + * @see WebViewDatabase#hasUsernamePassword */ public void savePassword(String host, String username, String password) { checkThread(); diff --git a/core/java/android/webkit/WebViewDatabase.java b/core/java/android/webkit/WebViewDatabase.java index 695c154acba0..f2748a6767c9 100644 --- a/core/java/android/webkit/WebViewDatabase.java +++ b/core/java/android/webkit/WebViewDatabase.java @@ -42,7 +42,7 @@ public class WebViewDatabase { // log tag protected static final String LOGTAG = "webviewdatabase"; - private static final int DATABASE_VERSION = 11; + private static final int DATABASE_VERSION = 12; // 2 -> 3 Modified Cache table to allow cache of redirects // 3 -> 4 Added Oma-Downloads table // 4 -> 5 Modified Cache table to support persistent contentLength @@ -55,6 +55,7 @@ public class WebViewDatabase { // 10 -> 11 Drop cookies and cache now managed by the chromium stack, // and update the form data table to use the new format // implemented for b/5265606. + // 11 -> 12 Add a delimiter between scheme and host when storing passwords private static final int CACHE_DATABASE_VERSION = 4; // 1 -> 2 Add expires String // 2 -> 3 Add content-disposition @@ -334,11 +335,23 @@ public class WebViewDatabase { private static void upgradeDatabase() { upgradeDatabaseToV10(); upgradeDatabaseFromV10ToV11(); + upgradeDatabaseFromV11ToV12(); // Add future database upgrade functions here, one version at a // time. mDatabase.setVersion(DATABASE_VERSION); } + private static void upgradeDatabaseFromV11ToV12() { + int oldVersion = sDatabase.getVersion(); + + if (oldVersion >= 12) { + // Nothing to do. + return; + } + // delete the rows in the database. + sDatabase.delete(mTableNames[TABLE_PASSWORD_ID], null, null); + } + private static void upgradeDatabaseFromV10ToV11() { int oldVersion = mDatabase.getVersion(); |