OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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_HELPER_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_LOGIN_SIGNED_SETTINGS_HELPER_H_ |
6 #define CHROME_BROWSER_CHROMEOS_LOGIN_SIGNED_SETTINGS_HELPER_H_ | 6 #define CHROME_BROWSER_CHROMEOS_LOGIN_SIGNED_SETTINGS_HELPER_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
| 9 #include <string> |
| 10 |
9 #include "chrome/browser/chromeos/login/signed_settings.h" | 11 #include "chrome/browser/chromeos/login/signed_settings.h" |
10 | 12 |
| 13 namespace enterprise_management { |
| 14 class PolicyFetchResponse; |
| 15 } // namespace enterprise_management |
| 16 namespace em = enterprise_management; |
11 namespace chromeos { | 17 namespace chromeos { |
12 | 18 |
13 class SignedSettings; | 19 class SignedSettings; |
14 | 20 |
15 // Helper to serialize signed settings ops, provide unified callback interface, | 21 // Helper to serialize signed settings ops, provide unified callback interface, |
16 // and handle callbacks destruction before ops completion. | 22 // and handle callbacks destruction before ops completion. |
17 class SignedSettingsHelper { | 23 class SignedSettingsHelper { |
18 public: | 24 public: |
19 class Callback { | 25 class Callback { |
20 public: | 26 public: |
(...skipping 15 matching lines...) Expand all Loading... |
36 virtual void OnStorePropertyCompleted( | 42 virtual void OnStorePropertyCompleted( |
37 SignedSettings::ReturnCode code, | 43 SignedSettings::ReturnCode code, |
38 const std::string& name, | 44 const std::string& name, |
39 const std::string& value) {} | 45 const std::string& value) {} |
40 | 46 |
41 // Callback of RetrievePropertyOp. | 47 // Callback of RetrievePropertyOp. |
42 virtual void OnRetrievePropertyCompleted( | 48 virtual void OnRetrievePropertyCompleted( |
43 SignedSettings::ReturnCode code, | 49 SignedSettings::ReturnCode code, |
44 const std::string& name, | 50 const std::string& name, |
45 const std::string& value) {} | 51 const std::string& value) {} |
| 52 |
| 53 // Callback of StorePolicyOp. |
| 54 virtual void OnStorePolicyCompleted( |
| 55 SignedSettings::ReturnCode code) {} |
| 56 |
| 57 // Callback of RetrievePolicyOp. |
| 58 virtual void OnRetrievePolicyCompleted( |
| 59 SignedSettings::ReturnCode code, |
| 60 const em::PolicyFetchResponse& policy) {} |
46 }; | 61 }; |
47 | 62 |
48 // Class factory | 63 // Class factory |
49 static SignedSettingsHelper* Get(); | 64 static SignedSettingsHelper* Get(); |
50 | 65 |
51 // Functions to start signed settings ops. | 66 // Functions to start signed settings ops. |
52 virtual void StartCheckWhitelistOp(const std::string& email, | 67 virtual void StartCheckWhitelistOp(const std::string& email, |
53 Callback* callback) = 0; | 68 Callback* callback) = 0; |
54 virtual void StartWhitelistOp(const std::string& email, | 69 virtual void StartWhitelistOp(const std::string& email, |
55 bool add_to_whitelist, | 70 bool add_to_whitelist, |
56 Callback* callback) = 0; | 71 Callback* callback) = 0; |
57 virtual void StartStorePropertyOp(const std::string& name, | 72 virtual void StartStorePropertyOp(const std::string& name, |
58 const std::string& value, | 73 const std::string& value, |
59 Callback* callback) = 0; | 74 Callback* callback) = 0; |
60 virtual void StartRetrieveProperty(const std::string& name, | 75 virtual void StartRetrieveProperty(const std::string& name, |
61 Callback* callback) = 0; | 76 Callback* callback) = 0; |
| 77 virtual void StartStorePolicyOp(const em::PolicyFetchResponse& policy, |
| 78 Callback* callback) = 0; |
| 79 virtual void StartRetrievePolicyOp(Callback* callback) = 0; |
62 | 80 |
63 // Cancels all pending calls of given callback. | 81 // Cancels all pending calls of given callback. |
64 virtual void CancelCallback(Callback* callback) = 0; | 82 virtual void CancelCallback(Callback* callback) = 0; |
65 | 83 |
66 class TestDelegate { | 84 class TestDelegate { |
67 public: | 85 public: |
68 virtual void OnOpCreated(SignedSettings* op) = 0; | 86 virtual void OnOpCreated(SignedSettings* op) = 0; |
69 virtual void OnOpStarted(SignedSettings* op) = 0; | 87 virtual void OnOpStarted(SignedSettings* op) = 0; |
70 virtual void OnOpCompleted(SignedSettings* op) = 0; | 88 virtual void OnOpCompleted(SignedSettings* op) = 0; |
71 }; | 89 }; |
72 | 90 |
73 #if defined(UNIT_TEST) | 91 #if defined(UNIT_TEST) |
74 void set_test_delegate(TestDelegate* test_delegate) { | 92 void set_test_delegate(TestDelegate* test_delegate) { |
75 test_delegate_ = test_delegate; | 93 test_delegate_ = test_delegate; |
76 } | 94 } |
77 #endif // defined(UNIT_TEST) | 95 #endif // defined(UNIT_TEST) |
78 | 96 |
79 protected: | 97 protected: |
80 SignedSettingsHelper() : test_delegate_(NULL) { | 98 SignedSettingsHelper() : test_delegate_(NULL) { |
81 } | 99 } |
82 | 100 |
83 TestDelegate* test_delegate_; | 101 TestDelegate* test_delegate_; |
84 }; | 102 }; |
85 | 103 |
86 } // namespace chromeos | 104 } // namespace chromeos |
87 | 105 |
88 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_SIGNED_SETTINGS_HELPER_H_ | 106 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_SIGNED_SETTINGS_HELPER_H_ |
OLD | NEW |