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

Side by Side Diff: chrome/browser/certificate_manager_model.h

Issue 18121007: *WIP* Store NSS slots per profile. Move keygen to chrome. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: more refactoring Created 7 years 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
« no previous file with comments | « no previous file | chrome/browser/certificate_manager_model.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 #ifndef CHROME_BROWSER_CERTIFICATE_MANAGER_MODEL_H_ 5 #ifndef CHROME_BROWSER_CERTIFICATE_MANAGER_MODEL_H_
6 #define CHROME_BROWSER_CERTIFICATE_MANAGER_MODEL_H_ 6 #define CHROME_BROWSER_CERTIFICATE_MANAGER_MODEL_H_
7 7
8 #include <map> 8 #include <map>
9 #include <string> 9 #include <string>
10 10
11 #include "base/memory/ref_counted.h" 11 #include "base/memory/ref_counted.h"
12 #include "base/memory/weak_ptr.h"
12 #include "base/strings/string16.h" 13 #include "base/strings/string16.h"
13 #include "net/cert/nss_cert_database.h" 14 #include "net/cert/nss_cert_database.h"
14 15
16 namespace content {
17 class BrowserContext;
18 } // namespace content
19
15 // CertificateManagerModel provides the data to be displayed in the certificate 20 // CertificateManagerModel provides the data to be displayed in the certificate
16 // manager dialog, and processes changes from the view. 21 // manager dialog, and processes changes from the view.
17 class CertificateManagerModel { 22 class CertificateManagerModel {
18 public: 23 public:
19 // Map from the subject organization name to the list of certs from that 24 // Map from the subject organization name to the list of certs from that
20 // organization. If a cert does not have an organization name, the 25 // organization. If a cert does not have an organization name, the
21 // subject's CertPrincipal::GetDisplayName() value is used instead. 26 // subject's CertPrincipal::GetDisplayName() value is used instead.
22 typedef std::map<std::string, net::CertificateList> OrgGroupingMap; 27 typedef std::map<std::string, net::CertificateList> OrgGroupingMap;
23 28
24 // Enumeration of the possible columns in the certificate manager tree view. 29 // Enumeration of the possible columns in the certificate manager tree view.
25 enum Column { 30 enum Column {
26 COL_SUBJECT_NAME, 31 COL_SUBJECT_NAME,
27 COL_CERTIFICATE_STORE, 32 COL_CERTIFICATE_STORE,
28 COL_SERIAL_NUMBER, 33 COL_SERIAL_NUMBER,
29 COL_EXPIRES_ON, 34 COL_EXPIRES_ON,
30 }; 35 };
31 36
32 class Observer { 37 class Observer {
33 public: 38 public:
39 // Called once the initializiation is complete and cert_db() is non-NULL.
40 virtual void CertificateManagerModelReady() = 0;
41
34 // Called to notify the view that the certificate list has been refreshed. 42 // Called to notify the view that the certificate list has been refreshed.
35 // TODO(mattm): do a more granular updating strategy? Maybe retrieve new 43 // TODO(mattm): do a more granular updating strategy? Maybe retrieve new
36 // list of certs, diff against past list, and then notify of the changes? 44 // list of certs, diff against past list, and then notify of the changes?
37 virtual void CertificatesRefreshed() = 0; 45 virtual void CertificatesRefreshed() = 0;
38 }; 46 };
39 47
40 explicit CertificateManagerModel(Observer* observer); 48 // Create the CertificateManagerModel. Caller should wait until
49 // |observer->CertificateManagerModelReady| has been called before using.
50 CertificateManagerModel(content::BrowserContext* browser_context,
51 Observer* observer);
41 ~CertificateManagerModel(); 52 ~CertificateManagerModel();
42 53
54 bool is_ready() const { return cert_db_; }
55
43 // Accessor for read-only access to the underlying NSSCertDatabase. 56 // Accessor for read-only access to the underlying NSSCertDatabase.
44 const net::NSSCertDatabase* cert_db() const { return cert_db_; } 57 const net::NSSCertDatabase* cert_db() const { return cert_db_; }
45 58
46 // Trigger a refresh of the list of certs, unlock any slots if necessary. 59 // Trigger a refresh of the list of certs, unlock any slots if necessary.
47 // Following this call, the observer CertificatesRefreshed method will be 60 // Following this call, the observer CertificatesRefreshed method will be
48 // called so the view can call FilterAndBuildOrgGroupingMap as necessary to 61 // called so the view can call FilterAndBuildOrgGroupingMap as necessary to
49 // refresh its tree views. 62 // refresh its tree views.
50 void Refresh(); 63 void Refresh();
51 64
52 // Fill |map| with the certificates matching |filter_type|. 65 // Fill |map| with the certificates matching |filter_type|.
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 net::NSSCertDatabase::TrustBits trust_bits); 111 net::NSSCertDatabase::TrustBits trust_bits);
99 112
100 // Delete the cert. Returns true on success. |cert| is still valid when this 113 // Delete the cert. Returns true on success. |cert| is still valid when this
101 // function returns. 114 // function returns.
102 bool Delete(net::X509Certificate* cert); 115 bool Delete(net::X509Certificate* cert);
103 116
104 // IsHardwareBacked returns true if |cert| is hardware backed. 117 // IsHardwareBacked returns true if |cert| is hardware backed.
105 bool IsHardwareBacked(const net::X509Certificate* cert) const; 118 bool IsHardwareBacked(const net::X509Certificate* cert) const;
106 119
107 private: 120 private:
121 // We got the cert database corresponding to the BrowserContext.
122 void DidGetCertDB(net::NSSCertDatabase* cert_db);
123
108 // Callback used by Refresh() for when the cert slots have been unlocked. 124 // Callback used by Refresh() for when the cert slots have been unlocked.
109 // This method does the actual refreshing. 125 // This method does the actual refreshing.
110 void RefreshSlotsUnlocked(); 126 void RefreshSlotsUnlocked();
111 127
112 net::NSSCertDatabase* cert_db_; 128 net::NSSCertDatabase* cert_db_;
113 net::CertificateList cert_list_; 129 net::CertificateList cert_list_;
114 130
115 // The observer to notify when certificate list is refreshed. 131 // The observer to notify when certificate list is refreshed.
116 Observer* observer_; 132 Observer* observer_;
117 133
134 base::WeakPtrFactory<CertificateManagerModel> weak_ptr_factory_;
135
118 DISALLOW_COPY_AND_ASSIGN(CertificateManagerModel); 136 DISALLOW_COPY_AND_ASSIGN(CertificateManagerModel);
119 }; 137 };
120 138
121 #endif // CHROME_BROWSER_CERTIFICATE_MANAGER_MODEL_H_ 139 #endif // CHROME_BROWSER_CERTIFICATE_MANAGER_MODEL_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/certificate_manager_model.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698