| 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/chrome_security_state_model_client.h" | 5 #include "chrome/browser/ssl/chrome_security_state_model_client.h" |
| 6 | 6 |
| 7 #include <openssl/ssl.h> | 7 #include <openssl/ssl.h> |
| 8 | 8 |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/command_line.h" | 11 #include "base/command_line.h" |
| 12 #include "base/metrics/field_trial.h" | 12 #include "base/metrics/field_trial.h" |
| 13 #include "base/metrics/histogram_macros.h" | 13 #include "base/metrics/histogram_macros.h" |
| 14 #include "base/strings/string16.h" | 14 #include "base/strings/string16.h" |
| 15 #include "base/strings/utf_string_conversions.h" | 15 #include "base/strings/utf_string_conversions.h" |
| 16 #include "build/build_config.h" | 16 #include "build/build_config.h" |
| 17 #include "chrome/browser/browser_process.h" | 17 #include "chrome/browser/browser_process.h" |
| 18 #include "chrome/browser/chromeos/policy/policy_cert_service.h" | 18 #include "chrome/browser/chromeos/policy/policy_cert_service.h" |
| 19 #include "chrome/browser/chromeos/policy/policy_cert_service_factory.h" | 19 #include "chrome/browser/chromeos/policy/policy_cert_service_factory.h" |
| 20 #include "chrome/browser/profiles/profile.h" | 20 #include "chrome/browser/profiles/profile.h" |
| 21 #include "chrome/browser/safe_browsing/safe_browsing_service.h" | 21 #include "chrome/browser/safe_browsing/safe_browsing_service.h" |
| 22 #include "chrome/browser/safe_browsing/ui_manager.h" | 22 #include "chrome/browser/safe_browsing/ui_manager.h" |
| 23 #include "chrome/grit/generated_resources.h" | 23 #include "chrome/grit/generated_resources.h" |
| 24 #include "content/public/browser/navigation_entry.h" | 24 #include "content/public/browser/navigation_entry.h" |
| 25 #include "content/public/browser/navigation_handle.h" |
| 26 #include "content/public/browser/render_frame_host.h" |
| 25 #include "content/public/browser/security_style_explanation.h" | 27 #include "content/public/browser/security_style_explanation.h" |
| 26 #include "content/public/browser/security_style_explanations.h" | 28 #include "content/public/browser/security_style_explanations.h" |
| 27 #include "content/public/browser/ssl_status.h" | 29 #include "content/public/browser/ssl_status.h" |
| 28 #include "content/public/browser/web_contents.h" | 30 #include "content/public/browser/web_contents.h" |
| 29 #include "content/public/common/origin_util.h" | 31 #include "content/public/common/origin_util.h" |
| 30 #include "net/base/net_errors.h" | 32 #include "net/base/net_errors.h" |
| 31 #include "net/cert/x509_certificate.h" | 33 #include "net/cert/x509_certificate.h" |
| 32 #include "net/ssl/ssl_cipher_suite_names.h" | 34 #include "net/ssl/ssl_cipher_suite_names.h" |
| 33 #include "net/ssl/ssl_connection_status_flags.h" | 35 #include "net/ssl/ssl_connection_status_flags.h" |
| 34 #include "ui/base/l10n/l10n_util.h" | 36 #include "ui/base/l10n/l10n_util.h" |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 159 if (sb_ui_manager->IsUrlWhitelistedOrPendingForWebContents( | 161 if (sb_ui_manager->IsUrlWhitelistedOrPendingForWebContents( |
| 160 entry->GetURL(), false, entry, web_contents, false)) { | 162 entry->GetURL(), false, entry, web_contents, false)) { |
| 161 state->fails_malware_check = true; | 163 state->fails_malware_check = true; |
| 162 } | 164 } |
| 163 } | 165 } |
| 164 | 166 |
| 165 } // namespace | 167 } // namespace |
| 166 | 168 |
| 167 ChromeSecurityStateModelClient::ChromeSecurityStateModelClient( | 169 ChromeSecurityStateModelClient::ChromeSecurityStateModelClient( |
| 168 content::WebContents* web_contents) | 170 content::WebContents* web_contents) |
| 169 : web_contents_(web_contents), | 171 : content::WebContentsObserver(web_contents), |
| 170 security_state_model_(new SecurityStateModel()) { | 172 web_contents_(web_contents), |
| 173 security_state_model_(new SecurityStateModel()), |
| 174 logged_http_warning_on_current_navigation_(false) { |
| 171 security_state_model_->SetClient(this); | 175 security_state_model_->SetClient(this); |
| 172 } | 176 } |
| 173 | 177 |
| 174 ChromeSecurityStateModelClient::~ChromeSecurityStateModelClient() {} | 178 ChromeSecurityStateModelClient::~ChromeSecurityStateModelClient() {} |
| 175 | 179 |
| 176 // static | 180 // static |
| 177 blink::WebSecurityStyle ChromeSecurityStateModelClient::GetSecurityStyle( | 181 blink::WebSecurityStyle ChromeSecurityStateModelClient::GetSecurityStyle( |
| 178 const security_state::SecurityStateModel::SecurityInfo& security_info, | 182 const security_state::SecurityStateModel::SecurityInfo& security_info, |
| 179 content::SecurityStyleExplanations* security_style_explanations) { | 183 content::SecurityStyleExplanations* security_style_explanations) { |
| 180 const blink::WebSecurityStyle security_style = | 184 const blink::WebSecurityStyle security_style = |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 294 } | 298 } |
| 295 | 299 |
| 296 return security_style; | 300 return security_style; |
| 297 } | 301 } |
| 298 | 302 |
| 299 void ChromeSecurityStateModelClient::GetSecurityInfo( | 303 void ChromeSecurityStateModelClient::GetSecurityInfo( |
| 300 SecurityStateModel::SecurityInfo* result) const { | 304 SecurityStateModel::SecurityInfo* result) const { |
| 301 security_state_model_->GetSecurityInfo(result); | 305 security_state_model_->GetSecurityInfo(result); |
| 302 } | 306 } |
| 303 | 307 |
| 308 void ChromeSecurityStateModelClient::VisibleSSLStateChanged() { |
| 309 if (logged_http_warning_on_current_navigation_) |
| 310 return; |
| 311 |
| 312 security_state::SecurityStateModel::SecurityInfo security_info; |
| 313 GetSecurityInfo(&security_info); |
| 314 if (security_info.security_level == |
| 315 security_state::SecurityStateModel::HTTP_SHOW_WARNING) { |
| 316 web_contents_->GetMainFrame()->AddMessageToConsole( |
| 317 content::CONSOLE_MESSAGE_LEVEL_WARNING, |
| 318 "In Chrome M56 (Jan 2017), this page will be marked " |
| 319 "as \"not secure\" in the URL bar. For more " |
| 320 "information, see https://goo.gl/zmWq3m"); |
| 321 logged_http_warning_on_current_navigation_ = true; |
| 322 } |
| 323 } |
| 324 |
| 325 void ChromeSecurityStateModelClient::DidFinishNavigation( |
| 326 content::NavigationHandle* navigation_handle) { |
| 327 if (navigation_handle->IsInMainFrame() && |
| 328 !navigation_handle->IsSynchronousNavigation()) { |
| 329 // Only reset the console message flag for main-frame navigations, |
| 330 // and not for synchronous navigations like reference fragments and |
| 331 // pushState. |
| 332 logged_http_warning_on_current_navigation_ = false; |
| 333 } |
| 334 } |
| 335 |
| 304 bool ChromeSecurityStateModelClient::UsedPolicyInstalledCertificate() { | 336 bool ChromeSecurityStateModelClient::UsedPolicyInstalledCertificate() { |
| 305 #if defined(OS_CHROMEOS) | 337 #if defined(OS_CHROMEOS) |
| 306 policy::PolicyCertService* service = | 338 policy::PolicyCertService* service = |
| 307 policy::PolicyCertServiceFactory::GetForProfile( | 339 policy::PolicyCertServiceFactory::GetForProfile( |
| 308 Profile::FromBrowserContext(web_contents_->GetBrowserContext())); | 340 Profile::FromBrowserContext(web_contents_->GetBrowserContext())); |
| 309 if (service && service->UsedPolicyCertificates()) | 341 if (service && service->UsedPolicyCertificates()) |
| 310 return true; | 342 return true; |
| 311 #endif | 343 #endif |
| 312 return false; | 344 return false; |
| 313 } | 345 } |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 357 !!(ssl.content_status & content::SSLStatus::RAN_CONTENT_WITH_CERT_ERRORS); | 389 !!(ssl.content_status & content::SSLStatus::RAN_CONTENT_WITH_CERT_ERRORS); |
| 358 state->displayed_password_field_on_http = | 390 state->displayed_password_field_on_http = |
| 359 !!(ssl.content_status & | 391 !!(ssl.content_status & |
| 360 content::SSLStatus::DISPLAYED_PASSWORD_FIELD_ON_HTTP); | 392 content::SSLStatus::DISPLAYED_PASSWORD_FIELD_ON_HTTP); |
| 361 state->displayed_credit_card_field_on_http = | 393 state->displayed_credit_card_field_on_http = |
| 362 !!(ssl.content_status & | 394 !!(ssl.content_status & |
| 363 content::SSLStatus::DISPLAYED_CREDIT_CARD_FIELD_ON_HTTP); | 395 content::SSLStatus::DISPLAYED_CREDIT_CARD_FIELD_ON_HTTP); |
| 364 | 396 |
| 365 CheckSafeBrowsingStatus(entry, web_contents_, state); | 397 CheckSafeBrowsingStatus(entry, web_contents_, state); |
| 366 } | 398 } |
| OLD | NEW |