base::Time multiplicative operator overloading
[chromium-blink-merge.git] / chrome / browser / ssl / ssl_client_auth_observer.h
blob62e3fde9ddfd8c4c161768ef423895508b054379
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
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_SSL_SSL_CLIENT_AUTH_OBSERVER_H_
6 #define CHROME_BROWSER_SSL_SSL_CLIENT_AUTH_OBSERVER_H_
8 #include "base/callback.h"
9 #include "base/memory/ref_counted.h"
10 #include "content/public/browser/notification_observer.h"
11 #include "content/public/browser/notification_registrar.h"
13 namespace net {
14 class SSLCertRequestInfo;
15 class X509Certificate;
18 namespace content {
19 class BrowserContext;
22 class SSLClientAuthObserver : public content::NotificationObserver {
23 public:
24 SSLClientAuthObserver(
25 const content::BrowserContext* browser_context,
26 const scoped_refptr<net::SSLCertRequestInfo>& cert_request_info,
27 const base::Callback<void(net::X509Certificate*)>& callback);
28 ~SSLClientAuthObserver() override;
30 // UI should implement this to close the dialog.
31 virtual void OnCertSelectedByNotification() = 0;
33 // Send content the certificate. Can also call with NULL if the user
34 // cancelled. Derived classes must use this instead of caching the callback
35 // and calling it directly.
36 void CertificateSelected(net::X509Certificate* cert);
38 // Begins observing notifications from other SSLClientAuthHandler instances.
39 // If another instance chooses a cert for a matching SSLCertRequestInfo, we
40 // will also use the same cert and OnCertSelectedByNotification will be called
41 // so that the cert selection UI can be closed.
42 void StartObserving();
44 // Stops observing notifications. We will no longer act on client auth
45 // notifications.
46 void StopObserving();
48 net::SSLCertRequestInfo* cert_request_info() const {
49 return cert_request_info_.get();
52 private:
53 // content::NotificationObserver implementation:
54 void Observe(int type,
55 const content::NotificationSource& source,
56 const content::NotificationDetails& details) override;
58 const content::BrowserContext* browser_context_;
59 scoped_refptr<net::SSLCertRequestInfo> cert_request_info_;
60 base::Callback<void(net::X509Certificate*)> callback_;
61 content::NotificationRegistrar notification_registrar_;
63 DISALLOW_COPY_AND_ASSIGN(SSLClientAuthObserver);
66 #endif // CHROME_BROWSER_SSL_SSL_CLIENT_AUTH_OBSERVER_H_