| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROME_BROWSER_SSL_SECURITY_STATE_MODEL_H_ | 5 #ifndef CHROME_BROWSER_SSL_SECURITY_STATE_MODEL_H_ |
| 6 #define CHROME_BROWSER_SSL_SECURITY_STATE_MODEL_H_ | 6 #define CHROME_BROWSER_SSL_SECURITY_STATE_MODEL_H_ |
| 7 | 7 |
| 8 #include "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "content/public/browser/web_contents_user_data.h" | 9 #include "content/public/browser/web_contents_user_data.h" |
| 10 #include "content/public/common/security_style.h" | 10 #include "content/public/common/security_style.h" |
| 11 #include "content/public/common/ssl_status.h" | 11 #include "content/public/common/ssl_status.h" |
| 12 #include "net/cert/cert_status_flags.h" | 12 #include "net/cert/cert_status_flags.h" |
| 13 #include "net/cert/sct_status_flags.h" | 13 #include "net/cert/sct_status_flags.h" |
| 14 #include "net/cert/x509_certificate.h" | 14 #include "net/cert/x509_certificate.h" |
| 15 | 15 |
| 16 namespace content { | 16 namespace content { |
| 17 class NavigationHandle; | 17 class NavigationHandle; |
| 18 class WebContents; | 18 class WebContents; |
| 19 } // namespace content | 19 } // namespace content |
| 20 | 20 |
| 21 class Profile; | 21 class Profile; |
| 22 class SecurityStateModelClient; | 22 class SecurityStateModelClient; |
| 23 | 23 |
| 24 // SecurityStateModel provides high-level security information about a | 24 // SecurityStateModel provides high-level security information about a |
| 25 // page or request. It is attached to a WebContents and will provide the | 25 // page or request. |
| 26 // security info for that WebContents. | |
| 27 // | 26 // |
| 28 // SecurityStateModel::SecurityInfo is the main data structure computed | 27 // SecurityStateModel::SecurityInfo is the main data structure computed |
| 29 // by a SecurityStateModel. SecurityInfo contains a SecurityLevel (which | 28 // by a SecurityStateModel. SecurityInfo contains a SecurityLevel (which |
| 30 // is a single value describing the overall security state) along with | 29 // is a single value describing the overall security state) along with |
| 31 // information that a consumer might want to display in UI to explain or | 30 // information that a consumer might want to display in UI to explain or |
| 32 // elaborate on the SecurityLevel. | 31 // elaborate on the SecurityLevel. |
| 33 class SecurityStateModel | 32 class SecurityStateModel { |
| 34 : public content::WebContentsUserData<SecurityStateModel> { | |
| 35 public: | 33 public: |
| 36 // Describes the overall security state of the page. | 34 // Describes the overall security state of the page. |
| 37 // | 35 // |
| 38 // If you reorder, add, or delete values from this enum, you must also | 36 // If you reorder, add, or delete values from this enum, you must also |
| 39 // update the UI icons in ToolbarModelImpl::GetIconForSecurityLevel. | 37 // update the UI icons in ToolbarModelImpl::GetIconForSecurityLevel. |
| 40 // | 38 // |
| 41 // A Java counterpart will be generated for this enum. | 39 // A Java counterpart will be generated for this enum. |
| 42 // GENERATED_JAVA_ENUM_PACKAGE: org.chromium.chrome.browser.ssl | 40 // GENERATED_JAVA_ENUM_PACKAGE: org.chromium.chrome.browser.ssl |
| 43 // GENERATED_JAVA_CLASS_NAME_OVERRIDE: ConnectionSecurityLevel | 41 // GENERATED_JAVA_CLASS_NAME_OVERRIDE: ConnectionSecurityLevel |
| 44 enum SecurityLevel { | 42 enum SecurityLevel { |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 117 // are considered secure. | 115 // are considered secure. |
| 118 bool is_secure_protocol_and_ciphersuite; | 116 bool is_secure_protocol_and_ciphersuite; |
| 119 }; | 117 }; |
| 120 | 118 |
| 121 // These security styles describe the treatment given to pages that | 119 // These security styles describe the treatment given to pages that |
| 122 // display and run mixed content. They are used to coordinate the | 120 // display and run mixed content. They are used to coordinate the |
| 123 // treatment of mixed content with other security UI elements. | 121 // treatment of mixed content with other security UI elements. |
| 124 static const content::SecurityStyle kDisplayedInsecureContentStyle; | 122 static const content::SecurityStyle kDisplayedInsecureContentStyle; |
| 125 static const content::SecurityStyle kRanInsecureContentStyle; | 123 static const content::SecurityStyle kRanInsecureContentStyle; |
| 126 | 124 |
| 127 ~SecurityStateModel() override; | 125 explicit SecurityStateModel(content::WebContents* web_contents); |
| 126 virtual ~SecurityStateModel(); |
| 128 | 127 |
| 129 // Returns a SecurityInfo describing the current page. Results are | 128 // Returns a SecurityInfo describing the current page. Results are |
| 130 // cached so that computation is only done once per visible | 129 // cached so that computation is only done once per visible |
| 131 // NavigationEntry. | 130 // NavigationEntry. |
| 132 const SecurityInfo& GetSecurityInfo() const; | 131 const SecurityInfo& GetSecurityInfo() const; |
| 133 | 132 |
| 133 void SetClient(SecurityStateModelClient* client); |
| 134 |
| 134 // Returns a SecurityInfo describing an individual request for the | 135 // Returns a SecurityInfo describing an individual request for the |
| 135 // given |profile|. | 136 // given |profile|. |
| 136 static void SecurityInfoForRequest( | 137 static void SecurityInfoForRequest( |
| 137 const GURL& url, | 138 const GURL& url, |
| 138 const content::SSLStatus& ssl, | 139 const content::SSLStatus& ssl, |
| 139 Profile* profile, | 140 Profile* profile, |
| 140 const scoped_refptr<net::X509Certificate>& cert, | 141 const scoped_refptr<net::X509Certificate>& cert, |
| 141 bool used_known_mitm_certificate, | 142 bool used_known_mitm_certificate, |
| 142 SecurityInfo* security_info); | 143 SecurityInfo* security_info); |
| 143 | 144 |
| 144 private: | 145 private: |
| 145 explicit SecurityStateModel(content::WebContents* web_contents); | |
| 146 friend class content::WebContentsUserData<SecurityStateModel>; | |
| 147 | |
| 148 // The WebContents for which this class describes the security status. | 146 // The WebContents for which this class describes the security status. |
| 147 // |
| 148 // TODO(estark): this should go away shortly and the model should rely |
| 149 // on its delegate to provide whatever it needs from the |
| 150 // WebContents. https://crbug.com/515071 |
| 149 content::WebContents* web_contents_; | 151 content::WebContents* web_contents_; |
| 150 | 152 |
| 151 // These data members cache the SecurityInfo for the visible | 153 // These data members cache the SecurityInfo for the visible |
| 152 // NavigationEntry. They are marked mutable so that the const accessor | 154 // NavigationEntry. They are marked mutable so that the const accessor |
| 153 // GetSecurityInfo() can update the cache. | 155 // GetSecurityInfo() can update the cache. |
| 154 mutable SecurityInfo security_info_; | 156 mutable SecurityInfo security_info_; |
| 155 mutable GURL visible_url_; | 157 mutable GURL visible_url_; |
| 156 mutable content::SSLStatus visible_ssl_status_; | 158 mutable content::SSLStatus visible_ssl_status_; |
| 157 | 159 |
| 158 // TODO(estark): The SecurityStateModel temporarily owns and | 160 SecurityStateModelClient* client_; |
| 159 // instantiates this member, but it will soon be injected, once the | |
| 160 // model is compnentized. https://crbug.com/515071 | |
| 161 scoped_ptr<SecurityStateModelClient> client_; | |
| 162 | 161 |
| 163 DISALLOW_COPY_AND_ASSIGN(SecurityStateModel); | 162 DISALLOW_COPY_AND_ASSIGN(SecurityStateModel); |
| 164 }; | 163 }; |
| 165 | 164 |
| 166 #endif // CHROME_BROWSER_SSL_SECURITY_STATE_MODEL_H_ | 165 #endif // CHROME_BROWSER_SSL_SECURITY_STATE_MODEL_H_ |
| OLD | NEW |