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

Side by Side Diff: components/security_interstitials/core/safe_browsing_error_ui.h

Issue 2852333003: Rename SafeBrowsingErrorUI to SafeBrowsingLoudErrorUI (Closed)
Patch Set: Comments Created 3 years, 7 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2016 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 #ifndef COMPONENTS_SECURITY_INTERSTITIALS_CORE_SAFE_BROWSING_ERROR_UI_H_
6 #define COMPONENTS_SECURITY_INTERSTITIALS_CORE_SAFE_BROWSING_ERROR_UI_H_
7
8 #include "base/macros.h"
9 #include "base/time/time.h"
10 #include "base/values.h"
11 #include "components/security_interstitials/core/controller_client.h"
12 #include "url/gurl.h"
13
14 namespace security_interstitials {
15
16 // This class displays UI for Safe Browsing errors that block page loads. This
17 // class is purely about visual display; it does not do any error-handling logic
18 // to determine what type of error should be displayed when.
19 class SafeBrowsingErrorUI {
20 public:
21 enum SBInterstitialReason {
22 SB_REASON_MALWARE,
23 SB_REASON_HARMFUL,
24 SB_REASON_PHISHING,
25 };
26
27 struct SBErrorDisplayOptions {
28 SBErrorDisplayOptions(bool is_main_frame_load_blocked,
29 bool is_extended_reporting_opt_in_allowed,
30 bool is_off_the_record,
31 bool is_extended_reporting_enabled,
32 bool is_scout_reporting_enabled,
33 bool is_proceed_anyway_disabled,
34 bool is_resource_cancellable)
35 : is_main_frame_load_blocked(is_main_frame_load_blocked),
36 is_extended_reporting_opt_in_allowed(
37 is_extended_reporting_opt_in_allowed),
38 is_off_the_record(is_off_the_record),
39 is_extended_reporting_enabled(is_extended_reporting_enabled),
40 is_scout_reporting_enabled(is_scout_reporting_enabled),
41 is_proceed_anyway_disabled(is_proceed_anyway_disabled),
42 is_resource_cancellable(is_resource_cancellable) {}
43
44 // Indicates if this SB interstitial is blocking main frame load.
45 bool is_main_frame_load_blocked;
46
47 // Indicates if user is allowed to opt-in extended reporting preference.
48 bool is_extended_reporting_opt_in_allowed;
49
50 // Indicates if user is in incognito mode.
51 bool is_off_the_record;
52
53 // Indicates if user opted in for SB extended reporting.
54 bool is_extended_reporting_enabled;
55
56 // Indicates if user opted in for Scout extended reporting.
57 bool is_scout_reporting_enabled;
58
59 // Indicates if kSafeBrowsingProceedAnywayDisabled preference is set.
60 bool is_proceed_anyway_disabled;
61
62 // Indicates if "back to safety" should cancel the pending navigation or
63 // navigate back after it's committed.
64 bool is_resource_cancellable;
65 };
66
67 SafeBrowsingErrorUI(const GURL& request_url,
68 const GURL& main_frame_url,
69 SBInterstitialReason reason,
70 const SBErrorDisplayOptions& display_options,
71 const std::string& app_locale,
72 const base::Time& time_triggered,
73 ControllerClient* controller);
74 ~SafeBrowsingErrorUI();
75
76 void PopulateStringsForHTML(base::DictionaryValue* load_time_data);
77 void HandleCommand(SecurityInterstitialCommands command);
78
79 // Checks if we should even show the extended reporting option. We don't show
80 // it in incognito mode or if kSafeBrowsingExtendedReportingOptInAllowed
81 // preference is disabled.
82 bool CanShowExtendedReportingOption();
83
84 bool is_main_frame_load_blocked() const {
85 return display_options_.is_main_frame_load_blocked;
86 }
87
88 bool is_extended_reporting_opt_in_allowed() const {
89 return display_options_.is_extended_reporting_opt_in_allowed;
90 }
91
92 bool is_off_the_record() const {
93 return display_options_.is_off_the_record;
94 }
95
96 bool is_extended_reporting_enabled() const {
97 return display_options_.is_extended_reporting_enabled;
98 }
99
100 bool is_proceed_anyway_disabled() const {
101 return display_options_.is_proceed_anyway_disabled;
102 }
103
104 const std::string app_locale() const {
105 return app_locale_;
106 }
107
108 private:
109 // Fills the passed dictionary with the values to be passed to the template
110 // when creating the HTML.
111 void PopulateExtendedReportingOption(base::DictionaryValue* load_time_data);
112 void PopulateMalwareLoadTimeData(base::DictionaryValue* load_time_data);
113 void PopulateHarmfulLoadTimeData(base::DictionaryValue* load_time_data);
114 void PopulatePhishingLoadTimeData(base::DictionaryValue* load_time_data);
115
116 const GURL request_url_;
117 const GURL main_frame_url_;
118 const SBInterstitialReason interstitial_reason_;
119 SBErrorDisplayOptions display_options_;
120 const std::string app_locale_;
121 const base::Time time_triggered_;
122
123 ControllerClient* controller_;
124
125 DISALLOW_COPY_AND_ASSIGN(SafeBrowsingErrorUI);
126 };
127
128 } // security_interstitials
129
130 #endif // COMPONENTS_SECURITY_INTERSTITIALS_CORE_SAFE_BROWSING_ERROR_UI_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698