| 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 #include "chrome/browser/ssl/security_state_tab_helper.h" | 5 #include "chrome/browser/ssl/security_state_tab_helper.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/metrics/histogram_macros.h" | 8 #include "base/metrics/histogram_macros.h" |
| 9 #include "base/time/time.h" | 9 #include "base/time/time.h" |
| 10 #include "build/build_config.h" | 10 #include "build/build_config.h" |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 if (security_info.displayed_password_field_on_http) { | 83 if (security_info.displayed_password_field_on_http) { |
| 84 UMA_HISTOGRAM_BOOLEAN( | 84 UMA_HISTOGRAM_BOOLEAN( |
| 85 "Security.HTTPBad.UserWarnedAboutSensitiveInput.Password", | 85 "Security.HTTPBad.UserWarnedAboutSensitiveInput.Password", |
| 86 warning_is_user_visible); | 86 warning_is_user_visible); |
| 87 } | 87 } |
| 88 } | 88 } |
| 89 | 89 |
| 90 void SecurityStateTabHelper::DidStartNavigation( | 90 void SecurityStateTabHelper::DidStartNavigation( |
| 91 content::NavigationHandle* navigation_handle) { | 91 content::NavigationHandle* navigation_handle) { |
| 92 if (time_of_http_warning_on_current_navigation_.is_null() || | 92 if (time_of_http_warning_on_current_navigation_.is_null() || |
| 93 !navigation_handle->IsInMainFrame() || navigation_handle->IsSamePage()) { | 93 !navigation_handle->IsInMainFrame() || |
| 94 navigation_handle->IsSameDocument()) { |
| 94 return; | 95 return; |
| 95 } | 96 } |
| 96 // Record how quickly a user leaves a site after encountering an | 97 // Record how quickly a user leaves a site after encountering an |
| 97 // HTTP-bad warning. A navigation here only counts if it is a | 98 // HTTP-bad warning. A navigation here only counts if it is a |
| 98 // main-frame, not-same-page navigation, since it aims to measure how | 99 // main-frame, not-same-page navigation, since it aims to measure how |
| 99 // quickly a user leaves a site after seeing the HTTP warning. | 100 // quickly a user leaves a site after seeing the HTTP warning. |
| 100 UMA_HISTOGRAM_LONG_TIMES( | 101 UMA_HISTOGRAM_LONG_TIMES( |
| 101 "Security.HTTPBad.NavigationStartedAfterUserWarnedAboutSensitiveInput", | 102 "Security.HTTPBad.NavigationStartedAfterUserWarnedAboutSensitiveInput", |
| 102 base::Time::Now() - time_of_http_warning_on_current_navigation_); | 103 base::Time::Now() - time_of_http_warning_on_current_navigation_); |
| 103 // After recording the histogram, clear the time of the warning. A | 104 // After recording the histogram, clear the time of the warning. A |
| 104 // timing histogram will not be recorded again on this page, because | 105 // timing histogram will not be recorded again on this page, because |
| 105 // the time is only set the first time the HTTP-bad warning is shown | 106 // the time is only set the first time the HTTP-bad warning is shown |
| 106 // per page. | 107 // per page. |
| 107 time_of_http_warning_on_current_navigation_ = base::Time(); | 108 time_of_http_warning_on_current_navigation_ = base::Time(); |
| 108 } | 109 } |
| 109 | 110 |
| 110 void SecurityStateTabHelper::DidFinishNavigation( | 111 void SecurityStateTabHelper::DidFinishNavigation( |
| 111 content::NavigationHandle* navigation_handle) { | 112 content::NavigationHandle* navigation_handle) { |
| 112 if (navigation_handle->IsInMainFrame() && !navigation_handle->IsSamePage()) { | 113 if (navigation_handle->IsInMainFrame() && |
| 114 !navigation_handle->IsSameDocument()) { |
| 113 // Only reset the console message flag for main-frame navigations, | 115 // Only reset the console message flag for main-frame navigations, |
| 114 // and not for same-page navigations like reference fragments and pushState. | 116 // and not for same-document navigations like reference fragments and |
| 117 // pushState. |
| 115 logged_http_warning_on_current_navigation_ = false; | 118 logged_http_warning_on_current_navigation_ = false; |
| 116 } | 119 } |
| 117 } | 120 } |
| 118 | 121 |
| 119 void SecurityStateTabHelper::WebContentsDestroyed() { | 122 void SecurityStateTabHelper::WebContentsDestroyed() { |
| 120 if (time_of_http_warning_on_current_navigation_.is_null()) { | 123 if (time_of_http_warning_on_current_navigation_.is_null()) { |
| 121 return; | 124 return; |
| 122 } | 125 } |
| 123 // Record how quickly the tab is closed after a user encounters an | 126 // Record how quickly the tab is closed after a user encounters an |
| 124 // HTTP-bad warning. This histogram will only be recorded if the | 127 // HTTP-bad warning. This histogram will only be recorded if the |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 186 std::unique_ptr<security_state::VisibleSecurityState> | 189 std::unique_ptr<security_state::VisibleSecurityState> |
| 187 SecurityStateTabHelper::GetVisibleSecurityState() const { | 190 SecurityStateTabHelper::GetVisibleSecurityState() const { |
| 188 auto state = security_state::GetVisibleSecurityState(web_contents()); | 191 auto state = security_state::GetVisibleSecurityState(web_contents()); |
| 189 | 192 |
| 190 // Malware status might already be known even if connection security | 193 // Malware status might already be known even if connection security |
| 191 // information is still being initialized, thus no need to check for that. | 194 // information is still being initialized, thus no need to check for that. |
| 192 state->malicious_content_status = GetMaliciousContentStatus(); | 195 state->malicious_content_status = GetMaliciousContentStatus(); |
| 193 | 196 |
| 194 return state; | 197 return state; |
| 195 } | 198 } |
| OLD | NEW |