Chromium Code Reviews| 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 <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/metrics/field_trial.h" | 10 #include "base/metrics/field_trial.h" |
| (...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 188 security_state::SecurityStateModel::HTTP_SHOW_WARNING) { | 188 security_state::SecurityStateModel::HTTP_SHOW_WARNING) { |
| 189 // If the HTTP_SHOW_WARNING field trial is in use, display an | 189 // If the HTTP_SHOW_WARNING field trial is in use, display an |
| 190 // unauthenticated explanation explaining why the omnibox warning is | 190 // unauthenticated explanation explaining why the omnibox warning is |
| 191 // present. | 191 // present. |
| 192 security_style_explanations->unauthenticated_explanations.push_back( | 192 security_style_explanations->unauthenticated_explanations.push_back( |
| 193 content::SecurityStyleExplanation( | 193 content::SecurityStyleExplanation( |
| 194 l10n_util::GetStringUTF8(IDS_PRIVATE_USER_DATA_INPUT), | 194 l10n_util::GetStringUTF8(IDS_PRIVATE_USER_DATA_INPUT), |
| 195 l10n_util::GetStringUTF8(IDS_PRIVATE_USER_DATA_INPUT_DESCRIPTION))); | 195 l10n_util::GetStringUTF8(IDS_PRIVATE_USER_DATA_INPUT_DESCRIPTION))); |
| 196 } else if (security_info.security_level == | 196 } else if (security_info.security_level == |
| 197 security_state::SecurityStateModel::NONE && | 197 security_state::SecurityStateModel::NONE && |
| 198 security_info.displayed_private_user_data_input_on_http) { | 198 (security_info.displayed_password_field_on_http || |
| 199 security_info.displayed_credit_card_field_on_http)) { | |
| 199 // If the HTTP_SHOW_WARNING field trial isn't in use yet, display an | 200 // If the HTTP_SHOW_WARNING field trial isn't in use yet, display an |
| 200 // informational note that the omnibox will contain a warning for | 201 // informational note that the omnibox will contain a warning for |
| 201 // this site in a future version of Chrome. | 202 // this site in a future version of Chrome. |
| 202 security_style_explanations->info_explanations.push_back( | 203 security_style_explanations->info_explanations.push_back( |
| 203 content::SecurityStyleExplanation( | 204 content::SecurityStyleExplanation( |
| 204 l10n_util::GetStringUTF8(IDS_PRIVATE_USER_DATA_INPUT), | 205 l10n_util::GetStringUTF8(IDS_PRIVATE_USER_DATA_INPUT), |
| 205 l10n_util::GetStringUTF8( | 206 l10n_util::GetStringUTF8( |
| 206 IDS_PRIVATE_USER_DATA_INPUT_FUTURE_DESCRIPTION))); | 207 IDS_PRIVATE_USER_DATA_INPUT_FUTURE_DESCRIPTION))); |
| 207 } | 208 } |
| 208 | 209 |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 326 SecurityStateModel::SecurityInfo* result) const { | 327 SecurityStateModel::SecurityInfo* result) const { |
| 327 security_state_model_->GetSecurityInfo(result); | 328 security_state_model_->GetSecurityInfo(result); |
| 328 } | 329 } |
| 329 | 330 |
| 330 void ChromeSecurityStateModelClient::VisibleSecurityStateChanged() { | 331 void ChromeSecurityStateModelClient::VisibleSecurityStateChanged() { |
| 331 if (logged_http_warning_on_current_navigation_) | 332 if (logged_http_warning_on_current_navigation_) |
| 332 return; | 333 return; |
| 333 | 334 |
| 334 security_state::SecurityStateModel::SecurityInfo security_info; | 335 security_state::SecurityStateModel::SecurityInfo security_info; |
| 335 GetSecurityInfo(&security_info); | 336 GetSecurityInfo(&security_info); |
| 336 if (!security_info.displayed_private_user_data_input_on_http) | 337 if (!security_info.displayed_password_field_on_http && |
| 338 !security_info.displayed_credit_card_field_on_http) | |
|
estark
2016/11/09 15:56:46
nit: now that the conditional spans two lines, can
lshang
2016/11/10 04:53:54
Done.
| |
| 337 return; | 339 return; |
| 338 | 340 |
| 339 std::string warning; | 341 std::string warning; |
| 340 bool warning_is_user_visible = false; | 342 bool warning_is_user_visible = false; |
| 341 switch (security_info.security_level) { | 343 switch (security_info.security_level) { |
| 342 case security_state::SecurityStateModel::HTTP_SHOW_WARNING: | 344 case security_state::SecurityStateModel::HTTP_SHOW_WARNING: |
| 343 warning = | 345 warning = |
| 344 "This page includes a password or credit card input in a non-secure " | 346 "This page includes a password or credit card input in a non-secure " |
| 345 "context. A warning has been added to the URL bar. For more " | 347 "context. A warning has been added to the URL bar. For more " |
| 346 "information, see https://goo.gl/zmWq3m."; | 348 "information, see https://goo.gl/zmWq3m."; |
| 347 warning_is_user_visible = true; | 349 warning_is_user_visible = true; |
| 348 break; | 350 break; |
| 349 case security_state::SecurityStateModel::NONE: | 351 case security_state::SecurityStateModel::NONE: |
| 350 case security_state::SecurityStateModel::DANGEROUS: | 352 case security_state::SecurityStateModel::DANGEROUS: |
| 351 warning = | 353 warning = |
| 352 "This page includes a password or credit card input in a non-secure " | 354 "This page includes a password or credit card input in a non-secure " |
| 353 "context. A warning will be added to the URL bar in Chrome 56 (Jan " | 355 "context. A warning will be added to the URL bar in Chrome 56 (Jan " |
| 354 "2017). For more information, see https://goo.gl/zmWq3m."; | 356 "2017). For more information, see https://goo.gl/zmWq3m."; |
| 355 break; | 357 break; |
| 356 default: | 358 default: |
| 357 return; | 359 return; |
| 358 } | 360 } |
| 359 | 361 |
| 360 logged_http_warning_on_current_navigation_ = true; | 362 logged_http_warning_on_current_navigation_ = true; |
| 361 web_contents_->GetMainFrame()->AddMessageToConsole( | 363 web_contents_->GetMainFrame()->AddMessageToConsole( |
| 362 content::CONSOLE_MESSAGE_LEVEL_WARNING, warning); | 364 content::CONSOLE_MESSAGE_LEVEL_WARNING, warning); |
| 363 UMA_HISTOGRAM_BOOLEAN("Security.HTTPBad.UserWarnedAboutSensitiveInput", | 365 |
| 364 warning_is_user_visible); | 366 UMA_HISTOGRAM_BOOLEAN( |
| 367 "Security.HTTPBad.UserWarnedAboutSensitiveInput.CreditCard", | |
| 368 security_info.displayed_credit_card_field_on_http && | |
|
estark
2016/11/09 15:56:46
Hmm. I think we ought to only record the histogram
lshang
2016/11/10 04:53:54
Done.
| |
| 369 warning_is_user_visible); | |
| 370 UMA_HISTOGRAM_BOOLEAN( | |
| 371 "Security.HTTPBad.UserWarnedAboutSensitiveInput.Password", | |
| 372 security_info.displayed_password_field_on_http && | |
| 373 warning_is_user_visible); | |
| 365 } | 374 } |
| 366 | 375 |
| 367 void ChromeSecurityStateModelClient::DidFinishNavigation( | 376 void ChromeSecurityStateModelClient::DidFinishNavigation( |
| 368 content::NavigationHandle* navigation_handle) { | 377 content::NavigationHandle* navigation_handle) { |
| 369 if (navigation_handle->IsInMainFrame() && !navigation_handle->IsSamePage()) { | 378 if (navigation_handle->IsInMainFrame() && !navigation_handle->IsSamePage()) { |
| 370 // Only reset the console message flag for main-frame navigations, | 379 // Only reset the console message flag for main-frame navigations, |
| 371 // and not for same-page navigations like reference fragments and pushState. | 380 // and not for same-page navigations like reference fragments and pushState. |
| 372 logged_http_warning_on_current_navigation_ = false; | 381 logged_http_warning_on_current_navigation_ = false; |
| 373 } | 382 } |
| 374 } | 383 } |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 429 !!(ssl.content_status & content::SSLStatus::RAN_CONTENT_WITH_CERT_ERRORS); | 438 !!(ssl.content_status & content::SSLStatus::RAN_CONTENT_WITH_CERT_ERRORS); |
| 430 state->displayed_password_field_on_http = | 439 state->displayed_password_field_on_http = |
| 431 !!(ssl.content_status & | 440 !!(ssl.content_status & |
| 432 content::SSLStatus::DISPLAYED_PASSWORD_FIELD_ON_HTTP); | 441 content::SSLStatus::DISPLAYED_PASSWORD_FIELD_ON_HTTP); |
| 433 state->displayed_credit_card_field_on_http = | 442 state->displayed_credit_card_field_on_http = |
| 434 !!(ssl.content_status & | 443 !!(ssl.content_status & |
| 435 content::SSLStatus::DISPLAYED_CREDIT_CARD_FIELD_ON_HTTP); | 444 content::SSLStatus::DISPLAYED_CREDIT_CARD_FIELD_ON_HTTP); |
| 436 | 445 |
| 437 CheckSafeBrowsingStatus(entry, web_contents_, state); | 446 CheckSafeBrowsingStatus(entry, web_contents_, state); |
| 438 } | 447 } |
| OLD | NEW |