Bug 957131 - Synced bookmarks appear in guest mode but not in default profile. r=rnewman

This commit is contained in:
Wesley Johnston
2014-01-14 21:45:59 -08:00
parent 89317fab8a
commit a8fe6d77a8
11 changed files with 32 additions and 24 deletions

View File

@@ -2514,7 +2514,7 @@ abstract public class BrowserApp extends GeckoApp
@Override @Override
protected String getDefaultProfileName() { protected String getDefaultProfileName() {
String profile = GeckoProfile.findDefaultProfile(this); String profile = GeckoProfile.findDefaultProfile(this);
return (profile != null ? profile : "default"); return (profile != null ? profile : GeckoProfile.DEFAULT_PROFILE);
} }
/** /**

View File

@@ -1180,7 +1180,7 @@ public abstract class GeckoApp
if (profileName == null) { if (profileName == null) {
profileName = getDefaultProfileName(); profileName = getDefaultProfileName();
if (profileName == null) if (profileName == null)
profileName = "default"; profileName = GeckoProfile.DEFAULT_PROFILE;
} }
GeckoProfile.sIsUsingCustomProfile = true; GeckoProfile.sIsUsingCustomProfile = true;
} }

View File

@@ -26,6 +26,7 @@ public final class GeckoProfile {
private static final String LOGTAG = "GeckoProfile"; private static final String LOGTAG = "GeckoProfile";
// Used to "lock" the guest profile, so that we'll always restart in it // Used to "lock" the guest profile, so that we'll always restart in it
private static final String LOCK_FILE_NAME = ".active_lock"; 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 HashMap<String, GeckoProfile> sProfileCache = new HashMap<String, GeckoProfile>();
private static String sDefaultProfileName = null; private static String sDefaultProfileName = null;
@@ -113,7 +114,7 @@ public final class GeckoProfile {
if (TextUtils.isEmpty(profileName) && profileDir == null) { if (TextUtils.isEmpty(profileName) && profileDir == null) {
profileName = GeckoProfile.findDefaultProfile(context); profileName = GeckoProfile.findDefaultProfile(context);
if (profileName == null) if (profileName == null)
profileName = "default"; profileName = DEFAULT_PROFILE;
} }
// actually try to look up the profile // actually try to look up the profile

View File

@@ -67,7 +67,7 @@ public class UpgradeReceiver extends BroadcastReceiver {
final String product = GlobalConstants.BROWSER_INTENT_PACKAGE; final String product = GlobalConstants.BROWSER_INTENT_PACKAGE;
final String username = params.username; final String username = params.username;
final String serverURL = params.serverURL; final String serverURL = params.serverURL;
final String profile = "default"; final String profile = Constants.DEFAULT_PROFILE;
try { try {
ConfigurationMigrator.ensurePrefsAreVersion(SyncConfiguration.CURRENT_PREFS_VERSION, context, accountManager, account, ConfigurationMigrator.ensurePrefsAreVersion(SyncConfiguration.CURRENT_PREFS_VERSION, context, accountManager, account,
product, username, serverURL, profile); product, username, serverURL, profile);

View File

@@ -9,32 +9,35 @@ import java.util.HashMap;
import java.util.Map; import java.util.Map;
import org.mozilla.gecko.db.BrowserContract; import org.mozilla.gecko.db.BrowserContract;
import org.mozilla.gecko.sync.setup.Constants;
import android.net.Uri; import android.net.Uri;
public class BrowserContractHelpers extends BrowserContract { public class BrowserContractHelpers extends BrowserContract {
protected static Uri withSyncAndDeleted(Uri u) { protected static Uri withSyncAndDeletedAndProfile(Uri u) {
return u.buildUpon() return u.buildUpon()
.appendQueryParameter(PARAM_PROFILE, Constants.DEFAULT_PROFILE)
.appendQueryParameter(PARAM_IS_SYNC, "true") .appendQueryParameter(PARAM_IS_SYNC, "true")
.appendQueryParameter(PARAM_SHOW_DELETED, "true") .appendQueryParameter(PARAM_SHOW_DELETED, "true")
.build(); .build();
} }
protected static Uri withSync(Uri u) { protected static Uri withSyncAndProfile(Uri u) {
return u.buildUpon() return u.buildUpon()
.appendQueryParameter(PARAM_PROFILE, Constants.DEFAULT_PROFILE)
.appendQueryParameter(PARAM_IS_SYNC, "true") .appendQueryParameter(PARAM_IS_SYNC, "true")
.build(); .build();
} }
public static final Uri BOOKMARKS_CONTENT_URI = withSyncAndDeleted(Bookmarks.CONTENT_URI); public static final Uri BOOKMARKS_CONTENT_URI = withSyncAndDeletedAndProfile(Bookmarks.CONTENT_URI);
public static final Uri BOOKMARKS_PARENTS_CONTENT_URI = withSyncAndDeleted(Bookmarks.PARENTS_CONTENT_URI); public static final Uri BOOKMARKS_PARENTS_CONTENT_URI = withSyncAndDeletedAndProfile(Bookmarks.PARENTS_CONTENT_URI);
public static final Uri BOOKMARKS_POSITIONS_CONTENT_URI = withSyncAndDeleted(Bookmarks.POSITIONS_CONTENT_URI); public static final Uri BOOKMARKS_POSITIONS_CONTENT_URI = withSyncAndDeletedAndProfile(Bookmarks.POSITIONS_CONTENT_URI);
public static final Uri HISTORY_CONTENT_URI = withSyncAndDeleted(History.CONTENT_URI); public static final Uri HISTORY_CONTENT_URI = withSyncAndDeletedAndProfile(History.CONTENT_URI);
public static final Uri SCHEMA_CONTENT_URI = withSyncAndDeleted(Schema.CONTENT_URI); public static final Uri SCHEMA_CONTENT_URI = withSyncAndDeletedAndProfile(Schema.CONTENT_URI);
public static final Uri PASSWORDS_CONTENT_URI = withSyncAndDeleted(Passwords.CONTENT_URI); public static final Uri PASSWORDS_CONTENT_URI = withSyncAndDeletedAndProfile(Passwords.CONTENT_URI);
public static final Uri DELETED_PASSWORDS_CONTENT_URI = withSyncAndDeleted(DeletedPasswords.CONTENT_URI); public static final Uri DELETED_PASSWORDS_CONTENT_URI = withSyncAndDeletedAndProfile(DeletedPasswords.CONTENT_URI);
public static final Uri FORM_HISTORY_CONTENT_URI = withSync(FormHistory.CONTENT_URI); public static final Uri FORM_HISTORY_CONTENT_URI = withSyncAndProfile(FormHistory.CONTENT_URI);
public static final Uri DELETED_FORM_HISTORY_CONTENT_URI = withSync(DeletedFormHistory.CONTENT_URI); public static final Uri DELETED_FORM_HISTORY_CONTENT_URI = withSyncAndProfile(DeletedFormHistory.CONTENT_URI);
public static final String[] PasswordColumns = new String[] { public static final String[] PasswordColumns = new String[] {
Passwords.ID, Passwords.ID,

View File

@@ -12,16 +12,17 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import org.json.simple.JSONArray; import org.json.simple.JSONArray;
import org.mozilla.gecko.sync.CommandProcessor.Command; import org.mozilla.gecko.sync.CommandProcessor.Command;
import org.mozilla.gecko.sync.repositories.NullCursorException; import org.mozilla.gecko.sync.repositories.NullCursorException;
import org.mozilla.gecko.sync.repositories.domain.ClientRecord; import org.mozilla.gecko.sync.repositories.domain.ClientRecord;
import org.mozilla.gecko.sync.setup.Constants;
import android.content.Context; import android.content.Context;
import android.database.Cursor; import android.database.Cursor;
public class ClientsDatabaseAccessor { 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"; public static final String LOG_TAG = "ClientsDatabaseAccessor";
private ClientsDatabase db; private ClientsDatabase db;
@@ -147,7 +148,7 @@ public class ClientsDatabaseAccessor {
} }
private String getProfileId() { private String getProfileId() {
return ClientsDatabaseAccessor.PROFILE_ID; return Constants.DEFAULT_PROFILE;
} }
public void wipeDB() { public void wipeDB() {

View File

@@ -34,7 +34,7 @@ class DatabaseHelper {
} else { } else {
mAsserter.ok(false, "The wrong data type has been provided = " + dataType.toString(), "Please provide the correct data type"); 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(); .appendQueryParameter("sync", "true").build();
return uri; return uri;
} }

View File

@@ -8,6 +8,7 @@ import android.os.SystemClock;
import java.util.UUID; import java.util.UUID;
import java.util.Random; import java.util.Random;
import org.mozilla.gecko.GeckoProfile;
import org.mozilla.gecko.db.BrowserDB; import org.mozilla.gecko.db.BrowserDB;
/* /*
@@ -241,7 +242,7 @@ public class testBrowserProviderPerf extends ContentProviderTest {
} }
public void testBrowserProviderPerf() throws Exception { public void testBrowserProviderPerf() throws Exception {
BrowserDB.initialize("default"); BrowserDB.initialize(GeckoProfile.DEFAULT_PROFILE);
loadMobileFolderId(); loadMobileFolderId();
addTonsOfUrls(); addTonsOfUrls();

View File

@@ -117,7 +117,7 @@ public class testImportFromAndroid extends AboutHomeTest {
// Add a few history items in Firefox Mobile // Add a few history items in Firefox Mobile
ContentResolver resolver = getActivity().getContentResolver(); ContentResolver resolver = getActivity().getContentResolver();
Uri uri = Uri.parse("content://" + TestConstants.ANDROID_PACKAGE_NAME + ".db.browser/history"); 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(); .appendQueryParameter("sync", "true").build();
for (String url:androidData) { for (String url:androidData) {
// Add every 3rd website from Android History to Firefox Mobile // Add every 3rd website from Android History to Firefox Mobile

View File

@@ -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.android.ClientsDatabaseAccessor;
import org.mozilla.gecko.sync.repositories.domain.ClientRecord; import org.mozilla.gecko.sync.repositories.domain.ClientRecord;
import org.mozilla.gecko.sync.repositories.domain.HistoryRecord; import org.mozilla.gecko.sync.repositories.domain.HistoryRecord;
import org.mozilla.gecko.sync.setup.Constants;
import android.database.Cursor; import android.database.Cursor;
import android.test.AndroidTestCase; import android.test.AndroidTestCase;
@@ -33,7 +34,7 @@ public class TestCachedSQLiteOpenHelper extends AndroidTestCase {
// clientsDB gracefully does its thing and closes. // clientsDB gracefully does its thing and closes.
clientsDB.wipeClientsTable(); clientsDB.wipeClientsTable();
ClientRecord record = new ClientRecord(); ClientRecord record = new ClientRecord();
String profileConst = ClientsDatabaseAccessor.PROFILE_ID; String profileConst = Constants.DEFAULT_PROFILE;
clientsDB.store(profileConst, record); clientsDB.store(profileConst, record);
clientsDB.close(); clientsDB.close();

View File

@@ -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.ClientsDatabaseAccessor;
import org.mozilla.gecko.sync.repositories.android.RepoUtils; import org.mozilla.gecko.sync.repositories.android.RepoUtils;
import org.mozilla.gecko.sync.repositories.domain.ClientRecord; import org.mozilla.gecko.sync.repositories.domain.ClientRecord;
import org.mozilla.gecko.sync.setup.Constants;
import android.database.Cursor; import android.database.Cursor;
import android.test.AndroidTestCase; import android.test.AndroidTestCase;
@@ -27,7 +28,7 @@ public class TestClientsDatabase extends AndroidTestCase {
public void testStoreAndFetch() { public void testStoreAndFetch() {
ClientRecord record = new ClientRecord(); ClientRecord record = new ClientRecord();
String profileConst = ClientsDatabaseAccessor.PROFILE_ID; String profileConst = Constants.DEFAULT_PROFILE;
db.store(profileConst, record); db.store(profileConst, record);
Cursor cur = null; Cursor cur = null;
@@ -124,7 +125,7 @@ public class TestClientsDatabase extends AndroidTestCase {
public void testDelete() { public void testDelete() {
ClientRecord record1 = new ClientRecord(); ClientRecord record1 = new ClientRecord();
ClientRecord record2 = new ClientRecord(); ClientRecord record2 = new ClientRecord();
String profileConst = ClientsDatabaseAccessor.PROFILE_ID; String profileConst = Constants.DEFAULT_PROFILE;
db.store(profileConst, record1); db.store(profileConst, record1);
db.store(profileConst, record2); db.store(profileConst, record2);
@@ -163,7 +164,7 @@ public class TestClientsDatabase extends AndroidTestCase {
public void testWipe() { public void testWipe() {
ClientRecord record1 = new ClientRecord(); ClientRecord record1 = new ClientRecord();
ClientRecord record2 = new ClientRecord(); ClientRecord record2 = new ClientRecord();
String profileConst = ClientsDatabaseAccessor.PROFILE_ID; String profileConst = Constants.DEFAULT_PROFILE;
db.store(profileConst, record1); db.store(profileConst, record1);
db.store(profileConst, record2); db.store(profileConst, record2);