OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "chrome/browser/net/nss_context.h" |
| 6 |
| 7 #include "chrome/browser/profiles/profile_io_data.h" |
| 8 #include "content/public/browser/browser_thread.h" |
| 9 #include "crypto/nss_util_internal.h" |
| 10 |
| 11 namespace { |
| 12 #if defined(OS_CHROMEOS) |
| 13 std::string GetUsername(content::ResourceContext* context) { |
| 14 return ProfileIOData::FromResourceContext(context)->username_hash(); |
| 15 } |
| 16 #endif // defined(OS_CHROMEOS) |
| 17 } // namespace |
| 18 |
| 19 void OnPrivateNSSKeySlotForResourceContextReady( |
| 20 content::ResourceContext* context, |
| 21 const base::Callback<void(crypto::ScopedPK11Slot)>& callback) { |
| 22 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)); |
| 23 #if defined(OS_CHROMEOS) |
| 24 crypto::OnPrivateSlotReadyForChromeOSUser(GetUsername(context), callback); |
| 25 #else |
| 26 callback.Run(crypto::ScopedPK11Slot(crypto::GetPrivateNSSKeySlot())); |
| 27 #endif |
| 28 } |
| 29 |
| 30 void OnNSSKeySlotsForResourceContextReady( |
| 31 content::ResourceContext* context, |
| 32 const base::Callback< |
| 33 void(crypto::ScopedPK11Slot, crypto::ScopedPK11Slot)>& callback) { |
| 34 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)); |
| 35 #if defined(OS_CHROMEOS) |
| 36 std::string username_hash = GetUsername(context); |
| 37 crypto::OnPrivateSlotReadyForChromeOSUser( |
| 38 username_hash, |
| 39 base::Bind( |
| 40 callback, |
| 41 base::Passed(crypto::GetPublicSlotForChromeOSUser(username_hash)))); |
| 42 #else |
| 43 callback.Run(crypto::ScopedPK11Slot(crypto::GetPublicNSSKeySlot()), |
| 44 crypto::ScopedPK11Slot(crypto::GetPrivateNSSKeySlot())); |
| 45 #endif |
| 46 } |
OLD | NEW |