Index: chrome/browser/chromeos/attestation/attestation_policy_observer.cc |
diff --git a/chrome/browser/chromeos/attestation/attestation_policy_observer.cc b/chrome/browser/chromeos/attestation/attestation_policy_observer.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..8ba5659a6ef403875a2752f2777ba6c988f7e2ed |
--- /dev/null |
+++ b/chrome/browser/chromeos/attestation/attestation_policy_observer.cc |
@@ -0,0 +1,60 @@ |
+// 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. |
+ |
+#include "chrome/browser/chromeos/attestation/attestation_policy_observer.h" |
+ |
+#include <string> |
+ |
+#include "chrome/browser/policy/cloud/cloud_policy_client.h" |
+#include "chrome/browser/policy/cloud/cloud_policy_manager.h" |
+#include "chrome/common/chrome_notification_types.h" |
+#include "content/public/browser/notification_details.h" |
+ |
+using std::string; |
+ |
+namespace chromeos { |
+namespace attestation { |
+ |
+AttestationPolicyObserver::AttestationPolicyObserver( |
+ CrosSettings* settings, |
+ policy::CloudPolicyManager* policy_manager, |
Mattias Nissler (ping if slow)
2013/03/27 14:16:34
Just pass a CloudPolicyClient pointer if that's al
dkrahn
2013/03/27 21:20:44
From my reading of the code (correct me if I'm wro
Mattias Nissler (ping if slow)
2013/04/02 12:49:39
You're right about the CloudPolicyClient not neces
dkrahn
2013/04/04 21:27:26
Moved to DeviceCloudPolicyManagerChromeOS and adde
|
+ scoped_ptr<AttestationFlow> attestation_flow) |
+ : settings_(settings), |
+ policy_manager_(policy_manager), |
+ attestation_flow_(attestation_flow.Pass()) { |
+ settings_->AddSettingsObserver(kDeviceAttestationEnabled, this); |
+} |
+ |
+AttestationPolicyObserver::~AttestationPolicyObserver() { |
+ settings_->RemoveSettingsObserver(kDeviceAttestationEnabled, this); |
+} |
+ |
+void AttestationPolicyObserver::Observe( |
+ int type, |
+ const content::NotificationSource& source, |
+ const content::NotificationDetails& details) { |
+ string* path = content::Details<string>(details).ptr(); |
+ if (type != chrome::NOTIFICATION_SYSTEM_SETTING_CHANGED || |
+ *path != kDeviceAttestationEnabled) { |
+ LOG(WARNING) << "AttestationPolicyObserver: Unexpected event received."; |
+ return; |
+ } |
+ |
+ // If attestation is not enabled, there is nothing to do. |
+ bool enabled = false; |
+ if (!settings_->GetBoolean(kDeviceAttestationEnabled, &enabled) || !enabled) |
+ return; |
+ |
+ // We need a valid CloudPolicyClient to proceed. |
+ policy::CloudPolicyClient* client = policy_manager_->core()->client(); |
+ if (!client) { |
+ LOG(ERROR) << "AttestationPolicyObserver: Invalid CloudPolicyClient."; |
+ return; |
+ } |
+ |
+ // TODO(dkrahn): Generate EMK and upload EMCert if necessary. |
Mattias Nissler (ping if slow)
2013/03/27 14:16:34
Are you meaning to commit this in the half-baked s
dkrahn
2013/03/27 21:20:44
Yes. Before I do a lot of work I want your +1 tha
Mattias Nissler (ping if slow)
2013/04/02 12:49:39
Hard for me to figure out with significant pieces
dkrahn
2013/04/04 21:27:26
I've added more meat here, although there are stil
|
+} |
+ |
+} // namespace attestation |
+} // namespace chromeos |