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