Commit 1bdf4140 authored by Marc Treib's avatar Marc Treib Committed by Commit Bot

Consent auditor: Add method RecordAccountPasswordsConsent()

This CL adds the plumbing in ConsentAuditor[Impl] to record this new
type of consent, and the corresponding sync proto messages. It's not
used so far; that will follow in another CL.

Bug: 1111252
Change-Id: Ib528273e88bfbd6546e6d1fc26c0884fef1e6e9d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2351923
Commit-Queue: Marc Treib <treib@chromium.org>
Reviewed-by: default avatarChristian Dullweber <dullweber@chromium.org>
Cr-Commit-Position: refs/heads/master@{#797365}
parent 483205f5
...@@ -5,15 +5,13 @@ ...@@ -5,15 +5,13 @@
#ifndef COMPONENTS_CONSENT_AUDITOR_CONSENT_AUDITOR_H_ #ifndef COMPONENTS_CONSENT_AUDITOR_CONSENT_AUDITOR_H_
#define COMPONENTS_CONSENT_AUDITOR_CONSENT_AUDITOR_H_ #define COMPONENTS_CONSENT_AUDITOR_CONSENT_AUDITOR_H_
#include <memory>
#include <string> #include <string>
#include <utility>
#include <vector>
#include "base/macros.h" #include "base/macros.h"
#include "base/memory/weak_ptr.h" #include "base/memory/weak_ptr.h"
#include "components/keyed_service/core/keyed_service.h" #include "components/keyed_service/core/keyed_service.h"
#include "components/sync/model/model_type_sync_bridge.h" #include "components/sync/model/model_type_controller_delegate.h"
#include "components/sync/protocol/user_consent_types.pb.h"
#include "google_apis/gaia/core_account_id.h" #include "google_apis/gaia/core_account_id.h"
namespace consent_auditor { namespace consent_auditor {
...@@ -82,6 +80,12 @@ class ConsentAuditor : public KeyedService { ...@@ -82,6 +80,12 @@ class ConsentAuditor : public KeyedService {
const sync_pb::UserConsentTypes::AssistantActivityControlConsent& const sync_pb::UserConsentTypes::AssistantActivityControlConsent&
consent) = 0; consent) = 0;
// Records the |consent| to download and use passwords from the signed-in GAIA
// account with the ID |account_id| (as defined in AccountInfo).
virtual void RecordAccountPasswordsConsent(
const CoreAccountId& account_id,
const sync_pb::UserConsentTypes::AccountPasswordsConsent& consent) = 0;
// Records that the user consented to a |feature|. The user was presented with // Records that the user consented to a |feature|. The user was presented with
// |description_text| and accepted it by interacting |confirmation_text| // |description_text| and accepted it by interacting |confirmation_text|
// (e.g. clicking on a button; empty if not applicable). // (e.g. clicking on a button; empty if not applicable).
......
...@@ -131,6 +131,16 @@ void ConsentAuditorImpl::RecordAssistantActivityControlConsent( ...@@ -131,6 +131,16 @@ void ConsentAuditorImpl::RecordAssistantActivityControlConsent(
consent_sync_bridge_->RecordConsent(std::move(specifics)); consent_sync_bridge_->RecordConsent(std::move(specifics));
} }
void ConsentAuditorImpl::RecordAccountPasswordsConsent(
const CoreAccountId& account_id,
const sync_pb::UserConsentTypes::AccountPasswordsConsent& consent) {
std::unique_ptr<sync_pb::UserConsentSpecifics> specifics =
CreateUserConsentSpecifics(account_id, app_locale_, clock_);
specifics->mutable_account_passwords_consent()->CopyFrom(consent);
consent_sync_bridge_->RecordConsent(std::move(specifics));
}
void ConsentAuditorImpl::RecordLocalConsent( void ConsentAuditorImpl::RecordLocalConsent(
const std::string& feature, const std::string& feature,
const std::string& description_text, const std::string& description_text,
......
...@@ -14,12 +14,6 @@ ...@@ -14,12 +14,6 @@
#include "base/time/clock.h" #include "base/time/clock.h"
#include "components/consent_auditor/consent_auditor.h" #include "components/consent_auditor/consent_auditor.h"
#include "components/consent_auditor/consent_sync_bridge.h" #include "components/consent_auditor/consent_sync_bridge.h"
#include "components/keyed_service/core/keyed_service.h"
#include "components/sync/model/model_type_sync_bridge.h"
namespace sync_pb {
class UserConsentSpecifics;
} // namespace sync_pb
class PrefService; class PrefService;
class PrefRegistrySimple; class PrefRegistrySimple;
...@@ -60,6 +54,10 @@ class ConsentAuditorImpl : public ConsentAuditor { ...@@ -60,6 +54,10 @@ class ConsentAuditorImpl : public ConsentAuditor {
const CoreAccountId& account_id, const CoreAccountId& account_id,
const sync_pb::UserConsentTypes::AssistantActivityControlConsent& consent) const sync_pb::UserConsentTypes::AssistantActivityControlConsent& consent)
override; override;
void RecordAccountPasswordsConsent(
const CoreAccountId& account_id,
const sync_pb::UserConsentTypes::AccountPasswordsConsent& consent)
override;
void RecordLocalConsent(const std::string& feature, void RecordLocalConsent(const std::string& feature,
const std::string& description_text, const std::string& description_text,
const std::string& confirmation_text) override; const std::string& confirmation_text) override;
...@@ -67,13 +65,6 @@ class ConsentAuditorImpl : public ConsentAuditor { ...@@ -67,13 +65,6 @@ class ConsentAuditorImpl : public ConsentAuditor {
override; override;
private: private:
std::unique_ptr<sync_pb::UserConsentSpecifics> ConstructUserConsentSpecifics(
const CoreAccountId& account_id,
Feature feature,
const std::vector<int>& description_grd_ids,
int confirmation_grd_id,
ConsentStatus status);
PrefService* pref_service_; PrefService* pref_service_;
std::unique_ptr<ConsentSyncBridge> consent_sync_bridge_; std::unique_ptr<ConsentSyncBridge> consent_sync_bridge_;
std::string app_version_; std::string app_version_;
......
...@@ -27,9 +27,9 @@ consent_auditor::ConsentStatus ConvertConsentStatus( ...@@ -27,9 +27,9 @@ consent_auditor::ConsentStatus ConvertConsentStatus(
namespace consent_auditor { namespace consent_auditor {
FakeConsentAuditor::FakeConsentAuditor() {} FakeConsentAuditor::FakeConsentAuditor() = default;
FakeConsentAuditor::~FakeConsentAuditor() {} FakeConsentAuditor::~FakeConsentAuditor() = default;
void FakeConsentAuditor::RecordSyncConsent( void FakeConsentAuditor::RecordSyncConsent(
const CoreAccountId& account_id, const CoreAccountId& account_id,
...@@ -49,6 +49,12 @@ void FakeConsentAuditor::RecordAssistantActivityControlConsent( ...@@ -49,6 +49,12 @@ void FakeConsentAuditor::RecordAssistantActivityControlConsent(
NOTIMPLEMENTED(); NOTIMPLEMENTED();
} }
void FakeConsentAuditor::RecordAccountPasswordsConsent(
const CoreAccountId& account_id,
const sync_pb::UserConsentTypes::AccountPasswordsConsent& consent) {
NOTIMPLEMENTED();
}
void FakeConsentAuditor::RecordGaiaConsent( void FakeConsentAuditor::RecordGaiaConsent(
const CoreAccountId& account_id, const CoreAccountId& account_id,
consent_auditor::Feature feature, consent_auditor::Feature feature,
......
...@@ -41,6 +41,10 @@ class FakeConsentAuditor : public ConsentAuditor { ...@@ -41,6 +41,10 @@ class FakeConsentAuditor : public ConsentAuditor {
const CoreAccountId& account_id, const CoreAccountId& account_id,
const sync_pb::UserConsentTypes::AssistantActivityControlConsent& consent) const sync_pb::UserConsentTypes::AssistantActivityControlConsent& consent)
override; override;
void RecordAccountPasswordsConsent(
const CoreAccountId& account_id,
const sync_pb::UserConsentTypes::AccountPasswordsConsent& consent)
override;
void RecordLocalConsent(const std::string& feature, void RecordLocalConsent(const std::string& feature,
const std::string& description_text, const std::string& description_text,
......
...@@ -1038,6 +1038,7 @@ VISIT_PROTO_FIELDS(const sync_pb::UserConsentSpecifics& proto) { ...@@ -1038,6 +1038,7 @@ VISIT_PROTO_FIELDS(const sync_pb::UserConsentSpecifics& proto) {
VISIT(arc_backup_and_restore_consent); VISIT(arc_backup_and_restore_consent);
VISIT(arc_location_service_consent); VISIT(arc_location_service_consent);
VISIT(arc_play_terms_of_service_consent); VISIT(arc_play_terms_of_service_consent);
VISIT(account_passwords_consent);
} }
VISIT_PROTO_FIELDS( VISIT_PROTO_FIELDS(
...@@ -1072,6 +1073,13 @@ VISIT_PROTO_FIELDS(const sync_pb::UserConsentTypes::UnifiedConsent& proto) { ...@@ -1072,6 +1073,13 @@ VISIT_PROTO_FIELDS(const sync_pb::UserConsentTypes::UnifiedConsent& proto) {
VISIT_ENUM(status); VISIT_ENUM(status);
} }
VISIT_PROTO_FIELDS(
const sync_pb::UserConsentTypes::AccountPasswordsConsent& proto) {
VISIT_REP(description_grd_ids);
VISIT(confirmation_grd_id);
VISIT_ENUM(status);
}
VISIT_PROTO_FIELDS(const sync_pb::UserEventSpecifics& proto) { VISIT_PROTO_FIELDS(const sync_pb::UserEventSpecifics& proto) {
VISIT(event_time_usec); VISIT(event_time_usec);
VISIT(navigation_id); VISIT(navigation_id);
......
...@@ -57,6 +57,8 @@ message UserConsentSpecifics { ...@@ -57,6 +57,8 @@ message UserConsentSpecifics {
UserConsentTypes.AssistantActivityControlConsent UserConsentTypes.AssistantActivityControlConsent
assistant_activity_control_consent = 14; assistant_activity_control_consent = 14;
UserConsentTypes.AccountPasswordsConsent account_passwords_consent = 15;
} }
reserved "arc_metrics_and_usage_consent"; reserved "arc_metrics_and_usage_consent";
reserved 11; reserved 11;
......
...@@ -136,4 +136,19 @@ message UserConsentTypes { ...@@ -136,4 +136,19 @@ message UserConsentTypes {
// whether the consent was given or not given. // whether the consent was given or not given.
optional ConsentStatus status = 2; optional ConsentStatus status = 2;
} }
// The User Consent for downloading and using passwords stored in the user's
// Google Account. Determined during the opt-in flow for the feature.
message AccountPasswordsConsent {
// Ids of the strings of the 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
// the consent dialog.
optional int32 confirmation_grd_id = 2;
// The status of the consent. This specifies whether the consent was given
// or not given/revoked.
optional ConsentStatus status = 3;
}
} }
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