зеркало из https://github.com/mozilla/gecko-dev.git
Bug 725052 - Check if a password is in the deleted database before inserting it. r=rnewman
This commit is contained in:
Родитель
8cb3acf165
Коммит
e5a7a3e889
|
@ -54,6 +54,9 @@ public class FormHistoryProvider extends GeckoProvider {
|
|||
private static int DB_VERSION = 4;
|
||||
private static String DB_FILENAME = "formhistory.sqlite";
|
||||
|
||||
private static final String WHERE_GUID_IS_NULL = BrowserContract.DeletedFormHistory.GUID + " IS NULL";
|
||||
private static final String WHERE_GUID_IS_VALUE = BrowserContract.DeletedFormHistory.GUID + " = ?";
|
||||
|
||||
static {
|
||||
URI_MATCHER = new UriMatcher(UriMatcher.NO_MATCH);
|
||||
URI_MATCHER.addURI(BrowserContract.FORM_HISTORY_AUTHORITY, "formhistory", FORM_HISTORY);
|
||||
|
@ -144,9 +147,27 @@ public class FormHistoryProvider extends GeckoProvider {
|
|||
GeckoAppShell.sendEventToGecko(GeckoEvent.createBroadcastEvent("FormHistory:Init", null));
|
||||
}
|
||||
|
||||
public void onPreInsert(ContentValues values, Uri uri) { }
|
||||
@Override
|
||||
public void onPreInsert(ContentValues values, Uri uri, SQLiteBridge db) {
|
||||
if (!values.containsKey(FormHistory.GUID)) {
|
||||
return;
|
||||
}
|
||||
String guid = values.getAsString(FormHistory.GUID);
|
||||
try {
|
||||
if (guid == null) {
|
||||
db.delete(TABLE_DELETED_FORM_HISTORY, WHERE_GUID_IS_NULL, null);
|
||||
return;
|
||||
}
|
||||
String[] args = new String[] { guid };
|
||||
db.delete(TABLE_DELETED_FORM_HISTORY, WHERE_GUID_IS_VALUE, args);
|
||||
} catch(SQLiteBridgeException ex) {
|
||||
Log.w(getLogTag(), "Error removing entry with GUID " + guid, ex);
|
||||
}
|
||||
}
|
||||
|
||||
public void onPreUpdate(ContentValues values, Uri uri) { }
|
||||
@Override
|
||||
public void onPreUpdate(ContentValues values, Uri uri, SQLiteBridge db) { }
|
||||
|
||||
public void onPostQuery(Cursor cursor, Uri uri) { }
|
||||
@Override
|
||||
public void onPostQuery(Cursor cursor, Uri uri, SQLiteBridge db) { }
|
||||
}
|
||||
|
|
|
@ -222,7 +222,7 @@ public abstract class GeckoProvider extends ContentProvider {
|
|||
|
||||
setupDefaults(uri, values);
|
||||
|
||||
onPreInsert(values, uri);
|
||||
onPreInsert(values, uri, db);
|
||||
|
||||
try {
|
||||
id = db.insert(getTable(uri), null, values);
|
||||
|
@ -245,7 +245,7 @@ public abstract class GeckoProvider extends ContentProvider {
|
|||
if (db == null)
|
||||
return updated;
|
||||
|
||||
onPreUpdate(values, uri);
|
||||
onPreUpdate(values, uri, db);
|
||||
|
||||
try {
|
||||
updated = db.update(getTable(uri), values, selection, selectionArgs);
|
||||
|
@ -272,7 +272,7 @@ public abstract class GeckoProvider extends ContentProvider {
|
|||
|
||||
try {
|
||||
cursor = db.query(getTable(uri), projection, selection, selectionArgs, null, null, sortOrder, null);
|
||||
onPostQuery(cursor, uri);
|
||||
onPostQuery(cursor, uri, db);
|
||||
} catch (SQLiteBridgeException ex) {
|
||||
Log.e(mLogTag, "Error querying database", ex);
|
||||
}
|
||||
|
@ -288,9 +288,9 @@ public abstract class GeckoProvider extends ContentProvider {
|
|||
|
||||
public abstract void initGecko();
|
||||
|
||||
public abstract void onPreInsert(ContentValues values, Uri uri);
|
||||
public abstract void onPreInsert(ContentValues values, Uri uri, SQLiteBridge db);
|
||||
|
||||
public abstract void onPreUpdate(ContentValues values, Uri uri);
|
||||
public abstract void onPreUpdate(ContentValues values, Uri uri, SQLiteBridge db);
|
||||
|
||||
public abstract void onPostQuery(Cursor cursor, Uri uri);
|
||||
public abstract void onPostQuery(Cursor cursor, Uri uri, SQLiteBridge db);
|
||||
}
|
||||
|
|
|
@ -59,6 +59,9 @@ public class PasswordsProvider extends GeckoProvider {
|
|||
private static final int DB_VERSION = 5;
|
||||
private static final String DB_FILENAME = "signons.sqlite";
|
||||
|
||||
private static final String WHERE_GUID_IS_NULL = BrowserContract.DeletedPasswords.GUID + " IS NULL";
|
||||
private static final String WHERE_GUID_IS_VALUE = BrowserContract.DeletedPasswords.GUID + " = ?";
|
||||
|
||||
static {
|
||||
URI_MATCHER = new UriMatcher(UriMatcher.NO_MATCH);
|
||||
|
||||
|
@ -210,19 +213,22 @@ public class PasswordsProvider extends GeckoProvider {
|
|||
return result;
|
||||
}
|
||||
|
||||
public void onPreInsert(ContentValues values, Uri uri) {
|
||||
if (values.containsKey(Passwords.ENCRYPTED_PASSWORD)) {
|
||||
String res = doCrypto(values.getAsString(Passwords.ENCRYPTED_PASSWORD), uri, true);
|
||||
values.put(Passwords.ENCRYPTED_PASSWORD, res);
|
||||
@Override
|
||||
public void onPreInsert(ContentValues values, Uri uri, SQLiteBridge db) {
|
||||
if (values.containsKey(Passwords.GUID)) {
|
||||
String guid = values.getAsString(Passwords.GUID);
|
||||
try {
|
||||
if (guid == null) {
|
||||
db.delete(TABLE_DELETED_PASSWORDS, WHERE_GUID_IS_NULL, null);
|
||||
return;
|
||||
}
|
||||
String[] args = new String[] { guid };
|
||||
db.delete(TABLE_DELETED_PASSWORDS, WHERE_GUID_IS_VALUE, args);
|
||||
} catch(SQLiteBridgeException ex) {
|
||||
Log.w(getLogTag(), "Error removing entry with GUID " + guid, ex);
|
||||
}
|
||||
}
|
||||
|
||||
if (values.containsKey(Passwords.ENCRYPTED_USERNAME)) {
|
||||
String res = doCrypto(values.getAsString(Passwords.ENCRYPTED_USERNAME), uri, true);
|
||||
values.put(Passwords.ENCRYPTED_USERNAME, res);
|
||||
}
|
||||
}
|
||||
|
||||
public void onPreUpdate(ContentValues values, Uri uri) {
|
||||
if (values.containsKey(Passwords.ENCRYPTED_PASSWORD)) {
|
||||
String res = doCrypto(values.getAsString(Passwords.ENCRYPTED_PASSWORD), uri, true);
|
||||
values.put(Passwords.ENCRYPTED_PASSWORD, res);
|
||||
|
@ -234,7 +240,21 @@ public class PasswordsProvider extends GeckoProvider {
|
|||
}
|
||||
}
|
||||
|
||||
public void onPostQuery(Cursor cursor, Uri uri) {
|
||||
@Override
|
||||
public void onPreUpdate(ContentValues values, Uri uri, SQLiteBridge db) {
|
||||
if (values.containsKey(Passwords.ENCRYPTED_PASSWORD)) {
|
||||
String res = doCrypto(values.getAsString(Passwords.ENCRYPTED_PASSWORD), uri, true);
|
||||
values.put(Passwords.ENCRYPTED_PASSWORD, res);
|
||||
}
|
||||
|
||||
if (values.containsKey(Passwords.ENCRYPTED_USERNAME)) {
|
||||
String res = doCrypto(values.getAsString(Passwords.ENCRYPTED_USERNAME), uri, true);
|
||||
values.put(Passwords.ENCRYPTED_USERNAME, res);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPostQuery(Cursor cursor, Uri uri, SQLiteBridge db) {
|
||||
int passwordIndex = -1;
|
||||
int usernameIndex = -1;
|
||||
String profilePath = null;
|
||||
|
|
Загрузка…
Ссылка в новой задаче