| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CHROME_BROWSER_CHROMEOS_LOGIN_SIGNED_SETTINGS_HELPER_H_ | |
| 6 #define CHROME_BROWSER_CHROMEOS_LOGIN_SIGNED_SETTINGS_HELPER_H_ | |
| 7 | |
| 8 #include "chrome/browser/chromeos/login/signed_settings.h" | |
| 9 | |
| 10 namespace enterprise_management { | |
| 11 class PolicyFetchResponse; | |
| 12 } // namespace enterprise_management | |
| 13 | |
| 14 namespace chromeos { | |
| 15 | |
| 16 // Helper to serialize signed settings ops, provide unified callback interface, | |
| 17 // and handle callbacks destruction before ops completion. | |
| 18 class SignedSettingsHelper { | |
| 19 public: | |
| 20 typedef base::Callback<void(SignedSettings::ReturnCode)> StorePolicyCallback; | |
| 21 typedef | |
| 22 base::Callback<void(SignedSettings::ReturnCode, | |
| 23 const enterprise_management::PolicyFetchResponse&)> | |
| 24 RetrievePolicyCallback; | |
| 25 | |
| 26 // Class factory | |
| 27 static SignedSettingsHelper* Get(); | |
| 28 | |
| 29 // Functions to start signed settings ops. | |
| 30 virtual void StartStorePolicyOp( | |
| 31 const enterprise_management::PolicyFetchResponse& policy, | |
| 32 StorePolicyCallback callback) = 0; | |
| 33 virtual void StartRetrievePolicyOp( | |
| 34 RetrievePolicyCallback callback) = 0; | |
| 35 | |
| 36 class TestDelegate { | |
| 37 public: | |
| 38 virtual void OnOpCreated(SignedSettings* op) = 0; | |
| 39 virtual void OnOpStarted(SignedSettings* op) = 0; | |
| 40 virtual void OnOpCompleted(SignedSettings* op) = 0; | |
| 41 }; | |
| 42 | |
| 43 #if defined(UNIT_TEST) | |
| 44 void set_test_delegate(TestDelegate* test_delegate) { | |
| 45 test_delegate_ = test_delegate; | |
| 46 } | |
| 47 #endif // defined(UNIT_TEST) | |
| 48 | |
| 49 protected: | |
| 50 SignedSettingsHelper() : test_delegate_(NULL) { | |
| 51 } | |
| 52 | |
| 53 TestDelegate* test_delegate_; | |
| 54 }; | |
| 55 | |
| 56 } // namespace chromeos | |
| 57 | |
| 58 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_SIGNED_SETTINGS_HELPER_H_ | |
| OLD | NEW |