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_interstitials/core/ssl_error_ui.h" | 5 #include "components/security_interstitials/core/ssl_error_ui.h" |
6 | 6 |
7 #include "base/i18n/time_formatting.h" | 7 #include "base/i18n/time_formatting.h" |
8 #include "components/security_interstitials/core/common_string_util.h" | 8 #include "components/security_interstitials/core/common_string_util.h" |
9 #include "components/security_interstitials/core/metrics_helper.h" | 9 #include "components/security_interstitials/core/metrics_helper.h" |
10 #include "components/ssl_errors/error_classification.h" | 10 #include "components/ssl_errors/error_classification.h" |
(...skipping 11 matching lines...) Expand all Loading... |
22 return ((options & mask) != 0); | 22 return ((options & mask) != 0); |
23 } | 23 } |
24 | 24 |
25 } // namespace | 25 } // namespace |
26 | 26 |
27 SSLErrorUI::SSLErrorUI(const GURL& request_url, | 27 SSLErrorUI::SSLErrorUI(const GURL& request_url, |
28 int cert_error, | 28 int cert_error, |
29 const net::SSLInfo& ssl_info, | 29 const net::SSLInfo& ssl_info, |
30 int display_options, | 30 int display_options, |
31 const base::Time& time_triggered, | 31 const base::Time& time_triggered, |
32 const std::string& languages, | |
33 ControllerClient* controller) | 32 ControllerClient* controller) |
34 : request_url_(request_url), | 33 : request_url_(request_url), |
35 cert_error_(cert_error), | 34 cert_error_(cert_error), |
36 ssl_info_(ssl_info), | 35 ssl_info_(ssl_info), |
37 time_triggered_(time_triggered), | 36 time_triggered_(time_triggered), |
38 languages_(languages), | |
39 requested_strict_enforcement_( | 37 requested_strict_enforcement_( |
40 IsMasked(display_options, STRICT_ENFORCEMENT)), | 38 IsMasked(display_options, STRICT_ENFORCEMENT)), |
41 soft_override_enabled_(IsMasked(display_options, SOFT_OVERRIDE_ENABLED)), | 39 soft_override_enabled_(IsMasked(display_options, SOFT_OVERRIDE_ENABLED)), |
42 hard_override_enabled_( | 40 hard_override_enabled_( |
43 !IsMasked(display_options, HARD_OVERRIDE_DISABLED)), | 41 !IsMasked(display_options, HARD_OVERRIDE_DISABLED)), |
44 controller_(controller), | 42 controller_(controller), |
45 user_made_decision_(false) { | 43 user_made_decision_(false) { |
46 controller_->metrics_helper()->RecordUserDecision(MetricsHelper::SHOW); | 44 controller_->metrics_helper()->RecordUserDecision(MetricsHelper::SHOW); |
47 controller_->metrics_helper()->RecordUserInteraction( | 45 controller_->metrics_helper()->RecordUserInteraction( |
48 MetricsHelper::TOTAL_VISITS); | 46 MetricsHelper::TOTAL_VISITS); |
(...skipping 23 matching lines...) Expand all Loading... |
72 // Shared values for both the overridable and non-overridable versions. | 70 // Shared values for both the overridable and non-overridable versions. |
73 load_time_data->SetBoolean("bad_clock", false); | 71 load_time_data->SetBoolean("bad_clock", false); |
74 load_time_data->SetString("tabTitle", | 72 load_time_data->SetString("tabTitle", |
75 l10n_util::GetStringUTF16(IDS_SSL_V2_TITLE)); | 73 l10n_util::GetStringUTF16(IDS_SSL_V2_TITLE)); |
76 load_time_data->SetString("heading", | 74 load_time_data->SetString("heading", |
77 l10n_util::GetStringUTF16(IDS_SSL_V2_HEADING)); | 75 l10n_util::GetStringUTF16(IDS_SSL_V2_HEADING)); |
78 load_time_data->SetString( | 76 load_time_data->SetString( |
79 "primaryParagraph", | 77 "primaryParagraph", |
80 l10n_util::GetStringFUTF16( | 78 l10n_util::GetStringFUTF16( |
81 IDS_SSL_V2_PRIMARY_PARAGRAPH, | 79 IDS_SSL_V2_PRIMARY_PARAGRAPH, |
82 common_string_util::GetFormattedHostName(request_url_, languages_))); | 80 common_string_util::GetFormattedHostName(request_url_))); |
83 | 81 |
84 if (soft_override_enabled_) | 82 if (soft_override_enabled_) |
85 PopulateOverridableStrings(load_time_data); | 83 PopulateOverridableStrings(load_time_data); |
86 else | 84 else |
87 PopulateNonOverridableStrings(load_time_data); | 85 PopulateNonOverridableStrings(load_time_data); |
88 } | 86 } |
89 | 87 |
90 void SSLErrorUI::PopulateOverridableStrings( | 88 void SSLErrorUI::PopulateOverridableStrings( |
91 base::DictionaryValue* load_time_data) { | 89 base::DictionaryValue* load_time_data) { |
92 DCHECK(soft_override_enabled_); | 90 DCHECK(soft_override_enabled_); |
93 | 91 |
94 base::string16 url( | 92 base::string16 url(common_string_util::GetFormattedHostName(request_url_)); |
95 common_string_util::GetFormattedHostName(request_url_, languages_)); | |
96 ssl_errors::ErrorInfo error_info = ssl_errors::ErrorInfo::CreateError( | 93 ssl_errors::ErrorInfo error_info = ssl_errors::ErrorInfo::CreateError( |
97 ssl_errors::ErrorInfo::NetErrorToErrorType(cert_error_), | 94 ssl_errors::ErrorInfo::NetErrorToErrorType(cert_error_), |
98 ssl_info_.cert.get(), request_url_); | 95 ssl_info_.cert.get(), request_url_); |
99 | 96 |
100 load_time_data->SetBoolean("overridable", true); | 97 load_time_data->SetBoolean("overridable", true); |
101 load_time_data->SetString("explanationParagraph", error_info.details()); | 98 load_time_data->SetString("explanationParagraph", error_info.details()); |
102 load_time_data->SetString( | 99 load_time_data->SetString( |
103 "primaryButtonText", | 100 "primaryButtonText", |
104 l10n_util::GetStringUTF16(IDS_SSL_OVERRIDABLE_SAFETY_BUTTON)); | 101 l10n_util::GetStringUTF16(IDS_SSL_OVERRIDABLE_SAFETY_BUTTON)); |
105 load_time_data->SetString( | 102 load_time_data->SetString( |
106 "finalParagraph", | 103 "finalParagraph", |
107 l10n_util::GetStringFUTF16(IDS_SSL_OVERRIDABLE_PROCEED_PARAGRAPH, url)); | 104 l10n_util::GetStringFUTF16(IDS_SSL_OVERRIDABLE_PROCEED_PARAGRAPH, url)); |
108 } | 105 } |
109 | 106 |
110 void SSLErrorUI::PopulateNonOverridableStrings( | 107 void SSLErrorUI::PopulateNonOverridableStrings( |
111 base::DictionaryValue* load_time_data) { | 108 base::DictionaryValue* load_time_data) { |
112 DCHECK(!soft_override_enabled_); | 109 DCHECK(!soft_override_enabled_); |
113 | 110 |
114 base::string16 url( | 111 base::string16 url(common_string_util::GetFormattedHostName(request_url_)); |
115 common_string_util::GetFormattedHostName(request_url_, languages_)); | |
116 ssl_errors::ErrorInfo::ErrorType type = | 112 ssl_errors::ErrorInfo::ErrorType type = |
117 ssl_errors::ErrorInfo::NetErrorToErrorType(cert_error_); | 113 ssl_errors::ErrorInfo::NetErrorToErrorType(cert_error_); |
118 | 114 |
119 load_time_data->SetBoolean("overridable", false); | 115 load_time_data->SetBoolean("overridable", false); |
120 load_time_data->SetString( | 116 load_time_data->SetString( |
121 "explanationParagraph", | 117 "explanationParagraph", |
122 l10n_util::GetStringFUTF16(IDS_SSL_NONOVERRIDABLE_MORE, url)); | 118 l10n_util::GetStringFUTF16(IDS_SSL_NONOVERRIDABLE_MORE, url)); |
123 load_time_data->SetString("primaryButtonText", | 119 load_time_data->SetString("primaryButtonText", |
124 l10n_util::GetStringUTF16(IDS_SSL_RELOAD)); | 120 l10n_util::GetStringUTF16(IDS_SSL_RELOAD)); |
125 | 121 |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
193 NOTREACHED() << "Unsupported command: " << command; | 189 NOTREACHED() << "Unsupported command: " << command; |
194 case CMD_ERROR: | 190 case CMD_ERROR: |
195 case CMD_TEXT_FOUND: | 191 case CMD_TEXT_FOUND: |
196 case CMD_TEXT_NOT_FOUND: | 192 case CMD_TEXT_NOT_FOUND: |
197 // Commands are for testing. | 193 // Commands are for testing. |
198 break; | 194 break; |
199 } | 195 } |
200 } | 196 } |
201 | 197 |
202 } // security_interstitials | 198 } // security_interstitials |
OLD | NEW |