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 "components/security_interstitials/core/bad_clock_ui.h" | 5 #include "components/security_interstitials/core/bad_clock_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 "grit/components_strings.h" | 10 #include "grit/components_strings.h" |
| 11 #include "ui/base/l10n/l10n_util.h" | 11 #include "ui/base/l10n/l10n_util.h" |
| 12 | 12 |
| 13 namespace network_time { | |
| 14 class NetworkTimeTracker; | |
| 15 } | |
| 16 | |
| 13 namespace security_interstitials { | 17 namespace security_interstitials { |
| 14 | 18 |
| 15 BadClockUI::BadClockUI(const GURL& request_url, | 19 BadClockUI::BadClockUI( |
| 16 int cert_error, | 20 const GURL& request_url, int cert_error, const net::SSLInfo& ssl_info, |
|
estark
2016/03/10 20:10:08
This formatting looks a little strange to me. Do y
mab
2016/03/11 04:18:41
Neato. Done.
| |
| 17 const net::SSLInfo& ssl_info, | 21 const base::Time& time_triggered, |
| 18 const base::Time& time_triggered, | 22 const network_time::NetworkTimeTracker* network_time_tracker, |
| 19 const std::string& languages, | 23 const std::string& languages, ControllerClient* controller) |
| 20 ControllerClient* controller) | |
| 21 : request_url_(request_url), | 24 : request_url_(request_url), |
| 22 cert_error_(cert_error), | 25 cert_error_(cert_error), |
| 23 ssl_info_(ssl_info), | 26 ssl_info_(ssl_info), |
| 24 time_triggered_(time_triggered), | 27 time_triggered_(time_triggered), |
| 25 languages_(languages), | 28 languages_(languages), |
| 26 controller_(controller) { | 29 controller_(controller), |
| 30 network_time_tracker_(network_time_tracker) { | |
| 27 controller_->metrics_helper()->RecordUserInteraction( | 31 controller_->metrics_helper()->RecordUserInteraction( |
| 28 security_interstitials::MetricsHelper::TOTAL_VISITS); | 32 security_interstitials::MetricsHelper::TOTAL_VISITS); |
| 29 | 33 |
| 30 // TODO(felt): Separate the clock statistics from the main ssl statistics. | 34 // TODO(felt): Separate the clock statistics from the main ssl statistics. |
| 31 ssl_errors::RecordUMAStatistics(false, time_triggered_, request_url_, | 35 ssl_errors::RecordUMAStatistics(false, time_triggered_, network_time_tracker_, |
| 32 cert_error_, *ssl_info_.cert.get()); | 36 request_url_, cert_error_, |
| 37 *ssl_info_.cert.get()); | |
| 33 } | 38 } |
| 34 | 39 |
| 35 BadClockUI::~BadClockUI() { | 40 BadClockUI::~BadClockUI() { |
| 36 controller_->metrics_helper()->RecordShutdownMetrics(); | 41 controller_->metrics_helper()->RecordShutdownMetrics(); |
| 37 } | 42 } |
| 38 | 43 |
| 39 void BadClockUI::PopulateStringsForHTML(base::DictionaryValue* load_time_data) { | 44 void BadClockUI::PopulateStringsForHTML(base::DictionaryValue* load_time_data) { |
| 40 CHECK(load_time_data); | 45 CHECK(load_time_data); |
| 41 | 46 |
| 42 // Shared with other SSL errors. | 47 // Shared with other SSL errors. |
| 43 common_string_util::PopulateSSLLayoutStrings(cert_error_, load_time_data); | 48 common_string_util::PopulateSSLLayoutStrings(cert_error_, load_time_data); |
| 44 common_string_util::PopulateSSLDebuggingStrings(ssl_info_, time_triggered_, | 49 common_string_util::PopulateSSLDebuggingStrings(ssl_info_, time_triggered_, |
| 45 load_time_data); | 50 load_time_data); |
| 46 | 51 |
| 47 // Clock-specific strings. | 52 // Clock-specific strings. |
| 48 PopulateClockStrings(load_time_data); | 53 PopulateClockStrings(load_time_data); |
| 49 load_time_data->SetString("finalParagraph", std::string()); // Placeholder. | 54 load_time_data->SetString("finalParagraph", std::string()); // Placeholder. |
| 50 } | 55 } |
| 51 | 56 |
| 52 void BadClockUI::PopulateClockStrings(base::DictionaryValue* load_time_data) { | 57 void BadClockUI::PopulateClockStrings(base::DictionaryValue* load_time_data) { |
| 53 load_time_data->SetBoolean("bad_clock", true); | 58 load_time_data->SetBoolean("bad_clock", true); |
| 54 load_time_data->SetBoolean("overridable", false); | 59 load_time_data->SetBoolean("overridable", false); |
| 55 load_time_data->SetBoolean("hide_primary_button", | 60 load_time_data->SetBoolean("hide_primary_button", |
| 56 !controller_->CanLaunchDateAndTimeSettings()); | 61 !controller_->CanLaunchDateAndTimeSettings()); |
| 57 int heading_string = ssl_errors::IsUserClockInTheFuture(time_triggered_) | 62 int heading_string; |
| 58 ? IDS_CLOCK_ERROR_AHEAD_HEADING | 63 switch (ssl_errors::GetClockState(time_triggered_, network_time_tracker_)) { |
| 59 : IDS_CLOCK_ERROR_BEHIND_HEADING; | 64 case ssl_errors::NETWORK_FUTURE: |
| 65 case ssl_errors::BUILD_FUTURE: | |
| 66 heading_string = IDS_CLOCK_ERROR_AHEAD_HEADING; | |
| 67 break; | |
| 68 case ssl_errors::NETWORK_OK: | |
| 69 case ssl_errors::NETWORK_PAST: | |
| 70 case ssl_errors::BUILD_PAST: | |
| 71 case ssl_errors::UNKNOWN: | |
| 72 heading_string = IDS_CLOCK_ERROR_BEHIND_HEADING; | |
|
estark
2016/03/10 20:10:08
Eh? NETWORK_OK and UNKNOWN => CLOCK_ERROR_BEHIND?
mab
2016/03/11 04:18:41
It seems ever so slightly unsafe, but, done.
| |
| 73 break; | |
| 74 } | |
| 60 load_time_data->SetString("tabTitle", | 75 load_time_data->SetString("tabTitle", |
| 61 l10n_util::GetStringUTF16(IDS_CLOCK_ERROR_TITLE)); | 76 l10n_util::GetStringUTF16(IDS_CLOCK_ERROR_TITLE)); |
| 62 load_time_data->SetString("heading", | 77 load_time_data->SetString("heading", |
| 63 l10n_util::GetStringUTF16(heading_string)); | 78 l10n_util::GetStringUTF16(heading_string)); |
| 64 load_time_data->SetString( | 79 load_time_data->SetString( |
| 65 "primaryParagraph", | 80 "primaryParagraph", |
| 66 l10n_util::GetStringFUTF16( | 81 l10n_util::GetStringFUTF16( |
| 67 IDS_CLOCK_ERROR_PRIMARY_PARAGRAPH, | 82 IDS_CLOCK_ERROR_PRIMARY_PARAGRAPH, |
| 68 common_string_util::GetFormattedHostName(request_url_, languages_), | 83 common_string_util::GetFormattedHostName(request_url_, languages_), |
| 69 base::TimeFormatFriendlyDateAndTime(time_triggered_))); | 84 base::TimeFormatFriendlyDateAndTime(time_triggered_))); |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 110 NOTREACHED() << "Unsupported command: " << command; | 125 NOTREACHED() << "Unsupported command: " << command; |
| 111 case CMD_ERROR: | 126 case CMD_ERROR: |
| 112 case CMD_TEXT_FOUND: | 127 case CMD_TEXT_FOUND: |
| 113 case CMD_TEXT_NOT_FOUND: | 128 case CMD_TEXT_NOT_FOUND: |
| 114 // Commands are only for testing. | 129 // Commands are only for testing. |
| 115 NOTREACHED() << "Unexpected command: " << command; | 130 NOTREACHED() << "Unexpected command: " << command; |
| 116 } | 131 } |
| 117 } | 132 } |
| 118 | 133 |
| 119 } // security_interstitials | 134 } // security_interstitials |
| OLD | NEW |