OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "components/security_interstitials/core/bad_clock_ui.h" |
| 6 |
| 7 #include "base/i18n/time_formatting.h" |
| 8 #include "components/security_interstitials/core/common_string_util.h" |
| 9 #include "components/security_interstitials/core/metrics_helper.h" |
| 10 #include "grit/components_strings.h" |
| 11 #include "ui/base/l10n/l10n_util.h" |
| 12 |
| 13 namespace security_interstitials { |
| 14 |
| 15 BadClockUI::BadClockUI(const GURL& request_url, |
| 16 int cert_error, |
| 17 const net::SSLInfo& ssl_info, |
| 18 const base::Time& time_triggered, |
| 19 const std::string& languages, |
| 20 ControllerClient* controller) |
| 21 : request_url_(request_url), |
| 22 cert_error_(cert_error), |
| 23 ssl_info_(ssl_info), |
| 24 time_triggered_(time_triggered), |
| 25 languages_(languages), |
| 26 controller_(controller) { |
| 27 controller_->metrics_helper()->RecordUserInteraction( |
| 28 security_interstitials::MetricsHelper::TOTAL_VISITS); |
| 29 |
| 30 // TODO(felt): Separate the clock statistics from the main ssl statistics. |
| 31 ssl_errors::RecordUMAStatistics(false, time_triggered_, request_url_, |
| 32 cert_error_, *ssl_info_.cert.get()); |
| 33 } |
| 34 |
| 35 BadClockUI::~BadClockUI() { |
| 36 controller_->metrics_helper()->RecordShutdownMetrics(); |
| 37 } |
| 38 |
| 39 void BadClockUI::PopulateStringsForHTML(base::DictionaryValue* load_time_data) { |
| 40 CHECK(load_time_data); |
| 41 |
| 42 // Shared with other SSL errors. |
| 43 common_string_util::PopulateSSLLayoutStrings(cert_error_, load_time_data); |
| 44 common_string_util::PopulateSSLDebuggingStrings(ssl_info_, time_triggered_, |
| 45 load_time_data); |
| 46 |
| 47 // Clock-specific strings. |
| 48 PopulateClockStrings(load_time_data); |
| 49 load_time_data->SetString("finalParagraph", std::string()); // Placeholder. |
| 50 } |
| 51 |
| 52 void BadClockUI::PopulateClockStrings(base::DictionaryValue* load_time_data) { |
| 53 load_time_data->SetBoolean("bad_clock", true); |
| 54 load_time_data->SetBoolean("overridable", false); |
| 55 load_time_data->SetBoolean("hide_primary_button", |
| 56 !controller_->CanLaunchDateAndTimeSettings()); |
| 57 int heading_string = ssl_errors::IsUserClockInTheFuture(time_triggered_) |
| 58 ? IDS_CLOCK_ERROR_AHEAD_HEADING |
| 59 : IDS_CLOCK_ERROR_BEHIND_HEADING; |
| 60 load_time_data->SetString("tabTitle", |
| 61 l10n_util::GetStringUTF16(IDS_CLOCK_ERROR_TITLE)); |
| 62 load_time_data->SetString("heading", |
| 63 l10n_util::GetStringUTF16(heading_string)); |
| 64 load_time_data->SetString( |
| 65 "primaryParagraph", |
| 66 l10n_util::GetStringFUTF16( |
| 67 IDS_CLOCK_ERROR_PRIMARY_PARAGRAPH, |
| 68 common_string_util::GetFormattedHostName(request_url_, languages_), |
| 69 base::TimeFormatFriendlyDateAndTime(time_triggered_))); |
| 70 load_time_data->SetString( |
| 71 "primaryButtonText", |
| 72 l10n_util::GetStringUTF16(IDS_CLOCK_ERROR_UPDATE_DATE_AND_TIME)); |
| 73 load_time_data->SetString( |
| 74 "explanationParagraph", |
| 75 l10n_util::GetStringUTF16(IDS_CLOCK_ERROR_EXPLANATION)); |
| 76 } |
| 77 |
| 78 void BadClockUI::HandleCommand(SecurityInterstitialCommands command) { |
| 79 switch (command) { |
| 80 case CMD_DONT_PROCEED: |
| 81 controller_->GoBack(); |
| 82 break; |
| 83 case CMD_DO_REPORT: |
| 84 controller_->SetReportingPreference(true); |
| 85 break; |
| 86 case CMD_DONT_REPORT: |
| 87 controller_->SetReportingPreference(false); |
| 88 break; |
| 89 case CMD_SHOW_MORE_SECTION: |
| 90 controller_->metrics_helper()->RecordUserInteraction( |
| 91 security_interstitials::MetricsHelper::SHOW_ADVANCED); |
| 92 break; |
| 93 case CMD_OPEN_DATE_SETTINGS: |
| 94 if (!controller_->CanLaunchDateAndTimeSettings()) |
| 95 NOTREACHED() << "This platform does not support date settings"; |
| 96 controller_->metrics_helper()->RecordUserInteraction( |
| 97 security_interstitials::MetricsHelper::OPEN_TIME_SETTINGS); |
| 98 controller_->LaunchDateAndTimeSettings(); |
| 99 break; |
| 100 case CMD_OPEN_REPORTING_PRIVACY: |
| 101 controller_->OpenExtendedReportingPrivacyPolicy(); |
| 102 break; |
| 103 case CMD_PROCEED: |
| 104 case CMD_OPEN_HELP_CENTER: |
| 105 case CMD_RELOAD: |
| 106 case CMD_OPEN_DIAGNOSTIC: |
| 107 case CMD_OPEN_LOGIN: |
| 108 case CMD_REPORT_PHISHING_ERROR: |
| 109 // Not supported by the bad clock error page. |
| 110 NOTREACHED() << "Unsupported command: " << command; |
| 111 case CMD_ERROR: |
| 112 case CMD_TEXT_FOUND: |
| 113 case CMD_TEXT_NOT_FOUND: |
| 114 // Commands are only for testing. |
| 115 NOTREACHED() << "Unexpected command: " << command; |
| 116 } |
| 117 } |
| 118 |
| 119 } // security_interstitials |
OLD | NEW |