Chromium Code Reviews| Index: chrome/browser/chromeos/attestation/attestation_policy_observer.h |
| diff --git a/chrome/browser/chromeos/attestation/attestation_policy_observer.h b/chrome/browser/chromeos/attestation/attestation_policy_observer.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..aad46f9f3334abf4e8a8014588ee19908e282a94 |
| --- /dev/null |
| +++ b/chrome/browser/chromeos/attestation/attestation_policy_observer.h |
| @@ -0,0 +1,86 @@ |
| +// Copyright (c) 2013 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. |
| + |
| +#ifndef CHROME_BROWSER_CHROMEOS_ATTESTATION_ATTESTATION_POLICY_OBSERVER_H_ |
| +#define CHROME_BROWSER_CHROMEOS_ATTESTATION_ATTESTATION_POLICY_OBSERVER_H_ |
| + |
| +#include <string> |
| + |
| +#include "base/basictypes.h" |
| +#include "base/memory/scoped_ptr.h" |
| +#include "base/memory/weak_ptr.h" |
| +#include "content/public/browser/notification_observer.h" |
| + |
| +namespace policy { |
| +class CloudPolicyClient; |
| +} |
| + |
| +namespace chromeos { |
| + |
| +class CrosSettings; |
| +class CryptohomeClient; |
| + |
| +namespace attestation { |
| + |
| +class AttestationFlow; |
| + |
| +// A class which observes policy changes and triggers device attestation work if |
| +// necessary. |
| +class AttestationPolicyObserver : public content::NotificationObserver { |
| + public: |
| + // The observer immediately connects with CrosSettings to listen for policy |
| + // changes. The CloudPolicyClient is used to upload the device certificate to |
| + // the server if one is created in response to policy changes; it must be in |
| + // the registered state. This class does not take ownership of |
| + // |policy_client|. |
| + explicit AttestationPolicyObserver(policy::CloudPolicyClient* policy_client); |
| + |
| + // A constructor which allows custom CryptohomeClient and AttestationFlow |
| + // implementations. Useful for testing. |
| + AttestationPolicyObserver(policy::CloudPolicyClient* policy_client, |
| + CryptohomeClient* cryptohome_client, |
| + AttestationFlow* attestation_flow); |
| + |
| + virtual ~AttestationPolicyObserver(); |
| + |
| + // content::NotificationObserver: |
| + virtual void Observe(int type, |
| + const content::NotificationSource& source, |
| + const content::NotificationDetails& details) OVERRIDE; |
| + |
| + private: |
| + static const char kEnterpriseMachineKey[]; |
| + |
| + // Checks attestation policy and starts any necessary work. |
| + void Start(); |
| + |
| + // Gets a new certificate for the Enterprise Machine Key (EMK). |
| + void GetNewCertificate(); |
| + |
| + // Gets the existing EMK certificate and sends it to CheckCertificateExpiry. |
| + void GetExistingCertificate(); |
| + |
| + // Checks if the given certificate is expired and, if so, get a new one. |
| + void CheckCertificateExpiry(const std::string& certificate); |
| + |
| + // Uploads a certificate to the policy server. |
| + void UploadCertificate(const std::string& certificate); |
| + |
| + // Checks if a certificate has already been uploaded and, if not, upload. |
| + void CheckIfUploaded(const std::string& certificate); |
| + |
| + base::WeakPtrFactory<AttestationPolicyObserver> weak_factory_; |
|
satorux1
2013/04/18 05:43:16
nit: Please move this to the end. Shouldn't matter
dkrahn
2013/04/18 18:29:41
Done.
|
| + CrosSettings* cros_settings_; |
| + policy::CloudPolicyClient* policy_client_; |
| + CryptohomeClient* cryptohome_client_; |
| + AttestationFlow* attestation_flow_; |
| + scoped_ptr<AttestationFlow> default_attestation_flow_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(AttestationPolicyObserver); |
| +}; |
| + |
| +} // namespace attestation |
| +} // namespace chromeos |
| + |
| +#endif // CHROME_BROWSER_CHROMEOS_ATTESTATION_ATTESTATION_POLICY_OBSERVER_H_ |