OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_CHROMEOS_LOGIN_SIGNED_SETTINGS_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_LOGIN_SIGNED_SETTINGS_H_ |
6 #define CHROME_BROWSER_CHROMEOS_LOGIN_SIGNED_SETTINGS_H_ | 6 #define CHROME_BROWSER_CHROMEOS_LOGIN_SIGNED_SETTINGS_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 }; | 44 }; |
45 | 45 |
46 template <class T> | 46 template <class T> |
47 class Delegate { | 47 class Delegate { |
48 public: | 48 public: |
49 // This method will be called on the UI thread. | 49 // This method will be called on the UI thread. |
50 virtual void OnSettingsOpCompleted(ReturnCode code, T value) {} | 50 virtual void OnSettingsOpCompleted(ReturnCode code, T value) {} |
51 }; | 51 }; |
52 | 52 |
53 SignedSettings(); | 53 SignedSettings(); |
54 virtual ~SignedSettings(); | |
55 | 54 |
56 // These are both "policy" operations, and only one instance of | 55 // These are both "policy" operations, and only one instance of |
57 // one type can be in flight at a time. | 56 // one type can be in flight at a time. |
58 static SignedSettings* CreateStorePolicyOp( | 57 static SignedSettings* CreateStorePolicyOp( |
59 enterprise_management::PolicyFetchResponse* policy, | 58 enterprise_management::PolicyFetchResponse* policy, |
60 SignedSettings::Delegate<bool>* d); | 59 SignedSettings::Delegate<bool>* d); |
61 | 60 |
62 static SignedSettings* CreateRetrievePolicyOp( | 61 static SignedSettings* CreateRetrievePolicyOp( |
63 SignedSettings::Delegate< | 62 SignedSettings::Delegate< |
64 const enterprise_management::PolicyFetchResponse&>* d); | 63 const enterprise_management::PolicyFetchResponse&>* d); |
65 | 64 |
66 static ReturnCode MapKeyOpCode(OwnerManager::KeyOpCode code); | 65 static ReturnCode MapKeyOpCode(OwnerManager::KeyOpCode code); |
67 | 66 |
68 virtual void Execute() = 0; | 67 virtual void Execute() = 0; |
69 | 68 |
70 virtual void Fail(ReturnCode code) = 0; | 69 virtual void Fail(ReturnCode code) = 0; |
71 | 70 |
72 // Implementation of OwnerManager::Delegate | 71 // Implementation of OwnerManager::Delegate |
73 virtual void OnKeyOpComplete(const OwnerManager::KeyOpCode return_code, | 72 virtual void OnKeyOpComplete(const OwnerManager::KeyOpCode return_code, |
74 const std::vector<uint8>& payload) = 0; | 73 const std::vector<uint8>& payload) = 0; |
75 | 74 |
76 protected: | 75 protected: |
| 76 virtual ~SignedSettings(); |
| 77 |
77 static bool PolicyIsSane( | 78 static bool PolicyIsSane( |
78 const enterprise_management::PolicyFetchResponse& value, | 79 const enterprise_management::PolicyFetchResponse& value, |
79 enterprise_management::PolicyData* poldata); | 80 enterprise_management::PolicyData* poldata); |
80 | 81 |
81 void set_service(OwnershipService* service) { service_ = service; } | 82 void set_service(OwnershipService* service) { service_ = service; } |
82 | 83 |
83 OwnershipService* service_; | 84 OwnershipService* service_; |
84 | 85 |
85 private: | 86 private: |
| 87 friend class base::RefCountedThreadSafe<SignedSettings>; |
86 friend class SignedSettingsTest; | 88 friend class SignedSettingsTest; |
87 friend class SignedSettingsHelperTest; | 89 friend class SignedSettingsHelperTest; |
88 | 90 |
89 DISALLOW_COPY_AND_ASSIGN(SignedSettings); | 91 DISALLOW_COPY_AND_ASSIGN(SignedSettings); |
90 }; | 92 }; |
91 | 93 |
92 } // namespace chromeos | 94 } // namespace chromeos |
93 | 95 |
94 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_SIGNED_SETTINGS_H_ | 96 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_SIGNED_SETTINGS_H_ |
OLD | NEW |