diff options
author | rouslan <rouslan@chromium.org> | 2015-05-22 09:57:10 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-05-22 16:57:52 +0000 |
commit | 39765cfcec81f43376d609c092975c423f019921 (patch) | |
tree | 55642fbee3c9527f88ee4a7201a87b32cfc63780 | |
parent | 38344c8cd965062411bed6b178f75c41220f6190 (diff) | |
download | chromium_src-39765cfcec81f43376d609c092975c423f019921.zip chromium_src-39765cfcec81f43376d609c092975c423f019921.tar.gz chromium_src-39765cfcec81f43376d609c092975c423f019921.tar.bz2 |
[sync] Add AUTOFILL_WALLET_METADATA sync datatype.
BUG=481595
Review URL: https://codereview.chromium.org/1125143006
Cr-Commit-Position: refs/heads/master@{#331130}
19 files changed, 75 insertions, 9 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 38f618a..bd0d9a3 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 @@ -377,6 +377,9 @@ public class ProfileSyncService { if ((modelTypeSelection & ModelTypeSelection.AUTOFILL_WALLET) != 0) { syncTypes.add(ModelType.AUTOFILL_WALLET); } + if ((modelTypeSelection & ModelTypeSelection.AUTOFILL_WALLET_METADATA) != 0) { + syncTypes.add(ModelType.AUTOFILL_WALLET_METADATA); + } if ((modelTypeSelection & ModelTypeSelection.BOOKMARK) != 0) { syncTypes.add(ModelType.BOOKMARK); } diff --git a/chrome/browser/sync/profile_sync_components_factory_impl.cc b/chrome/browser/sync/profile_sync_components_factory_impl.cc index 1d02228..c970912 100644 --- a/chrome/browser/sync/profile_sync_components_factory_impl.cc +++ b/chrome/browser/sync/profile_sync_components_factory_impl.cc @@ -494,7 +494,8 @@ base::WeakPtr<syncer::SyncableService> ProfileSyncComponentsFactoryImpl:: syncer::PRIORITY_PREFERENCES)->AsWeakPtr(); case syncer::AUTOFILL: case syncer::AUTOFILL_PROFILE: - case syncer::AUTOFILL_WALLET_DATA: { + case syncer::AUTOFILL_WALLET_DATA: + case syncer::AUTOFILL_WALLET_METADATA: { if (!web_data_service_.get()) return base::WeakPtr<syncer::SyncableService>(); if (type == syncer::AUTOFILL) { @@ -503,6 +504,8 @@ base::WeakPtr<syncer::SyncableService> ProfileSyncComponentsFactoryImpl:: } else if (type == syncer::AUTOFILL_PROFILE) { return autofill::AutofillProfileSyncableService::FromWebDataService( web_data_service_.get())->AsWeakPtr(); + } else if (type == syncer::AUTOFILL_WALLET_METADATA) { + return base::WeakPtr<syncer::SyncableService>(); } return autofill::AutofillWalletSyncableService::FromWebDataService( web_data_service_.get())->AsWeakPtr(); diff --git a/chrome/browser/sync/profile_sync_service.cc b/chrome/browser/sync/profile_sync_service.cc index 5f0bffd..c075463 100644 --- a/chrome/browser/sync/profile_sync_service.cc +++ b/chrome/browser/sync/profile_sync_service.cc @@ -1708,7 +1708,7 @@ void ProfileSyncService::UpdateSelectedTypesHistogram( sync_driver::user_selectable_type::PROXY_TABS, }; - static_assert(35 == syncer::MODEL_TYPE_COUNT, + static_assert(36 == syncer::MODEL_TYPE_COUNT, "custom config histogram must be updated"); if (!sync_everything) { diff --git a/chrome/browser/sync/profile_sync_service_android.cc b/chrome/browser/sync/profile_sync_service_android.cc index 3cc460c..363fd41 100644 --- a/chrome/browser/sync/profile_sync_service_android.cc +++ b/chrome/browser/sync/profile_sync_service_android.cc @@ -66,6 +66,7 @@ enum ModelTypeSelection { SUPERVISED_USER_SETTING = 1 << 13, SUPERVISED_USER_WHITELIST = 1 << 14, AUTOFILL_WALLET = 1 << 15, + AUTOFILL_WALLET_METADATA = 1 << 16, }; // Native callback for the JNI GetAllNodes method. When @@ -512,6 +513,9 @@ jlong ProfileSyncServiceAndroid::ModelTypeSetToSelection( if (types.Has(syncer::AUTOFILL_WALLET_DATA)) { model_type_selection |= AUTOFILL_WALLET; } + if (types.Has(syncer::AUTOFILL_WALLET_METADATA)) { + model_type_selection |= AUTOFILL_WALLET_METADATA; + } if (types.Has(syncer::PASSWORDS)) { model_type_selection |= PASSWORD; } diff --git a/chrome/browser/sync/test/integration/migration_test.cc b/chrome/browser/sync/test/integration/migration_test.cc index 55fbf3e..ce67f4b1 100644 --- a/chrome/browser/sync/test/integration/migration_test.cc +++ b/chrome/browser/sync/test/integration/migration_test.cc @@ -103,6 +103,7 @@ class MigrationTest : public SyncTest { // Autofill wallet will be unready during this test, so we should not // request that it be migrated. preferred_data_types.Remove(syncer::AUTOFILL_WALLET_DATA); + preferred_data_types.Remove(syncer::AUTOFILL_WALLET_METADATA); // Make sure all clients have the same preferred data types. for (int i = 1; i < num_clients(); ++i) { diff --git a/components/sync_driver/model_association_manager.cc b/components/sync_driver/model_association_manager.cc index 71fbdd5..ebbbd37 100644 --- a/components/sync_driver/model_association_manager.cc +++ b/components/sync_driver/model_association_manager.cc @@ -31,6 +31,7 @@ static const syncer::ModelType kStartOrder[] = { syncer::AUTOFILL, syncer::AUTOFILL_PROFILE, syncer::AUTOFILL_WALLET_DATA, + syncer::AUTOFILL_WALLET_METADATA, syncer::EXTENSION_SETTINGS, syncer::APP_SETTINGS, syncer::TYPED_URLS, diff --git a/components/sync_driver/pref_names.cc b/components/sync_driver/pref_names.cc index 8caf875..9148525 100644 --- a/components/sync_driver/pref_names.cc +++ b/components/sync_driver/pref_names.cc @@ -34,6 +34,7 @@ const char kSyncApps[] = "sync.apps"; const char kSyncArticles[] = "sync.articles"; const char kSyncAutofillProfile[] = "sync.autofill_profile"; const char kSyncAutofillWallet[] = "sync.autofill_wallet"; +const char kSyncAutofillWalletMetadata[] = "sync.autofill_wallet_metadata"; const char kSyncAutofill[] = "sync.autofill"; const char kSyncBookmarks[] = "sync.bookmarks"; const char kSyncDeviceInfo[] = "sync.device_info"; diff --git a/components/sync_driver/pref_names.h b/components/sync_driver/pref_names.h index 2491390..e56dda4 100644 --- a/components/sync_driver/pref_names.h +++ b/components/sync_driver/pref_names.h @@ -23,6 +23,7 @@ extern const char kSyncApps[]; extern const char kSyncArticles[]; extern const char kSyncAutofillProfile[]; extern const char kSyncAutofillWallet[]; +extern const char kSyncAutofillWalletMetadata[]; extern const char kSyncAutofill[]; extern const char kSyncBookmarks[]; extern const char kSyncDeviceInfo[]; diff --git a/components/sync_driver/sync_prefs.cc b/components/sync_driver/sync_prefs.cc index fe465e8..d2cf098 100644 --- a/components/sync_driver/sync_prefs.cc +++ b/components/sync_driver/sync_prefs.cc @@ -255,6 +255,8 @@ const char* SyncPrefs::GetPrefNameForDataType(syncer::ModelType data_type) { return prefs::kSyncAutofillProfile; case syncer::AUTOFILL_WALLET_DATA: return prefs::kSyncAutofillWallet; + case syncer::AUTOFILL_WALLET_METADATA: + return prefs::kSyncAutofillWalletMetadata; case syncer::THEMES: return prefs::kSyncThemes; case syncer::TYPED_URLS: @@ -351,6 +353,7 @@ void SyncPrefs::RegisterPrefGroups() { pref_groups_[syncer::AUTOFILL].Put(syncer::AUTOFILL_PROFILE); pref_groups_[syncer::AUTOFILL].Put(syncer::AUTOFILL_WALLET_DATA); + pref_groups_[syncer::AUTOFILL].Put(syncer::AUTOFILL_WALLET_METADATA); pref_groups_[syncer::EXTENSIONS].Put(syncer::EXTENSION_SETTINGS); diff --git a/components/sync_driver/sync_prefs_unittest.cc b/components/sync_driver/sync_prefs_unittest.cc index bcfbc7b..69c0066 100644 --- a/components/sync_driver/sync_prefs_unittest.cc +++ b/components/sync_driver/sync_prefs_unittest.cc @@ -141,6 +141,7 @@ TEST_F(SyncPrefsTest, PreferredTypesNotKeepEverythingSynced) { if (it.Get() == syncer::AUTOFILL) { expected_preferred_types.Put(syncer::AUTOFILL_PROFILE); expected_preferred_types.Put(syncer::AUTOFILL_WALLET_DATA); + expected_preferred_types.Put(syncer::AUTOFILL_WALLET_METADATA); } if (it.Get() == syncer::PREFERENCES) { expected_preferred_types.Put(syncer::DICTIONARY); diff --git a/sync/android/java/src/org/chromium/sync/internal_api/pub/base/ModelType.java b/sync/android/java/src/org/chromium/sync/internal_api/pub/base/ModelType.java index 325df51..1e9fe0c 100644 --- a/sync/android/java/src/org/chromium/sync/internal_api/pub/base/ModelType.java +++ b/sync/android/java/src/org/chromium/sync/internal_api/pub/base/ModelType.java @@ -86,7 +86,11 @@ public enum ModelType { /** * An autofill wallet data object. */ - AUTOFILL_WALLET("AUTOFILL_WALLET"); + AUTOFILL_WALLET("AUTOFILL_WALLET"), + /** + * Usage counts and last use dates for autofill wallet data objects. + */ + AUTOFILL_WALLET_METADATA("AUTOFILL_WALLET_METADATA"); /** Special type representing all possible types. */ public static final String ALL_TYPES_TYPE = "ALL_TYPES"; diff --git a/sync/internal_api/public/base/model_type.h b/sync/internal_api/public/base/model_type.h index 0639181..b07f80d 100644 --- a/sync/internal_api/public/base/model_type.h +++ b/sync/internal_api/public/base/model_type.h @@ -67,6 +67,9 @@ enum ModelType { // Credit cards and addresses synced from the user's account. These are // read-only on the client. AUTOFILL_WALLET_DATA, + // Usage counts and last use dates for Wallet cards and addresses. This data + // is both readable and writable. + AUTOFILL_WALLET_METADATA, // A themes object. THEMES, // A typed_url object. diff --git a/sync/protocol/nigori_specifics.proto b/sync/protocol/nigori_specifics.proto index 407281f..eaefe78 100644 --- a/sync/protocol/nigori_specifics.proto +++ b/sync/protocol/nigori_specifics.proto @@ -128,5 +128,9 @@ message NigoriSpecifics { // Boolean corresponding to whether app list items should be encrypted. optional bool encrypt_app_list = 38; + + // Boolean corresponding to whether usage count and last use date of Wallet + // data should be encrypted. + optional bool encrypt_autofill_wallet_metadata = 39; } diff --git a/sync/protocol/proto_value_conversions_unittest.cc b/sync/protocol/proto_value_conversions_unittest.cc index ab4e1e4..9796c68 100644 --- a/sync/protocol/proto_value_conversions_unittest.cc +++ b/sync/protocol/proto_value_conversions_unittest.cc @@ -57,7 +57,7 @@ TEST_F(ProtoValueConversionsTest, ProtoChangeCheck) { // If this number changes, that means we added or removed a data // type. Don't forget to add a unit test for {New // type}SpecificsToValue below. - EXPECT_EQ(35, MODEL_TYPE_COUNT); + EXPECT_EQ(36, MODEL_TYPE_COUNT); // We'd also like to check if we changed any field in our messages. // However, that's hard to do: sizeof could work, but it's @@ -325,8 +325,8 @@ TEST_F(ProtoValueConversionsTest, EntitySpecificsToValue) { SET_FIELD(theme); SET_FIELD(typed_url); SET_FIELD(wifi_credential); - SET_FIELD(autofill_wallet); + SET_FIELD(wallet_metadata); #undef SET_FIELD diff --git a/sync/syncable/model_type.cc b/sync/syncable/model_type.cc index cfe5c2f..602582b 100644 --- a/sync/syncable/model_type.cc +++ b/sync/syncable/model_type.cc @@ -44,7 +44,7 @@ const char* kUserSelectableDataTypeNames[] = { }; static_assert( - 35 == MODEL_TYPE_COUNT, + 36 == MODEL_TYPE_COUNT, "update kUserSelectableDataTypeName to match UserSelectableTypes"); void AddDefaultFieldValue(ModelType datatype, @@ -72,6 +72,9 @@ void AddDefaultFieldValue(ModelType datatype, case AUTOFILL_WALLET_DATA: specifics->mutable_autofill_wallet(); break; + case AUTOFILL_WALLET_METADATA: + specifics->mutable_wallet_metadata(); + break; case THEMES: specifics->mutable_theme(); break; @@ -181,6 +184,8 @@ int GetSpecificsFieldNumberFromModelType(ModelType model_type) { return sync_pb::EntitySpecifics::kAutofillProfileFieldNumber; case AUTOFILL_WALLET_DATA: return sync_pb::EntitySpecifics::kAutofillWalletFieldNumber; + case AUTOFILL_WALLET_METADATA: + return sync_pb::EntitySpecifics::kWalletMetadataFieldNumber; case THEMES: return sync_pb::EntitySpecifics::kThemeFieldNumber; case TYPED_URLS: @@ -292,6 +297,9 @@ ModelType GetModelTypeFromSpecifics(const sync_pb::EntitySpecifics& specifics) { if (specifics.has_autofill_wallet()) return AUTOFILL_WALLET_DATA; + if (specifics.has_wallet_metadata()) + return AUTOFILL_WALLET_METADATA; + if (specifics.has_theme()) return THEMES; @@ -597,6 +605,8 @@ const char* ModelTypeToString(ModelType model_type) { return "Tabs"; case AUTOFILL_WALLET_DATA: return "Autofill Wallet"; + case AUTOFILL_WALLET_METADATA: + return "Autofill Wallet Metadata"; default: break; } @@ -682,6 +692,8 @@ int ModelTypeToHistogramInt(ModelType model_type) { return 33; case AUTOFILL_WALLET_DATA: return 34; + case AUTOFILL_WALLET_METADATA: + return 35; // Silence a compiler warning. case MODEL_TYPE_COUNT: return 0; @@ -729,6 +741,8 @@ ModelType ModelTypeFromString(const std::string& model_type_string) { return AUTOFILL_PROFILE; else if (model_type_string == "Autofill Wallet") return AUTOFILL_WALLET_DATA; + else if (model_type_string == "Autofill Wallet Metadata") + return AUTOFILL_WALLET_METADATA; else if (model_type_string == "Themes") return THEMES; else if (model_type_string == "Typed URLs") @@ -875,6 +889,8 @@ std::string ModelTypeToRootTag(ModelType type) { return "google_chrome_autofill_profiles"; case AUTOFILL_WALLET_DATA: return "google_chrome_autofill_wallet"; + case AUTOFILL_WALLET_METADATA: + return "google_chrome_autofill_wallet_metadata"; case APP_SETTINGS: return "google_chrome_app_settings"; case EXTENSION_SETTINGS: @@ -939,6 +955,8 @@ const char kAppListNotificationType[] = "APP_LIST"; const char kSearchEngineNotificationType[] = "SEARCH_ENGINE"; const char kSessionNotificationType[] = "SESSION"; const char kAutofillProfileNotificationType[] = "AUTOFILL_PROFILE"; +const char kAutofillWalletMetadataNotificationType[] = + "AUTOFILL_WALLET_METADATA"; const char kAutofillWalletNotificationType[] = "AUTOFILL_WALLET"; const char kAppNotificationNotificationType[] = "APP_NOTIFICATION"; const char kHistoryDeleteDirectiveNotificationType[] = @@ -1009,6 +1027,9 @@ bool RealModelTypeToNotificationType(ModelType model_type, case AUTOFILL_WALLET_DATA: *notification_type = kAutofillWalletNotificationType; return true; + case AUTOFILL_WALLET_METADATA: + *notification_type = kAutofillWalletMetadataNotificationType; + return true; case EXTENSION_SETTINGS: *notification_type = kExtensionSettingNotificationType; return true; @@ -1111,6 +1132,9 @@ bool NotificationTypeToRealModelType(const std::string& notification_type, } else if (notification_type == kAutofillWalletNotificationType) { *model_type = AUTOFILL_WALLET_DATA; return true; + } else if (notification_type == kAutofillWalletMetadataNotificationType) { + *model_type = AUTOFILL_WALLET_METADATA; + return true; } else if (notification_type == kAppSettingNotificationType) { *model_type = APP_SETTINGS; return true; diff --git a/sync/syncable/nigori_util.cc b/sync/syncable/nigori_util.cc index 1ad5095..db779a4 100644 --- a/sync/syncable/nigori_util.cc +++ b/sync/syncable/nigori_util.cc @@ -242,7 +242,7 @@ void UpdateNigoriFromEncryptedTypes(ModelTypeSet encrypted_types, bool encrypt_everything, sync_pb::NigoriSpecifics* nigori) { nigori->set_encrypt_everything(encrypt_everything); - static_assert(35 == MODEL_TYPE_COUNT, "update encrypted types"); + static_assert(36 == MODEL_TYPE_COUNT, "update encrypted types"); nigori->set_encrypt_bookmarks( encrypted_types.Has(BOOKMARKS)); nigori->set_encrypt_preferences( @@ -250,6 +250,8 @@ void UpdateNigoriFromEncryptedTypes(ModelTypeSet encrypted_types, nigori->set_encrypt_autofill_profile( encrypted_types.Has(AUTOFILL_PROFILE)); nigori->set_encrypt_autofill(encrypted_types.Has(AUTOFILL)); + nigori->set_encrypt_autofill_wallet_metadata( + encrypted_types.Has(AUTOFILL_WALLET_METADATA)); nigori->set_encrypt_themes(encrypted_types.Has(THEMES)); nigori->set_encrypt_typed_urls( encrypted_types.Has(TYPED_URLS)); @@ -278,7 +280,7 @@ ModelTypeSet GetEncryptedTypesFromNigori( return ModelTypeSet::All(); ModelTypeSet encrypted_types; - static_assert(35 == MODEL_TYPE_COUNT, "update encrypted types"); + static_assert(36 == MODEL_TYPE_COUNT, "update encrypted types"); if (nigori.encrypt_bookmarks()) encrypted_types.Put(BOOKMARKS); if (nigori.encrypt_preferences()) @@ -287,6 +289,8 @@ ModelTypeSet GetEncryptedTypesFromNigori( encrypted_types.Put(AUTOFILL_PROFILE); if (nigori.encrypt_autofill()) encrypted_types.Put(AUTOFILL); + if (nigori.encrypt_autofill_wallet_metadata()) + encrypted_types.Put(AUTOFILL_WALLET_METADATA); if (nigori.encrypt_themes()) encrypted_types.Put(THEMES); if (nigori.encrypt_typed_urls()) diff --git a/sync/tools/testserver/chromiumsync.py b/sync/tools/testserver/chromiumsync.py index d51f8cf..459f1e1 100644 --- a/sync/tools/testserver/chromiumsync.py +++ b/sync/tools/testserver/chromiumsync.py @@ -69,6 +69,7 @@ ALL_TYPES = ( ARTICLE, AUTOFILL, AUTOFILL_PROFILE, + AUTOFILL_WALLET_METADATA, BOOKMARK, DEVICE_INFO, DICTIONARY, @@ -92,7 +93,7 @@ ALL_TYPES = ( EXTENSION_SETTINGS, FAVICON_IMAGES, FAVICON_TRACKING, - WIFI_CREDENTIAL) = range(32) + WIFI_CREDENTIAL) = range(33) # An enumeration on the frequency at which the server should send errors # to the client. This would be specified by the url that triggers the error. @@ -116,6 +117,7 @@ SYNC_TYPE_TO_DESCRIPTOR = { ARTICLE: SYNC_TYPE_FIELDS['article'], AUTOFILL: SYNC_TYPE_FIELDS['autofill'], AUTOFILL_PROFILE: SYNC_TYPE_FIELDS['autofill_profile'], + AUTOFILL_WALLET_METADATA: SYNC_TYPE_FIELDS['wallet_metadata'], BOOKMARK: SYNC_TYPE_FIELDS['bookmark'], DEVICE_INFO: SYNC_TYPE_FIELDS['device_info'], DICTIONARY: SYNC_TYPE_FIELDS['dictionary'], @@ -511,6 +513,9 @@ class SyncDataModel(object): parent_tag=ROOT_ID, sync_type=AUTOFILL), PermanentItem('google_chrome_autofill_profiles', name='Autofill Profiles', parent_tag=ROOT_ID, sync_type=AUTOFILL_PROFILE), + PermanentItem('google_chrome_autofill_wallet_metadata', + name='Autofill Wallet Metadata', parent_tag=ROOT_ID, + sync_type=AUTOFILL_WALLET_METADATA), PermanentItem('google_chrome_device_info', name='Device Info', parent_tag=ROOT_ID, sync_type=DEVICE_INFO), PermanentItem('google_chrome_experiments', name='Experiments', diff --git a/sync/util/data_type_histogram.h b/sync/util/data_type_histogram.h index 2c4ac8e..0f7e6a9 100644 --- a/sync/util/data_type_histogram.h +++ b/sync/util/data_type_histogram.h @@ -54,6 +54,9 @@ case ::syncer::AUTOFILL_WALLET_DATA: \ PER_DATA_TYPE_MACRO("AutofillWallet"); \ break; \ + case ::syncer::AUTOFILL_WALLET_METADATA: \ + PER_DATA_TYPE_MACRO("AutofillWalletMetadata"); \ + break; \ case ::syncer::THEMES: \ PER_DATA_TYPE_MACRO("Themes"); \ break; \ diff --git a/tools/metrics/histograms/histograms.xml b/tools/metrics/histograms/histograms.xml index 1717e8b..2d9d9df 100644 --- a/tools/metrics/histograms/histograms.xml +++ b/tools/metrics/histograms/histograms.xml @@ -65135,6 +65135,7 @@ To add a new entry, add it with any value and run test to compute valid value. <int value="32" label="Wifi Credentials"/> <int value="33" label="Managed User Whitelists"/> <int value="34" label="Autofill Wallet"/> + <int value="35" label="Autofill Wallet Metadata"/> </enum> <enum name="SyncNigoriMigrationResult" type="int"> |