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

Side by Side Diff: chrome/browser/net/nss_slot_factory.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: Created 7 years, 5 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
(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_slot_factory.h"
6
7 // XXX:
8 #include "chrome/browser/profiles/incognito_helpers.h"
9 #include "components/browser_context_keyed_service/browser_context_dependency_ma nager.h"
10 #include "crypto/nss_util_internal.h"
11
12 namespace chrome {
13
14 namespace {
15
16 class NSSSlotService : public BrowserContextKeyedService {
17 public:
18 explicit NSSSlotService(content::BrowserContext* context);
19
20 crypto::ScopedPK11Slot GetPublicNSSKeySlot();
21 crypto::ScopedPK11Slot GetPrivateNSSKeySlot();
22
23 private:
24 crypto::ScopedPK11Slot public_slot_;
25 crypto::ScopedPK11Slot private_slot_;
26
27 DISALLOW_COPY_AND_ASSIGN(NSSSlotService);
28 };
29
30 NSSSlotService::NSSSlotService(content::BrowserContext* context) {
31 // TODO: #ifdef OS_CHROMEOS
32 // load public slot using context->GetPath().
33 // load private slot using ??? (dbus call to cryptohomed?)
34 // #else
35 public_slot_.reset(crypto::GetPublicNSSKeySlot());
36 private_slot_.reset(crypto::GetPrivateNSSKeySlot());
37 }
38
39 crypto::ScopedPK11Slot NSSSlotService::GetPublicNSSKeySlot() {
40 return crypto::ScopedPK11Slot(PK11_ReferenceSlot(public_slot_.get()));
41 }
42
43 crypto::ScopedPK11Slot NSSSlotService::GetPrivateNSSKeySlot() {
44 return crypto::ScopedPK11Slot(PK11_ReferenceSlot(private_slot_.get()));
45 }
46
47 } // namespace
48
49 // static
50 crypto::ScopedPK11Slot NSSSlotFactory::GetPublicSlotForBrowserContext(
51 content::BrowserContext* context) {
52 NSSSlotService* service = static_cast<NSSSlotService*>(
53 GetInstance()->GetServiceForBrowserContext(context, true));
54 return service->GetPublicNSSKeySlot();
55 }
56
57 // static
58 crypto::ScopedPK11Slot NSSSlotFactory::GetPrivateSlotForBrowserContext(
59 content::BrowserContext* context) {
60 NSSSlotService* service = static_cast<NSSSlotService*>(
61 GetInstance()->GetServiceForBrowserContext(context, true));
62 return service->GetPrivateNSSKeySlot();
63 }
64
65 // static
66 NSSSlotFactory* NSSSlotFactory::GetInstance() {
67 return Singleton<NSSSlotFactory>::get();
68 }
69
70 BrowserContextKeyedService* NSSSlotFactory::BuildServiceInstanceFor(
71 content::BrowserContext* context) const {
72 NSSSlotService* service = new NSSSlotService(context);
73
74 return service;
75 }
76
77 content::BrowserContext* NSSSlotFactory::GetBrowserContextToUse(
78 content::BrowserContext* context) const {
79 return chrome::GetBrowserContextRedirectedInIncognito(context);
80 }
81
82 NSSSlotFactory::NSSSlotFactory()
83 : BrowserContextKeyedServiceFactory(
84 "NSSSlotService",
85 BrowserContextDependencyManager::GetInstance()) {
86 }
87
88 NSSSlotFactory::~NSSSlotFactory() {
89 }
90
91 } // namespace chrome
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698