Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(160)

Side by Side Diff: components/security_state/security_state_model.cc

Issue 2344043003: Rename HTTP bad-related flags to be more clear (Closed)
Patch Set: sfijdf Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/metrics/field_trial.h" 10 #include "base/metrics/field_trial.h"
11 #include "base/metrics/histogram_macros.h" 11 #include "base/metrics/histogram_macros.h"
12 #include "components/security_state/security_state_model_client.h" 12 #include "components/security_state/security_state_model_client.h"
13 #include "components/security_state/switches.h" 13 #include "components/security_state/switches.h"
14 #include "net/ssl/ssl_cipher_suite_names.h" 14 #include "net/ssl/ssl_cipher_suite_names.h"
15 #include "net/ssl/ssl_connection_status_flags.h" 15 #include "net/ssl/ssl_connection_status_flags.h"
16 16
17 namespace security_state { 17 namespace security_state {
18 18
19 namespace { 19 namespace {
20 20
21 // Do not change or reorder this enum, and add new values at the end. It is used 21 // Do not change or reorder this enum, and add new values at the end. It is used
22 // in the MarkHttpAs histogram. 22 // in the MarkHttpAs histogram.
23 enum MarkHttpStatus { NEUTRAL, NON_SECURE, HTTP_SHOW_WARNING, LAST_STATUS }; 23 enum MarkHttpStatus { NEUTRAL, NON_SECURE, HTTP_SHOW_WARNING, LAST_STATUS };
24 24
25 // If |switch_or_field_trial_group| corresponds to a valid 25 // If |switch_or_field_trial_group| corresponds to a valid
26 // MarkNonSecureAs group, sets |*level| and |*histogram_status| to the 26 // MarkHttpAs group, sets |*level| and |*histogram_status| to the
27 // appropriate values and returns true. Otherwise, returns false. 27 // appropriate values and returns true. Otherwise, returns false.
28 bool GetSecurityLevelAndHistogramValueForNonSecureFieldTrial( 28 bool GetSecurityLevelAndHistogramValueForNonSecureFieldTrial(
29 std::string switch_or_field_trial_group, 29 std::string switch_or_field_trial_group,
30 bool displayed_sensitive_input_on_http, 30 bool displayed_sensitive_input_on_http,
31 SecurityStateModel::SecurityLevel* level, 31 SecurityStateModel::SecurityLevel* level,
32 MarkHttpStatus* histogram_status) { 32 MarkHttpStatus* histogram_status) {
33 if (switch_or_field_trial_group == switches::kMarkNonSecureAsNeutral) { 33 if (switch_or_field_trial_group == switches::kMarkHttpAsNeutral) {
34 *level = SecurityStateModel::NONE; 34 *level = SecurityStateModel::NONE;
35 *histogram_status = NEUTRAL; 35 *histogram_status = NEUTRAL;
36 return true; 36 return true;
37 } 37 }
38 38
39 if (switch_or_field_trial_group == switches::kMarkNonSecureAsNonSecure) { 39 if (switch_or_field_trial_group == switches::kMarkHttpAsDangerous) {
40 *level = SecurityStateModel::SECURITY_ERROR; 40 *level = SecurityStateModel::SECURITY_ERROR;
41 *histogram_status = NON_SECURE; 41 *histogram_status = NON_SECURE;
42 return true; 42 return true;
43 } 43 }
44 44
45 if (switch_or_field_trial_group == 45 if (switch_or_field_trial_group ==
46 switches::kMarkNonSecureWithPasswordsOrCcAsNonSecure) { 46 switches::kMarkHttpWithPasswordsOrCcWithChip) {
47 if (displayed_sensitive_input_on_http) { 47 if (displayed_sensitive_input_on_http) {
48 *level = SecurityStateModel::HTTP_SHOW_WARNING; 48 *level = SecurityStateModel::HTTP_SHOW_WARNING;
49 *histogram_status = HTTP_SHOW_WARNING; 49 *histogram_status = HTTP_SHOW_WARNING;
50 } else { 50 } else {
51 *level = SecurityStateModel::NONE; 51 *level = SecurityStateModel::NONE;
52 *histogram_status = NEUTRAL; 52 *histogram_status = NEUTRAL;
53 } 53 }
54 return true; 54 return true;
55 } 55 }
56 56
57 return false; 57 return false;
58 } 58 }
59 59
60 SecurityStateModel::SecurityLevel GetSecurityLevelForNonSecureFieldTrial( 60 SecurityStateModel::SecurityLevel GetSecurityLevelForNonSecureFieldTrial(
61 bool displayed_sensitive_input_on_http) { 61 bool displayed_sensitive_input_on_http) {
62 std::string choice = 62 std::string choice =
63 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( 63 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
64 switches::kMarkNonSecureAs); 64 switches::kMarkHttpAs);
65 std::string group = base::FieldTrialList::FindFullName("MarkNonSecureAs"); 65 std::string group = base::FieldTrialList::FindFullName("MarkNonSecureAs");
66 66
67 const char kEnumeration[] = "MarkHttpAs"; 67 const char kEnumeration[] = "MarkHttpAs";
68 68
69 SecurityStateModel::SecurityLevel level = SecurityStateModel::NONE; 69 SecurityStateModel::SecurityLevel level = SecurityStateModel::NONE;
70 MarkHttpStatus status; 70 MarkHttpStatus status;
71 71
72 // If the command-line switch is set, then it takes precedence over 72 // If the command-line switch is set, then it takes precedence over
73 // the field trial group. 73 // the field trial group.
74 if (!GetSecurityLevelAndHistogramValueForNonSecureFieldTrial( 74 if (!GetSecurityLevelAndHistogramValueForNonSecureFieldTrial(
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after
342 other.displayed_content_with_cert_errors && 342 other.displayed_content_with_cert_errors &&
343 ran_content_with_cert_errors == other.ran_content_with_cert_errors && 343 ran_content_with_cert_errors == other.ran_content_with_cert_errors &&
344 pkp_bypassed == other.pkp_bypassed && 344 pkp_bypassed == other.pkp_bypassed &&
345 displayed_password_field_on_http == 345 displayed_password_field_on_http ==
346 other.displayed_password_field_on_http && 346 other.displayed_password_field_on_http &&
347 displayed_credit_card_field_on_http == 347 displayed_credit_card_field_on_http ==
348 other.displayed_credit_card_field_on_http); 348 other.displayed_credit_card_field_on_http);
349 } 349 }
350 350
351 } // namespace security_state 351 } // namespace security_state
OLDNEW
« no previous file with comments | « chrome/browser/ssl/ssl_browser_tests.cc ('k') | components/security_state/security_state_model_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698