| OLD | NEW |
| 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/callback.h" | 11 #include "base/callback.h" |
| 12 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
| 13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
| 14 #include "base/memory/weak_ptr.h" |
| 14 #include "base/strings/string16.h" | 15 #include "base/strings/string16.h" |
| 15 #include "net/cert/nss_cert_database.h" | 16 #include "net/cert/nss_cert_database.h" |
| 16 | 17 |
| 18 class CertDatabaseServiceIOPart; |
| 19 |
| 17 namespace content { | 20 namespace content { |
| 18 class BrowserContext; | 21 class BrowserContext; |
| 19 class ResourceContext; | 22 class ResourceContext; |
| 20 } // namespace content | 23 } // namespace content |
| 21 | 24 |
| 22 // CertificateManagerModel provides the data to be displayed in the certificate | 25 // CertificateManagerModel provides the data to be displayed in the certificate |
| 23 // manager dialog, and processes changes from the view. | 26 // manager dialog, and processes changes from the view. |
| 24 class CertificateManagerModel { | 27 class CertificateManagerModel { |
| 25 public: | 28 public: |
| 26 // Map from the subject organization name to the list of certs from that | 29 // Map from the subject organization name to the list of certs from that |
| (...skipping 16 matching lines...) Expand all Loading... |
| 43 public: | 46 public: |
| 44 // Called to notify the view that the certificate list has been refreshed. | 47 // Called to notify the view that the certificate list has been refreshed. |
| 45 // TODO(mattm): do a more granular updating strategy? Maybe retrieve new | 48 // TODO(mattm): do a more granular updating strategy? Maybe retrieve new |
| 46 // list of certs, diff against past list, and then notify of the changes? | 49 // list of certs, diff against past list, and then notify of the changes? |
| 47 virtual void CertificatesRefreshed() = 0; | 50 virtual void CertificatesRefreshed() = 0; |
| 48 }; | 51 }; |
| 49 | 52 |
| 50 // Creates a CertificateManagerModel. The model will be passed to the callback | 53 // Creates a CertificateManagerModel. The model will be passed to the callback |
| 51 // when it is ready. The caller must ensure the model does not outlive the | 54 // when it is ready. The caller must ensure the model does not outlive the |
| 52 // |browser_context|. | 55 // |browser_context|. |
| 53 static void Create(content::BrowserContext* browser_context, | 56 static void Create(content::BrowserContext* context, |
| 54 Observer* observer, | 57 Observer* observer, |
| 55 const CreationCallback& callback); | 58 const CreationCallback& callback); |
| 56 | 59 |
| 57 ~CertificateManagerModel(); | 60 ~CertificateManagerModel(); |
| 58 | 61 |
| 59 bool is_tpm_available() const { return is_tpm_available_; } | 62 bool is_tpm_available() const { return is_tpm_available_; } |
| 60 | 63 |
| 61 // Accessor for read-only access to the underlying NSSCertDatabase. | 64 // Accessor for read-only access to the underlying NSSCertDatabase. |
| 62 const net::NSSCertDatabase* cert_db() const { return cert_db_; } | 65 const net::NSSCertDatabase* cert_db() const { return cert_db_; } |
| 63 | 66 |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 131 // file for details. | 134 // file for details. |
| 132 static void DidGetCertDBOnUIThread( | 135 static void DidGetCertDBOnUIThread( |
| 133 net::NSSCertDatabase* cert_db, | 136 net::NSSCertDatabase* cert_db, |
| 134 bool is_tpm_available, | 137 bool is_tpm_available, |
| 135 CertificateManagerModel::Observer* observer, | 138 CertificateManagerModel::Observer* observer, |
| 136 const CreationCallback& callback); | 139 const CreationCallback& callback); |
| 137 static void DidGetCertDBOnIOThread( | 140 static void DidGetCertDBOnIOThread( |
| 138 CertificateManagerModel::Observer* observer, | 141 CertificateManagerModel::Observer* observer, |
| 139 const CreationCallback& callback, | 142 const CreationCallback& callback, |
| 140 net::NSSCertDatabase* cert_db); | 143 net::NSSCertDatabase* cert_db); |
| 141 static void GetCertDBOnIOThread(content::ResourceContext* context, | 144 static void GetCertDBOnIOThread( |
| 142 CertificateManagerModel::Observer* observer, | 145 base::WeakPtr<CertDatabaseServiceIOPart> cert_db_service_io, |
| 143 const CreationCallback& callback); | 146 CertificateManagerModel::Observer* observer, |
| 147 const CreationCallback& callback); |
| 144 | 148 |
| 145 // Callback used by Refresh() for when the cert slots have been unlocked. | 149 // Callback used by Refresh() for when the cert slots have been unlocked. |
| 146 // This method does the actual refreshing. | 150 // This method does the actual refreshing. |
| 147 void RefreshSlotsUnlocked(); | 151 void RefreshSlotsUnlocked(); |
| 148 | 152 |
| 149 net::NSSCertDatabase* cert_db_; | 153 net::NSSCertDatabase* cert_db_; |
| 150 net::CertificateList cert_list_; | 154 net::CertificateList cert_list_; |
| 151 bool is_tpm_available_; | 155 bool is_tpm_available_; |
| 152 | 156 |
| 153 // The observer to notify when certificate list is refreshed. | 157 // The observer to notify when certificate list is refreshed. |
| 154 Observer* observer_; | 158 Observer* observer_; |
| 155 | 159 |
| 156 DISALLOW_COPY_AND_ASSIGN(CertificateManagerModel); | 160 DISALLOW_COPY_AND_ASSIGN(CertificateManagerModel); |
| 157 }; | 161 }; |
| 158 | 162 |
| 159 #endif // CHROME_BROWSER_CERTIFICATE_MANAGER_MODEL_H_ | 163 #endif // CHROME_BROWSER_CERTIFICATE_MANAGER_MODEL_H_ |
| OLD | NEW |