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_CHROME_SECURITY_STATE_MODEL_CLIENT_H_ | 5 #ifndef CHROME_BROWSER_SSL_CHROME_SECURITY_STATE_MODEL_CLIENT_H_ |
6 #define CHROME_BROWSER_SSL_CHROME_SECURITY_STATE_MODEL_CLIENT_H_ | 6 #define CHROME_BROWSER_SSL_CHROME_SECURITY_STATE_MODEL_CLIENT_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 | 9 |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
11 #include "components/security_state/security_state_model.h" | 11 #include "components/security_state/security_state_model.h" |
12 #include "components/security_state/security_state_model_client.h" | 12 #include "components/security_state/security_state_model_client.h" |
13 #include "content/public/browser/web_contents_user_data.h" | 13 #include "content/public/browser/web_contents_user_data.h" |
| 14 #include "content/public/common/security_style.h" |
14 | 15 |
15 namespace content { | 16 namespace content { |
| 17 struct SecurityStyleExplanations; |
16 class WebContents; | 18 class WebContents; |
17 } // namespace content | 19 } // namespace content |
18 | 20 |
19 // Uses a WebContents to provide a SecurityStateModel with the | 21 // Uses a WebContents to provide a SecurityStateModel with the |
20 // information that it needs to determine the page's security status. | 22 // information that it needs to determine the page's security status. |
21 class ChromeSecurityStateModelClient | 23 class ChromeSecurityStateModelClient |
22 : public security_state::SecurityStateModelClient, | 24 : public security_state::SecurityStateModelClient, |
23 public content::WebContentsUserData<ChromeSecurityStateModelClient> { | 25 public content::WebContentsUserData<ChromeSecurityStateModelClient> { |
24 public: | 26 public: |
25 ~ChromeSecurityStateModelClient() override; | 27 ~ChromeSecurityStateModelClient() override; |
26 | 28 |
27 const security_state::SecurityStateModel::SecurityInfo& GetSecurityInfo() | 29 const security_state::SecurityStateModel::SecurityInfo& GetSecurityInfo() |
28 const; | 30 const; |
29 | 31 |
| 32 // Returns the SecurityStyle that should be applied to a WebContents |
| 33 // with the given |security_info|. Populates |
| 34 // |security_style_explanations| to explain why the returned |
| 35 // SecurityStyle was chosen. |
| 36 static content::SecurityStyle GetSecurityStyle( |
| 37 const security_state::SecurityStateModel::SecurityInfo& security_info, |
| 38 content::SecurityStyleExplanations* security_style_explanations); |
| 39 |
30 // SecurityStateModelClient: | 40 // SecurityStateModelClient: |
31 void GetVisibleSecurityState( | 41 void GetVisibleSecurityState( |
32 security_state::SecurityStateModel::VisibleSecurityState* state) override; | 42 security_state::SecurityStateModel::VisibleSecurityState* state) override; |
33 bool RetrieveCert(scoped_refptr<net::X509Certificate>* cert) override; | 43 bool RetrieveCert(scoped_refptr<net::X509Certificate>* cert) override; |
34 bool UsedPolicyInstalledCertificate() override; | 44 bool UsedPolicyInstalledCertificate() override; |
35 bool IsOriginSecure(const GURL& url) override; | 45 bool IsOriginSecure(const GURL& url) override; |
36 | 46 |
37 private: | 47 private: |
38 explicit ChromeSecurityStateModelClient(content::WebContents* web_contents); | 48 explicit ChromeSecurityStateModelClient(content::WebContents* web_contents); |
39 friend class content::WebContentsUserData<ChromeSecurityStateModelClient>; | 49 friend class content::WebContentsUserData<ChromeSecurityStateModelClient>; |
40 | 50 |
41 content::WebContents* web_contents_; | 51 content::WebContents* web_contents_; |
42 std::unique_ptr<security_state::SecurityStateModel> security_state_model_; | 52 std::unique_ptr<security_state::SecurityStateModel> security_state_model_; |
43 | 53 |
44 DISALLOW_COPY_AND_ASSIGN(ChromeSecurityStateModelClient); | 54 DISALLOW_COPY_AND_ASSIGN(ChromeSecurityStateModelClient); |
45 }; | 55 }; |
46 | 56 |
47 #endif // CHROME_BROWSER_SSL_CHROME_SECURITY_STATE_MODEL_CLIENT_H_ | 57 #endif // CHROME_BROWSER_SSL_CHROME_SECURITY_STATE_MODEL_CLIENT_H_ |
OLD | NEW |