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..0430cafd17c834839c81ac94b5c18aca59e4fb5b |
--- /dev/null |
+++ b/chrome/browser/chromeos/attestation/attestation_policy_observer.h |
@@ -0,0 +1,88 @@ |
+// 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: |
+ AttestationPolicyObserver(); |
+ virtual ~AttestationPolicyObserver(); |
+ |
+ // Connects the observer to the CrosSettings instance. 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 |settings| or |policy_client|. |
Mattias Nissler (ping if slow)
2013/04/10 17:31:03
No |settings| passed in here?
dkrahn
2013/04/12 01:17:29
Done.
|
+ virtual void Connect(policy::CloudPolicyClient* policy_client); |
+ |
+ // content::NotificationObserver: |
+ virtual void Observe(int type, |
+ const content::NotificationSource& source, |
+ const content::NotificationDetails& details); |
+ |
+ // Setters useful for testing. |
Mattias Nissler (ping if slow)
2013/04/10 17:31:03
most policy code just takes these as ctor paramete
dkrahn
2013/04/12 01:17:29
I wanted to make it easy to construct this class b
|
+ void set_cryptohome_client(CryptohomeClient* cryptohome_client) { |
+ cryptohome_client_ = cryptohome_client; |
+ } |
+ void set_attestation_flow(AttestationFlow* attestation_flow) { |
+ attestation_flow_ = attestation_flow; |
+ } |
+ |
+ 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_; |
+ 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_ |