| OLD | NEW |
| (Empty) |
| 1 // Copyright 2015 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. | |
| 4 | |
| 5 #ifndef CHROME_BROWSER_SSL_SECURITY_STATE_MODEL_H_ | |
| 6 #define CHROME_BROWSER_SSL_SECURITY_STATE_MODEL_H_ | |
| 7 | |
| 8 #include "base/macros.h" | |
| 9 #include "net/cert/cert_status_flags.h" | |
| 10 #include "net/cert/sct_status_flags.h" | |
| 11 #include "net/cert/x509_certificate.h" | |
| 12 #include "url/gurl.h" | |
| 13 | |
| 14 class Profile; | |
| 15 class SecurityStateModelClient; | |
| 16 | |
| 17 // SecurityStateModel provides high-level security information about a | |
| 18 // page or request. | |
| 19 // | |
| 20 // SecurityStateModel::SecurityInfo is the main data structure computed | |
| 21 // by a SecurityStateModel. SecurityInfo contains a SecurityLevel (which | |
| 22 // is a single value describing the overall security state) along with | |
| 23 // information that a consumer might want to display in UI to explain or | |
| 24 // elaborate on the SecurityLevel. | |
| 25 class SecurityStateModel { | |
| 26 public: | |
| 27 // Describes the overall security state of the page. | |
| 28 // | |
| 29 // If you reorder, add, or delete values from this enum, you must also | |
| 30 // update the UI icons in ToolbarModelImpl::GetIconForSecurityLevel. | |
| 31 // | |
| 32 // A Java counterpart will be generated for this enum. | |
| 33 // GENERATED_JAVA_ENUM_PACKAGE: org.chromium.chrome.browser.ssl | |
| 34 // GENERATED_JAVA_CLASS_NAME_OVERRIDE: ConnectionSecurityLevel | |
| 35 enum SecurityLevel { | |
| 36 // HTTP/no URL/HTTPS but with insecure passive content on the page | |
| 37 NONE, | |
| 38 | |
| 39 // HTTPS with valid EV cert | |
| 40 EV_SECURE, | |
| 41 | |
| 42 // HTTPS (non-EV) with valid cert | |
| 43 SECURE, | |
| 44 | |
| 45 // HTTPS, but with an outdated protocol version | |
| 46 SECURITY_WARNING, | |
| 47 | |
| 48 // HTTPS, but the certificate verification chain is anchored on a | |
| 49 // certificate that was installed by the system administrator | |
| 50 SECURITY_POLICY_WARNING, | |
| 51 | |
| 52 // Attempted HTTPS and failed, page not authenticated, or HTTPS with | |
| 53 // insecure active content on the page | |
| 54 SECURITY_ERROR, | |
| 55 }; | |
| 56 | |
| 57 // Describes how the SHA1 deprecation policy applies to an HTTPS | |
| 58 // connection. | |
| 59 enum SHA1DeprecationStatus { | |
| 60 // No SHA1 deprecation policy applies. | |
| 61 NO_DEPRECATED_SHA1, | |
| 62 // The connection used a certificate with a SHA1 signature in the | |
| 63 // chain, and policy says that the connection should be treated with a | |
| 64 // warning. | |
| 65 DEPRECATED_SHA1_MINOR, | |
| 66 // The connection used a certificate with a SHA1 signature in the | |
| 67 // chain, and policy says that the connection should be treated as | |
| 68 // broken HTTPS. | |
| 69 DEPRECATED_SHA1_MAJOR, | |
| 70 }; | |
| 71 | |
| 72 // Describes the type of mixed content (if any) that a site | |
| 73 // displayed/ran. | |
| 74 enum MixedContentStatus { | |
| 75 NO_MIXED_CONTENT, | |
| 76 // The site displayed insecure resources (passive mixed content). | |
| 77 DISPLAYED_MIXED_CONTENT, | |
| 78 // The site ran insecure code (active mixed content). | |
| 79 RAN_MIXED_CONTENT, | |
| 80 // The site both ran and displayed insecure resources. | |
| 81 RAN_AND_DISPLAYED_MIXED_CONTENT, | |
| 82 }; | |
| 83 | |
| 84 // Describes the security status of a page or request. This is the | |
| 85 // main data structure provided by this class. | |
| 86 struct SecurityInfo { | |
| 87 SecurityInfo(); | |
| 88 ~SecurityInfo(); | |
| 89 SecurityLevel security_level; | |
| 90 SHA1DeprecationStatus sha1_deprecation_status; | |
| 91 MixedContentStatus mixed_content_status; | |
| 92 // The verification statuses of the signed certificate timestamps | |
| 93 // for the connection. | |
| 94 std::vector<net::ct::SCTVerifyStatus> sct_verify_statuses; | |
| 95 bool scheme_is_cryptographic; | |
| 96 net::CertStatus cert_status; | |
| 97 int cert_id; | |
| 98 // The security strength, in bits, of the SSL cipher suite. In late | |
| 99 // 2015, 128 is considered the minimum. | |
| 100 // 0 means the connection is not encrypted. | |
| 101 // -1 means the security strength is unknown. | |
| 102 int security_bits; | |
| 103 // Information about the SSL connection, such as protocol and | |
| 104 // ciphersuite. See ssl_connection_flags.h in net. | |
| 105 int connection_status; | |
| 106 // True if the protocol version and ciphersuite for the connection | |
| 107 // are considered secure. | |
| 108 bool is_secure_protocol_and_ciphersuite; | |
| 109 }; | |
| 110 | |
| 111 // Contains the security state relevant to computing the SecurityInfo | |
| 112 // for a page. This is the input to GetSecurityInfo() provided by the | |
| 113 // model's client. | |
| 114 struct VisibleSecurityState { | |
| 115 VisibleSecurityState(); | |
| 116 ~VisibleSecurityState(); | |
| 117 bool operator==(const VisibleSecurityState& other) const; | |
| 118 bool initialized; | |
| 119 GURL url; | |
| 120 // The baseline SecurityLevel describing the page or request before | |
| 121 // any SecurityStateModel policies have been applied. | |
| 122 SecurityLevel initial_security_level; | |
| 123 // The following fields contain information about the connection | |
| 124 // used to load the page or request. | |
| 125 int cert_id; | |
| 126 net::CertStatus cert_status; | |
| 127 int connection_status; | |
| 128 int security_bits; | |
| 129 // The verification statuses of the Signed Certificate | |
| 130 // Timestamps (if any) that the server provided. | |
| 131 std::vector<net::ct::SCTVerifyStatus> sct_verify_statuses; | |
| 132 // True if the page displayed passive mixed content. | |
| 133 bool displayed_mixed_content; | |
| 134 // True if the page ran active mixed content. | |
| 135 bool ran_mixed_content; | |
| 136 }; | |
| 137 | |
| 138 // These security levels describe the treatment given to pages that | |
| 139 // display and run mixed content. They are used to coordinate the | |
| 140 // treatment of mixed content with other security UI elements. | |
| 141 static const SecurityLevel kDisplayedInsecureContentLevel; | |
| 142 static const SecurityLevel kRanInsecureContentLevel; | |
| 143 | |
| 144 SecurityStateModel(); | |
| 145 virtual ~SecurityStateModel(); | |
| 146 | |
| 147 // Returns a SecurityInfo describing the current page. Results are | |
| 148 // cached so that computation is only done when the relevant security | |
| 149 // state has changed. | |
| 150 const SecurityInfo& GetSecurityInfo() const; | |
| 151 | |
| 152 void SetClient(SecurityStateModelClient* client); | |
| 153 | |
| 154 private: | |
| 155 // Caches the SecurityInfo for the visible page. Marked | |
| 156 // mutable so that the const accessor GetSecurityInfo() can update the | |
| 157 // cached values. | |
| 158 mutable SecurityInfo security_info_; | |
| 159 mutable VisibleSecurityState visible_security_state_; | |
| 160 | |
| 161 SecurityStateModelClient* client_; | |
| 162 | |
| 163 DISALLOW_COPY_AND_ASSIGN(SecurityStateModel); | |
| 164 }; | |
| 165 | |
| 166 #endif // CHROME_BROWSER_SSL_SECURITY_STATE_MODEL_H_ | |
| OLD | NEW |