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 NET_SSL_SSL_CONFIG_SERVICE_H_
6 #define NET_SSL_SSL_CONFIG_SERVICE_H_
10 #include "base/memory/ref_counted.h"
11 #include "base/observer_list.h"
12 #include "net/base/net_export.h"
13 #include "net/cert/crl_set.h"
14 #include "net/cert/ct_ev_whitelist.h"
15 #include "net/ssl/ssl_config.h"
19 // The interface for retrieving the SSL configuration. This interface
20 // does not cover setting the SSL configuration, as on some systems, the
21 // SSLConfigService objects may not have direct access to the configuration, or
22 // live longer than the configuration preferences.
23 class NET_EXPORT SSLConfigService
24 : public base::RefCountedThreadSafe
<SSLConfigService
> {
26 // Observer is notified when SSL config settings have changed.
27 class NET_EXPORT Observer
{
29 // Notify observers if SSL settings have changed. We don't check all of the
30 // data in SSLConfig, just those that qualify as a user config change.
31 // The following settings are considered user changes:
32 // rev_checking_enabled
35 // disabled_cipher_suites
37 // false_start_enabled
38 // require_forward_secrecy
39 virtual void OnSSLConfigChanged() = 0;
42 virtual ~Observer() {}
47 // May not be thread-safe, should only be called on the IO thread.
48 virtual void GetSSLConfig(SSLConfig
* config
) = 0;
50 // Sets and gets the current, global CRL set.
51 static void SetCRLSet(scoped_refptr
<CRLSet
> crl_set
);
52 static scoped_refptr
<CRLSet
> GetCRLSet();
54 // Sets and gets the current, global EV certificates whitelist
55 static void SetEVCertsWhitelist(
56 scoped_refptr
<ct::EVCertsWhitelist
> ev_whitelist
);
57 static scoped_refptr
<ct::EVCertsWhitelist
> GetEVCertsWhitelist();
59 // Add an observer of this service.
60 void AddObserver(Observer
* observer
);
62 // Remove an observer of this service.
63 void RemoveObserver(Observer
* observer
);
65 // Calls the OnSSLConfigChanged method of registered observers. Should only be
66 // called on the IO thread.
67 void NotifySSLConfigChange();
70 friend class base::RefCountedThreadSafe
<SSLConfigService
>;
72 virtual ~SSLConfigService();
74 // Process before/after config update.
75 void ProcessConfigUpdate(const SSLConfig
& orig_config
,
76 const SSLConfig
& new_config
);
79 base::ObserverList
<Observer
> observer_list_
;
84 #endif // NET_SSL_SSL_CONFIG_SERVICE_H_