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

Side by Side Diff: chrome/browser/chromeos/certificate_provider/certificate_provider_service.h

Issue 2094333002: Implementation for chrome.certificateProvider.requestPin/stopPinRequest (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Small fix Created 4 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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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_CHROMEOS_CERTIFICATE_PROVIDER_CERTIFICATE_PROVIDER_SERVIC E_H_ 5 #ifndef CHROME_BROWSER_CHROMEOS_CERTIFICATE_PROVIDER_CERTIFICATE_PROVIDER_SERVIC E_H_
6 #define CHROME_BROWSER_CHROMEOS_CERTIFICATE_PROVIDER_CERTIFICATE_PROVIDER_SERVIC E_H_ 6 #define CHROME_BROWSER_CHROMEOS_CERTIFICATE_PROVIDER_CERTIFICATE_PROVIDER_SERVIC E_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <map> 10 #include <map>
11 #include <memory> 11 #include <memory>
12 #include <string> 12 #include <string>
13 #include <vector> 13 #include <vector>
14 14
15 #include "base/callback_forward.h" 15 #include "base/callback_forward.h"
16 #include "base/macros.h" 16 #include "base/macros.h"
17 #include "base/memory/ref_counted.h" 17 #include "base/memory/ref_counted.h"
18 #include "base/memory/weak_ptr.h" 18 #include "base/memory/weak_ptr.h"
19 #include "base/threading/thread_checker.h" 19 #include "base/threading/thread_checker.h"
20 #include "chrome/browser/chromeos/certificate_provider/certificate_info.h" 20 #include "chrome/browser/chromeos/certificate_provider/certificate_info.h"
21 #include "chrome/browser/chromeos/certificate_provider/certificate_requests.h" 21 #include "chrome/browser/chromeos/certificate_provider/certificate_requests.h"
22 #include "chrome/browser/chromeos/certificate_provider/sign_requests.h" 22 #include "chrome/browser/chromeos/certificate_provider/sign_requests.h"
23 #include "chrome/browser/chromeos/certificate_provider/thread_safe_certificate_m ap.h" 23 #include "chrome/browser/chromeos/certificate_provider/thread_safe_certificate_m ap.h"
24 #include "chrome/browser/chromeos/options/request_pin_view.h"
24 #include "components/keyed_service/core/keyed_service.h" 25 #include "components/keyed_service/core/keyed_service.h"
25 #include "net/cert/x509_certificate.h" 26 #include "net/cert/x509_certificate.h"
26 #include "net/ssl/ssl_private_key.h" 27 #include "net/ssl/ssl_private_key.h"
27 28
28 namespace chromeos { 29 namespace chromeos {
29 30
30 class CertificateProvider; 31 class CertificateProvider;
31 32
32 // A keyed service that manages registrations of extensions as certificate 33 // A keyed service that manages registrations of extensions as certificate
33 // providers. It exposes all certificates that are provided by extensions 34 // providers. It exposes all certificates that are provided by extensions
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 // call its |GetCertificates()|. The returned provider is valid even after the 144 // call its |GetCertificates()|. The returned provider is valid even after the
144 // destruction of this service. 145 // destruction of this service.
145 // The returned provider can be used on any thread. 146 // The returned provider can be used on any thread.
146 std::unique_ptr<CertificateProvider> CreateCertificateProvider(); 147 std::unique_ptr<CertificateProvider> CreateCertificateProvider();
147 148
148 // Must be called if extension with id |extension_id| is unloaded and cannot 149 // Must be called if extension with id |extension_id| is unloaded and cannot
149 // serve certificates anymore. This should be called everytime the 150 // serve certificates anymore. This should be called everytime the
150 // corresponding notification of the ExtensionRegistry is triggered. 151 // corresponding notification of the ExtensionRegistry is triggered.
151 void OnExtensionUnloaded(const std::string& extension_id); 152 void OnExtensionUnloaded(const std::string& extension_id);
152 153
154 // The user provided input to dialog. |closed| tells whether the dialog was
155 // closed by the user without providing any input.
156 void OnPinDialogInput(const std::string& extension_id, const bool closed);
157
158 // This callback function is called by the view when user closes the PIN
159 // dialog while the last input is still processing at extension side. |value|
160 // is not used, but checked that it's empty.
161 void OnFlowInterrupted(const base::string16& value);
162
163 // Returns whether the last PIN dialog from this extension was closed by the
164 // user.
165 bool LastPinDialogClosed(const std::string& extension_id);
166
167 // Creates a new RequestPinView object and displays it in a dialog or reuses
168 // the old dialog if active one exists just updating the parameters. Returns
169 // if the dialog is displayed and extension owns it.
170 bool ShowPinDialog(const std::string& extension_id,
171 const std::string& extension_name,
172 const std::string& dialog_type,
173 const base::string16& error_message,
174 const bool accept_input,
175 const RequestPinView::UserInputCallback& callback);
176
177 // The active dialog is closed if the |extension_id| matches the
178 // |active_dialog_extension_id_|. Returns whether the dialog was closed.
179 bool CloseDialog(const std::string& extension_id);
180
181 RequestPinView* active_view_for_testing() { return active_pin_dialog_; }
182 views::Widget* active_window_for_testing() { return active_window_; }
183
153 private: 184 private:
154 class CertKeyProviderImpl; 185 class CertKeyProviderImpl;
155 class CertificateProviderImpl; 186 class CertificateProviderImpl;
156 class SSLPrivateKey; 187 class SSLPrivateKey;
157 188
158 // Requests the current list of certificates from every registered extension. 189 // Requests the current list of certificates from every registered extension.
159 // Once all extensions replied or a timeout was reached, the internal 190 // Once all extensions replied or a timeout was reached, the internal
160 // |extension_to_certificates_| is updated and |callback| is run with the 191 // |extension_to_certificates_| is updated and |callback| is run with the
161 // retrieved list of certificates. 192 // retrieved list of certificates.
162 void GetCertificatesFromExtensions( 193 void GetCertificatesFromExtensions(
(...skipping 27 matching lines...) Expand all
190 // An instance of net::ClientKeyStore::CertKeyProvider that is registered at 221 // An instance of net::ClientKeyStore::CertKeyProvider that is registered at
191 // the net::ClientKeyStore singleton. 222 // the net::ClientKeyStore singleton.
192 std::unique_ptr<CertKeyProviderImpl> cert_key_provider_; 223 std::unique_ptr<CertKeyProviderImpl> cert_key_provider_;
193 224
194 // State about all pending sign requests. 225 // State about all pending sign requests.
195 certificate_provider::SignRequests sign_requests_; 226 certificate_provider::SignRequests sign_requests_;
196 227
197 // Contains all pending certificate requests. 228 // Contains all pending certificate requests.
198 certificate_provider::CertificateRequests certificate_requests_; 229 certificate_provider::CertificateRequests certificate_requests_;
199 230
231 // State about last response from user to the ShowPinDialog extension.
232 std::map<std::string, bool> last_rejected_;
233
234 // There can be only one active dialog to request PIN from this extension.
235 // Keeps the ownership.
236 chromeos::RequestPinView* active_pin_dialog_ = nullptr;
237 std::string active_dialog_extension_id_;
238 views::Widget* active_window_ = nullptr;
239
200 // Contains all certificates that the extensions returned during the lifetime 240 // Contains all certificates that the extensions returned during the lifetime
201 // of this service. Each certificate is associated with the extension that 241 // of this service. Each certificate is associated with the extension that
202 // reported the certificate in response to the most recent certificate 242 // reported the certificate in response to the most recent certificate
203 // request. If a certificate was reported previously but in the most recent 243 // request. If a certificate was reported previously but in the most recent
204 // responses, it is still cached but not loses it's association with any 244 // responses, it is still cached but not loses it's association with any
205 // extension. This ensures that a certificate can't magically appear as 245 // extension. This ensures that a certificate can't magically appear as
206 // platform certificate (e.g. in the client certificate selection dialog) 246 // platform certificate (e.g. in the client certificate selection dialog)
207 // after an extension doesn't report it anymore. 247 // after an extension doesn't report it anymore.
208 certificate_provider::ThreadSafeCertificateMap certificate_map_; 248 certificate_provider::ThreadSafeCertificateMap certificate_map_;
209 249
210 base::ThreadChecker thread_checker_; 250 base::ThreadChecker thread_checker_;
211 base::WeakPtrFactory<CertificateProviderService> weak_factory_; 251 base::WeakPtrFactory<CertificateProviderService> weak_factory_;
212 252
213 DISALLOW_COPY_AND_ASSIGN(CertificateProviderService); 253 DISALLOW_COPY_AND_ASSIGN(CertificateProviderService);
214 }; 254 };
215 255
216 } // namespace chromeos 256 } // namespace chromeos
217 257
218 #endif // CHROME_BROWSER_CHROMEOS_CERTIFICATE_PROVIDER_CERTIFICATE_PROVIDER_SER VICE_H_ 258 #endif // CHROME_BROWSER_CHROMEOS_CERTIFICATE_PROVIDER_CERTIFICATE_PROVIDER_SER VICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698