summaryrefslogtreecommitdiffstats
path: root/chrome/browser/website_settings_model.h
blob: 2e895c7e42722fed22f8bc8269195ace901a829a (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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
// Copyright (c) 2012 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_WEBSITE_SETTINGS_MODEL_H_
#define CHROME_BROWSER_WEBSITE_SETTINGS_MODEL_H_

#include "base/string16.h"
#include "googleurl/src/gurl.h"

namespace content {
struct SSLStatus;
}

class CertStore;
class Profile;
class TabContentsWrapper;

// The |WebsiteSettingsModel| provides information about the connection and the
// identity of a website. The |WebsiteSettingsModel| is the backend for the
// WebsiteSettingsUI which displays this information.
class WebsiteSettingsModel {
 public:
  // Status of a connection to a website.
  enum SiteConnectionStatus {
    SITE_CONNECTION_STATUS_UNKNOWN = 0,      // No status available.
    SITE_CONNECTION_STATUS_ENCRYPTED,        // Connection is encrypted.
    SITE_CONNECTION_STATUS_MIXED_CONTENT,    // Site has unencrypted content.
    SITE_CONNECTION_STATUS_UNENCRYPTED,      // Connection is not encrypted.
    SITE_CONNECTION_STATUS_ENCRYPTED_ERROR,  // Connection error occured.
    SITE_CONNECTION_STATUS_INTERNAL_PAGE,    // Internal site.
  };

  // Validation status of a website's identity.
  enum SiteIdentityStatus {
    // No status about the website's identity available.
    SITE_IDENTITY_STATUS_UNKNOWN = 0,
    // The website provided a valid certificate.
    SITE_IDENTITY_STATUS_CERT,
    // The website provided a valid EV certificate.
    SITE_IDENTITY_STATUS_EV_CERT,
    // The website provided a valid DNSSEC certificate.
    SITE_IDENTITY_STATUS_DNSSEC_CERT,
    // The website provided a valid certificate but no revocation check could be
    // performed.
    SITE_IDENTITY_STATUS_CERT_REVOCATION_UNKNOWN,
    // Site identity could not be verified because the site did not provide a
    // certificate. This is the expected state for HTTP connections.
    SITE_IDENTITY_STATUS_NO_CERT,
    // An error occured while verifying the site identity.
    SITE_IDENTITY_STATUS_ERROR,
    // The site is a trusted internal chrome page.
    SITE_IDENTITY_STATUS_INTERNAL_PAGE,
  };

  // Creates a WebsiteSettingsModel for the passed |url| using the given |ssl|
  // status object to determine the status of the site's connection.
  WebsiteSettingsModel(Profile* profile,
                       const GURL& url,
                       const content::SSLStatus& ssl,
                       CertStore* cert_store);

  virtual ~WebsiteSettingsModel();

  // Accessors.
  SiteConnectionStatus site_connection_status() const {
    return site_connection_status_;
  }

  SiteIdentityStatus site_identity_status() const {
    return site_identity_status_;
  }

  string16 site_connection_details() const {
    return site_connection_details_;
  }

  string16 site_identity_details() const {
    return site_identity_details_;
  }

  string16 organization_name() const {
    return organization_name_;
  }

 private:
  // Initializes the |WebsiteSettingsModel|.
  void Init(Profile* profile,
            const GURL& url,
            const content::SSLStatus& ssl);

  // Status of the website's identity verification check.
  SiteIdentityStatus site_identity_status_;

  // Status of the connection to the website.
  SiteConnectionStatus site_connection_status_;

  // Details about the website's identity. If the website's identity has been
  // verified then |site_identity_details_| contains who verified the identity.
  string16 site_identity_details_;

  // Details about the connection to the website. In case of an encrypted
  // connection |site_connection_details_| contains encryption details, like
  // encryption strength and ssl protocol version.
  string16 site_connection_details_;

  // For websites that provided an EV certificate |orgainization_name_| contains
  // the organization name of the certificate. In all other cases
  // |organization_name| is an empty string.
  string16 organization_name_;

  // The |CertStore| provides all X509Certificates.
  CertStore* cert_store_;

  DISALLOW_COPY_AND_ASSIGN(WebsiteSettingsModel);
};

#endif  // CHROME_BROWSER_WEBSITE_SETTINGS_MODEL_H_