Commit f0998a8a authored by vitaliii's avatar vitaliii Committed by Commit Bot

[Sync] Add consent_specifics proto.

Add consent_specifics proto as a preparation for separation of consents
into a separate model type from user events. The proto is based on
UserEventSpecifics::UserConsent. The proto has to land before the actual
split itself, so that the server is aware of the new datatype.

Bug: 840357
Change-Id: I2d3ab6575990d081315a93725fb5cee655af63b9
Reviewed-on: https://chromium-review.googlesource.com/1055567Reviewed-by: default avatarMikel Astiz <mastiz@chromium.org>
Reviewed-by: default avatarMarkus Heintz <markusheintz@chromium.org>
Commit-Queue: vitaliii <vitaliii@chromium.org>
Cr-Commit-Position: refs/heads/master@{#559453}
parent dc39f455
......@@ -295,6 +295,33 @@ const char* ProtoEnumToString(sync_pb::TabNavigation::PasswordState state) {
return "";
}
const char* ProtoEnumToString(sync_pb::UserConsentSpecifics::Feature feature) {
ASSERT_ENUM_BOUNDS(sync_pb::UserConsentSpecifics, Feature,
FEATURE_UNSPECIFIED, GOOGLE_LOCATION_SERVICE);
switch (feature) {
ENUM_CASE(sync_pb::UserConsentSpecifics, FEATURE_UNSPECIFIED);
ENUM_CASE(sync_pb::UserConsentSpecifics, CHROME_SYNC);
ENUM_CASE(sync_pb::UserConsentSpecifics, PLAY_STORE);
ENUM_CASE(sync_pb::UserConsentSpecifics, BACKUP_AND_RESTORE);
ENUM_CASE(sync_pb::UserConsentSpecifics, GOOGLE_LOCATION_SERVICE);
}
NOTREACHED();
return "";
}
const char* ProtoEnumToString(
sync_pb::UserConsentSpecifics::ConsentStatus status) {
ASSERT_ENUM_BOUNDS(sync_pb::UserConsentSpecifics, ConsentStatus,
CONSENT_STATUS_UNSPECIFIED, GIVEN);
switch (status) {
ENUM_CASE(sync_pb::UserConsentSpecifics, CONSENT_STATUS_UNSPECIFIED);
ENUM_CASE(sync_pb::UserConsentSpecifics, NOT_GIVEN);
ENUM_CASE(sync_pb::UserConsentSpecifics, GIVEN);
}
NOTREACHED();
return "";
}
const char* ProtoEnumToString(
sync_pb::UserEventSpecifics::Translation::Interaction interaction) {
ASSERT_ENUM_BOUNDS(sync_pb::UserEventSpecifics::Translation, Interaction,
......
......@@ -65,6 +65,11 @@ const char* ProtoEnumToString(sync_pb::TabNavigation::BlockedState state);
const char* ProtoEnumToString(sync_pb::TabNavigation::PasswordState state);
const char* ProtoEnumToString(sync_pb::UserConsentSpecifics::Feature feature);
const char* ProtoEnumToString(
sync_pb::UserConsentSpecifics::ConsentStatus status);
const char* ProtoEnumToString(
sync_pb::UserEventSpecifics::Translation::Interaction interaction);
......
......@@ -349,6 +349,7 @@ IMPLEMENT_PROTO_TO_VALUE(TabNavigation)
IMPLEMENT_PROTO_TO_VALUE(ThemeSpecifics)
IMPLEMENT_PROTO_TO_VALUE(TimeRangeDirective)
IMPLEMENT_PROTO_TO_VALUE(TypedUrlSpecifics)
IMPLEMENT_PROTO_TO_VALUE(UserConsentSpecifics)
IMPLEMENT_PROTO_TO_VALUE(UserEventSpecifics)
IMPLEMENT_PROTO_TO_VALUE(WalletMaskedCreditCard)
IMPLEMENT_PROTO_TO_VALUE(WalletMetadataSpecifics)
......
......@@ -68,6 +68,7 @@ class TabNavigation;
class ThemeSpecifics;
class TimeRangeDirective;
class TypedUrlSpecifics;
class UserConsentSpecifics;
class UserEventSpecifics;
class WalletMaskedCreditCard;
class WalletMetadataSpecifics;
......@@ -248,6 +249,9 @@ std::unique_ptr<base::DictionaryValue> TimeRangeDirectiveToValue(
std::unique_ptr<base::DictionaryValue> TypedUrlSpecificsToValue(
const sync_pb::TypedUrlSpecifics& typed_url_specifics);
std::unique_ptr<base::DictionaryValue> UserConsentSpecificsToValue(
const sync_pb::UserConsentSpecifics& user_consent_specifics);
std::unique_ptr<base::DictionaryValue> UserEventSpecificsToValue(
const sync_pb::UserEventSpecifics& user_event_specifics);
......
......@@ -346,6 +346,10 @@ TEST_F(ProtoValueConversionsTest, TypedUrlSpecificsToValue) {
TestSpecificsToValue(TypedUrlSpecificsToValue);
}
TEST_F(ProtoValueConversionsTest, UserConsentSpecificsToValue) {
TestSpecificsToValue(UserConsentSpecificsToValue);
}
TEST_F(ProtoValueConversionsTest, UserEventSpecificsToValue) {
TestSpecificsToValue(UserEventSpecificsToValue);
}
......
......@@ -36,6 +36,7 @@
#include "components/sync/protocol/theme_specifics.pb.h"
#include "components/sync/protocol/typed_url_specifics.pb.h"
#include "components/sync/protocol/unique_position.pb.h"
#include "components/sync/protocol/user_consent_specifics.pb.h"
#include "components/sync/protocol/user_event_specifics.pb.h"
// This file implements VisitProtoFields() functions for sync protos.
......@@ -401,6 +402,7 @@ VISIT_PROTO_FIELDS(const sync_pb::EntitySpecifics& proto) {
VISIT(synced_notification_app_info);
VISIT(theme);
VISIT(typed_url);
VISIT(user_consent);
VISIT(user_event);
VISIT(wallet_metadata);
VISIT(wifi_credential);
......@@ -906,6 +908,53 @@ VISIT_PROTO_FIELDS(const sync_pb::UniquePosition& proto) {
VISIT_BYTES(custom_compressed_v1);
}
VISIT_PROTO_FIELDS(const sync_pb::UserConsentSpecifics& proto) {
VISIT_ENUM(feature);
VISIT_REP(description_grd_ids);
VISIT(confirmation_grd_id);
VISIT(locale);
VISIT_ENUM(status);
VISIT(account_id);
VISIT(sync_consent);
VISIT(arc_backup_and_restore_consent);
VISIT(arc_location_service_consent);
VISIT(arc_play_terms_of_service_consent);
VISIT(arc_metrics_and_usage_consent);
}
VISIT_PROTO_FIELDS(
const sync_pb::UserConsentSpecifics::ArcBackupAndRestoreConsent& proto) {
VISIT_REP(description_grd_ids);
VISIT_ENUM(status);
}
VISIT_PROTO_FIELDS(
const sync_pb::UserConsentSpecifics::ArcGoogleLocationServiceConsent&
proto) {
VISIT_REP(description_grd_ids);
VISIT_ENUM(status);
}
VISIT_PROTO_FIELDS(
const sync_pb::UserConsentSpecifics::ArcMetricsAndUsageConsent& proto) {
VISIT_REP(description_grd_ids);
VISIT_ENUM(status);
}
VISIT_PROTO_FIELDS(
const sync_pb::UserConsentSpecifics::ArcPlayTermsOfServiceConsent& proto) {
VISIT(play_terms_of_service_text_length);
VISIT(play_terms_of_service_hash);
VISIT(confirmation_grd_id);
VISIT_ENUM(status);
}
VISIT_PROTO_FIELDS(const sync_pb::UserConsentSpecifics::SyncConsent& proto) {
VISIT_REP(description_grd_ids);
VISIT(confirmation_grd_id);
VISIT_ENUM(status);
}
VISIT_PROTO_FIELDS(const sync_pb::UserEventSpecifics& proto) {
VISIT(event_time_usec);
VISIT(navigation_id);
......
......@@ -27,13 +27,13 @@ sync_protocol_sources = [
"//components/sync/protocol/history_delete_directive_specifics.proto",
"//components/sync/protocol/history_status.proto",
"//components/sync/protocol/loopback_server.proto",
"//components/sync/protocol/nigori_specifics.proto",
"//components/sync/protocol/managed_user_setting_specifics.proto",
"//components/sync/protocol/managed_user_shared_setting_specifics.proto",
"//components/sync/protocol/managed_user_specifics.proto",
"//components/sync/protocol/managed_user_whitelist_specifics.proto",
"//components/sync/protocol/model_type_state.proto",
"//components/sync/protocol/model_type_store_schema_descriptor.proto",
"//components/sync/protocol/nigori_specifics.proto",
"//components/sync/protocol/password_specifics.proto",
"//components/sync/protocol/preference_specifics.proto",
"//components/sync/protocol/printer_specifics.proto",
......@@ -49,6 +49,7 @@ sync_protocol_sources = [
"//components/sync/protocol/theme_specifics.proto",
"//components/sync/protocol/typed_url_specifics.proto",
"//components/sync/protocol/unique_position.proto",
"//components/sync/protocol/user_consent_specifics.proto",
"//components/sync/protocol/user_event_specifics.proto",
"//components/sync/protocol/wifi_credential_specifics.proto",
]
......@@ -33,11 +33,11 @@ import "favicon_image_specifics.proto";
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 "managed_user_shared_setting_specifics.proto";
import "managed_user_specifics.proto";
import "managed_user_whitelist_specifics.proto";
import "nigori_specifics.proto";
import "password_specifics.proto";
import "preference_specifics.proto";
import "printer_specifics.proto";
......@@ -51,6 +51,7 @@ import "synced_notification_specifics.proto";
import "theme_specifics.proto";
import "typed_url_specifics.proto";
import "unique_position.proto";
import "user_consent_specifics.proto";
import "user_event_specifics.proto";
import "wifi_credential_specifics.proto";
......@@ -141,6 +142,7 @@ message EntitySpecifics {
optional PrinterSpecifics printer = 410745;
optional ReadingListSpecifics reading_list = 411028;
optional UserEventSpecifics user_event = 455206;
optional UserConsentSpecifics user_consent = 556014;
}
message SyncEntity {
......
// Copyright 2018 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 user consents.
// If you change or add any fields in this file, update proto_visitors.h and
// potentially proto_enum_conversions.{h, cc}.
syntax = "proto2";
option optimize_for = LITE_RUNTIME;
package sync_pb;
// Next id: 13
message UserConsentSpecifics {
// ===========================================================================
// Fields common to all Chrome User Consents.
// ===========================================================================
// The UI language Chrome is using, represented as the IETF language tag
// defined in BCP 47. The region subtag is not included when it adds no
// distinguishing information to the language tag (e.g. both "en-US"
// and "fr" are correct here).
optional string locale = 4;
// The local time on the client when the user consent was recorded. The time
// as measured by client is given in microseconds since Windows epoch. This
// is needed since user consent recording may happen when a client is
// offline.
optional int64 client_consent_time_usec = 12;
// ===========================================================================
// Common messages and enums used by multiple user consent types.
// ===========================================================================
// The status of a particular User Consent. The status describes the state
// of the consent as it is: given, not_given.
enum ConsentStatus {
// The status is unspecified e.g. because the user was not asked to
// consent yet or an error happened or the decision was delayed.
CONSENT_STATUS_UNSPECIFIED = 0;
// The consent is not given. This means the user either revoked the
// consent or did not grant it in the first place.
NOT_GIVEN = 1;
// The consent is given. This means the user did grant the consent.
GIVEN = 2;
}
// ===========================================================================
// The specific Chrome User Consent types. Add new User Consent types here
// and keep them sorted alphabetically.
// ===========================================================================
// The user consent for the ARC Backup And Restore feature. The consent
// status is determined by the corresponding setting on the ARC setup dialog.
message ArcBackupAndRestoreConsent {
// Ids of the strings of the setting text presented to the user.
repeated int32 description_grd_ids = 1;
// Id of the string of the UI element the user clicked when consenting.
optional int32 confirmation_grd_id = 2;
optional ConsentStatus status = 3;
}
// The user consent for the Google Location Service. The consent status is
// determined by the corresponding setting on the ARC setup dialog.
message ArcGoogleLocationServiceConsent {
// Ids of the strings of the setting text presented to the user.
repeated int32 description_grd_ids = 1;
// Id of the string of the UI element the user clicked when consenting.
optional int32 confirmation_grd_id = 2;
optional ConsentStatus status = 3;
}
// The user consent for Metrics and Usage reporting on Android for Chrome OS.
message ArcMetricsAndUsageConsent {
// Ids of the strings of the setting text presented to the user.
repeated int32 description_grd_ids = 1;
// Id of the string of the UI element the user clicked when consenting.
optional int32 confirmation_grd_id = 2;
optional ConsentStatus status = 3;
}
// The user consent for the Play terms of service is determined by the user
// action on the ARC setup dialog that presents the Play Terms of Service.
message ArcPlayTermsOfServiceConsent {
// The length of the UTF-8 encoded string of the Play Terms of Service
// text. The length is given in number of bytes.
optional int32 play_terms_of_service_text_length = 1;
// The SHA1 hash of UTF-8 encoded string of the Play Terms of Service
// displayed to the user.
optional bytes play_terms_of_service_hash = 2;
// Id of the string of the UI element the user clicked when consenting.
optional int32 confirmation_grd_id = 3;
// The status of the Play Terms of Service consent. This specifies whether
// the consent was given or not given/revoked.
optional ConsentStatus status = 4;
}
// The User Consent for Chrome Sync is determined by the user action on the
// corresponding Sync Consent dialog.
message SyncConsent {
// Ids of the strings of the sync consent text presented to the user.
repeated int32 description_grd_ids = 1;
// Id of the string of the UI element the user clicked in order to confirm
// and close the sync consent dialog.
optional int32 confirmation_grd_id = 2;
// The status of the sync consent. This specifies whether the consent was
// given or not given/revoked.
optional ConsentStatus status = 3;
}
// The specific consent type.
oneof consent {
SyncConsent sync_consent = 7;
ArcBackupAndRestoreConsent arc_backup_and_restore_consent = 8;
ArcGoogleLocationServiceConsent arc_location_service_consent = 9;
ArcPlayTermsOfServiceConsent arc_play_terms_of_service_consent = 10;
ArcMetricsAndUsageConsent arc_metrics_and_usage_consent = 11;
}
// ===========================================================================
// Client only fields.
// ===========================================================================
// TODO(markusheintz): Refactor the code so that these fields can be moved out
// of this message.
// The account ID of the user who gave the consent. This field is used
// by UserEventService to distinguish consents from different users,
// as UserConsent does not get deleted when a user signs out. However,
// it should be cleared before being sent over the wire, as the UserEvent
// is sent over an authenticated channel, so this information would be
// redundant.
//
// For semantics and usage of the |account_id| in the signin codebase,
// see SigninManagerBase::GetAuthenticatedAccountId()
// or AccountInfo::account_id.
optional string account_id = 6;
// ===========================================================================
// Deprecated fields. Please do not use them !
// ===========================================================================
// TODO(vitaliii): Deprecate them completely once the USER_CONSENTS bridge
// uses the fields above instead.
// Which feature does the consent apply to?
enum Feature {
FEATURE_UNSPECIFIED = 0;
CHROME_SYNC = 1;
PLAY_STORE = 2;
BACKUP_AND_RESTORE = 3;
GOOGLE_LOCATION_SERVICE = 4;
}
optional Feature feature = 1 [deprecated = true];
// Ids of the strings of the consent text presented to the user.
repeated int32 description_grd_ids = 2 [deprecated = true];
// Id of the string of the UI element the user clicked when consenting.
optional int32 confirmation_grd_id = 3 [deprecated = true];
// Was the consent for |feature| given or not given (denied/revoked)?
optional ConsentStatus status = 5 [deprecated = true];
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment