Disable view source for Developer Tools.
[chromium-blink-merge.git] / chrome / browser / ssl / ssl_add_cert_handler.h
blob16320fdd3ceb46b9c91039c2ec8675068fb543e0
1 // Copyright (c) 2011 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.
5 #ifndef CHROME_BROWSER_SSL_SSL_ADD_CERT_HANDLER_H_
6 #define CHROME_BROWSER_SSL_SSL_ADD_CERT_HANDLER_H_
8 #include "base/basictypes.h"
9 #include "base/memory/ref_counted.h"
11 namespace net {
12 class URLRequest;
13 class X509Certificate;
16 // This class handles adding a newly-generated client cert. It ensures there's a
17 // private key for the cert, displays the cert to the user, and adds it upon
18 // user approval.
19 // It is self-owned and deletes itself when finished.
20 class SSLAddCertHandler : public base::RefCountedThreadSafe<SSLAddCertHandler> {
21 public:
22 SSLAddCertHandler(net::URLRequest* request, net::X509Certificate* cert,
23 int render_process_host_id, int render_view_id);
25 net::X509Certificate* cert() { return cert_.get(); }
27 int network_request_id() const { return network_request_id_; }
29 // The platform-specific code calls this when it's done, to clean up.
30 // If |addCert| is true, the cert will be added to the CertDatabase.
31 void Finished(bool add_cert);
33 private:
34 friend class base::RefCountedThreadSafe<SSLAddCertHandler>;
35 virtual ~SSLAddCertHandler();
37 // Runs the handler. Called on the IO thread.
38 void Run();
40 // Platform-specific code that asks the user whether to add the cert.
41 // Called on the UI thread.
42 void AskToAddCert();
44 // Methods called on the UI thread to call the SSL helper.
45 void CallVerifyClientCertificateError(int cert_error);
46 void CallAddClientCertificate(bool add_cert, int cert_error);
48 // The cert to add.
49 scoped_refptr<net::X509Certificate> cert_;
51 // The id of the request which started the process.
52 int network_request_id_;
53 // The id of the |RenderProcessHost| which started the download.
54 int render_process_host_id_;
55 // The id of the |RenderView| which started the download.
56 int render_view_id_;
58 DISALLOW_COPY_AND_ASSIGN(SSLAddCertHandler);
61 #endif // CHROME_BROWSER_SSL_SSL_ADD_CERT_HANDLER_H_