1 // Copyright (c) 2013 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 CHROME_BROWSER_CHROMEOS_ATTESTATION_ATTESTATION_POLICY_OBSERVER_H_ 6 #define CHROME_BROWSER_CHROMEOS_ATTESTATION_ATTESTATION_POLICY_OBSERVER_H_ 7 8 #include <memory> 9 #include <string> 10 11 #include "base/callback.h" 12 #include "base/macros.h" 13 #include "base/memory/weak_ptr.h" 14 #include "chrome/browser/chromeos/settings/cros_settings.h" 15 #include "chromeos/dbus/constants/attestation_constants.h" 16 17 namespace chromeos { 18 namespace attestation { 19 20 class MachineCertificateUploader; 21 22 // A class which observes policy changes and uploads a certificate if necessary. 23 class AttestationPolicyObserver { 24 public: 25 // The observer immediately connects with CrosSettings to listen for policy 26 // changes. The CertificateUploader is used to obtain and upload a 27 // certificate. This class does not take ownership of |certificate_uploader|. 28 explicit AttestationPolicyObserver( 29 MachineCertificateUploader* certificate_uploader); 30 31 ~AttestationPolicyObserver(); 32 33 private: 34 // Called when the attestation setting changes. 35 void AttestationSettingChanged(); 36 37 // Checks attestation policy and starts any necessary work. 38 void Start(); 39 40 CrosSettings* cros_settings_; 41 MachineCertificateUploader* certificate_uploader_; 42 43 std::unique_ptr<CrosSettings::ObserverSubscription> attestation_subscription_; 44 45 DISALLOW_COPY_AND_ASSIGN(AttestationPolicyObserver); 46 }; 47 48 } // namespace attestation 49 } // namespace chromeos 50 51 #endif // CHROME_BROWSER_CHROMEOS_ATTESTATION_ATTESTATION_POLICY_OBSERVER_H_ 52