1 // Copyright 2017 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 #ifndef COMPONENTS_CONSENT_AUDITOR_CONSENT_AUDITOR_H_ 6 #define COMPONENTS_CONSENT_AUDITOR_CONSENT_AUDITOR_H_ 7 8 #include <memory> 9 #include <string> 10 #include <utility> 11 #include <vector> 12 13 #include "base/macros.h" 14 #include "base/memory/weak_ptr.h" 15 #include "components/keyed_service/core/keyed_service.h" 16 #include "components/sync/model/model_type_sync_bridge.h" 17 #include "google_apis/gaia/core_account_id.h" 18 19 namespace consent_auditor { 20 21 // Feature for which a consent moment is to be recorded. 22 // 23 // This enum is used in histograms. Entries should not be renumbered and 24 // numeric values should never be reused. 25 // 26 // A Java counterpart will be generated for this enum. 27 // GENERATED_JAVA_ENUM_PACKAGE: org.chromium.chrome.browser.consent_auditor 28 // GENERATED_JAVA_CLASS_NAME_OVERRIDE: ConsentAuditorFeature 29 enum class Feature { 30 CHROME_SYNC = 0, 31 PLAY_STORE = 1, 32 BACKUP_AND_RESTORE = 2, 33 GOOGLE_LOCATION_SERVICE = 3, 34 // CHROME_UNIFIED_CONSENT = 4, (deprecated, not used) 35 ASSISTANT_ACTIVITY_CONTROL = 5, 36 37 FEATURE_LAST = ASSISTANT_ACTIVITY_CONTROL 38 }; 39 40 // Whether a consent is given or not given. 41 // 42 // A Java counterpart will be generated for this enum. 43 // GENERATED_JAVA_ENUM_PACKAGE: org.chromium.chrome.browser.consent_auditor 44 enum class ConsentStatus { NOT_GIVEN, GIVEN }; 45 46 // TODO(markusheintz): Document this class. 47 class ConsentAuditor : public KeyedService { 48 public: 49 ConsentAuditor() = default; 50 ~ConsentAuditor() override = default; 51 52 // Records the ARC Play |consent| for the signed-in GAIA account with the ID 53 // |account_id| (as defined in AccountInfo). 54 virtual void RecordArcPlayConsent( 55 const CoreAccountId& account_id, 56 const sync_pb::UserConsentTypes::ArcPlayTermsOfServiceConsent& 57 consent) = 0; 58 59 // Records the ARC Google Location Service |consent| for the signed-in GAIA 60 // account with the ID |account_id| (as defined in AccountInfo). 61 virtual void RecordArcGoogleLocationServiceConsent( 62 const CoreAccountId& account_id, 63 const sync_pb::UserConsentTypes::ArcGoogleLocationServiceConsent& 64 consent) = 0; 65 66 // Records the ARC Backup and Restore |consent| for the signed-in GAIA 67 // account with the ID |account_id| (as defined in AccountInfo). 68 virtual void RecordArcBackupAndRestoreConsent( 69 const CoreAccountId& account_id, 70 const sync_pb::UserConsentTypes::ArcBackupAndRestoreConsent& consent) = 0; 71 72 // Records the Sync |consent| for the signed-in GAIA account with the ID 73 // |account_id| (as defined in AccountInfo). 74 virtual void RecordSyncConsent( 75 const CoreAccountId& account_id, 76 const sync_pb::UserConsentTypes::SyncConsent& consent) = 0; 77 78 // Records the Assistant activity control |consent| for the signed-in GAIA 79 // account with the ID |accounts_id| (as defined in Account Info). 80 virtual void RecordAssistantActivityControlConsent( 81 const CoreAccountId& account_id, 82 const sync_pb::UserConsentTypes::AssistantActivityControlConsent& 83 consent) = 0; 84 85 // Records that the user consented to a |feature|. The user was presented with 86 // |description_text| and accepted it by interacting |confirmation_text| 87 // (e.g. clicking on a button; empty if not applicable). 88 // Returns true if successful. 89 virtual void RecordLocalConsent(const std::string& feature, 90 const std::string& description_text, 91 const std::string& confirmation_text) = 0; 92 93 // Returns the underlying Sync integration point. 94 virtual base::WeakPtr<syncer::ModelTypeControllerDelegate> 95 GetControllerDelegate() = 0; 96 97 private: 98 DISALLOW_COPY_AND_ASSIGN(ConsentAuditor); 99 }; 100 101 } // namespace consent_auditor 102 103 #endif // COMPONENTS_CONSENT_AUDITOR_CONSENT_AUDITOR_H_ 104