| 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> | 9 #include "chrome/browser/chromeos/login/signed_settings.h" |
| 10 | 10 |
| 11 namespace chromeos { | 11 namespace chromeos { |
| 12 | 12 |
| 13 class SignedSettings; | 13 class SignedSettings; |
| 14 | 14 |
| 15 // Helper to serialize signed settings ops, provide unified callback interface, | 15 // Helper to serialize signed settings ops, provide unified callback interface, |
| 16 // and handle callbacks destruction before ops completion. | 16 // and handle callbacks destruction before ops completion. |
| 17 class SignedSettingsHelper { | 17 class SignedSettingsHelper { |
| 18 public: | 18 public: |
| 19 class Callback { | 19 class Callback { |
| 20 public: | 20 public: |
| 21 // Callback of CheckWhitelistOp. |success| indicates whether the op succeeds | 21 // Callback of CheckWhitelistOp. |success| indicates whether the op succeeds |
| 22 // or not. |email| is the email that is checked against. | 22 // or not. |email| is the email that is checked against. |
| 23 virtual void OnCheckWhiteListCompleted( | 23 virtual void OnCheckWhitelistCompleted( |
| 24 bool success, const std::string& email) {} | 24 SignedSettings::ReturnCode code, |
| 25 const std::string& email) {} |
| 25 | 26 |
| 26 // Callback of WhitelistOp that adds |email| to the whitelist. | 27 // Callback of WhitelistOp that adds |email| to the whitelist. |
| 27 virtual void OnWhitelistCompleted( | 28 virtual void OnWhitelistCompleted( |
| 28 bool success, const std::string& email) {} | 29 SignedSettings::ReturnCode code, const std::string& email) {} |
| 29 | 30 |
| 30 // Callback of WhitelistOp that removes |email| to the whitelist. | 31 // Callback of WhitelistOp that removes |email| to the whitelist. |
| 31 virtual void OnUnwhitelistCompleted( | 32 virtual void OnUnwhitelistCompleted( |
| 32 bool success, const std::string& email) {} | 33 SignedSettings::ReturnCode code, const std::string& email) {} |
| 33 | 34 |
| 34 // Callback of StorePropertyOp. | 35 // Callback of StorePropertyOp. |
| 35 virtual void OnStorePropertyCompleted( | 36 virtual void OnStorePropertyCompleted( |
| 36 bool success, const std::string& name, const std::string& value) {} | 37 SignedSettings::ReturnCode code, |
| 38 const std::string& name, |
| 39 const std::string& value) {} |
| 37 | 40 |
| 38 // Callback of RetrievePropertyOp. | 41 // Callback of RetrievePropertyOp. |
| 39 virtual void OnRetrievePropertyCompleted( | 42 virtual void OnRetrievePropertyCompleted( |
| 40 bool success, const std::string& name, const std::string& value) {} | 43 SignedSettings::ReturnCode code, |
| 44 const std::string& name, |
| 45 const std::string& value) {} |
| 41 }; | 46 }; |
| 42 | 47 |
| 43 // Class factory | 48 // Class factory |
| 44 static SignedSettingsHelper* Get(); | 49 static SignedSettingsHelper* Get(); |
| 45 | 50 |
| 46 // Functions to start signed settings ops. | 51 // Functions to start signed settings ops. |
| 47 virtual void StartCheckWhitelistOp(const std::string& email, | 52 virtual void StartCheckWhitelistOp(const std::string& email, |
| 48 Callback* callback) = 0; | 53 Callback* callback) = 0; |
| 49 virtual void StartWhitelistOp(const std::string& email, | 54 virtual void StartWhitelistOp(const std::string& email, |
| 50 bool add_to_whitelist, | 55 bool add_to_whitelist, |
| (...skipping 23 matching lines...) Expand all Loading... |
| 74 protected: | 79 protected: |
| 75 SignedSettingsHelper() : test_delegate_(NULL) { | 80 SignedSettingsHelper() : test_delegate_(NULL) { |
| 76 } | 81 } |
| 77 | 82 |
| 78 TestDelegate* test_delegate_; | 83 TestDelegate* test_delegate_; |
| 79 }; | 84 }; |
| 80 | 85 |
| 81 } // namespace chromeos | 86 } // namespace chromeos |
| 82 | 87 |
| 83 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_SIGNED_SETTINGS_HELPER_H_ | 88 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_SIGNED_SETTINGS_HELPER_H_ |
| OLD | NEW |