summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
Diffstat (limited to 'chrome')
-rw-r--r--chrome/android/java/src/org/chromium/chrome/browser/sync/ProfileSyncService.java54
-rw-r--r--chrome/browser/sync/profile_sync_service_android.cc84
-rw-r--r--chrome/browser/sync/profile_sync_service_android.h21
-rw-r--r--chrome/browser/sync/profile_sync_service_model_type_selection_android.h30
4 files changed, 116 insertions, 73 deletions
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/sync/ProfileSyncService.java b/chrome/android/java/src/org/chromium/chrome/browser/sync/ProfileSyncService.java
index 3b28021..b7d3c2a 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/sync/ProfileSyncService.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/sync/ProfileSyncService.java
@@ -420,22 +420,47 @@ public class ProfileSyncService {
* @return Set of enabled types.
*/
public Set<ModelType> getPreferredDataTypes() {
+ long modelTypeSelection =
+ nativeGetEnabledDataTypes(mNativeProfileSyncServiceAndroid);
Set<ModelType> syncTypes = new HashSet<ModelType>();
-
- if (nativeIsAutofillSyncEnabled(mNativeProfileSyncServiceAndroid)) {
- syncTypes.add(ModelType.AUTOFILL);
+ if ((modelTypeSelection & ModelTypeSelection.AUTOFILL) != 0) {
+ syncTypes.add(ModelType.AUTOFILL);
+ }
+ if ((modelTypeSelection & ModelTypeSelection.AUTOFILL_PROFILE) != 0) {
+ syncTypes.add(ModelType.AUTOFILL_PROFILE);
+ }
+ if ((modelTypeSelection & ModelTypeSelection.BOOKMARK) != 0) {
+ syncTypes.add(ModelType.BOOKMARK);
+ }
+ if ((modelTypeSelection & ModelTypeSelection.EXPERIMENTS) != 0) {
+ syncTypes.add(ModelType.EXPERIMENTS);
+ }
+ if ((modelTypeSelection & ModelTypeSelection.NIGORI) != 0) {
+ syncTypes.add(ModelType.NIGORI);
+ }
+ if ((modelTypeSelection & ModelTypeSelection.PASSWORD) != 0) {
+ syncTypes.add(ModelType.PASSWORD);
+ }
+ if ((modelTypeSelection & ModelTypeSelection.SESSION) != 0) {
+ syncTypes.add(ModelType.SESSION);
+ }
+ if ((modelTypeSelection & ModelTypeSelection.TYPED_URL) != 0) {
+ syncTypes.add(ModelType.TYPED_URL);
+ }
+ if ((modelTypeSelection & ModelTypeSelection.HISTORY_DELETE_DIRECTIVE) != 0) {
+ syncTypes.add(ModelType.HISTORY_DELETE_DIRECTIVE);
}
- if (nativeIsBookmarkSyncEnabled(mNativeProfileSyncServiceAndroid)) {
- syncTypes.add(ModelType.BOOKMARK);
+ if ((modelTypeSelection & ModelTypeSelection.DEVICE_INFO) != 0) {
+ syncTypes.add(ModelType.DEVICE_INFO);
}
- if (nativeIsPasswordSyncEnabled(mNativeProfileSyncServiceAndroid)) {
- syncTypes.add(ModelType.PASSWORD);
+ if ((modelTypeSelection & ModelTypeSelection.PROXY_TABS) != 0) {
+ syncTypes.add(ModelType.PROXY_TABS);
}
- if (nativeIsTypedUrlSyncEnabled(mNativeProfileSyncServiceAndroid)) {
- syncTypes.add(ModelType.TYPED_URL);
+ if ((modelTypeSelection & ModelTypeSelection.FAVICON_IMAGE) != 0) {
+ syncTypes.add(ModelType.FAVICON_IMAGE);
}
- if (nativeIsSessionSyncEnabled(mNativeProfileSyncServiceAndroid)) {
- syncTypes.add(ModelType.SESSION);
+ if ((modelTypeSelection & ModelTypeSelection.FAVICON_TRACKING) != 0) {
+ syncTypes.add(ModelType.FAVICON_TRACKING);
}
return syncTypes;
}
@@ -577,6 +602,8 @@ public class ProfileSyncService {
private native String nativeGetSyncEnterCustomPassphraseBodyText(
int nativeProfileSyncServiceAndroid);
private native boolean nativeIsSyncKeystoreMigrationDone(int nativeProfileSyncServiceAndroid);
+ private native long nativeGetEnabledDataTypes(
+ int nativeProfileSyncServiceAndroid);
private native void nativeSetPreferredDataTypes(
int nativeProfileSyncServiceAndroid, boolean syncEverything, long modelTypeSelection);
private native void nativeSetSetupInProgress(
@@ -584,11 +611,6 @@ public class ProfileSyncService {
private native void nativeSetSyncSetupCompleted(int nativeProfileSyncServiceAndroid);
private native boolean nativeHasSyncSetupCompleted(int nativeProfileSyncServiceAndroid);
private native boolean nativeHasKeepEverythingSynced(int nativeProfileSyncServiceAndroid);
- private native boolean nativeIsAutofillSyncEnabled(int nativeProfileSyncServiceAndroid);
- private native boolean nativeIsBookmarkSyncEnabled(int nativeProfileSyncServiceAndroid);
- private native boolean nativeIsPasswordSyncEnabled(int nativeProfileSyncServiceAndroid);
- private native boolean nativeIsTypedUrlSyncEnabled(int nativeProfileSyncServiceAndroid);
- private native boolean nativeIsSessionSyncEnabled(int nativeProfileSyncServiceAndroid);
private native boolean nativeHasUnrecoverableError(int nativeProfileSyncServiceAndroid);
private native String nativeGetAboutInfoForTest(int nativeProfileSyncServiceAndroid);
private native void nativeOAuth2TokenFetched(
diff --git a/chrome/browser/sync/profile_sync_service_android.cc b/chrome/browser/sync/profile_sync_service_android.cc
index c2cf934..b20e7d8 100644
--- a/chrome/browser/sync/profile_sync_service_android.cc
+++ b/chrome/browser/sync/profile_sync_service_android.cc
@@ -461,12 +461,60 @@ jboolean ProfileSyncServiceAndroid::IsSyncKeystoreMigrationDone(
return is_status_valid && !status.keystore_migration_time.is_null();
}
+jlong ProfileSyncServiceAndroid::GetEnabledDataTypes(JNIEnv* env,
+ jobject obj) {
+ jlong model_type_selection = 0;
+ syncer::ModelTypeSet types = sync_service_->GetPreferredDataTypes();
+ types.PutAll(syncer::ControlTypes());
+ if (types.Has(syncer::BOOKMARKS)) {
+ model_type_selection |= BOOKMARK;
+ }
+ if (types.Has(syncer::AUTOFILL)) {
+ model_type_selection |= AUTOFILL;
+ }
+ if (types.Has(syncer::AUTOFILL_PROFILE)) {
+ model_type_selection |= AUTOFILL_PROFILE;
+ }
+ if (types.Has(syncer::PASSWORDS)) {
+ model_type_selection |= PASSWORD;
+ }
+ if (types.Has(syncer::TYPED_URLS)) {
+ model_type_selection |= TYPED_URL;
+ }
+ if (types.Has(syncer::SESSIONS)) {
+ model_type_selection |= SESSION;
+ }
+ if (types.Has(syncer::HISTORY_DELETE_DIRECTIVES)) {
+ model_type_selection |= HISTORY_DELETE_DIRECTIVE;
+ }
+ if (types.Has(syncer::PROXY_TABS)) {
+ model_type_selection |= PROXY_TABS;
+ }
+ if (types.Has(syncer::FAVICON_IMAGES)) {
+ model_type_selection |= FAVICON_IMAGE;
+ }
+ if (types.Has(syncer::FAVICON_TRACKING)) {
+ model_type_selection |= FAVICON_TRACKING;
+ }
+ if (types.Has(syncer::DEVICE_INFO)) {
+ model_type_selection |= DEVICE_INFO;
+ }
+ if (types.Has(syncer::NIGORI)) {
+ model_type_selection |= NIGORI;
+ }
+ if (types.Has(syncer::EXPERIMENTS)) {
+ model_type_selection |= EXPERIMENTS;
+ }
+ return model_type_selection;
+}
+
void ProfileSyncServiceAndroid::SetPreferredDataTypes(
JNIEnv* env, jobject obj,
jboolean sync_everything,
jlong model_type_selection) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
syncer::ModelTypeSet types;
+ // Note: only user selectable types should be included here.
if (model_type_selection & AUTOFILL)
types.Put(syncer::AUTOFILL);
if (model_type_selection & BOOKMARK)
@@ -477,6 +525,7 @@ void ProfileSyncServiceAndroid::SetPreferredDataTypes(
types.Put(syncer::SESSIONS);
if (model_type_selection & TYPED_URL)
types.Put(syncer::TYPED_URLS);
+ DCHECK(syncer::UserSelectableTypes().HasAll(types));
sync_service_->OnUserChoseDatatypes(sync_everything, types);
}
@@ -511,41 +560,6 @@ jboolean ProfileSyncServiceAndroid::HasKeepEverythingSynced(
return prefs.HasKeepEverythingSynced();
}
-jboolean ProfileSyncServiceAndroid::IsAutofillSyncEnabled(
- JNIEnv* env, jobject obj) {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
- return HasKeepEverythingSynced(env, obj) ||
- sync_service_->GetPreferredDataTypes().Has(syncer::AUTOFILL);
-}
-
-jboolean ProfileSyncServiceAndroid::IsBookmarkSyncEnabled(
- JNIEnv* env, jobject obj) {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
- return HasKeepEverythingSynced(env, obj) ||
- sync_service_->GetPreferredDataTypes().Has(syncer::BOOKMARKS);
-}
-
-jboolean ProfileSyncServiceAndroid::IsPasswordSyncEnabled(
- JNIEnv* env, jobject obj) {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
- return HasKeepEverythingSynced(env, obj) ||
- sync_service_->GetPreferredDataTypes().Has(syncer::PASSWORDS);
-}
-
-jboolean ProfileSyncServiceAndroid::IsTypedUrlSyncEnabled(
- JNIEnv* env, jobject obj) {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
- return HasKeepEverythingSynced(env, obj) ||
- sync_service_->GetPreferredDataTypes().Has(syncer::TYPED_URLS);
-}
-
-jboolean ProfileSyncServiceAndroid::IsSessionSyncEnabled(
- JNIEnv* env, jobject obj) {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
- return HasKeepEverythingSynced(env, obj) ||
- sync_service_->GetPreferredDataTypes().Has(syncer::SESSIONS);
-}
-
jboolean ProfileSyncServiceAndroid::HasUnrecoverableError(
JNIEnv* env, jobject) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
diff --git a/chrome/browser/sync/profile_sync_service_android.h b/chrome/browser/sync/profile_sync_service_android.h
index 0495a04..a43c7d4 100644
--- a/chrome/browser/sync/profile_sync_service_android.h
+++ b/chrome/browser/sync/profile_sync_service_android.h
@@ -149,6 +149,12 @@ class ProfileSyncServiceAndroid : public ProfileSyncServiceObserver {
// Returns true if sync has been migrated.
jboolean IsSyncKeystoreMigrationDone(JNIEnv* env, jobject obj);
+ // Get the set of enabled data types. These are the types currently both
+ // registered and preferred. Note that control types are always included here.
+ // Returns a bit map of the values from
+ // profile_sync_service_model_type_selection_android.h.
+ jlong GetEnabledDataTypes(JNIEnv* env, jobject obj);
+
// Enables the passed data types.
// If |sync_everything| is true, then all data types are enabled and the
// contents of |model_type_selection| is
@@ -173,21 +179,6 @@ class ProfileSyncServiceAndroid : public ProfileSyncServiceObserver {
// Returns true if sync is configured to "sync everything".
jboolean HasKeepEverythingSynced(JNIEnv* env, jobject obj);
- // Returns true if the user has autofill sync enabled.
- jboolean IsAutofillSyncEnabled(JNIEnv* env, jobject obj);
-
- // Returns true if the user has bookmark sync enabled.
- jboolean IsBookmarkSyncEnabled(JNIEnv* env, jobject obj);
-
- // Returns true if the user has password sync enabled.
- jboolean IsPasswordSyncEnabled(JNIEnv* env, jobject obj);
-
- // Returns true if the user has typed URL sync enabled.
- jboolean IsTypedUrlSyncEnabled(JNIEnv* env, jobject obj);
-
- // Returns true if the user has session sync enabled.
- jboolean IsSessionSyncEnabled(JNIEnv* env, jobject obj);
-
// Turns on encryption for all data types. This is an asynchronous operation
// which happens after the current configuration pass is done, so a call to
// this routine must be followed by a call to SetEnabledDataTypes().
diff --git a/chrome/browser/sync/profile_sync_service_model_type_selection_android.h b/chrome/browser/sync/profile_sync_service_model_type_selection_android.h
index 3628596..822814d 100644
--- a/chrome/browser/sync/profile_sync_service_model_type_selection_android.h
+++ b/chrome/browser/sync/profile_sync_service_model_type_selection_android.h
@@ -5,15 +5,31 @@
// This file intentionally does not have header guards, it's included
// inside a macro to generate enum.
-// This file contains the list of sync ModelTypes that Android can select as
-// preferred types.
+// This file contains the list of sync ModelTypes that Android can register for
+// invalidations for.
-DEFINE_MODEL_TYPE_SELECTION(AUTOFILL, 1)
+DEFINE_MODEL_TYPE_SELECTION(AUTOFILL, 1<<0)
-DEFINE_MODEL_TYPE_SELECTION(BOOKMARK, 2)
+DEFINE_MODEL_TYPE_SELECTION(BOOKMARK, 1<<1)
-DEFINE_MODEL_TYPE_SELECTION(PASSWORD, 4)
+DEFINE_MODEL_TYPE_SELECTION(PASSWORD, 1<<2)
-DEFINE_MODEL_TYPE_SELECTION(SESSION, 8)
+DEFINE_MODEL_TYPE_SELECTION(SESSION, 1<<3)
-DEFINE_MODEL_TYPE_SELECTION(TYPED_URL, 16)
+DEFINE_MODEL_TYPE_SELECTION(TYPED_URL, 1<<4)
+
+DEFINE_MODEL_TYPE_SELECTION(AUTOFILL_PROFILE, 1<<5)
+
+DEFINE_MODEL_TYPE_SELECTION(HISTORY_DELETE_DIRECTIVE, 1<<6)
+
+DEFINE_MODEL_TYPE_SELECTION(PROXY_TABS, 1<<7)
+
+DEFINE_MODEL_TYPE_SELECTION(FAVICON_IMAGE, 1<<8)
+
+DEFINE_MODEL_TYPE_SELECTION(FAVICON_TRACKING, 1<<9)
+
+DEFINE_MODEL_TYPE_SELECTION(NIGORI, 1<<10)
+
+DEFINE_MODEL_TYPE_SELECTION(DEVICE_INFO, 1<<11)
+
+DEFINE_MODEL_TYPE_SELECTION(EXPERIMENTS, 1<<12)