OLD | NEW |
(Empty) | |
| 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 #include "chrome/browser/chromeos/attestation/attestation_policy_observer.h" |
| 6 |
| 7 #include <string> |
| 8 |
| 9 #include "chrome/browser/policy/cloud/cloud_policy_client.h" |
| 10 #include "chrome/browser/policy/cloud/cloud_policy_manager.h" |
| 11 #include "chrome/common/chrome_notification_types.h" |
| 12 #include "content/public/browser/notification_details.h" |
| 13 |
| 14 using std::string; |
| 15 |
| 16 namespace chromeos { |
| 17 namespace attestation { |
| 18 |
| 19 AttestationPolicyObserver::AttestationPolicyObserver( |
| 20 CrosSettings* settings, |
| 21 policy::CloudPolicyManager* policy_manager, |
| 22 scoped_ptr<AttestationFlow> attestation_flow) |
| 23 : settings_(settings), |
| 24 policy_manager_(policy_manager), |
| 25 attestation_flow_(attestation_flow.Pass()) { |
| 26 settings_->AddSettingsObserver(kDeviceAttestationEnabled, this); |
| 27 } |
| 28 |
| 29 AttestationPolicyObserver::~AttestationPolicyObserver() { |
| 30 settings_->RemoveSettingsObserver(kDeviceAttestationEnabled, this); |
| 31 } |
| 32 |
| 33 void AttestationPolicyObserver::Observe( |
| 34 int type, |
| 35 const content::NotificationSource& source, |
| 36 const content::NotificationDetails& details) { |
| 37 string* path = content::Details<string>(details).ptr(); |
| 38 if (type != chrome::NOTIFICATION_SYSTEM_SETTING_CHANGED || |
| 39 *path != kDeviceAttestationEnabled) { |
| 40 LOG(WARNING) << "AttestationPolicyObserver: Unexpected event received."; |
| 41 return; |
| 42 } |
| 43 |
| 44 // If attestation is not enabled, there is nothing to do. |
| 45 bool enabled = false; |
| 46 if (!settings_->GetBoolean(kDeviceAttestationEnabled, &enabled) || !enabled) |
| 47 return; |
| 48 |
| 49 // We need a valid CloudPolicyClient to proceed. |
| 50 policy::CloudPolicyClient* client = policy_manager_->core()->client(); |
| 51 if (!client) { |
| 52 LOG(ERROR) << "AttestationPolicyObserver: Invalid CloudPolicyClient."; |
| 53 return; |
| 54 } |
| 55 |
| 56 // TODO(dkrahn): Generate EMK and upload EMCert if necessary. |
| 57 } |
| 58 |
| 59 } // namespace attestation |
| 60 } // namespace chromeos |
OLD | NEW |