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

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

Issue 6821075: Chrome-side lockbox bindings (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: ...and now again only my stuff! Created 9 years, 8 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) 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 #include "chrome/browser/chromeos/cros/cryptohome_library.h" 5 #include "chrome/browser/chromeos/cros/cryptohome_library.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/hash_tables.h" 8 #include "base/hash_tables.h"
9 #include "base/message_loop.h" 9 #include "base/message_loop.h"
10 #include "chrome/browser/chromeos/cros/cros_library.h" 10 #include "chrome/browser/chromeos/cros/cros_library.h"
11 #include "chrome/common/chrome_switches.h" 11 #include "chrome/common/chrome_switches.h"
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 } 155 }
156 156
157 void TpmCanAttemptOwnership() { 157 void TpmCanAttemptOwnership() {
158 chromeos::CryptohomeTpmCanAttemptOwnership(); 158 chromeos::CryptohomeTpmCanAttemptOwnership();
159 } 159 }
160 160
161 void TpmClearStoredPassword() { 161 void TpmClearStoredPassword() {
162 chromeos::CryptohomeTpmClearStoredPassword(); 162 chromeos::CryptohomeTpmClearStoredPassword();
163 } 163 }
164 164
165 bool InstallAttributesGet(const std::string& name, std::string* value) {
166 char* local_value;
167 bool done =
168 chromeos::CryptohomeInstallAttributesGet(name.c_str(), &local_value);
169 *value = local_value;
170 chromeos::CryptohomeFreeString(local_value);
171 return done;
172 }
173
174 bool InstallAttributesSet(const std::string& name, const std::string& value) {
175 return chromeos::CryptohomeInstallAttributesSet(name.c_str(),
176 value.c_str());
177 }
178
179 int InstallAttributesCount() {
180 return chromeos::CryptohomeInstallAttributesCount();
181 }
182
183 bool InstallAttributesFinalize() {
184 return chromeos::CryptohomeInstallAttributesFinalize();
185 }
186
187 bool InstallAttributesIsReady() {
188 return chromeos::CryptohomeInstallAttributesIsReady();
189 }
190
191 bool InstallAttributesIsSecure() {
192 return chromeos::CryptohomeInstallAttributesIsSecure();
193 }
194
195 bool InstallAttributesIsInvalid() {
196 return chromeos::CryptohomeInstallAttributesIsInvalid();
197 }
198
199 bool InstallAttributesIsFirstInstall() {
200 return chromeos::CryptohomeInstallAttributesIsFirstInstall();
201 }
202
165 private: 203 private:
166 static void Handler(const chromeos::CryptohomeAsyncCallStatus& event, 204 static void Handler(const chromeos::CryptohomeAsyncCallStatus& event,
167 void* cryptohome_library) { 205 void* cryptohome_library) {
168 CryptohomeLibraryImpl* library = 206 CryptohomeLibraryImpl* library =
169 reinterpret_cast<CryptohomeLibraryImpl*>(cryptohome_library); 207 reinterpret_cast<CryptohomeLibraryImpl*>(cryptohome_library);
170 library->Dispatch(event); 208 library->Dispatch(event);
171 } 209 }
172 210
173 void Init() { 211 void Init() {
174 cryptohome_connection_ = chromeos::CryptohomeMonitorSession(&Handler, this); 212 cryptohome_connection_ = chromeos::CryptohomeMonitorSession(&Handler, this);
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
325 363
326 bool TpmGetPassword(std::string* password) { 364 bool TpmGetPassword(std::string* password) {
327 *password = "Stub-TPM-password"; 365 *password = "Stub-TPM-password";
328 return true; 366 return true;
329 } 367 }
330 368
331 void TpmCanAttemptOwnership() {} 369 void TpmCanAttemptOwnership() {}
332 370
333 void TpmClearStoredPassword() {} 371 void TpmClearStoredPassword() {}
334 372
373 bool InstallAttributesGet(const std::string& name, std::string* value) {
374 if (lockbox_.find(name) != lockbox_.end()) {
375 *value = lockbox_[name];
376 return true;
377 }
378 return false;
379 }
380
381 bool InstallAttributesSet(const std::string& name, const std::string& value) {
382 lockbox_[name] = value;
kmixter1 2011/04/14 16:52:22 why? Is this just until the actual implementation
383 return true;
384 }
385
386 int InstallAttributesCount() {
387 return lockbox_.size();
388 }
389
390 bool InstallAttributesFinalize() {
391 locked_ = true;
392 return true;
393 }
394
395 bool InstallAttributesIsReady() {
396 return true;
397 }
398
399 bool InstallAttributesIsSecure() {
400 return locked_;
401 }
402
403 bool InstallAttributesIsInvalid() {
404 return false;
405 }
406
407 bool InstallAttributesIsFirstInstall() {
408 return false;
409 }
410
335 private: 411 private:
336 static void DoStubCallback(Delegate* callback) { 412 static void DoStubCallback(Delegate* callback) {
337 if (callback) 413 if (callback)
338 callback->OnComplete(true, kCryptohomeMountErrorNone); 414 callback->OnComplete(true, kCryptohomeMountErrorNone);
339 } 415 }
416
417 std::map<std::string, std::string> lockbox_;
418 bool locked_;
340 DISALLOW_COPY_AND_ASSIGN(CryptohomeLibraryStubImpl); 419 DISALLOW_COPY_AND_ASSIGN(CryptohomeLibraryStubImpl);
341 }; 420 };
342 421
343 // static 422 // static
344 CryptohomeLibrary* CryptohomeLibrary::GetImpl(bool stub) { 423 CryptohomeLibrary* CryptohomeLibrary::GetImpl(bool stub) {
345 if (stub) 424 if (stub)
346 return new CryptohomeLibraryStubImpl(); 425 return new CryptohomeLibraryStubImpl();
347 else 426 else
348 return new CryptohomeLibraryImpl(); 427 return new CryptohomeLibraryImpl();
349 } 428 }
350 429
351 } // namespace chromeos 430 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698