1 // Copyright 2018 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #include <string>
6 #include <utility>
7 
8 #include "components/consent_auditor/consent_auditor.h"
9 #include "components/consent_auditor/fake_consent_auditor.h"
10 
11 namespace {
12 
ConvertConsentStatus(sync_pb::UserConsentTypes::ConsentStatus consent_status)13 consent_auditor::ConsentStatus ConvertConsentStatus(
14     sync_pb::UserConsentTypes::ConsentStatus consent_status) {
15   DCHECK_NE(consent_status,
16             sync_pb::UserConsentTypes::ConsentStatus::
17                 UserConsentTypes_ConsentStatus_CONSENT_STATUS_UNSPECIFIED);
18 
19   if (consent_status == sync_pb::UserConsentTypes::ConsentStatus::
20                             UserConsentTypes_ConsentStatus_GIVEN) {
21     return consent_auditor::ConsentStatus::GIVEN;
22   }
23   return consent_auditor::ConsentStatus::NOT_GIVEN;
24 }
25 
26 }  // namespace
27 
28 namespace consent_auditor {
29 
FakeConsentAuditor()30 FakeConsentAuditor::FakeConsentAuditor() {}
31 
~FakeConsentAuditor()32 FakeConsentAuditor::~FakeConsentAuditor() {}
33 
RecordSyncConsent(const CoreAccountId & account_id,const sync_pb::UserConsentTypes::SyncConsent & consent)34 void FakeConsentAuditor::RecordSyncConsent(
35     const CoreAccountId& account_id,
36     const sync_pb::UserConsentTypes::SyncConsent& consent) {
37   // TODO(markusheintz): Change the Fake to store the proto instead of calling
38   // RecordGaiaConsent.
39   std::vector<int> description_grd_ids(consent.description_grd_ids().begin(),
40                                        consent.description_grd_ids().end());
41   RecordGaiaConsent(account_id, Feature::CHROME_SYNC, description_grd_ids,
42                     consent.confirmation_grd_id(),
43                     ConvertConsentStatus(consent.status()));
44 }
45 
RecordAssistantActivityControlConsent(const CoreAccountId & account_id,const sync_pb::UserConsentTypes::AssistantActivityControlConsent & consent)46 void FakeConsentAuditor::RecordAssistantActivityControlConsent(
47     const CoreAccountId& account_id,
48     const sync_pb::UserConsentTypes::AssistantActivityControlConsent& consent) {
49   NOTIMPLEMENTED();
50 }
51 
RecordGaiaConsent(const CoreAccountId & account_id,consent_auditor::Feature feature,const std::vector<int> & description_grd_ids,int confirmation_grd_id,consent_auditor::ConsentStatus status)52 void FakeConsentAuditor::RecordGaiaConsent(
53     const CoreAccountId& account_id,
54     consent_auditor::Feature feature,
55     const std::vector<int>& description_grd_ids,
56     int confirmation_grd_id,
57     consent_auditor::ConsentStatus status) {
58   account_id_ = account_id;
59   recorded_id_vectors_.push_back(description_grd_ids);
60   recorded_confirmation_ids_.push_back(confirmation_grd_id);
61   recorded_features_.push_back(feature);
62   recorded_statuses_.push_back(status);
63 }
64 
RecordLocalConsent(const std::string & feature,const std::string & description_text,const std::string & confirmation_text)65 void FakeConsentAuditor::RecordLocalConsent(
66     const std::string& feature,
67     const std::string& description_text,
68     const std::string& confirmation_text) {
69   NOTIMPLEMENTED();
70 }
71 
72 base::WeakPtr<syncer::ModelTypeControllerDelegate>
GetControllerDelegate()73 FakeConsentAuditor::GetControllerDelegate() {
74   NOTIMPLEMENTED();
75   return nullptr;
76 }
77 
78 }  // namespace consent_auditor
79