Bug 957131 - Synced bookmarks appear in guest mode but not in default profile. r=rnewman
This commit is contained in:
@@ -2514,7 +2514,7 @@ abstract public class BrowserApp extends GeckoApp
|
||||
@Override
|
||||
protected String getDefaultProfileName() {
|
||||
String profile = GeckoProfile.findDefaultProfile(this);
|
||||
return (profile != null ? profile : "default");
|
||||
return (profile != null ? profile : GeckoProfile.DEFAULT_PROFILE);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1180,7 +1180,7 @@ public abstract class GeckoApp
|
||||
if (profileName == null) {
|
||||
profileName = getDefaultProfileName();
|
||||
if (profileName == null)
|
||||
profileName = "default";
|
||||
profileName = GeckoProfile.DEFAULT_PROFILE;
|
||||
}
|
||||
GeckoProfile.sIsUsingCustomProfile = true;
|
||||
}
|
||||
|
||||
@@ -26,6 +26,7 @@ public final class GeckoProfile {
|
||||
private static final String LOGTAG = "GeckoProfile";
|
||||
// Used to "lock" the guest profile, so that we'll always restart in it
|
||||
private static final String LOCK_FILE_NAME = ".active_lock";
|
||||
public static final String DEFAULT_PROFILE = "default";
|
||||
|
||||
private static HashMap<String, GeckoProfile> sProfileCache = new HashMap<String, GeckoProfile>();
|
||||
private static String sDefaultProfileName = null;
|
||||
@@ -113,7 +114,7 @@ public final class GeckoProfile {
|
||||
if (TextUtils.isEmpty(profileName) && profileDir == null) {
|
||||
profileName = GeckoProfile.findDefaultProfile(context);
|
||||
if (profileName == null)
|
||||
profileName = "default";
|
||||
profileName = DEFAULT_PROFILE;
|
||||
}
|
||||
|
||||
// actually try to look up the profile
|
||||
|
||||
@@ -67,7 +67,7 @@ public class UpgradeReceiver extends BroadcastReceiver {
|
||||
final String product = GlobalConstants.BROWSER_INTENT_PACKAGE;
|
||||
final String username = params.username;
|
||||
final String serverURL = params.serverURL;
|
||||
final String profile = "default";
|
||||
final String profile = Constants.DEFAULT_PROFILE;
|
||||
try {
|
||||
ConfigurationMigrator.ensurePrefsAreVersion(SyncConfiguration.CURRENT_PREFS_VERSION, context, accountManager, account,
|
||||
product, username, serverURL, profile);
|
||||
|
||||
@@ -9,32 +9,35 @@ import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.mozilla.gecko.db.BrowserContract;
|
||||
import org.mozilla.gecko.sync.setup.Constants;
|
||||
|
||||
import android.net.Uri;
|
||||
|
||||
public class BrowserContractHelpers extends BrowserContract {
|
||||
|
||||
protected static Uri withSyncAndDeleted(Uri u) {
|
||||
protected static Uri withSyncAndDeletedAndProfile(Uri u) {
|
||||
return u.buildUpon()
|
||||
.appendQueryParameter(PARAM_PROFILE, Constants.DEFAULT_PROFILE)
|
||||
.appendQueryParameter(PARAM_IS_SYNC, "true")
|
||||
.appendQueryParameter(PARAM_SHOW_DELETED, "true")
|
||||
.build();
|
||||
}
|
||||
protected static Uri withSync(Uri u) {
|
||||
protected static Uri withSyncAndProfile(Uri u) {
|
||||
return u.buildUpon()
|
||||
.appendQueryParameter(PARAM_PROFILE, Constants.DEFAULT_PROFILE)
|
||||
.appendQueryParameter(PARAM_IS_SYNC, "true")
|
||||
.build();
|
||||
}
|
||||
|
||||
public static final Uri BOOKMARKS_CONTENT_URI = withSyncAndDeleted(Bookmarks.CONTENT_URI);
|
||||
public static final Uri BOOKMARKS_PARENTS_CONTENT_URI = withSyncAndDeleted(Bookmarks.PARENTS_CONTENT_URI);
|
||||
public static final Uri BOOKMARKS_POSITIONS_CONTENT_URI = withSyncAndDeleted(Bookmarks.POSITIONS_CONTENT_URI);
|
||||
public static final Uri HISTORY_CONTENT_URI = withSyncAndDeleted(History.CONTENT_URI);
|
||||
public static final Uri SCHEMA_CONTENT_URI = withSyncAndDeleted(Schema.CONTENT_URI);
|
||||
public static final Uri PASSWORDS_CONTENT_URI = withSyncAndDeleted(Passwords.CONTENT_URI);
|
||||
public static final Uri DELETED_PASSWORDS_CONTENT_URI = withSyncAndDeleted(DeletedPasswords.CONTENT_URI);
|
||||
public static final Uri FORM_HISTORY_CONTENT_URI = withSync(FormHistory.CONTENT_URI);
|
||||
public static final Uri DELETED_FORM_HISTORY_CONTENT_URI = withSync(DeletedFormHistory.CONTENT_URI);
|
||||
public static final Uri BOOKMARKS_CONTENT_URI = withSyncAndDeletedAndProfile(Bookmarks.CONTENT_URI);
|
||||
public static final Uri BOOKMARKS_PARENTS_CONTENT_URI = withSyncAndDeletedAndProfile(Bookmarks.PARENTS_CONTENT_URI);
|
||||
public static final Uri BOOKMARKS_POSITIONS_CONTENT_URI = withSyncAndDeletedAndProfile(Bookmarks.POSITIONS_CONTENT_URI);
|
||||
public static final Uri HISTORY_CONTENT_URI = withSyncAndDeletedAndProfile(History.CONTENT_URI);
|
||||
public static final Uri SCHEMA_CONTENT_URI = withSyncAndDeletedAndProfile(Schema.CONTENT_URI);
|
||||
public static final Uri PASSWORDS_CONTENT_URI = withSyncAndDeletedAndProfile(Passwords.CONTENT_URI);
|
||||
public static final Uri DELETED_PASSWORDS_CONTENT_URI = withSyncAndDeletedAndProfile(DeletedPasswords.CONTENT_URI);
|
||||
public static final Uri FORM_HISTORY_CONTENT_URI = withSyncAndProfile(FormHistory.CONTENT_URI);
|
||||
public static final Uri DELETED_FORM_HISTORY_CONTENT_URI = withSyncAndProfile(DeletedFormHistory.CONTENT_URI);
|
||||
|
||||
public static final String[] PasswordColumns = new String[] {
|
||||
Passwords.ID,
|
||||
|
||||
@@ -12,16 +12,17 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.json.simple.JSONArray;
|
||||
|
||||
import org.mozilla.gecko.sync.CommandProcessor.Command;
|
||||
import org.mozilla.gecko.sync.repositories.NullCursorException;
|
||||
import org.mozilla.gecko.sync.repositories.domain.ClientRecord;
|
||||
import org.mozilla.gecko.sync.setup.Constants;
|
||||
|
||||
import android.content.Context;
|
||||
import android.database.Cursor;
|
||||
|
||||
public class ClientsDatabaseAccessor {
|
||||
|
||||
public static final String PROFILE_ID = "default"; // Generic profile id for now, until multiple profiles are implemented.
|
||||
public static final String LOG_TAG = "ClientsDatabaseAccessor";
|
||||
|
||||
private ClientsDatabase db;
|
||||
@@ -147,7 +148,7 @@ public class ClientsDatabaseAccessor {
|
||||
}
|
||||
|
||||
private String getProfileId() {
|
||||
return ClientsDatabaseAccessor.PROFILE_ID;
|
||||
return Constants.DEFAULT_PROFILE;
|
||||
}
|
||||
|
||||
public void wipeDB() {
|
||||
|
||||
@@ -34,7 +34,7 @@ class DatabaseHelper {
|
||||
} else {
|
||||
mAsserter.ok(false, "The wrong data type has been provided = " + dataType.toString(), "Please provide the correct data type");
|
||||
}
|
||||
uri = uri.buildUpon().appendQueryParameter("profile", "default")
|
||||
uri = uri.buildUpon().appendQueryParameter("profile", GeckoProfile.DEFAULT_PROFILE)
|
||||
.appendQueryParameter("sync", "true").build();
|
||||
return uri;
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ import android.os.SystemClock;
|
||||
import java.util.UUID;
|
||||
import java.util.Random;
|
||||
|
||||
import org.mozilla.gecko.GeckoProfile;
|
||||
import org.mozilla.gecko.db.BrowserDB;
|
||||
|
||||
/*
|
||||
@@ -241,7 +242,7 @@ public class testBrowserProviderPerf extends ContentProviderTest {
|
||||
}
|
||||
|
||||
public void testBrowserProviderPerf() throws Exception {
|
||||
BrowserDB.initialize("default");
|
||||
BrowserDB.initialize(GeckoProfile.DEFAULT_PROFILE);
|
||||
|
||||
loadMobileFolderId();
|
||||
addTonsOfUrls();
|
||||
|
||||
@@ -117,7 +117,7 @@ public class testImportFromAndroid extends AboutHomeTest {
|
||||
// Add a few history items in Firefox Mobile
|
||||
ContentResolver resolver = getActivity().getContentResolver();
|
||||
Uri uri = Uri.parse("content://" + TestConstants.ANDROID_PACKAGE_NAME + ".db.browser/history");
|
||||
uri = uri.buildUpon().appendQueryParameter("profile", "default")
|
||||
uri = uri.buildUpon().appendQueryParameter("profile", GeckoProfile.DEFAULT_PROFILE)
|
||||
.appendQueryParameter("sync", "true").build();
|
||||
for (String url:androidData) {
|
||||
// Add every 3rd website from Android History to Firefox Mobile
|
||||
|
||||
@@ -10,6 +10,7 @@ import org.mozilla.gecko.sync.repositories.android.ClientsDatabase;
|
||||
import org.mozilla.gecko.sync.repositories.android.ClientsDatabaseAccessor;
|
||||
import org.mozilla.gecko.sync.repositories.domain.ClientRecord;
|
||||
import org.mozilla.gecko.sync.repositories.domain.HistoryRecord;
|
||||
import org.mozilla.gecko.sync.setup.Constants;
|
||||
|
||||
import android.database.Cursor;
|
||||
import android.test.AndroidTestCase;
|
||||
@@ -33,7 +34,7 @@ public class TestCachedSQLiteOpenHelper extends AndroidTestCase {
|
||||
// clientsDB gracefully does its thing and closes.
|
||||
clientsDB.wipeClientsTable();
|
||||
ClientRecord record = new ClientRecord();
|
||||
String profileConst = ClientsDatabaseAccessor.PROFILE_ID;
|
||||
String profileConst = Constants.DEFAULT_PROFILE;
|
||||
clientsDB.store(profileConst, record);
|
||||
clientsDB.close();
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@ import org.mozilla.gecko.sync.repositories.android.ClientsDatabase;
|
||||
import org.mozilla.gecko.sync.repositories.android.ClientsDatabaseAccessor;
|
||||
import org.mozilla.gecko.sync.repositories.android.RepoUtils;
|
||||
import org.mozilla.gecko.sync.repositories.domain.ClientRecord;
|
||||
import org.mozilla.gecko.sync.setup.Constants;
|
||||
|
||||
import android.database.Cursor;
|
||||
import android.test.AndroidTestCase;
|
||||
@@ -27,7 +28,7 @@ public class TestClientsDatabase extends AndroidTestCase {
|
||||
|
||||
public void testStoreAndFetch() {
|
||||
ClientRecord record = new ClientRecord();
|
||||
String profileConst = ClientsDatabaseAccessor.PROFILE_ID;
|
||||
String profileConst = Constants.DEFAULT_PROFILE;
|
||||
db.store(profileConst, record);
|
||||
|
||||
Cursor cur = null;
|
||||
@@ -124,7 +125,7 @@ public class TestClientsDatabase extends AndroidTestCase {
|
||||
public void testDelete() {
|
||||
ClientRecord record1 = new ClientRecord();
|
||||
ClientRecord record2 = new ClientRecord();
|
||||
String profileConst = ClientsDatabaseAccessor.PROFILE_ID;
|
||||
String profileConst = Constants.DEFAULT_PROFILE;
|
||||
|
||||
db.store(profileConst, record1);
|
||||
db.store(profileConst, record2);
|
||||
@@ -163,7 +164,7 @@ public class TestClientsDatabase extends AndroidTestCase {
|
||||
public void testWipe() {
|
||||
ClientRecord record1 = new ClientRecord();
|
||||
ClientRecord record2 = new ClientRecord();
|
||||
String profileConst = ClientsDatabaseAccessor.PROFILE_ID;
|
||||
String profileConst = Constants.DEFAULT_PROFILE;
|
||||
|
||||
db.store(profileConst, record1);
|
||||
db.store(profileConst, record2);
|
||||
|
||||
Reference in New Issue
Block a user