| 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_OWNERSHIP_SERVICE_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_LOGIN_OWNERSHIP_SERVICE_H_ |
| 6 #define CHROME_BROWSER_CHROMEOS_LOGIN_OWNERSHIP_SERVICE_H_ | 6 #define CHROME_BROWSER_CHROMEOS_LOGIN_OWNERSHIP_SERVICE_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 static OwnershipService* GetSharedInstance(); | 25 static OwnershipService* GetSharedInstance(); |
| 26 virtual ~OwnershipService(); | 26 virtual ~OwnershipService(); |
| 27 | 27 |
| 28 // If the device has been owned already, posts a task to the FILE thread to | 28 // If the device has been owned already, posts a task to the FILE thread to |
| 29 // fetch the public key off disk. | 29 // fetch the public key off disk. |
| 30 // | 30 // |
| 31 // Sends out a OWNER_KEY_FETCH_ATTEMPT_SUCCESS notification on success, | 31 // Sends out a OWNER_KEY_FETCH_ATTEMPT_SUCCESS notification on success, |
| 32 // OWNER_KEY_FETCH_ATTEMPT_FAILED on failure. | 32 // OWNER_KEY_FETCH_ATTEMPT_FAILED on failure. |
| 33 virtual void StartLoadOwnerKeyAttempt(); | 33 virtual void StartLoadOwnerKeyAttempt(); |
| 34 | 34 |
| 35 // If the device has not yet been owned, posts a task to the FILE | |
| 36 // thread to generate the owner's keys and put them in the right | |
| 37 // places. Keeps them in memory as well, for later use. | |
| 38 // | |
| 39 // Upon failure, sends out OWNER_KEY_FETCH_ATTEMPT_FAILED. | |
| 40 // Upon success, sends out OWNER_KEY_FETCH_ATTEMPT_SUCCESS. | |
| 41 // If no attempt is started (if the device is already owned), no | |
| 42 // notification is sent. | |
| 43 virtual void StartTakeOwnershipAttempt(const std::string& unused); | |
| 44 | |
| 45 // Initiate an attempt to sign |data| with |private_key_|. Will call | 35 // Initiate an attempt to sign |data| with |private_key_|. Will call |
| 46 // d->OnKeyOpComplete() when done. Upon success, the signature will be passed | 36 // d->OnKeyOpComplete() when done. Upon success, the signature will be passed |
| 47 // as the |payload| argument to d->OnKeyOpComplete(). | 37 // as the |payload| argument to d->OnKeyOpComplete(). |
| 48 // | 38 // |
| 49 // If you call this on a well-known thread, you'll be called back on that | 39 // If you call this on a well-known thread, you'll be called back on that |
| 50 // thread. Otherwise, you'll get called back on the UI thread. | 40 // thread. Otherwise, you'll get called back on the UI thread. |
| 51 virtual void StartSigningAttempt(const std::string& data, | 41 virtual void StartSigningAttempt(const std::string& data, |
| 52 OwnerManager::Delegate* d); | 42 OwnerManager::Delegate* d); |
| 53 | 43 |
| 54 // Initiate an attempt to verify that |signature| is valid over |data| with | 44 // Initiate an attempt to verify that |signature| is valid over |data| with |
| (...skipping 14 matching lines...) Expand all Loading... |
| 69 virtual bool IsAlreadyOwned(); | 59 virtual bool IsAlreadyOwned(); |
| 70 | 60 |
| 71 protected: | 61 protected: |
| 72 OwnershipService(); | 62 OwnershipService(); |
| 73 | 63 |
| 74 private: | 64 private: |
| 75 friend struct base::DefaultLazyInstanceTraits<OwnershipService>; | 65 friend struct base::DefaultLazyInstanceTraits<OwnershipService>; |
| 76 friend class OwnershipServiceTest; | 66 friend class OwnershipServiceTest; |
| 77 | 67 |
| 78 static void TryLoadOwnerKeyAttempt(OwnershipService* service); | 68 static void TryLoadOwnerKeyAttempt(OwnershipService* service); |
| 79 static void TryTakeOwnershipAttempt(OwnershipService* service); | |
| 80 static void TrySigningAttempt(OwnershipService* service, | 69 static void TrySigningAttempt(OwnershipService* service, |
| 81 const BrowserThread::ID thread_id, | 70 const BrowserThread::ID thread_id, |
| 82 const std::string& data, | 71 const std::string& data, |
| 83 OwnerManager::Delegate* d); | 72 OwnerManager::Delegate* d); |
| 84 static void TryVerifyAttempt(OwnershipService* service, | 73 static void TryVerifyAttempt(OwnershipService* service, |
| 85 const BrowserThread::ID thread_id, | 74 const BrowserThread::ID thread_id, |
| 86 const std::string& data, | 75 const std::string& data, |
| 87 const std::vector<uint8>& signature, | 76 const std::vector<uint8>& signature, |
| 88 OwnerManager::Delegate* d); | 77 OwnerManager::Delegate* d); |
| 89 static void FailAttempt(OwnerManager::Delegate* d); | 78 static void FailAttempt(OwnerManager::Delegate* d); |
| 90 | 79 |
| 91 OwnerManager* manager() { return manager_.get(); } | 80 OwnerManager* manager() { return manager_.get(); } |
| 92 | 81 |
| 93 scoped_refptr<OwnerManager> manager_; | 82 scoped_refptr<OwnerManager> manager_; |
| 94 scoped_refptr<OwnerKeyUtils> utils_; | 83 scoped_refptr<OwnerKeyUtils> utils_; |
| 95 }; | 84 }; |
| 96 | 85 |
| 97 } // namespace chromeos | 86 } // namespace chromeos |
| 98 | 87 |
| 99 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_OWNERSHIP_SERVICE_H_ | 88 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_OWNERSHIP_SERVICE_H_ |
| OLD | NEW |