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_DEVICE_POLICY_IDENTITY_STRATEGY_H_ | 5 #ifndef CHROME_BROWSER_POLICY_DEVICE_POLICY_IDENTITY_STRATEGY_H_ |
6 #define CHROME_BROWSER_POLICY_DEVICE_POLICY_IDENTITY_STRATEGY_H_ | 6 #define CHROME_BROWSER_POLICY_DEVICE_POLICY_IDENTITY_STRATEGY_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #include "chrome/browser/policy/cloud_policy_identity_strategy.h" | 11 #include "chrome/browser/policy/cloud_policy_identity_strategy.h" |
12 #include "chrome/common/notification_observer.h" | 12 #include "chrome/common/notification_observer.h" |
13 #include "chrome/common/notification_registrar.h" | 13 #include "chrome/common/notification_registrar.h" |
14 | 14 |
15 class TokenService; | 15 class TokenService; |
16 | 16 |
17 namespace policy { | 17 namespace policy { |
18 | 18 |
19 // DM token provider that stores the token in CrOS signed settings. | 19 // DM token provider that stores the token in CrOS signed settings. |
20 class DevicePolicyIdentityStrategy : public CloudPolicyIdentityStrategy, | 20 class DevicePolicyIdentityStrategy : public CloudPolicyIdentityStrategy, |
21 public NotificationObserver { | 21 public NotificationObserver { |
22 public: | 22 public: |
23 DevicePolicyIdentityStrategy(); | 23 DevicePolicyIdentityStrategy(); |
24 virtual ~DevicePolicyIdentityStrategy() {} | 24 virtual ~DevicePolicyIdentityStrategy() {} |
25 | 25 |
26 // CloudPolicyIdentityStrategy implementation: | 26 // CloudPolicyIdentityStrategy implementation: |
27 virtual std::string GetDeviceToken(); | 27 virtual std::string GetDeviceToken(); |
28 virtual std::string GetDeviceID(); | 28 virtual std::string GetDeviceID(); |
| 29 virtual std::string GetMachineID(); |
| 30 virtual em::DeviceRegisterRequest_Type GetPolicyRegisterType(); |
| 31 virtual std::string GetPolicyType(); |
29 virtual bool GetCredentials(std::string* username, | 32 virtual bool GetCredentials(std::string* username, |
30 std::string* auth_token); | 33 std::string* auth_token); |
31 virtual void OnDeviceTokenAvailable(const std::string& token); | 34 virtual void OnDeviceTokenAvailable(const std::string& token); |
32 | 35 |
33 private: | 36 private: |
34 // Recheck whether all parameters are available and if so, trigger a | 37 // Recheck whether all parameters are available and if so, trigger a |
35 // credentials changed notification. | 38 // credentials changed notification. |
36 void CheckAndTriggerFetch(); | 39 void CheckAndTriggerFetch(); |
37 | 40 |
38 // NotificationObserver method overrides: | 41 // NotificationObserver method overrides: |
39 virtual void Observe(NotificationType type, | 42 virtual void Observe(NotificationType type, |
40 const NotificationSource& source, | 43 const NotificationSource& source, |
41 const NotificationDetails& details); | 44 const NotificationDetails& details); |
42 | 45 |
43 // The machine identifier. | 46 // The machine identifier. |
44 std::string machine_id_; | 47 std::string machine_id_; |
45 | 48 |
| 49 // The device identifier to be sent with requests. (This is actually more like |
| 50 // a session identifier since it is re-generated for each registration |
| 51 // request.) |
| 52 std::string device_id_; |
| 53 |
46 // Current token. Empty if not available. | 54 // Current token. Empty if not available. |
47 std::string device_token_; | 55 std::string device_token_; |
48 | 56 |
49 // Whether to try and register. Device policy enrollment does not happen | 57 // Whether to try and register. Device policy enrollment does not happen |
50 // automatically except for the case that the device gets claimed. This | 58 // automatically except for the case that the device gets claimed. This |
51 // situation is detected by listening for the OWNERSHIP_TAKEN notification. | 59 // situation is detected by listening for the OWNERSHIP_TAKEN notification. |
52 bool should_register_; | 60 bool should_register_; |
53 | 61 |
54 // Registers the provider for notification of successful Gaia logins. | 62 // Registers the provider for notification of successful Gaia logins. |
55 NotificationRegistrar registrar_; | 63 NotificationRegistrar registrar_; |
56 | 64 |
57 DISALLOW_COPY_AND_ASSIGN(DevicePolicyIdentityStrategy); | 65 DISALLOW_COPY_AND_ASSIGN(DevicePolicyIdentityStrategy); |
58 }; | 66 }; |
59 | 67 |
60 } // namespace policy | 68 } // namespace policy |
61 | 69 |
62 #endif // CHROME_BROWSER_POLICY_DEVICE_POLICY_IDENTITY_STRATEGY_H_ | 70 #endif // CHROME_BROWSER_POLICY_DEVICE_POLICY_IDENTITY_STRATEGY_H_ |
OLD | NEW |