diff options
author | bauerb@chromium.org <bauerb@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-04-17 12:46:01 +0000 |
---|---|---|
committer | bauerb@chromium.org <bauerb@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-04-17 12:46:01 +0000 |
commit | b40e52d752e1bffd81a40cb6a547d849546340ec (patch) | |
tree | 1f60a6a808bc4d283fc8e7d089ee4d24b13032b0 /sync | |
parent | be97da1bebcbbc5a53cad0092b4fb104da2af91e (diff) | |
download | chromium_src-b40e52d752e1bffd81a40cb6a547d849546340ec.zip chromium_src-b40e52d752e1bffd81a40cb6a547d849546340ec.tar.gz chromium_src-b40e52d752e1bffd81a40cb6a547d849546340ec.tar.bz2 |
Add ManagedUserSettings Sync data type.
This data type should not be visible in the UI, as it will be configured automatically for managed users.
TBR=atwilson@chromium.org
BUG=229383
Review URL: https://codereview.chromium.org/14053004
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@194582 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'sync')
-rw-r--r-- | sync/internal_api/base_node.cc | 6 | ||||
-rw-r--r-- | sync/internal_api/public/base/model_type.h | 2 | ||||
-rw-r--r-- | sync/internal_api/public/base_node.h | 5 | ||||
-rw-r--r-- | sync/internal_api/public/write_node.h | 5 | ||||
-rw-r--r-- | sync/internal_api/write_node.cc | 7 | ||||
-rw-r--r-- | sync/protocol/managed_user_setting_specifics.proto | 21 | ||||
-rw-r--r-- | sync/protocol/proto_value_conversions.cc | 9 | ||||
-rw-r--r-- | sync/protocol/proto_value_conversions.h | 4 | ||||
-rw-r--r-- | sync/protocol/proto_value_conversions_unittest.cc | 8 | ||||
-rw-r--r-- | sync/protocol/sync.proto | 2 | ||||
-rw-r--r-- | sync/sync_proto.gypi | 1 | ||||
-rw-r--r-- | sync/syncable/model_type.cc | 25 | ||||
-rw-r--r-- | sync/syncable/nigori_util.cc | 4 | ||||
-rw-r--r-- | sync/tools/testserver/chromiumsync.py | 8 | ||||
-rw-r--r-- | sync/util/data_type_histogram.h | 3 |
15 files changed, 106 insertions, 4 deletions
diff --git a/sync/internal_api/base_node.cc b/sync/internal_api/base_node.cc index b45787f..3da3a73 100644 --- a/sync/internal_api/base_node.cc +++ b/sync/internal_api/base_node.cc @@ -329,6 +329,12 @@ const sync_pb::SessionSpecifics& BaseNode::GetSessionSpecifics() const { return GetEntitySpecifics().session(); } +const sync_pb::ManagedUserSettingSpecifics& + BaseNode::GetManagedUserSettingSpecifics() const { + DCHECK_EQ(GetModelType(), MANAGED_USER_SETTINGS); + return GetEntitySpecifics().managed_user_setting(); +} + const sync_pb::DeviceInfoSpecifics& BaseNode::GetDeviceInfoSpecifics() const { DCHECK_EQ(GetModelType(), DEVICE_INFO); return GetEntitySpecifics().device_info(); diff --git a/sync/internal_api/public/base/model_type.h b/sync/internal_api/public/base/model_type.h index 197e695..268715a 100644 --- a/sync/internal_api/public/base/model_type.h +++ b/sync/internal_api/public/base/model_type.h @@ -93,6 +93,8 @@ enum ModelType { // These preferences are synced before other user types and are never // encrypted. PRIORITY_PREFERENCES, + // Managed user settings. + MANAGED_USER_SETTINGS, // ---- Proxy types ---- // Proxy types are excluded from the sync protocol, but are still considered diff --git a/sync/internal_api/public/base_node.h b/sync/internal_api/public/base_node.h index 3602923..7cf2edb 100644 --- a/sync/internal_api/public/base_node.h +++ b/sync/internal_api/public/base_node.h @@ -153,6 +153,11 @@ class SYNC_EXPORT BaseNode { // data. Can only be called if GetModelType() == SESSIONS. const sync_pb::SessionSpecifics& GetSessionSpecifics() const; + // Getter specific to the MANAGED_USER_SETTINGS datatype. Returns protobuf + // data. Can only be called if GetModelType() == MANAGED_USER_SETTINGS. + const sync_pb::ManagedUserSettingSpecifics& + GetManagedUserSettingSpecifics() const; + // Getter specific to the DEVICE_INFO datatype. Returns protobuf // data. Can only be called if GetModelType() == DEVICE_INFO. const sync_pb::DeviceInfoSpecifics& GetDeviceInfoSpecifics() const; diff --git a/sync/internal_api/public/write_node.h b/sync/internal_api/public/write_node.h index 07c896b..3cb4039 100644 --- a/sync/internal_api/public/write_node.h +++ b/sync/internal_api/public/write_node.h @@ -160,6 +160,11 @@ class SYNC_EXPORT WriteNode : public BaseNode { // Should only be called if GetModelType() == SESSIONS. void SetSessionSpecifics(const sync_pb::SessionSpecifics& specifics); + // Set the managed user setting specifics (name and value). + // Should only be called if GetModelType() == MANAGED_USER_SETTINGS. + void SetManagedUserSettingSpecifics( + const sync_pb::ManagedUserSettingSpecifics& specifics); + // Set the device info specifics. // Should only be called if GetModelType() == DEVICE_INFO. void SetDeviceInfoSpecifics(const sync_pb::DeviceInfoSpecifics& specifics); diff --git a/sync/internal_api/write_node.cc b/sync/internal_api/write_node.cc index 3a96764..db461d6 100644 --- a/sync/internal_api/write_node.cc +++ b/sync/internal_api/write_node.cc @@ -186,6 +186,13 @@ void WriteNode::SetSessionSpecifics( SetEntitySpecifics(entity_specifics); } +void WriteNode::SetManagedUserSettingSpecifics( + const sync_pb::ManagedUserSettingSpecifics& new_value) { + sync_pb::EntitySpecifics entity_specifics; + entity_specifics.mutable_managed_user_setting()->CopyFrom(new_value); + SetEntitySpecifics(entity_specifics); +} + void WriteNode::SetDeviceInfoSpecifics( const sync_pb::DeviceInfoSpecifics& new_value) { sync_pb::EntitySpecifics entity_specifics; diff --git a/sync/protocol/managed_user_setting_specifics.proto b/sync/protocol/managed_user_setting_specifics.proto new file mode 100644 index 0000000..fcd1d96 --- /dev/null +++ b/sync/protocol/managed_user_setting_specifics.proto @@ -0,0 +1,21 @@ +// Copyright (c) 2013 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. +// +// Sync protocol datatype extension for managed user settings. + +// Update proto_value_conversions{.h,.cc,_unittest.cc} if you change +// any fields in this file. + +syntax = "proto2"; + +option optimize_for = LITE_RUNTIME; +option retain_unknown_fields = true; + +package sync_pb; + +// Properties of managed user setting sync objects. +message ManagedUserSettingSpecifics { + optional string name = 1; + optional string value = 2; +} diff --git a/sync/protocol/proto_value_conversions.cc b/sync/protocol/proto_value_conversions.cc index fbf90eb..c830395 100644 --- a/sync/protocol/proto_value_conversions.cc +++ b/sync/protocol/proto_value_conversions.cc @@ -402,6 +402,14 @@ base::DictionaryValue* HistoryDeleteDirectiveSpecificsToValue( return value; } +base::DictionaryValue* ManagedUserSettingSpecificsToValue( + const sync_pb::ManagedUserSettingSpecifics& proto) { + base::DictionaryValue* value = new base::DictionaryValue(); + SET_STR(name); + SET_STR(value); + return value; +} + base::DictionaryValue* NigoriSpecificsToValue( const sync_pb::NigoriSpecifics& proto) { base::DictionaryValue* value = new base::DictionaryValue(); @@ -530,6 +538,7 @@ base::DictionaryValue* EntitySpecificsToValue( SET_FIELD(favicon_image, FaviconImageSpecificsToValue); SET_FIELD(favicon_tracking, FaviconTrackingSpecificsToValue); SET_FIELD(history_delete_directive, HistoryDeleteDirectiveSpecificsToValue); + SET_FIELD(managed_user_setting, ManagedUserSettingSpecificsToValue); SET_FIELD(nigori, NigoriSpecificsToValue); SET_FIELD(password, PasswordSpecificsToValue); SET_FIELD(preference, PreferenceSpecificsToValue); diff --git a/sync/protocol/proto_value_conversions.h b/sync/protocol/proto_value_conversions.h index 66dd684..5a98758 100644 --- a/sync/protocol/proto_value_conversions.h +++ b/sync/protocol/proto_value_conversions.h @@ -41,6 +41,7 @@ class FaviconTrackingSpecifics; class GlobalIdDirective; class HistoryDeleteDirectiveSpecifics; class KeystoreEncryptionFlagsSpecifics; +class ManagedUserSettingSpecifics; class NigoriSpecifics; class PasswordSpecifics; class PasswordSpecificsData; @@ -166,6 +167,9 @@ SYNC_EXPORT base::DictionaryValue* HistoryDeleteDirectiveSpecificsToValue( const sync_pb::HistoryDeleteDirectiveSpecifics& history_delete_directive_specifics); +SYNC_EXPORT_PRIVATE base::DictionaryValue* ManagedUserSettingSpecificsToValue( + const sync_pb::ManagedUserSettingSpecifics& managed_user_setting_specifics); + SYNC_EXPORT_PRIVATE base::DictionaryValue* NigoriSpecificsToValue( const sync_pb::NigoriSpecifics& nigori_specifics); diff --git a/sync/protocol/proto_value_conversions_unittest.cc b/sync/protocol/proto_value_conversions_unittest.cc index 6258fa6..fe2750c 100644 --- a/sync/protocol/proto_value_conversions_unittest.cc +++ b/sync/protocol/proto_value_conversions_unittest.cc @@ -23,6 +23,7 @@ #include "sync/protocol/extension_specifics.pb.h" #include "sync/protocol/favicon_image_specifics.pb.h" #include "sync/protocol/favicon_tracking_specifics.pb.h" +#include "sync/protocol/managed_user_setting_specifics.pb.h" #include "sync/protocol/nigori_specifics.pb.h" #include "sync/protocol/password_specifics.pb.h" #include "sync/protocol/preference_specifics.pb.h" @@ -52,7 +53,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(26, MODEL_TYPE_COUNT); + EXPECT_EQ(27, 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 @@ -173,6 +174,10 @@ TEST_F(ProtoValueConversionsTest, HistoryDeleteDirectiveSpecificsToValue) { TestSpecificsToValue(HistoryDeleteDirectiveSpecificsToValue); } +TEST_F(ProtoValueConversionsTest, ManagedUserSettingSpecificsToValue) { + TestSpecificsToValue(ManagedUserSettingSpecificsToValue); +} + TEST_F(ProtoValueConversionsTest, NigoriSpecificsToValue) { TestSpecificsToValue(NigoriSpecificsToValue); } @@ -231,6 +236,7 @@ TEST_F(ProtoValueConversionsTest, EntitySpecificsToValue) { SET_FIELD(favicon_image); SET_FIELD(favicon_tracking); SET_FIELD(history_delete_directive); + SET_FIELD(managed_user_setting); SET_FIELD(nigori); SET_FIELD(password); SET_FIELD(preference); diff --git a/sync/protocol/sync.proto b/sync/protocol/sync.proto index 37e4455..47f2433 100644 --- a/sync/protocol/sync.proto +++ b/sync/protocol/sync.proto @@ -32,6 +32,7 @@ import "favicon_tracking_specifics.proto"; import "get_updates_caller_info.proto"; import "history_delete_directive_specifics.proto"; import "nigori_specifics.proto"; +import "managed_user_setting_specifics.proto"; import "password_specifics.proto"; import "preference_specifics.proto"; import "priority_preference_specifics.proto"; @@ -114,6 +115,7 @@ message EntitySpecifics { optional DictionarySpecifics dictionary = 170540; optional FaviconTrackingSpecifics favicon_tracking = 181534; optional FaviconImageSpecifics favicon_image = 182019; + optional ManagedUserSettingSpecifics managed_user_setting = 186662; } message SyncEntity { diff --git a/sync/sync_proto.gypi b/sync/sync_proto.gypi index f56a36a..04f5e35 100644 --- a/sync/sync_proto.gypi +++ b/sync/sync_proto.gypi @@ -28,6 +28,7 @@ 'protocol/get_updates_caller_info.proto', 'protocol/history_delete_directive_specifics.proto', 'protocol/nigori_specifics.proto', + 'protocol/managed_user_setting_specifics.proto', 'protocol/password_specifics.proto', 'protocol/preference_specifics.proto', 'protocol/priority_preference_specifics.proto', diff --git a/sync/syncable/model_type.cc b/sync/syncable/model_type.cc index eb28f37..140d7ab 100644 --- a/sync/syncable/model_type.cc +++ b/sync/syncable/model_type.cc @@ -101,6 +101,9 @@ void AddDefaultFieldValue(ModelType datatype, case FAVICON_TRACKING: specifics->mutable_favicon_tracking(); break; + case MANAGED_USER_SETTINGS: + specifics->mutable_managed_user_setting(); + break; default: NOTREACHED() << "No known extension for model type."; } @@ -187,6 +190,8 @@ int GetSpecificsFieldNumberFromModelType(ModelType model_type) { return sync_pb::EntitySpecifics::kFaviconImageFieldNumber; case FAVICON_TRACKING: return sync_pb::EntitySpecifics::kFaviconTrackingFieldNumber; + case MANAGED_USER_SETTINGS: + return sync_pb::EntitySpecifics::kManagedUserSettingFieldNumber; default: NOTREACHED() << "No known extension for model type."; return 0; @@ -303,6 +308,9 @@ ModelType GetModelTypeFromSpecifics(const sync_pb::EntitySpecifics& specifics) { if (specifics.has_favicon_tracking()) return FAVICON_TRACKING; + if (specifics.has_managed_user_setting()) + return MANAGED_USER_SETTINGS; + return UNSPECIFIED; } @@ -352,6 +360,8 @@ ModelTypeSet EncryptableUserTypes() { // Priority preferences are not encrypted because they might be synced before // encryption is ready. encryptable_user_types.RemoveAll(PriorityUserTypes()); + // Managed user settings are not encrypted since they are set server-side. + encryptable_user_types.Remove(MANAGED_USER_SETTINGS); // Proxy types have no sync representation and are therefore not encrypted. // Note however that proxy types map to one or more protocol types, which // may or may not be encrypted themselves. @@ -440,6 +450,8 @@ const char* ModelTypeToString(ModelType model_type) { return "Favicon Images"; case FAVICON_TRACKING: return "Favicon Tracking"; + case MANAGED_USER_SETTINGS: + return "Managed User Settings"; case PROXY_TABS: return "Tabs"; default: @@ -507,6 +519,8 @@ int ModelTypeToHistogramInt(ModelType model_type) { return 24; case PROXY_TABS: return 25; + case MANAGED_USER_SETTINGS: + return 26; // Silence a compiler warning. case MODEL_TYPE_COUNT: return 0; @@ -588,6 +602,8 @@ ModelType ModelTypeFromString(const std::string& model_type_string) { return FAVICON_IMAGES; else if (model_type_string == "Favicon Tracking") return FAVICON_TRACKING; + else if (model_type_string == "Managed User Settings") + return MANAGED_USER_SETTINGS; else if (model_type_string == "Tabs") return PROXY_TABS; else @@ -676,6 +692,8 @@ std::string ModelTypeToRootTag(ModelType type) { return "google_chrome_favicon_images"; case FAVICON_TRACKING: return "google_chrome_favicon_tracking"; + case MANAGED_USER_SETTINGS: + return "google_chrome_managed_user_settings"; case PROXY_TABS: return std::string(); default: @@ -713,6 +731,7 @@ const char kPriorityPreferenceNotificationType[] = "PRIORITY_PREFERENCE"; const char kDictionaryNotificationType[] = "DICTIONARY"; const char kFaviconImageNotificationType[] = "FAVICON_IMAGE"; const char kFaviconTrackingNotificationType[] = "FAVICON_TRACKING"; +const char kManagedUserSettingNotificationType[] = "MANAGED_USER_SETTING"; } // namespace bool RealModelTypeToNotificationType(ModelType model_type, @@ -787,6 +806,9 @@ bool RealModelTypeToNotificationType(ModelType model_type, case FAVICON_TRACKING: *notification_type = kFaviconTrackingNotificationType; return true; + case MANAGED_USER_SETTINGS: + *notification_type = kManagedUserSettingNotificationType; + return true; default: break; } @@ -865,6 +887,9 @@ bool NotificationTypeToRealModelType(const std::string& notification_type, } else if (notification_type == kFaviconTrackingNotificationType) { *model_type = FAVICON_TRACKING; return true; + } else if (notification_type == kManagedUserSettingNotificationType) { + *model_type = MANAGED_USER_SETTINGS; + return true; } *model_type = UNSPECIFIED; return false; diff --git a/sync/syncable/nigori_util.cc b/sync/syncable/nigori_util.cc index 1b00dbd..5c88316 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); - COMPILE_ASSERT(26 == MODEL_TYPE_COUNT, UpdateEncryptedTypes); + COMPILE_ASSERT(27 == MODEL_TYPE_COUNT, UpdateEncryptedTypes); nigori->set_encrypt_bookmarks( encrypted_types.Has(BOOKMARKS)); nigori->set_encrypt_preferences( @@ -276,7 +276,7 @@ ModelTypeSet GetEncryptedTypesFromNigori( return ModelTypeSet::All(); ModelTypeSet encrypted_types; - COMPILE_ASSERT(26 == MODEL_TYPE_COUNT, UpdateEncryptedTypes); + COMPILE_ASSERT(27 == MODEL_TYPE_COUNT, UpdateEncryptedTypes); if (nigori.encrypt_bookmarks()) encrypted_types.Put(BOOKMARKS); if (nigori.encrypt_preferences()) diff --git a/sync/tools/testserver/chromiumsync.py b/sync/tools/testserver/chromiumsync.py index eecea5c..fbd3c5b 100644 --- a/sync/tools/testserver/chromiumsync.py +++ b/sync/tools/testserver/chromiumsync.py @@ -31,6 +31,7 @@ import extension_specifics_pb2 import favicon_image_specifics_pb2 import favicon_tracking_specifics_pb2 import history_delete_directive_specifics_pb2 +import managed_user_setting_specifics_pb2 import nigori_specifics_pb2 import password_specifics_pb2 import preference_specifics_pb2 @@ -60,6 +61,7 @@ ALL_TYPES = ( EXPERIMENTS, EXTENSIONS, HISTORY_DELETE_DIRECTIVE, + MANAGED_USER_SETTING, NIGORI, PASSWORD, PREFERENCE, @@ -71,7 +73,7 @@ ALL_TYPES = ( TYPED_URL, EXTENSION_SETTINGS, FAVICON_IMAGES, - FAVICON_TRACKING) = range(24) + FAVICON_TRACKING) = range(25) # 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. @@ -102,6 +104,7 @@ SYNC_TYPE_TO_DESCRIPTOR = { FAVICON_IMAGES: SYNC_TYPE_FIELDS['favicon_image'], FAVICON_TRACKING: SYNC_TYPE_FIELDS['favicon_tracking'], HISTORY_DELETE_DIRECTIVE: SYNC_TYPE_FIELDS['history_delete_directive'], + MANAGED_USER_SETTING: SYNC_TYPE_FIELDS['managed_user_setting'], NIGORI: SYNC_TYPE_FIELDS['nigori'], PASSWORD: SYNC_TYPE_FIELDS['password'], PREFERENCE: SYNC_TYPE_FIELDS['preference'], @@ -491,6 +494,9 @@ class SyncDataModel(object): name='Favicon Tracking', parent_tag=ROOT_ID, sync_type=FAVICON_TRACKING), + PermanentItem('google_chrome_managed_user_settings', + name='Managed User Settings', + parent_tag=ROOT_ID, sync_type=MANAGED_USER_SETTING), PermanentItem('google_chrome_nigori', name='Nigori', parent_tag=ROOT_ID, sync_type=NIGORI), PermanentItem('google_chrome_passwords', name='Passwords', diff --git a/sync/util/data_type_histogram.h b/sync/util/data_type_histogram.h index c911ce4..c2d8542 100644 --- a/sync/util/data_type_histogram.h +++ b/sync/util/data_type_histogram.h @@ -105,6 +105,9 @@ case ::syncer::FAVICON_TRACKING: \ PER_DATA_TYPE_MACRO("FaviconTracking"); \ break; \ + case ::syncer::MANAGED_USER_SETTINGS: \ + PER_DATA_TYPE_MACRO("ManagedUserSetting"); \ + break; \ case ::syncer::PROXY_TABS :\ PER_DATA_TYPE_MACRO("Tabs"); \ break; \ |