OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_OWNER_MANAGER_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_LOGIN_OWNER_MANAGER_H_ |
6 #define CHROME_BROWSER_CHROMEOS_LOGIN_OWNER_MANAGER_H_ | 6 #define CHROME_BROWSER_CHROMEOS_LOGIN_OWNER_MANAGER_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
12 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
13 #include "crypto/rsa_private_key.h" | 13 #include "crypto/rsa_private_key.h" |
14 #include "chrome/browser/chromeos/login/owner_key_utils.h" | 14 #include "chrome/browser/chromeos/login/owner_key_utils.h" |
15 #include "content/browser/browser_thread.h" | 15 #include "content/browser/browser_thread.h" |
16 | 16 |
17 class FilePath; | 17 class FilePath; |
18 class NotificationDetails; | 18 class NotificationDetails; |
19 class NotificationType; | 19 class int; |
20 | 20 |
21 namespace chromeos { | 21 namespace chromeos { |
22 | 22 |
23 // This class allows the registration of an Owner of a Chromium OS device. | 23 // This class allows the registration of an Owner of a Chromium OS device. |
24 // It handles generating the appropriate keys and storing them in the | 24 // It handles generating the appropriate keys and storing them in the |
25 // appropriate locations. | 25 // appropriate locations. |
26 class OwnerManager : public base::RefCountedThreadSafe<OwnerManager> { | 26 class OwnerManager : public base::RefCountedThreadSafe<OwnerManager> { |
27 public: | 27 public: |
28 // Return codes for public/private key operations. | 28 // Return codes for public/private key operations. |
29 enum KeyOpCode { | 29 enum KeyOpCode { |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 // successful return code, passing an empty string for |payload|. | 83 // successful return code, passing an empty string for |payload|. |
84 // On failure, calls d->OnKeyOpComplete() on |thread_id| with an appropriate | 84 // On failure, calls d->OnKeyOpComplete() on |thread_id| with an appropriate |
85 // error code, passing an empty string for |payload|. | 85 // error code, passing an empty string for |payload|. |
86 void Verify(const BrowserThread::ID thread_id, | 86 void Verify(const BrowserThread::ID thread_id, |
87 const std::string& data, | 87 const std::string& data, |
88 const std::vector<uint8>& signature, | 88 const std::vector<uint8>& signature, |
89 Delegate* d); | 89 Delegate* d); |
90 | 90 |
91 private: | 91 private: |
92 // A helper method to send a notification on another thread. | 92 // A helper method to send a notification on another thread. |
93 void SendNotification(NotificationType type, | 93 void SendNotification(int type, |
94 const NotificationDetails& details); | 94 const NotificationDetails& details); |
95 | 95 |
96 // Calls back a key update delegate on a given thread. | 96 // Calls back a key update delegate on a given thread. |
97 void CallKeyUpdateDelegate(KeyUpdateDelegate* d) { | 97 void CallKeyUpdateDelegate(KeyUpdateDelegate* d) { |
98 d->OnKeyUpdated(); | 98 d->OnKeyUpdated(); |
99 } | 99 } |
100 | 100 |
101 // A helper method to call back a delegte on another thread. | 101 // A helper method to call back a delegte on another thread. |
102 void CallDelegate(Delegate* d, | 102 void CallDelegate(Delegate* d, |
103 const KeyOpCode return_code, | 103 const KeyOpCode return_code, |
104 const std::vector<uint8>& payload) { | 104 const std::vector<uint8>& payload) { |
105 d->OnKeyOpComplete(return_code, payload); | 105 d->OnKeyOpComplete(return_code, payload); |
106 } | 106 } |
107 | 107 |
108 scoped_ptr<crypto::RSAPrivateKey> private_key_; | 108 scoped_ptr<crypto::RSAPrivateKey> private_key_; |
109 std::vector<uint8> public_key_; | 109 std::vector<uint8> public_key_; |
110 | 110 |
111 scoped_refptr<OwnerKeyUtils> utils_; | 111 scoped_refptr<OwnerKeyUtils> utils_; |
112 | 112 |
113 friend class OwnerManagerTest; | 113 friend class OwnerManagerTest; |
114 | 114 |
115 DISALLOW_COPY_AND_ASSIGN(OwnerManager); | 115 DISALLOW_COPY_AND_ASSIGN(OwnerManager); |
116 }; | 116 }; |
117 | 117 |
118 } // namespace chromeos | 118 } // namespace chromeos |
119 | 119 |
120 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_OWNER_MANAGER_H_ | 120 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_OWNER_MANAGER_H_ |
OLD | NEW |