summaryrefslogtreecommitdiffstats
path: root/chrome/browser/ssl/ssl_host_state.h
blob: 6d0194f4d39d0cee1b80b88fb30d2967592df97f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
// Copyright (c) 2006-2009 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef CHROME_BROWSER_SSL_SSL_HOST_STATE_H_
#define CHROME_BROWSER_SSL_SSL_HOST_STATE_H_

#include <string>
#include <map>
#include <set>

#include "base/basictypes.h"
#include "base/non_thread_safe.h"
#include "googleurl/src/gurl.h"
#include "net/base/x509_certificate.h"

// SSLHostState
//
// The SSLHostState encapulates the host-specific state for SSL errors.  For
// example, SSLHostState rememebers whether the user has whitelisted a
// particular broken cert for use with particular host.  We separate this state
// from the SSLManager because this state is shared across many navigation
// controllers.

class SSLHostState : public NonThreadSafe {
 public:
  SSLHostState();
  ~SSLHostState();

  // Records that |cert| is permitted to be used for |host| in the future.
  void DenyCertForHost(net::X509Certificate* cert, const std::string& host);

  // Records that |cert| is not permitted to be used for |host| in the future.
  void AllowCertForHost(net::X509Certificate* cert, const std::string& host);

  // Queries whether |cert| is allowed or denied for |host|.
  net::X509Certificate::Policy::Judgment QueryPolicy(
      net::X509Certificate* cert, const std::string& host);

  // Allow mixed/unsafe content to be visible (non filtered) for the specified
  // URL.
  // Note that the current implementation allows on a host name basis.
  void AllowShowInsecureContentForURL(const GURL& url);

  // Returns whether the specified URL is allowed to show insecure (mixed or
  // unsafe) content.
  bool CanShowInsecureContent(const GURL& url);

 private:
  // Certificate policies for each host.
  std::map<std::string, net::X509Certificate::Policy> cert_policy_for_host_;

  // Domains for which it is OK to show insecure content.
  std::set<std::string> can_show_insecure_content_for_host_;

  DISALLOW_COPY_AND_ASSIGN(SSLHostState);
};

#endif  // CHROME_BROWSER_SSL_SSL_HOST_STATE_H_