Index: components/security_interstitials/core/safe_browsing_error_ui.h |
diff --git a/components/security_interstitials/core/safe_browsing_error_ui.h b/components/security_interstitials/core/safe_browsing_error_ui.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..86c974853e4c0aaf98987d1e7bff62afefd521e3 |
--- /dev/null |
+++ b/components/security_interstitials/core/safe_browsing_error_ui.h |
@@ -0,0 +1,93 @@ |
+// 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. |
+ |
+#ifndef COMPONENTS_SECURITY_INTERSTITIALS_CORE_SAFE_BROWSING_ERROR_UI_H_ |
+#define COMPONENTS_SECURITY_INTERSTITIALS_CORE_SAFE_BROWSING_ERROR_UI_H_ |
+ |
+#include "base/macros.h" |
+#include "base/time/time.h" |
+#include "base/values.h" |
+#include "components/security_interstitials/core/controller_client.h" |
+#include "url/gurl.h" |
+ |
+namespace security_interstitials { |
+ |
+// This class displays UI for Safe Browsing errors that block page loads. This |
+// class is purely about visual display; it does not do any error-handling logic |
+// to determine what type of error should be displayed when. |
+class SafeBrowsingErrorUI { |
+ public: |
+ enum SBInterstitialReason { |
+ SB_REASON_MALWARE, |
+ SB_REASON_HARMFUL, |
+ SB_REASON_PHISHING, |
+ }; |
+ |
+ struct SBErrorDisplayOptions { |
+ SBErrorDisplayOptions(bool is_main_frame_load_blocked, |
+ bool can_show_threat_details_option, |
+ bool is_extended_reporting_enabled, |
+ bool is_scout_reporting_enabled, |
+ bool is_proceed_anyway_disabled) |
+ : is_main_frame_load_blocked(is_main_frame_load_blocked), |
+ can_show_threat_details_option(can_show_threat_details_option), |
+ is_extended_reporting_enabled(is_extended_reporting_enabled), |
+ is_scout_reporting_enabled(is_scout_reporting_enabled), |
+ is_proceed_anyway_disabled(is_proceed_anyway_disabled) {} |
+ |
+ // Indicates if this SB interstitial is blocking main frame load. |
+ bool is_main_frame_load_blocked; |
+ |
+ // Indicates if we can show extended reporting checkbox, |
+ bool can_show_threat_details_option; |
+ |
+ // Indicates if user opted in for SB extended reporting. |
+ bool is_extended_reporting_enabled; |
+ |
+ // Indicates if user opted in for Scout extended reporting. |
+ bool is_scout_reporting_enabled; |
+ |
+ // Indicates if kSafeBrowsingProceedAnywayDisabled preference is set. |
+ bool is_proceed_anyway_disabled; |
+ }; |
+ |
+ SafeBrowsingErrorUI(const GURL& request_url, |
+ const GURL& main_frame_url, |
+ SBInterstitialReason reason, |
+ const SBErrorDisplayOptions& display_options, |
+ const std::string& app_locale, |
+ const base::Time& time_triggered, |
+ ControllerClient* controller); |
+ ~SafeBrowsingErrorUI(); |
+ |
+ void PopulateStringsForHTML(base::DictionaryValue* load_time_data); |
+ void HandleCommand(SecurityInterstitialCommands command); |
+ bool is_main_frame_load_blocked() { |
+ return display_options_.is_main_frame_load_blocked; |
+ } |
+ |
+ private: |
+ // Fills the passed dictionary with the values to be passed to the template |
+ // when creating the HTML. |
+ void PopulateExtendedReportingOption(base::DictionaryValue* load_time_data); |
+ void PopulateMalwareLoadTimeData(base::DictionaryValue* load_time_data); |
+ void PopulateHarmfulLoadTimeData(base::DictionaryValue* load_time_data); |
+ void PopulatePhishingLoadTimeData(base::DictionaryValue* load_time_data); |
+ |
+ const GURL request_url_; |
+ const GURL main_frame_url_; |
+ const SBInterstitialReason interstitial_reason_; |
+ SBErrorDisplayOptions display_options_; |
Nathan Parker
2016/12/15 23:30:42
can this be const as well?
Jialiu Lin
2016/12/16 00:51:43
check/uncheck extended reporting box will change d
|
+ const std::string app_locale_; |
+ const base::Time time_triggered_; |
+ |
+ ControllerClient* controller_; |
+ bool user_made_decision_; // Whether the user made a choice in the UI. |
+ |
+ DISALLOW_COPY_AND_ASSIGN(SafeBrowsingErrorUI); |
+}; |
+ |
+} // security_interstitials |
+ |
+#endif // COMPONENTS_SECURITY_INTERSTITIALS_CORE_SAFE_BROWSING_ERROR_UI_H_ |