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

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

Issue 2854263003: Add quiet safe browsing interstitial for WebView (Closed)
Patch Set: Common CSS changes Created 3 years, 8 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 side-by-side diff with in-line comments
Download patch
Index: components/security_interstitials/core/safe_browsing_quiet_error_ui.cc
diff --git a/components/security_interstitials/core/safe_browsing_quiet_error_ui.cc b/components/security_interstitials/core/safe_browsing_quiet_error_ui.cc
new file mode 100644
index 0000000000000000000000000000000000000000..36185e263ec53793bd913545afda35e26a5e7fb2
--- /dev/null
+++ b/components/security_interstitials/core/safe_browsing_quiet_error_ui.cc
@@ -0,0 +1,91 @@
+// Copyright 2016 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/safe_browsing_quiet_error_ui.h"
+
+#include "base/i18n/time_formatting.h"
+#include "base/metrics/histogram_macros.h"
+#include "base/strings/stringprintf.h"
+#include "base/strings/utf_string_conversions.h"
+#include "components/google/core/browser/google_util.h"
+#include "components/security_interstitials/core/common_string_util.h"
+#include "components/security_interstitials/core/metrics_helper.h"
+#include "components/strings/grit/components_strings.h"
+#include "net/base/escape.h"
+#include "ui/base/l10n/l10n_util.h"
+
+namespace security_interstitials {
+
+SafeBrowsingQuietErrorUI::SafeBrowsingQuietErrorUI(
+ const GURL& request_url,
+ const GURL& main_frame_url,
+ SafeBrowsingErrorUI::SBInterstitialReason reason,
+ const SafeBrowsingErrorUI::SBErrorDisplayOptions& display_options,
+ ControllerClient* controller)
+ : request_url_(request_url),
+ main_frame_url_(main_frame_url),
+ interstitial_reason_(reason),
+ display_options_(display_options),
+ controller_(controller) {
+ controller_->metrics_helper()->RecordUserDecision(MetricsHelper::SHOW);
+ controller_->metrics_helper()->RecordUserInteraction(
+ MetricsHelper::TOTAL_VISITS);
+ if (display_options_.is_proceed_anyway_disabled)
+ controller_->metrics_helper()->RecordUserDecision(
+ security_interstitials::MetricsHelper::PROCEEDING_DISABLED);
+}
+
+SafeBrowsingQuietErrorUI::~SafeBrowsingQuietErrorUI() {
+ controller_->metrics_helper()->RecordShutdownMetrics();
+}
+
+void SafeBrowsingQuietErrorUI::PopulateStringsForHTML(
+ base::DictionaryValue* load_time_data) {
+ DCHECK(load_time_data);
+
+ load_time_data->SetString("type", "SAFEBROWSING");
+ load_time_data->SetString(
+ "tabTitle", l10n_util::GetStringUTF16(IDS_SAFEBROWSING_V3_TITLE));
+ // load_time_data->SetString(
+ // "openDetails",
+ // l10n_util::GetStringUTF16(IDS_SAFEBROWSING_V3_OPEN_DETAILS_BUTTON));
+ // load_time_data->SetString(
+ // "closeDetails",
+ // l10n_util::GetStringUTF16(IDS_SAFEBROWSING_V3_CLOSE_DETAILS_BUTTON));
+ load_time_data->SetBoolean("overridable",
+ !display_options_.is_proceed_anyway_disabled);
+
+ switch (interstitial_reason_) {
+ case SafeBrowsingErrorUI::SB_REASON_MALWARE:
+ PopulateMalwareLoadTimeData(load_time_data);
+ break;
+ case SafeBrowsingErrorUI::SB_REASON_HARMFUL:
+ break;
+ case SafeBrowsingErrorUI::SB_REASON_PHISHING:
+ PopulatePhishingLoadTimeData(load_time_data);
+ break;
+ }
+}
+
+void SafeBrowsingQuietErrorUI::PopulateMalwareLoadTimeData(
+ base::DictionaryValue* load_time_data) {
+ load_time_data->SetBoolean("phishing", false);
+ load_time_data->SetString(
+ "heading", l10n_util::GetStringUTF16(IDS_MALWARE_WEBVIEW_HEADING));
+ load_time_data->SetString(
+ "explanationParagraph",
+ l10n_util::GetStringUTF16(IDS_MALWARE_WEBVIEW_EXPLANATION_PARAGRAPH));
+}
+
+void SafeBrowsingQuietErrorUI::PopulatePhishingLoadTimeData(
+ base::DictionaryValue* load_time_data) {
+ load_time_data->SetBoolean("phishing", true);
+ load_time_data->SetString(
+ "heading", l10n_util::GetStringUTF16(IDS_PHISHING_WEBVIEW_HEADING));
+ load_time_data->SetString(
+ "explanationParagraph",
+ l10n_util::GetStringUTF16(IDS_PHISHING_WEBVIEW_EXPLANATION_PARAGRAPH));
+}
+
+} // security_interstitials

Powered by Google App Engine
This is Rietveld 408576698