summaryrefslogtreecommitdiffstats
path: root/sync
diff options
context:
space:
mode:
authorbauerb <bauerb@chromium.org>2014-12-16 03:23:45 -0800
committerCommit bot <commit-bot@chromium.org>2014-12-16 11:24:06 +0000
commit8a4355ef1a592e6eba484c354e6805fe8e097494 (patch)
tree3b3247f36ce01b497aff98b0e0f2ae394c542742 /sync
parent5a1036378757f8a44c4ee920baff6d6f34a18314 (diff)
downloadchromium_src-8a4355ef1a592e6eba484c354e6805fe8e097494.zip
chromium_src-8a4355ef1a592e6eba484c354e6805fe8e097494.tar.gz
chromium_src-8a4355ef1a592e6eba484c354e6805fe8e097494.tar.bz2
Add a datatype for supervised user whitelists.
BUG=436459 Review URL: https://codereview.chromium.org/754963004 Cr-Commit-Position: refs/heads/master@{#308569}
Diffstat (limited to 'sync')
-rw-r--r--sync/internal_api/public/base/model_type.h3
-rw-r--r--sync/protocol/BUILD.gn1
-rw-r--r--sync/protocol/managed_user_whitelist_specifics.proto25
-rw-r--r--sync/protocol/proto_value_conversions.cc9
-rw-r--r--sync/protocol/proto_value_conversions.h5
-rw-r--r--sync/protocol/proto_value_conversions_unittest.cc8
-rw-r--r--sync/protocol/sync.proto2
-rw-r--r--sync/sync.gyp1
-rw-r--r--sync/syncable/model_type.cc30
-rw-r--r--sync/syncable/nigori_util.cc4
-rw-r--r--sync/util/data_type_histogram.h3
11 files changed, 87 insertions, 4 deletions
diff --git a/sync/internal_api/public/base/model_type.h b/sync/internal_api/public/base/model_type.h
index 511f66b..8bca7ca 100644
--- a/sync/internal_api/public/base/model_type.h
+++ b/sync/internal_api/public/base/model_type.h
@@ -114,6 +114,9 @@ enum ModelType {
// WiFi credentials. Each item contains the information for connecting to one
// WiFi network. This includes, e.g., network name and password.
WIFI_CREDENTIALS,
+ // Supervised user whitelists. Each item contains a CRX ID (like an extension
+ // ID) and a name.
+ SUPERVISED_USER_WHITELISTS,
// ---- Proxy types ----
// Proxy types are excluded from the sync protocol, but are still considered
diff --git a/sync/protocol/BUILD.gn b/sync/protocol/BUILD.gn
index 5ec0001..ba9b602 100644
--- a/sync/protocol/BUILD.gn
+++ b/sync/protocol/BUILD.gn
@@ -31,6 +31,7 @@ proto_library("protocol") {
"managed_user_setting_specifics.proto",
"managed_user_shared_setting_specifics.proto",
"managed_user_specifics.proto",
+ "managed_user_whitelist_specifics.proto",
"password_specifics.proto",
"preference_specifics.proto",
"priority_preference_specifics.proto",
diff --git a/sync/protocol/managed_user_whitelist_specifics.proto b/sync/protocol/managed_user_whitelist_specifics.proto
new file mode 100644
index 0000000..e92dbfd
--- /dev/null
+++ b/sync/protocol/managed_user_whitelist_specifics.proto
@@ -0,0 +1,25 @@
+// Copyright (c) 2014 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 supervised user whitelists.
+
+// 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 supervised user whitelist sync objects.
+// The fields here are a subset of the fields in an ExtensionSpecifics.
+message ManagedUserWhitelistSpecifics {
+ // Globally unique id for this whitelist that identifies it in the Web Store.
+ optional string id = 1;
+
+ // The name of the whitelist.
+ optional string name = 2;
+}
diff --git a/sync/protocol/proto_value_conversions.cc b/sync/protocol/proto_value_conversions.cc
index 91a11e3..a9802c4 100644
--- a/sync/protocol/proto_value_conversions.cc
+++ b/sync/protocol/proto_value_conversions.cc
@@ -515,6 +515,14 @@ base::DictionaryValue* ManagedUserSharedSettingSpecificsToValue(
return value;
}
+base::DictionaryValue* ManagedUserWhitelistSpecificsToValue(
+ const sync_pb::ManagedUserWhitelistSpecifics& proto) {
+ base::DictionaryValue* value = new base::DictionaryValue();
+ SET_STR(id);
+ SET_STR(name);
+ return value;
+}
+
base::DictionaryValue* NigoriSpecificsToValue(
const sync_pb::NigoriSpecifics& proto) {
base::DictionaryValue* value = new base::DictionaryValue();
@@ -687,6 +695,7 @@ base::DictionaryValue* EntitySpecificsToValue(
SET_FIELD(managed_user_shared_setting,
ManagedUserSharedSettingSpecificsToValue);
SET_FIELD(managed_user, ManagedUserSpecificsToValue);
+ SET_FIELD(managed_user_whitelist, ManagedUserWhitelistSpecificsToValue);
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 aae3507..960ee45 100644
--- a/sync/protocol/proto_value_conversions.h
+++ b/sync/protocol/proto_value_conversions.h
@@ -49,6 +49,7 @@ class Media;
class ManagedUserSettingSpecifics;
class ManagedUserSharedSettingSpecifics;
class ManagedUserSpecifics;
+class ManagedUserWhitelistSpecifics;
class NavigationRedirect;
class NigoriSpecifics;
class PasswordSpecifics;
@@ -204,6 +205,10 @@ SYNC_EXPORT_PRIVATE base::DictionaryValue*
const sync_pb::ManagedUserSharedSettingSpecifics&
managed_user_shared_setting_specifics);
+SYNC_EXPORT_PRIVATE base::DictionaryValue* ManagedUserWhitelistSpecificsToValue(
+ const sync_pb::ManagedUserWhitelistSpecifics&
+ managed_user_whitelist_specifics);
+
SYNC_EXPORT_PRIVATE base::DictionaryValue* MediaToValue(
const sync_pb::Media& media);
diff --git a/sync/protocol/proto_value_conversions_unittest.cc b/sync/protocol/proto_value_conversions_unittest.cc
index 76aab6a..698da6b 100644
--- a/sync/protocol/proto_value_conversions_unittest.cc
+++ b/sync/protocol/proto_value_conversions_unittest.cc
@@ -26,6 +26,7 @@
#include "sync/protocol/managed_user_setting_specifics.pb.h"
#include "sync/protocol/managed_user_shared_setting_specifics.pb.h"
#include "sync/protocol/managed_user_specifics.pb.h"
+#include "sync/protocol/managed_user_whitelist_specifics.pb.h"
#include "sync/protocol/nigori_specifics.pb.h"
#include "sync/protocol/password_specifics.pb.h"
#include "sync/protocol/preference_specifics.pb.h"
@@ -56,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(33, MODEL_TYPE_COUNT);
+ EXPECT_EQ(34, 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
@@ -221,6 +222,10 @@ TEST_F(ProtoValueConversionsTest, ManagedUserSharedSettingSpecificsToValue) {
TestSpecificsToValue(ManagedUserSharedSettingSpecificsToValue);
}
+TEST_F(ProtoValueConversionsTest, ManagedUserWhitelistSpecificsToValue) {
+ TestSpecificsToValue(ManagedUserWhitelistSpecificsToValue);
+}
+
TEST_F(ProtoValueConversionsTest, NigoriSpecificsToValue) {
TestSpecificsToValue(NigoriSpecificsToValue);
}
@@ -295,6 +300,7 @@ TEST_F(ProtoValueConversionsTest, EntitySpecificsToValue) {
SET_FIELD(history_delete_directive);
SET_FIELD(managed_user_setting);
SET_FIELD(managed_user_shared_setting);
+ SET_FIELD(managed_user_whitelist);
SET_FIELD(managed_user);
SET_FIELD(nigori);
SET_FIELD(password);
diff --git a/sync/protocol/sync.proto b/sync/protocol/sync.proto
index 8974828..1687ea9 100644
--- a/sync/protocol/sync.proto
+++ b/sync/protocol/sync.proto
@@ -38,6 +38,7 @@ import "nigori_specifics.proto";
import "managed_user_setting_specifics.proto";
import "managed_user_shared_setting_specifics.proto";
import "managed_user_specifics.proto";
+import "managed_user_whitelist_specifics.proto";
import "password_specifics.proto";
import "preference_specifics.proto";
import "priority_preference_specifics.proto";
@@ -127,6 +128,7 @@ message EntitySpecifics {
optional ManagedUserSpecifics managed_user = 194582;
optional ManagedUserSharedSettingSpecifics managed_user_shared_setting =
202026;
+ optional ManagedUserWhitelistSpecifics managed_user_whitelist = 306060;
optional ArticleSpecifics article = 223759;
optional AppListSpecifics app_list = 229170;
optional WifiCredentialSpecifics wifi_credential = 218175;
diff --git a/sync/sync.gyp b/sync/sync.gyp
index 99478df..ea0d354 100644
--- a/sync/sync.gyp
+++ b/sync/sync.gyp
@@ -495,6 +495,7 @@
'protocol/managed_user_setting_specifics.proto',
'protocol/managed_user_shared_setting_specifics.proto',
'protocol/managed_user_specifics.proto',
+ 'protocol/managed_user_whitelist_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 5b92c78..321d546 100644
--- a/sync/syncable/model_type.cc
+++ b/sync/syncable/model_type.cc
@@ -44,7 +44,7 @@ const char* kUserSelectableDataTypeNames[] = {
};
COMPILE_ASSERT(
- 33 == MODEL_TYPE_COUNT,
+ 34 == MODEL_TYPE_COUNT,
update_kUserSelectableDataTypeNames_to_match_UserSelectableTypes);
void AddDefaultFieldValue(ModelType datatype,
@@ -138,6 +138,9 @@ void AddDefaultFieldValue(ModelType datatype,
case SUPERVISED_USER_SHARED_SETTINGS:
specifics->mutable_managed_user_shared_setting();
break;
+ case SUPERVISED_USER_WHITELISTS:
+ specifics->mutable_managed_user_whitelist();
+ break;
case ARTICLES:
specifics->mutable_article();
break;
@@ -219,6 +222,8 @@ int GetSpecificsFieldNumberFromModelType(ModelType model_type) {
return sync_pb::EntitySpecifics::kManagedUserFieldNumber;
case SUPERVISED_USER_SHARED_SETTINGS:
return sync_pb::EntitySpecifics::kManagedUserSharedSettingFieldNumber;
+ case SUPERVISED_USER_WHITELISTS:
+ return sync_pb::EntitySpecifics::kManagedUserWhitelistFieldNumber;
case ARTICLES:
return sync_pb::EntitySpecifics::kArticleFieldNumber;
case WIFI_CREDENTIALS:
@@ -348,6 +353,9 @@ ModelType GetModelTypeFromSpecifics(const sync_pb::EntitySpecifics& specifics) {
if (specifics.has_managed_user_shared_setting())
return SUPERVISED_USER_SHARED_SETTINGS;
+ if (specifics.has_managed_user_whitelist())
+ return SUPERVISED_USER_WHITELISTS;
+
if (specifics.has_article())
return ARTICLES;
@@ -429,6 +437,9 @@ ModelTypeSet EncryptableUserTypes() {
// Supervised user shared settings are not encrypted since they are managed
// server-side and shared between manager and supervised user.
encryptable_user_types.Remove(SUPERVISED_USER_SHARED_SETTINGS);
+ // Supervised user whitelists are not encrypted since they are managed
+ // server-side.
+ encryptable_user_types.Remove(SUPERVISED_USER_WHITELISTS);
// 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.
@@ -470,6 +481,7 @@ ModelTypeSet CoreTypes() {
result.Put(SYNCED_NOTIFICATIONS);
result.Put(SYNCED_NOTIFICATION_APP_INFO);
result.Put(SUPERVISED_USER_SHARED_SETTINGS);
+ result.Put(SUPERVISED_USER_WHITELISTS);
return result;
}
@@ -565,6 +577,8 @@ const char* ModelTypeToString(ModelType model_type) {
return "Managed Users";
case SUPERVISED_USER_SHARED_SETTINGS:
return "Managed User Shared Settings";
+ case SUPERVISED_USER_WHITELISTS:
+ return "Managed User Whitelists";
case ARTICLES:
return "Articles";
case WIFI_CREDENTIALS:
@@ -650,6 +664,8 @@ int ModelTypeToHistogramInt(ModelType model_type) {
return 31;
case WIFI_CREDENTIALS:
return 32;
+ case SUPERVISED_USER_WHITELISTS:
+ return 33;
// Silence a compiler warning.
case MODEL_TYPE_COUNT:
return 0;
@@ -741,6 +757,8 @@ ModelType ModelTypeFromString(const std::string& model_type_string) {
return SUPERVISED_USERS;
else if (model_type_string == "Managed User Shared Settings")
return SUPERVISED_USER_SHARED_SETTINGS;
+ else if (model_type_string == "Managed User Whitelists")
+ return SUPERVISED_USER_WHITELISTS;
else if (model_type_string == "Articles")
return ARTICLES;
else if (model_type_string == "WiFi Credentials")
@@ -867,6 +885,8 @@ std::string ModelTypeToRootTag(ModelType type) {
return "google_chrome_managed_users";
case SUPERVISED_USER_SHARED_SETTINGS:
return "google_chrome_managed_user_shared_settings";
+ case SUPERVISED_USER_WHITELISTS:
+ return "google_chrome_managed_user_whitelists";
case ARTICLES:
return "google_chrome_articles";
case WIFI_CREDENTIALS:
@@ -914,6 +934,8 @@ const char kSupervisedUserSettingNotificationType[] = "MANAGED_USER_SETTING";
const char kSupervisedUserNotificationType[] = "MANAGED_USER";
const char kSupervisedUserSharedSettingNotificationType[] =
"MANAGED_USER_SHARED_SETTING";
+const char kSupervisedUserWhitelistNotificationType[] =
+ "MANAGED_USER_WHITELIST";
const char kArticleNotificationType[] = "ARTICLE";
} // namespace
@@ -1004,6 +1026,9 @@ bool RealModelTypeToNotificationType(ModelType model_type,
case SUPERVISED_USER_SHARED_SETTINGS:
*notification_type = kSupervisedUserSharedSettingNotificationType;
return true;
+ case SUPERVISED_USER_WHITELISTS:
+ *notification_type = kSupervisedUserWhitelistNotificationType;
+ return true;
case ARTICLES:
*notification_type = kArticleNotificationType;
return true;
@@ -1101,6 +1126,9 @@ bool NotificationTypeToRealModelType(const std::string& notification_type,
kSupervisedUserSharedSettingNotificationType) {
*model_type = SUPERVISED_USER_SHARED_SETTINGS;
return true;
+ } else if (notification_type == kSupervisedUserWhitelistNotificationType) {
+ *model_type = SUPERVISED_USER_WHITELISTS;
+ return true;
} else if (notification_type == kArticleNotificationType) {
*model_type = ARTICLES;
return true;
diff --git a/sync/syncable/nigori_util.cc b/sync/syncable/nigori_util.cc
index eaf9eca..2731e7f 100644
--- a/sync/syncable/nigori_util.cc
+++ b/sync/syncable/nigori_util.cc
@@ -243,7 +243,7 @@ void UpdateNigoriFromEncryptedTypes(ModelTypeSet encrypted_types,
bool encrypt_everything,
sync_pb::NigoriSpecifics* nigori) {
nigori->set_encrypt_everything(encrypt_everything);
- COMPILE_ASSERT(33 == MODEL_TYPE_COUNT, UpdateEncryptedTypes);
+ COMPILE_ASSERT(34 == MODEL_TYPE_COUNT, UpdateEncryptedTypes);
nigori->set_encrypt_bookmarks(
encrypted_types.Has(BOOKMARKS));
nigori->set_encrypt_preferences(
@@ -279,7 +279,7 @@ ModelTypeSet GetEncryptedTypesFromNigori(
return ModelTypeSet::All();
ModelTypeSet encrypted_types;
- COMPILE_ASSERT(33 == MODEL_TYPE_COUNT, UpdateEncryptedTypes);
+ COMPILE_ASSERT(34 == MODEL_TYPE_COUNT, UpdateEncryptedTypes);
if (nigori.encrypt_bookmarks())
encrypted_types.Put(BOOKMARKS);
if (nigori.encrypt_preferences())
diff --git a/sync/util/data_type_histogram.h b/sync/util/data_type_histogram.h
index 1baaba3..49885a7 100644
--- a/sync/util/data_type_histogram.h
+++ b/sync/util/data_type_histogram.h
@@ -120,6 +120,9 @@
case ::syncer::SUPERVISED_USER_SHARED_SETTINGS: \
PER_DATA_TYPE_MACRO("ManagedUserSharedSetting"); \
break; \
+ case ::syncer::SUPERVISED_USER_WHITELISTS: \
+ PER_DATA_TYPE_MACRO("ManagedUserWhitelist"); \
+ break; \
case ::syncer::ARTICLES: \
PER_DATA_TYPE_MACRO("Article"); \
break; \