Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(318)

Unified Diff: chrome/browser/sync/profile_sync_service.cc

Issue 5159001: Rest of the autofill work. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Diff against the first part of the review. Created 10 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/sync/profile_sync_service.cc
diff --git a/chrome/browser/sync/profile_sync_service.cc b/chrome/browser/sync/profile_sync_service.cc
index 601807bab851442993a61302dbb9b2ab32afec3b..4f58d154accdf163d0cc89fa87c97ea18169a39b 100644
--- a/chrome/browser/sync/profile_sync_service.cc
+++ b/chrome/browser/sync/profile_sync_service.cc
@@ -25,6 +25,7 @@
#include "chrome/browser/prefs/pref_service.h"
#include "chrome/browser/profile.h"
#include "chrome/browser/net/gaia/token_service.h"
+#include "chrome/browser/sync/glue/autofill_profile_data_type_controller.h"
#include "chrome/browser/sync/glue/change_processor.h"
#include "chrome/browser/sync/glue/data_type_controller.h"
#include "chrome/browser/sync/glue/data_type_manager.h"
@@ -366,6 +367,12 @@ void ProfileSyncService::RegisterPreferences() {
enable_by_default);
pref_service->RegisterBooleanPref(prefs::kSyncManaged, false);
pref_service->RegisterStringPref(prefs::kEncryptionBootstrapToken, "");
+
+ // If you have never synced before until we have migrated autofill profile
+ // is disabled.
+ pref_service->RegisterBooleanPref(prefs::kSyncAutofill_profile, false);
+
+ pref_service->RegisterBooleanPref(prefs::kAutofillProfileMigrated, false);
}
void ProfileSyncService::ClearPreferences() {
@@ -548,6 +555,9 @@ const char* ProfileSyncService::GetPrefNameForDataType(
return prefs::kSyncPreferences;
case syncable::AUTOFILL:
return prefs::kSyncAutofill;
+ case syncable::AUTOFILL_PROFILE:
+ return prefs::kSyncAutofill_profile;
+ break;
case syncable::THEMES:
return prefs::kSyncThemes;
case syncable::TYPED_URLS:
@@ -876,6 +886,24 @@ void ProfileSyncService::ChangePreferredDataTypes(
continue;
profile_->GetPrefs()->SetBoolean(pref_name,
preferred_types.count(model_type) != 0);
+ if (syncable::AUTOFILL == model_type) {
+ if (profile_->GetPrefs()->GetBoolean(prefs::kAutofillProfileMigrated)) {
+ profile_->GetPrefs()->SetBoolean(prefs::kSyncAutofill_profile,
+ preferred_types.count(model_type) != 0);
+ syncable::ModelTypeSet registered_types;
+
+ // Now register autofill profile if necessary.
+ GetRegisteredDataTypes(&registered_types);
+ if (registered_types.count(syncable::AUTOFILL_PROFILE) == 0) {
+ RegisterDataTypeController(
+ new browser_sync::AutofillProfileDataTypeController(this->factory_,
+ profile_,
+ this));
+ }
+ } else {
+ profile_->GetPrefs()->SetBoolean(prefs::kSyncAutofill_profile, false);
+ }
+ }
}
// If we haven't initialized yet, don't configure the DTM as it could cause
@@ -884,17 +912,28 @@ void ProfileSyncService::ChangePreferredDataTypes(
ConfigureDataTypeManager();
}
+void ProfileSyncService::GetAllSyncableTypesForCurrentClientState(
+ syncable::ModelTypeSet* preferred_types) const {
+
+ GetRegisteredDataTypes(preferred_types);
+
+ if (!profile_->GetPrefs()->GetBoolean(prefs::kAutofillProfileMigrated)) {
+ preferred_types->erase(syncable::AUTOFILL_PROFILE);
+ }
+
+ return;
+}
+
void ProfileSyncService::GetPreferredDataTypes(
syncable::ModelTypeSet* preferred_types) const {
preferred_types->clear();
-
- // Filter out any datatypes which aren't registered, or for which
- // the preference can't be read.
- syncable::ModelTypeSet registered_types;
- GetRegisteredDataTypes(&registered_types);
if (profile_->GetPrefs()->GetBoolean(prefs::kKeepEverythingSynced)) {
- *preferred_types = registered_types;
+ GetAllSyncableTypesForCurrentClientState(preferred_types);
} else {
+ // Filter out any datatypes which aren't registered, or for which
+ // the preference can't be read.
+ syncable::ModelTypeSet registered_types;
+ GetRegisteredDataTypes(&registered_types);
for (int i = 0; i < syncable::MODEL_TYPE_COUNT; ++i) {
syncable::ModelType model_type = syncable::ModelTypeFromInt(i);
if (!registered_types.count(model_type))

Powered by Google App Engine
This is Rietveld 408576698