| Index: chrome/browser/policy/cloud_policy_controller.h
|
| diff --git a/chrome/browser/policy/cloud_policy_controller.h b/chrome/browser/policy/cloud_policy_controller.h
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..3299463e5f8c1a9f0206587978d2e16851ad44c5
|
| --- /dev/null
|
| +++ b/chrome/browser/policy/cloud_policy_controller.h
|
| @@ -0,0 +1,82 @@
|
| +// Copyright (c) 2011 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_POLICY_CLOUD_POLICY_CONTROLLER_H_
|
| +#define CHROME_BROWSER_POLICY_CLOUD_POLICY_CONTROLLER_H_
|
| +#pragma once
|
| +
|
| +#include <string>
|
| +#include <vector>
|
| +
|
| +#include "base/observer_list.h"
|
| +
|
| +namespace policy {
|
| +
|
| +// Manages a device management token, i.e. an identifier that represents a
|
| +// registration with the device management service.
|
| +class CloudPolicyController {
|
| + public:
|
| + class Observer {
|
| + public:
|
| + virtual ~Observer() {}
|
| +
|
| + // Notifies observers that the effective token for fetching policy has
|
| + // changed. The token can be queried by calling GetDeviceToken().
|
| + virtual void OnTokenChanged() = 0;
|
| +
|
| + // Authentication credentials for talking to the device management service
|
| + // changed. New auth data is available through GetCredentials().
|
| + virtual void OnCredentialsChanged() = 0;
|
| + };
|
| +
|
| + CloudPolicyController() {}
|
| + virtual ~CloudPolicyController() {}
|
| +
|
| + void AddObserver(Observer* obs) {
|
| + observer_list_.AddObserver(obs);
|
| + }
|
| +
|
| + void RemoveObserver(Observer* obs) {
|
| + observer_list_.RemoveObserver(obs);
|
| + }
|
| +
|
| + // Returns the device management token, if available. Returns the empty string
|
| + // if the device token is currently unavailable.
|
| + virtual std::string GetDeviceToken() = 0;
|
| +
|
| + // Returns the device ID for this device.
|
| + virtual std::string GetDeviceID() = 0;
|
| +
|
| + // Retrieves authentication credentials to use when talking to the device
|
| + // management service. Returns true if the data is available and writes the
|
| + // values to the provided pointers.
|
| + virtual bool GetCredentials(std::string* username,
|
| + std::string* auth_token) = 0;
|
| +
|
| + // Notifies the provider that a new token has been fetched. It is up to the
|
| + // provider to decide that token is going to be used, in which case it should
|
| + // send a OnTokenChanged() notification an return the new token in
|
| + // GetDeviceToken() calls.
|
| + virtual void OnTokenAvailable(const std::string& token) = 0;
|
| +
|
| + protected:
|
| + // Notify observers that the effective token has changed.
|
| + void NotifyTokenChanged() {
|
| + FOR_EACH_OBSERVER(Observer, observer_list_, OnTokenChanged());
|
| + }
|
| +
|
| + // Notify observers about authentication data change.
|
| + void NotifyAuthChanged() {
|
| + FOR_EACH_OBSERVER(Observer, observer_list_, OnCredentialsChanged());
|
| + }
|
| +
|
| + private:
|
| + ObserverList<Observer, true> observer_list_;
|
| +
|
| + DISALLOW_COPY_AND_ASSIGN(CloudPolicyController);
|
| +};
|
| +
|
| +} // namespace policy
|
| +
|
| +#endif // CHROME_BROWSER_POLICY_CLOUD_POLICY_CONTROLLER_H_
|
|
|