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/gtest_prod_util.h" |
10 #include "base/macros.h" | 11 #include "base/macros.h" |
11 #include "components/security_state/security_state_model.h" | 12 #include "components/security_state/content/web_contents_security_state_model.h" |
12 #include "components/security_state/security_state_model_client.h" | 13 #include "components/security_state/core/security_state_model.h" |
13 #include "content/public/browser/web_contents_observer.h" | 14 #include "content/public/browser/web_contents_observer.h" |
14 #include "content/public/browser/web_contents_user_data.h" | 15 #include "content/public/browser/web_contents_user_data.h" |
15 #include "third_party/WebKit/public/platform/WebSecurityStyle.h" | 16 #include "third_party/WebKit/public/platform/WebSecurityStyle.h" |
16 | 17 |
17 namespace content { | 18 namespace content { |
18 struct SecurityStyleExplanations; | 19 struct SecurityStyleExplanations; |
| 20 class NavigationEntry; |
19 class NavigationHandle; | 21 class NavigationHandle; |
20 class WebContents; | 22 class WebContents; |
21 } // namespace content | 23 } // namespace content |
22 | 24 |
23 // Uses a WebContents to provide a SecurityStateModel with the | 25 // Provides a WebContentsSecurityStateModel with chrome-specific information |
24 // information that it needs to determine the page's security status. | 26 // that it needs to determine the page's security status. |
25 class ChromeSecurityStateModelClient | 27 class ChromeSecurityStateModelClient |
26 : public security_state::SecurityStateModelClient, | 28 : public security_state::WebContentsSecurityStateModelClient, |
27 public content::WebContentsObserver, | 29 public content::WebContentsObserver, |
28 public content::WebContentsUserData<ChromeSecurityStateModelClient> { | 30 public content::WebContentsUserData<ChromeSecurityStateModelClient> { |
29 public: | 31 public: |
30 ~ChromeSecurityStateModelClient() override; | 32 ~ChromeSecurityStateModelClient() override; |
31 | 33 |
| 34 // See WebContentsSecurityStateModel::GetSecurityInfo. |
32 void GetSecurityInfo( | 35 void GetSecurityInfo( |
33 security_state::SecurityStateModel::SecurityInfo* result) const; | 36 security_state::SecurityStateModel::SecurityInfo* result) const; |
34 | 37 |
35 // Called when the NavigationEntry's SSLStatus changes. | 38 // Called when the NavigationEntry's SSLStatus changes. |
36 void VisibleSSLStateChanged(); | 39 void VisibleSSLStateChanged(); |
37 | 40 |
38 // content::WebContentsObserver: | 41 // content::WebContentsObserver: |
39 void DidFinishNavigation( | 42 void DidFinishNavigation( |
40 content::NavigationHandle* navigation_handle) override; | 43 content::NavigationHandle* navigation_handle) override; |
41 | 44 |
42 // Returns the SecurityStyle that should be applied to a WebContents | 45 // WebContentsSecurityStateModelClient: |
43 // with the given |security_info|. Populates | |
44 // |security_style_explanations| to explain why the returned | |
45 // SecurityStyle was chosen. | |
46 static blink::WebSecurityStyle GetSecurityStyle( | |
47 const security_state::SecurityStateModel::SecurityInfo& security_info, | |
48 content::SecurityStyleExplanations* security_style_explanations); | |
49 | |
50 // SecurityStateModelClient: | |
51 void GetVisibleSecurityState( | |
52 security_state::SecurityStateModel::VisibleSecurityState* state) override; | |
53 bool UsedPolicyInstalledCertificate() override; | 46 bool UsedPolicyInstalledCertificate() override; |
54 bool IsOriginSecure(const GURL& url) override; | 47 bool GetMalwareStatus(content::NavigationEntry* entry, |
| 48 content::WebContents* web_contents) override; |
55 | 49 |
56 private: | 50 private: |
57 explicit ChromeSecurityStateModelClient(content::WebContents* web_contents); | 51 explicit ChromeSecurityStateModelClient(content::WebContents* web_contents); |
58 friend class content::WebContentsUserData<ChromeSecurityStateModelClient>; | 52 friend class content::WebContentsUserData<ChromeSecurityStateModelClient>; |
59 | 53 |
60 content::WebContents* web_contents_; | 54 // For security_state_model_. |
61 std::unique_ptr<security_state::SecurityStateModel> security_state_model_; | 55 FRIEND_TEST_ALL_PREFIXES(ChromeSecurityStateModelClientTest, |
| 56 VisibleSecurityStateNonsecureFormInputs); |
| 57 |
| 58 std::unique_ptr<security_state::WebContentsSecurityStateModel> |
| 59 security_state_model_; |
62 | 60 |
63 // True if a console has been logged about an omnibox warning that | 61 // True if a console has been logged about an omnibox warning that |
64 // will be shown in future versions of Chrome for insecure HTTP | 62 // will be shown in future versions of Chrome for insecure HTTP |
65 // pages. This message should only be logged once per main-frame | 63 // pages. This message should only be logged once per main-frame |
66 // navigation. | 64 // navigation. |
67 bool logged_http_warning_on_current_navigation_; | 65 bool logged_http_warning_on_current_navigation_; |
68 | 66 |
69 DISALLOW_COPY_AND_ASSIGN(ChromeSecurityStateModelClient); | 67 DISALLOW_COPY_AND_ASSIGN(ChromeSecurityStateModelClient); |
70 }; | 68 }; |
71 | 69 |
72 #endif // CHROME_BROWSER_SSL_CHROME_SECURITY_STATE_MODEL_CLIENT_H_ | 70 #endif // CHROME_BROWSER_SSL_CHROME_SECURITY_STATE_MODEL_CLIENT_H_ |
OLD | NEW |