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

Unified Diff: components/security_interstitials/core/bad_clock_ui.cc

Issue 1481213003: Componentize the bad clock blocking page (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Change for pkasting Created 5 years 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 side-by-side diff with in-line comments
Download patch
Index: components/security_interstitials/core/bad_clock_ui.cc
diff --git a/components/security_interstitials/core/bad_clock_ui.cc b/components/security_interstitials/core/bad_clock_ui.cc
new file mode 100644
index 0000000000000000000000000000000000000000..7b39de7574d2a77bd92df3ed93bd7c7f978d3584
--- /dev/null
+++ b/components/security_interstitials/core/bad_clock_ui.cc
@@ -0,0 +1,119 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "components/security_interstitials/core/bad_clock_ui.h"
+
+#include "base/i18n/time_formatting.h"
+#include "components/security_interstitials/core/common_string_util.h"
+#include "components/security_interstitials/core/metrics_helper.h"
+#include "grit/components_strings.h"
+#include "ui/base/l10n/l10n_util.h"
+
+namespace security_interstitials {
+
+BadClockUI::BadClockUI(const GURL& request_url,
+ int cert_error,
+ const net::SSLInfo& ssl_info,
+ const base::Time& time_triggered,
+ const std::string& languages,
+ ControllerClient* controller)
+ : request_url_(request_url),
+ cert_error_(cert_error),
+ ssl_info_(ssl_info),
+ time_triggered_(time_triggered),
+ languages_(languages),
+ controller_(controller) {
+ controller_->metrics_helper()->RecordUserInteraction(
+ security_interstitials::MetricsHelper::TOTAL_VISITS);
+
+ // TODO(felt): Separate the clock statistics from the main ssl statistics.
+ ssl_errors::RecordUMAStatistics(false, time_triggered_, request_url_,
+ cert_error_, *ssl_info_.cert.get());
+}
+
+BadClockUI::~BadClockUI() {
+ controller_->metrics_helper()->RecordShutdownMetrics();
+}
+
+void BadClockUI::PopulateStringsForHTML(base::DictionaryValue* load_time_data) {
+ CHECK(load_time_data);
+
+ // Shared with other SSL errors.
+ common_string_util::PopulateSSLLayoutStrings(cert_error_, load_time_data);
+ common_string_util::PopulateSSLDebuggingStrings(ssl_info_, time_triggered_,
+ load_time_data);
+
+ // Clock-specific strings.
+ PopulateClockStrings(load_time_data);
+ load_time_data->SetString("finalParagraph", std::string()); // Placeholder.
+}
+
+void BadClockUI::PopulateClockStrings(base::DictionaryValue* load_time_data) {
+ load_time_data->SetBoolean("bad_clock", true);
+ load_time_data->SetBoolean("overridable", false);
+ load_time_data->SetBoolean("hide_primary_button",
+ !controller_->CanLaunchDateAndTimeSettings());
+ int heading_string = ssl_errors::IsUserClockInTheFuture(time_triggered_)
+ ? IDS_CLOCK_ERROR_AHEAD_HEADING
+ : IDS_CLOCK_ERROR_BEHIND_HEADING;
+ load_time_data->SetString("tabTitle",
+ l10n_util::GetStringUTF16(IDS_CLOCK_ERROR_TITLE));
+ load_time_data->SetString("heading",
+ l10n_util::GetStringUTF16(heading_string));
+ load_time_data->SetString(
+ "primaryParagraph",
+ l10n_util::GetStringFUTF16(
+ IDS_CLOCK_ERROR_PRIMARY_PARAGRAPH,
+ common_string_util::GetFormattedHostName(request_url_, languages_),
+ base::TimeFormatFriendlyDateAndTime(time_triggered_)));
+ load_time_data->SetString(
+ "primaryButtonText",
+ l10n_util::GetStringUTF16(IDS_CLOCK_ERROR_UPDATE_DATE_AND_TIME));
+ load_time_data->SetString(
+ "explanationParagraph",
+ l10n_util::GetStringUTF16(IDS_CLOCK_ERROR_EXPLANATION));
+}
+
+void BadClockUI::HandleCommand(SecurityInterstitialCommands command) {
+ switch (command) {
+ case CMD_DONT_PROCEED:
+ controller_->GoBack();
+ break;
+ case CMD_DO_REPORT:
+ controller_->SetReportingPreference(true);
+ break;
+ case CMD_DONT_REPORT:
+ controller_->SetReportingPreference(false);
+ break;
+ case CMD_SHOW_MORE_SECTION:
+ controller_->metrics_helper()->RecordUserInteraction(
+ security_interstitials::MetricsHelper::SHOW_ADVANCED);
+ break;
+ case CMD_OPEN_DATE_SETTINGS:
+ if (!controller_->CanLaunchDateAndTimeSettings())
+ NOTREACHED() << "This platform does not support date settings";
+ controller_->metrics_helper()->RecordUserInteraction(
+ security_interstitials::MetricsHelper::OPEN_TIME_SETTINGS);
+ controller_->LaunchDateAndTimeSettings();
+ break;
+ case CMD_OPEN_REPORTING_PRIVACY:
+ controller_->OpenExtendedReportingPrivacyPolicy();
+ break;
+ case CMD_PROCEED:
+ case CMD_OPEN_HELP_CENTER:
+ case CMD_RELOAD:
+ case CMD_OPEN_DIAGNOSTIC:
+ case CMD_OPEN_LOGIN:
+ case CMD_REPORT_PHISHING_ERROR:
+ // Not supported by the bad clock error page.
+ NOTREACHED() << "Unsupported command: " << command;
+ case CMD_ERROR:
+ case CMD_TEXT_FOUND:
+ case CMD_TEXT_NOT_FOUND:
+ // Commands are only for testing.
+ NOTREACHED() << "Unexpected command: " << command;
+ }
+}
+
+} // security_interstitials
« no previous file with comments | « components/security_interstitials/core/bad_clock_ui.h ('k') | components/security_interstitials/core/common_string_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698