| 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 "components/security_state/security_state_model.h" | 5 #include "components/security_state/security_state_model.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/test/histogram_tester.h" |
| 10 #include "components/security_state/security_state_model_client.h" | 11 #include "components/security_state/security_state_model_client.h" |
| 11 #include "components/security_state/switches.h" | 12 #include "components/security_state/switches.h" |
| 12 #include "net/cert/x509_certificate.h" | 13 #include "net/cert/x509_certificate.h" |
| 13 #include "net/ssl/ssl_cipher_suite_names.h" | 14 #include "net/ssl/ssl_cipher_suite_names.h" |
| 14 #include "net/ssl/ssl_connection_status_flags.h" | 15 #include "net/ssl/ssl_connection_status_flags.h" |
| 15 #include "net/test/cert_test_util.h" | 16 #include "net/test/cert_test_util.h" |
| 16 #include "net/test/test_certificate_data.h" | 17 #include "net/test/test_certificate_data.h" |
| 17 #include "net/test/test_data_directory.h" | 18 #include "net/test/test_data_directory.h" |
| 18 #include "testing/gtest/include/gtest/gtest.h" | 19 #include "testing/gtest/include/gtest/gtest.h" |
| 19 | 20 |
| (...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 295 TestSecurityStateModelClient client; | 296 TestSecurityStateModelClient client; |
| 296 client.UseHttpUrl(); | 297 client.UseHttpUrl(); |
| 297 SecurityStateModel model; | 298 SecurityStateModel model; |
| 298 model.SetClient(&client); | 299 model.SetClient(&client); |
| 299 SecurityStateModel::SecurityInfo security_info; | 300 SecurityStateModel::SecurityInfo security_info; |
| 300 model.GetSecurityInfo(&security_info); | 301 model.GetSecurityInfo(&security_info); |
| 301 EXPECT_FALSE(security_info.displayed_private_user_data_input_on_http); | 302 EXPECT_FALSE(security_info.displayed_private_user_data_input_on_http); |
| 302 EXPECT_EQ(SecurityStateModel::NONE, security_info.security_level); | 303 EXPECT_EQ(SecurityStateModel::NONE, security_info.security_level); |
| 303 } | 304 } |
| 304 | 305 |
| 306 // Tests that SSL.MarkHttpAsStatus histogram is updated when security state is |
| 307 // computed for a page containing a password field on HTTP. |
| 308 TEST(SecurityStateModelTest, MarkHttpAsStatusHistogram) { |
| 309 const char* kHistogramName = "SSL.MarkHttpAsStatus"; |
| 310 base::HistogramTester histograms; |
| 311 base::CommandLine::ForCurrentProcess()->AppendSwitchASCII( |
| 312 switches::kMarkHttpAs, switches::kMarkHttpWithPasswordsOrCcWithChip); |
| 313 TestSecurityStateModelClient client; |
| 314 client.UseHttpUrl(); |
| 315 SecurityStateModel model; |
| 316 model.SetClient(&client); |
| 317 client.set_displayed_password_field_on_http(true); |
| 318 SecurityStateModel::SecurityInfo security_info; |
| 319 histograms.ExpectTotalCount(kHistogramName, 0); |
| 320 model.GetSecurityInfo(&security_info); |
| 321 histograms.ExpectUniqueSample(kHistogramName, 2 /* HTTP_SHOW_WARNING */, 1); |
| 322 } |
| 323 |
| 305 } // namespace | 324 } // namespace |
| 306 | 325 |
| 307 } // namespace security_state | 326 } // namespace security_state |
| OLD | NEW |