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

Side by Side Diff: chrome/browser/net/nss_context.cc

Issue 53763003: Initialize per-ChromeOS-user NSS slots and provide the functions to access them. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: sync to r235279 Created 7 years, 1 month 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
(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 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698