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

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

Issue 18121007: *WIP* Store NSS slots per profile. Move keygen to chrome. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: certdb: handle GetCertTrust and IsUntrusted, failed attempt to handle SetCertTrust 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 "content/public/browser/nss_context.h"
6
7 #include "content/public/browser/browser_thread.h"
8 #include "content/public/browser/resource_context.h"
9 #include "crypto/nss_util_internal.h"
10 #include "net/cert/nss_cert_database.h"
11
12 #if defined(OS_CHROMEOS)
13 #include "net/cert/nss_cert_database_chromeos.h"
14 #endif
15
16 namespace content {
17
18 #if defined(OS_CHROMEOS)
19 namespace {
20
21 const void* kUserDataKey = &kUserDataKey;
22
23 class ChromeOSContextData : public ResourceContext::Data {
24 public:
25 ChromeOSContextData(const std::string username_hash);
26 virtual ~ChromeOSContextData();
27
28 std::string username_hash() const { return username_hash_; }
29
30 private:
31 std::string username_hash_;
32 };
33
34 ChromeOSContextData::ChromeOSContextData(const std::string username_hash)
35 : username_hash_(username_hash) {}
36 ChromeOSContextData::~ChromeOSContextData() {}
37
38 } // namespace
39
40 void SetChromeOSUserForResourceContext(ResourceContext* context,
41 const std::string username_hash) {
42 DCHECK(!context->GetUserData(kUserDataKey));
43 context->SetUserData(kUserDataKey, new ChromeOSContextData(username_hash));
44 }
45
46 std::string GetChromeOSUserForResourceContext(ResourceContext* context) {
47 ChromeOSContextData* data = reinterpret_cast<ChromeOSContextData*>(
48 context->GetUserData(kUserDataKey));
49 if (!data)
50 return std::string();
51 return data->username_hash();
52 }
53 #endif // defined(OS_CHROMEOS)
54
55 void OnPrivateNSSKeySlotForResourceContextReady(
56 ResourceContext* context,
57 const base::Callback<void(crypto::ScopedPK11Slot)>& callback) {
58 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
59 #if defined(OS_CHROMEOS)
60 std::string username_hash = GetChromeOSUserForResourceContext(context);
61 crypto::OnPrivateSlotReadyForChromeOSUser(username_hash, callback);
62 #else
63 callback.Run(crypto::ScopedPK11Slot(crypto::GetPrivateNSSKeySlot()));
64 #endif
65 }
66
67 void OnNSSKeySlotsForResourceContextReady(
68 ResourceContext* context,
69 const base::Callback<
70 void(crypto::ScopedPK11Slot, crypto::ScopedPK11Slot)>& callback) {
71 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
72 #if defined(OS_CHROMEOS)
73 std::string username_hash = GetChromeOSUserForResourceContext(context);
74 crypto::OnPrivateSlotReadyForChromeOSUser(
75 username_hash,
76 base::Bind(
77 callback,
78 base::Passed(crypto::GetPublicSlotForChromeOSUser(username_hash))));
79 #else
80 callback.Run(crypto::ScopedPK11Slot(crypto::GetPublicNSSKeySlot()),
81 crypto::ScopedPK11Slot(crypto::GetPrivateNSSKeySlot()));
82 #endif
83 }
84
85 void GetNSSCertDatabaseForResourceContext(
86 ResourceContext* context,
87 const base::Callback<void(net::NSSCertDatabase*)>& callback) {
88 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
89 #if defined(OS_CHROMEOS)
90 net::NSSCertDatabaseChromeOS::GetForUser(
91 GetChromeOSUserForResourceContext(context), callback);
92 #else
93 callback.Run(NSSCertDatabase::GetInstance());
94 #endif
95 }
96
97 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/net/keygen_handler.cc ('k') | content/browser/renderer_host/render_message_filter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698