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 CONTENT_BROWSER_SSL_SSL_HOST_STATE_H_
6 #define CONTENT_BROWSER_SSL_SSL_HOST_STATE_H_
12 #include "base/compiler_specific.h"
13 #include "base/basictypes.h"
14 #include "base/supports_user_data.h"
15 #include "base/threading/non_thread_safe.h"
16 #include "content/common/content_export.h"
17 #include "googleurl/src/gurl.h"
18 #include "net/base/x509_certificate.h"
25 // The SSLHostState encapulates the host-specific state for SSL errors. For
26 // example, SSLHostState remembers whether the user has whitelisted a
27 // particular broken cert for use with particular host. We separate this state
28 // from the SSLManager because this state is shared across many navigation
31 class CONTENT_EXPORT SSLHostState
32 : NON_EXPORTED_BASE(base::SupportsUserData::Data
),
33 NON_EXPORTED_BASE(public base::NonThreadSafe
) {
35 static SSLHostState
* GetFor(BrowserContext
* browser_context
);
38 virtual ~SSLHostState();
40 // Records that a host has run insecure content.
41 void HostRanInsecureContent(const std::string
& host
, int pid
);
43 // Returns whether the specified host ran insecure content.
44 bool DidHostRunInsecureContent(const std::string
& host
, int pid
) const;
46 // Records that |cert| is permitted to be used for |host| in the future.
47 void DenyCertForHost(net::X509Certificate
* cert
, const std::string
& host
);
49 // Records that |cert| is not permitted to be used for |host| in the future.
50 void AllowCertForHost(net::X509Certificate
* cert
, const std::string
& host
);
52 // Clear all allow/deny preferences.
55 // Queries whether |cert| is allowed or denied for |host|.
56 net::CertPolicy::Judgment
QueryPolicy(
57 net::X509Certificate
* cert
, const std::string
& host
);
60 // A BrokenHostEntry is a pair of (host, process_id) that indicates the host
61 // contains insecure content in that renderer process.
62 typedef std::pair
<std::string
, int> BrokenHostEntry
;
64 // Hosts which have been contaminated with insecure content in the
65 // specified process. Note that insecure content can travel between
66 // same-origin frames in one processs but cannot jump between processes.
67 std::set
<BrokenHostEntry
> ran_insecure_content_hosts_
;
69 // Certificate policies for each host.
70 std::map
<std::string
, net::CertPolicy
> cert_policy_for_host_
;
72 DISALLOW_COPY_AND_ASSIGN(SSLHostState
);
75 } // namespace content
77 #endif // CONTENT_BROWSER_SSL_SSL_HOST_STATE_H_