Chromium Code Reviews| 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 |
|
danno
2011/02/04 16:01:33
It does more than that... better comment?
Jakob Kummerow
2011/02/14 13:50:34
Done.
|
| +// registration with the device management service. |
| +class CloudPolicyController { |
|
danno
2011/02/04 16:01:33
CloudPolicyIdentityStrategy?
Jakob Kummerow
2011/02/14 13:50:34
Done.
|
| + 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; |
|
danno
2011/02/04 16:01:33
s/OnTokenChanged/OnDeviceTokenChanged/
Jakob Kummerow
2011/02/14 13:50:34
Done.
|
| + |
| + // 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 |
|
danno
2011/02/04 16:01:33
I don't think you mean provider, you mean controll
Jakob Kummerow
2011/02/14 13:50:34
Done. (s/provider/identity strategy/, to be precis
|
| + // provider to decide that token is going to be used, in which case it should |
|
danno
2011/02/04 16:01:33
provider -> controller
Jakob Kummerow
2011/02/14 13:50:34
Done.
|
| + // send a OnTokenChanged() notification an return the new token in |
|
danno
2011/02/04 16:01:33
s/an/and
danno
2011/02/04 16:01:33
Couldn't you also have OnTokenChanged return a boo
Jakob Kummerow
2011/02/14 13:50:34
Done.
Jakob Kummerow
2011/02/14 13:50:34
I don't currently see a use case for that...
|
| + // GetDeviceToken() calls. |
| + virtual void OnTokenAvailable(const std::string& token) = 0; |
|
danno
2011/02/04 16:01:33
s/OnTokenAvailable/OnDeviceTokenAvailable/ to disa
Jakob Kummerow
2011/02/14 13:50:34
Done.
|
| + |
| + protected: |
| + // Notify observers that the effective token has changed. |
| + void NotifyTokenChanged() { |
|
danno
2011/02/04 16:01:33
s/NotifyTokenChanged/NotifyDeviceTokenChanged/
Jakob Kummerow
2011/02/14 13:50:34
Done.
|
| + 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_ |