| 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,
|
| + 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.
|
| +}
|
| +
|
| +} // namespace attestation
|
| +} // namespace chromeos
|
|
|