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

Unified Diff: components/security_interstitials/core/safe_browsing_error_ui.h

Issue 2575623002: Componentizing SafeBrowsingBlockingPage Part 1 (Closed)
Patch Set: nits Created 4 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/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..fb489236a4c15c96a0c3d7c6a0b0b1263fae8575
--- /dev/null
+++ b/components/security_interstitials/core/safe_browsing_error_ui.h
@@ -0,0 +1,88 @@
+// 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 {
+
+class ControllerClient;
estark 2016/12/15 21:16:34 not needed, you have the #include above
Jialiu Lin 2016/12/15 22:12:53 Done.
+
+// 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,
+ };
+
+ enum SBErrorOptionsMask {
estark 2016/12/15 21:16:34 optional nit: this might be more readable as a str
Jialiu Lin 2016/12/15 22:12:53 Agree. Changed into struct of booleans instead.
+ // Indicates if this SB interstitial is blocking main frame load.
+ MAIN_FRAME_LOAD_BLOCKED = 1 << 0,
+ // Indicates if we can show extended reporting checkbox,
+ // i.e. !incognito && http && kSafeBrowsingExtendedReportingOptInAllowed.
estark 2016/12/15 21:16:34 nit: Line 33 seems likely to get out of date (i.e.
estark 2016/12/15 21:16:34 Does this mean we only show the extended reporting
Jialiu Lin 2016/12/15 22:12:53 Good question. My understanding is that there is n
Jialiu Lin 2016/12/15 22:12:53 Make sense. Done.
+ CAN_SHOW_THREAT_DETAILS_OPTION = 1 << 1,
+ // Indicates if user opted in for SB extended reporting.
+ EXTENDED_REPORTING_ENABLED = 1 << 2,
+ // Indicates if user opted in for Scout extended reporting.
+ SCOUT_REPORTING_ENABLED = 1 << 3,
+ // Indicates if kSafeBrowsingProceedAnywayDisabled preference is set.
+ PROCEED_ANYWAY_DISABLED = 1 << 4,
+ };
+
+ SafeBrowsingErrorUI(const GURL& request_url,
+ const GURL& main_frame_url,
+ SBInterstitialReason reason,
+ int display_options, // Bitmask of SBErrorOptionsMask.
+ 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 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_;
+
+ // True if the interstitial is blocking the main page because it is on one
+ // of our lists. False if a subresource is being blocked, or in the case of
+ // client-side detection where the interstitial is shown after page load
+ // finishes.
+ const bool is_main_frame_load_blocked_;
+ const bool can_show_threat_details_option_;
+ bool is_extended_reporting_;
+ bool is_scout_;
+ bool is_proceed_anyway_disabled_;
+ 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_

Powered by Google App Engine
This is Rietveld 408576698