Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROME_BROWSER_POLICY_CLOUD_POLICY_IDENTITY_STRATEGY_H_ | 5 #ifndef CHROME_BROWSER_POLICY_CLOUD_POLICY_IDENTITY_STRATEGY_H_ |
| 6 #define CHROME_BROWSER_POLICY_CLOUD_POLICY_IDENTITY_STRATEGY_H_ | 6 #define CHROME_BROWSER_POLICY_CLOUD_POLICY_IDENTITY_STRATEGY_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| 11 #include "base/observer_list.h" | 11 #include "base/observer_list.h" |
| 12 #include "chrome/browser/policy/proto/device_management_backend.pb.h" | |
| 12 | 13 |
| 13 namespace policy { | 14 namespace policy { |
| 14 | 15 |
| 16 namespace em = enterprise_management; | |
| 17 | |
| 15 // Manages a device management token, i.e. an identifier that represents a | 18 // Manages a device management token, i.e. an identifier that represents a |
| 16 // registration with the device management service, and the associated | 19 // registration with the device management service, and the associated |
| 17 // credentials. Responsibilities include storing and loading the token from | 20 // credentials. Responsibilities include storing and loading the token from |
| 18 // disk, observing and triggering relevant notifications. | 21 // disk, observing and triggering relevant notifications. |
| 19 class CloudPolicyIdentityStrategy { | 22 class CloudPolicyIdentityStrategy { |
| 20 public: | 23 public: |
| 21 class Observer { | 24 class Observer { |
| 22 public: | 25 public: |
| 23 virtual ~Observer() {} | 26 virtual ~Observer() {} |
| 24 | 27 |
| 25 // Notifies observers that the effective token for fetching policy has | 28 // Notifies observers that the effective token for fetching policy has |
| 26 // changed. The token can be queried by calling GetDeviceToken(). | 29 // changed. The token can be queried by calling GetDeviceToken(). |
| 27 virtual void OnDeviceTokenChanged() = 0; | 30 virtual void OnDeviceTokenChanged() = 0; |
| 28 | 31 |
| 29 // Authentication credentials for talking to the device management service | 32 // Authentication credentials for talking to the device management service |
| 30 // changed. New auth data is available through GetCredentials(). | 33 // changed. New auth data is available through GetCredentials(). |
| 31 virtual void OnCredentialsChanged() = 0; | 34 virtual void OnCredentialsChanged() = 0; |
| 32 }; | 35 }; |
| 33 | 36 |
| 34 CloudPolicyIdentityStrategy(); | 37 CloudPolicyIdentityStrategy(); |
| 35 virtual ~CloudPolicyIdentityStrategy(); | 38 virtual ~CloudPolicyIdentityStrategy(); |
| 36 | 39 |
| 37 void AddObserver(Observer* obs); | 40 void AddObserver(Observer* obs); |
| 38 void RemoveObserver(Observer* obs); | 41 void RemoveObserver(Observer* obs); |
| 39 | 42 |
| 40 // Returns the device management token, if available. Returns the empty string | 43 // Returns the device management token, if available. Returns the empty string |
| 41 // if the device token is currently unavailable. | 44 // if the device token is currently unavailable. |
| 42 virtual std::string GetDeviceToken() = 0; | 45 virtual std::string GetDeviceToken() = 0; |
| 43 | 46 |
| 44 // Returns the device ID for this device. | 47 // Returns the device ID for this device. |
|
Mattias Nissler (ping if slow)
2011/03/01 10:25:49
Can we add a sentence here saying how the device I
gfeher
2011/03/01 15:53:00
Done.
| |
| 45 virtual std::string GetDeviceID() = 0; | 48 virtual std::string GetDeviceID() = 0; |
| 46 | 49 |
| 50 // Returns physical machine ID for this device. | |
| 51 virtual std::string GetMachineID() = 0; | |
| 52 | |
| 53 // Returns the policy type to be used for registering at the device management | |
| 54 // server. | |
| 55 virtual em::DeviceRegisterRequest_Type GetPolicyRegisterType() = 0; | |
| 56 | |
| 57 // Returns the policy type to be used for requesting policies from the device | |
| 58 // management server. | |
| 59 virtual std::string GetPolicyType() = 0; | |
| 60 | |
| 47 // Retrieves authentication credentials to use when talking to the device | 61 // Retrieves authentication credentials to use when talking to the device |
| 48 // management service. Returns true if the data is available and writes the | 62 // management service. Returns true if the data is available and writes the |
| 49 // values to the provided pointers. | 63 // values to the provided pointers. |
| 50 virtual bool GetCredentials(std::string* username, | 64 virtual bool GetCredentials(std::string* username, |
| 51 std::string* auth_token) = 0; | 65 std::string* auth_token) = 0; |
| 52 | 66 |
| 53 // Notifies the identity strategy that a new token has been fetched. It is up | 67 // Notifies the identity strategy that a new token has been fetched. It is up |
| 54 // to the identity strategy to store the token, decide whether it is going | 68 // to the identity strategy to store the token, decide whether it is going |
| 55 // to be used, send out an appropriate OnDeviceTokenChanged() notification | 69 // to be used, send out an appropriate OnDeviceTokenChanged() notification |
| 56 // and return the new token in GetDeviceToken() calls. | 70 // and return the new token in GetDeviceToken() calls. |
| 57 virtual void OnDeviceTokenAvailable(const std::string& token) = 0; | 71 virtual void OnDeviceTokenAvailable(const std::string& token) = 0; |
| 58 | 72 |
| 59 protected: | 73 protected: |
| 60 // Notify observers that the effective token has changed. | 74 // Notify observers that the effective token has changed. |
| 61 void NotifyDeviceTokenChanged(); | 75 void NotifyDeviceTokenChanged(); |
| 62 | 76 |
| 63 // Notify observers about authentication data change. | 77 // Notify observers about authentication data change. |
| 64 void NotifyAuthChanged(); | 78 void NotifyAuthChanged(); |
| 65 | 79 |
| 66 private: | 80 private: |
| 67 ObserverList<Observer, true> observer_list_; | 81 ObserverList<Observer, true> observer_list_; |
| 68 | 82 |
| 69 DISALLOW_COPY_AND_ASSIGN(CloudPolicyIdentityStrategy); | 83 DISALLOW_COPY_AND_ASSIGN(CloudPolicyIdentityStrategy); |
| 70 }; | 84 }; |
| 71 | 85 |
| 72 } // namespace policy | 86 } // namespace policy |
| 73 | 87 |
| 74 #endif // CHROME_BROWSER_POLICY_CLOUD_POLICY_IDENTITY_STRATEGY_H_ | 88 #endif // CHROME_BROWSER_POLICY_CLOUD_POLICY_IDENTITY_STRATEGY_H_ |
| OLD | NEW |