Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(375)

Side by Side Diff: chrome/browser/chromeos/cros/login_library.cc

Issue 6538098: [Chrome OS] Owner keys are generated outside Chrome now; handle appropriately (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 #include "chrome/browser/chromeos/cros/login_library.h" 5 #include "chrome/browser/chromeos/cros/login_library.h"
6 6
7 #include "base/message_loop.h" 7 #include "base/message_loop.h"
8 #include "chrome/browser/browser_process.h"
8 #include "chrome/browser/browser_thread.h" 9 #include "chrome/browser/browser_thread.h"
9 #include "chrome/browser/chromeos/cros/cros_library.h" 10 #include "chrome/browser/chromeos/cros/cros_library.h"
11 #include "chrome/browser/chromeos/login/signed_settings_temp_storage.h"
12 #include "chrome/common/notification_service.h"
13 #include "chrome/common/notification_type.h"
10 14
11 namespace chromeos { 15 namespace chromeos {
12 16
13 class LoginLibraryImpl : public LoginLibrary { 17 class LoginLibraryImpl : public LoginLibrary {
14 public: 18 public:
15 LoginLibraryImpl() 19 LoginLibraryImpl()
16 : set_owner_key_callback_(NULL), 20 : set_owner_key_callback_(NULL),
17 whitelist_op_callback_(NULL), 21 whitelist_op_callback_(NULL),
18 property_op_callback_(NULL) { 22 property_op_callback_(NULL) {
19 if (CrosLibrary::Get()->EnsureLoaded()) 23 if (CrosLibrary::Get()->EnsureLoaded())
(...skipping 27 matching lines...) Expand all
47 if (chromeos::RetrievePropertySafe(name.c_str(), &prop)) { 51 if (chromeos::RetrievePropertySafe(name.c_str(), &prop)) {
48 OUT_value->assign(prop->value); 52 OUT_value->assign(prop->value);
49 CryptoBlob* sig = prop->signature; 53 CryptoBlob* sig = prop->signature;
50 OUT_signature->assign(sig->data, sig->data + sig->length); 54 OUT_signature->assign(sig->data, sig->data + sig->length);
51 chromeos::FreeProperty(prop); 55 chromeos::FreeProperty(prop);
52 return true; 56 return true;
53 } 57 }
54 return false; 58 return false;
55 } 59 }
56 60
57 bool SetOwnerKeyAsync(const std::vector<uint8>& public_key_der,
58 Delegate* callback) {
59 DCHECK(callback) << "must provide a callback to SetOwnerKeyAsync()";
60 if (set_owner_key_callback_)
61 return false;
62 set_owner_key_callback_ = callback;
63 CryptoBlob* key = chromeos::CreateCryptoBlob(&public_key_der[0],
64 public_key_der.size());
65 bool rv = chromeos::SetOwnerKeySafe(key);
66 chromeos::FreeCryptoBlob(key);
67 return rv;
68 }
69
70 bool StorePropertyAsync(const std::string& name, 61 bool StorePropertyAsync(const std::string& name,
71 const std::string& value, 62 const std::string& value,
72 const std::vector<uint8>& signature, 63 const std::vector<uint8>& signature,
73 Delegate* callback) { 64 Delegate* callback) {
74 DCHECK(callback) << "must provide a callback to StorePropertyAsync()"; 65 DCHECK(callback) << "must provide a callback to StorePropertyAsync()";
75 if (property_op_callback_) 66 if (property_op_callback_)
76 return false; 67 return false;
77 property_op_callback_ = callback; 68 property_op_callback_ = callback;
78 Property* prop = chromeos::CreateProperty(name.c_str(), 69 Property* prop = chromeos::CreateProperty(name.c_str(),
79 value.c_str(), 70 value.c_str(),
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 default: 158 default:
168 NOTREACHED(); 159 NOTREACHED();
169 break; 160 break;
170 } 161 }
171 } 162 }
172 163
173 void Init() { 164 void Init() {
174 session_connection_ = chromeos::MonitorSession(&Handler, this); 165 session_connection_ = chromeos::MonitorSession(&Handler, this);
175 } 166 }
176 167
177 void CompleteSetOwnerKey(bool result) { 168 void CompleteSetOwnerKey(bool value) {
178 if (set_owner_key_callback_) { 169 VLOG(1) << "Owner key generation: " << (value ? "success" : "fail");
179 set_owner_key_callback_->OnComplete(result); 170 NotificationType result =
180 set_owner_key_callback_ = NULL; 171 NotificationType::OWNER_KEY_FETCH_ATTEMPT_SUCCEEDED;
172 if (!value)
173 result = NotificationType::OWNER_KEY_FETCH_ATTEMPT_FAILED;
174
175 // Whether we exported the public key or not, send a notification indicating
176 // that we're done with this attempt.
177 NotificationService::current()->Notify(result,
178 NotificationService::AllSources(),
179 NotificationService::NoDetails());
180
181 // We stored some settings in transient storage before owner was assigned.
182 // Now owner is assigned and key is generated and we should persist
183 // those settings into signed storage.
184 if (g_browser_process && g_browser_process->local_state()) {
185 SignedSettingsTempStorage::Finalize(g_browser_process->local_state());
181 } 186 }
182 } 187 }
183 188
184 void CompleteWhitelistOp(bool result) { 189 void CompleteWhitelistOp(bool result) {
185 if (whitelist_op_callback_) { 190 if (whitelist_op_callback_) {
186 whitelist_op_callback_->OnComplete(result); 191 whitelist_op_callback_->OnComplete(result);
187 whitelist_op_callback_ = NULL; 192 whitelist_op_callback_ = NULL;
188 } 193 }
189 } 194 }
190 195
(...skipping 24 matching lines...) Expand all
215 OUT_signature->assign(2, 0); 220 OUT_signature->assign(2, 0);
216 return true; 221 return true;
217 } 222 }
218 bool RetrieveProperty(const std::string& name, 223 bool RetrieveProperty(const std::string& name,
219 std::string* OUT_value, 224 std::string* OUT_value,
220 std::vector<uint8>* OUT_signature) { 225 std::vector<uint8>* OUT_signature) {
221 OUT_value->assign("stub"); 226 OUT_value->assign("stub");
222 OUT_signature->assign(2, 0); 227 OUT_signature->assign(2, 0);
223 return true; 228 return true;
224 } 229 }
225 bool SetOwnerKeyAsync(const std::vector<uint8>& public_key_der,
226 Delegate* callback) {
227 BrowserThread::PostTask(
228 BrowserThread::UI, FROM_HERE,
229 NewRunnableFunction(&DoStubCallback, callback));
230 return true;
231 }
232 bool StorePropertyAsync(const std::string& name, 230 bool StorePropertyAsync(const std::string& name,
233 const std::string& value, 231 const std::string& value,
234 const std::vector<uint8>& signature, 232 const std::vector<uint8>& signature,
235 Delegate* callback) { 233 Delegate* callback) {
236 BrowserThread::PostTask( 234 BrowserThread::PostTask(
237 BrowserThread::UI, FROM_HERE, 235 BrowserThread::UI, FROM_HERE,
238 NewRunnableFunction(&DoStubCallback, callback)); 236 NewRunnableFunction(&DoStubCallback, callback));
239 return true; 237 return true;
240 } 238 }
241 bool UnwhitelistAsync(const std::string& email, 239 bool UnwhitelistAsync(const std::string& email,
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
273 271
274 // static 272 // static
275 LoginLibrary* LoginLibrary::GetImpl(bool stub) { 273 LoginLibrary* LoginLibrary::GetImpl(bool stub) {
276 if (stub) 274 if (stub)
277 return new LoginLibraryStubImpl(); 275 return new LoginLibraryStubImpl();
278 else 276 else
279 return new LoginLibraryImpl(); 277 return new LoginLibraryImpl();
280 } 278 }
281 279
282 } // namespace chromeos 280 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/cros/login_library.h ('k') | chrome/browser/chromeos/cros/mock_login_library.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698