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

Side by Side Diff: chrome/browser/safe_browsing/safe_browsing_blocking_page.cc

Issue 2852333003: Rename SafeBrowsingErrorUI to SafeBrowsingLoudErrorUI (Closed)
Patch Set: Move SafeBrowsingErrorUI to SafeBrowsingLoudErrorUI 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
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 // 4 //
5 // Implementation of the SafeBrowsingBlockingPage class. 5 // Implementation of the SafeBrowsingBlockingPage class.
6 6
7 #include "chrome/browser/safe_browsing/safe_browsing_blocking_page.h" 7 #include "chrome/browser/safe_browsing/safe_browsing_blocking_page.h"
8 8
9 #include "base/lazy_instance.h" 9 #include "base/lazy_instance.h"
10 #include "chrome/browser/history/history_service_factory.h" 10 #include "chrome/browser/history/history_service_factory.h"
11 #include "chrome/browser/interstitials/chrome_controller_client.h" 11 #include "chrome/browser/interstitials/chrome_controller_client.h"
12 #include "chrome/browser/interstitials/chrome_metrics_helper.h" 12 #include "chrome/browser/interstitials/chrome_metrics_helper.h"
13 #include "chrome/browser/profiles/profile.h" 13 #include "chrome/browser/profiles/profile.h"
14 #include "chrome/browser/renderer_preferences_util.h" 14 #include "chrome/browser/renderer_preferences_util.h"
15 #include "chrome/browser/safe_browsing/threat_details.h" 15 #include "chrome/browser/safe_browsing/threat_details.h"
16 #include "chrome/common/pref_names.h" 16 #include "chrome/common/pref_names.h"
17 #include "components/prefs/pref_service.h" 17 #include "components/prefs/pref_service.h"
18 #include "components/safe_browsing_db/safe_browsing_prefs.h" 18 #include "components/safe_browsing_db/safe_browsing_prefs.h"
19 #include "content/public/browser/browser_thread.h" 19 #include "content/public/browser/browser_thread.h"
20 #include "content/public/browser/interstitial_page.h" 20 #include "content/public/browser/interstitial_page.h"
21 #include "content/public/browser/navigation_entry.h" 21 #include "content/public/browser/navigation_entry.h"
22 #include "content/public/browser/web_contents.h" 22 #include "content/public/browser/web_contents.h"
23 23
24 using content::BrowserThread; 24 using content::BrowserThread;
25 using content::InterstitialPage; 25 using content::InterstitialPage;
26 using content::WebContents; 26 using content::WebContents;
27 using security_interstitials::SafeBrowsingErrorUI; 27 using security_interstitials::BaseSafeBrowsingErrorUI;
28 using security_interstitials::SafeBrowsingLoudErrorUI;
28 using security_interstitials::SecurityInterstitialControllerClient; 29 using security_interstitials::SecurityInterstitialControllerClient;
29 30
30 namespace safe_browsing { 31 namespace safe_browsing {
31 32
32 namespace { 33 namespace {
33 34
34 // Constants for the Experience Sampling instrumentation. 35 // Constants for the Experience Sampling instrumentation.
35 const char kEventNameMalware[] = "safebrowsing_interstitial_"; 36 const char kEventNameMalware[] = "safebrowsing_interstitial_";
36 const char kEventNameHarmful[] = "harmful_interstitial_"; 37 const char kEventNameHarmful[] = "harmful_interstitial_";
37 const char kEventNamePhishing[] = "phishing_interstitial_"; 38 const char kEventNamePhishing[] = "phishing_interstitial_";
(...skipping 22 matching lines...) Expand all
60 bool is_extended_reporting_opt_in_allowed = 61 bool is_extended_reporting_opt_in_allowed =
61 prefs->GetBoolean(prefs::kSafeBrowsingExtendedReportingOptInAllowed); 62 prefs->GetBoolean(prefs::kSafeBrowsingExtendedReportingOptInAllowed);
62 bool is_proceed_anyway_disabled = 63 bool is_proceed_anyway_disabled =
63 prefs->GetBoolean(prefs::kSafeBrowsingProceedAnywayDisabled); 64 prefs->GetBoolean(prefs::kSafeBrowsingProceedAnywayDisabled);
64 65
65 // Determine if any prefs need to be updated prior to showing the security 66 // Determine if any prefs need to be updated prior to showing the security
66 // interstitial. This must happen before querying IsScout to populate the 67 // interstitial. This must happen before querying IsScout to populate the
67 // Display Options below. 68 // Display Options below.
68 safe_browsing::UpdatePrefsBeforeSecurityInterstitial(prefs); 69 safe_browsing::UpdatePrefsBeforeSecurityInterstitial(prefs);
69 70
70 SafeBrowsingErrorUI::SBErrorDisplayOptions display_options( 71 BaseSafeBrowsingErrorUI::SBErrorDisplayOptions display_options(
71 BaseBlockingPage::IsMainPageLoadBlocked(unsafe_resources), 72 BaseBlockingPage::IsMainPageLoadBlocked(unsafe_resources),
72 is_extended_reporting_opt_in_allowed, 73 is_extended_reporting_opt_in_allowed,
73 web_contents->GetBrowserContext()->IsOffTheRecord(), 74 web_contents->GetBrowserContext()->IsOffTheRecord(),
74 IsExtendedReportingEnabled(*prefs), IsScout(*prefs), 75 IsExtendedReportingEnabled(*prefs), IsScout(*prefs),
75 is_proceed_anyway_disabled, 76 is_proceed_anyway_disabled,
76 BaseBlockingPage::IsMainPageLoadBlocked(unsafe_resources)); 77 BaseBlockingPage::IsMainPageLoadBlocked(unsafe_resources));
77 78
78 return new SafeBrowsingBlockingPage(ui_manager, web_contents, 79 return new SafeBrowsingBlockingPage(ui_manager, web_contents,
79 main_frame_url, unsafe_resources, 80 main_frame_url, unsafe_resources,
80 display_options); 81 display_options);
(...skipping 14 matching lines...) Expand all
95 // static 96 // static
96 content::InterstitialPageDelegate::TypeID 97 content::InterstitialPageDelegate::TypeID
97 SafeBrowsingBlockingPage::kTypeForTesting = 98 SafeBrowsingBlockingPage::kTypeForTesting =
98 &SafeBrowsingBlockingPage::kTypeForTesting; 99 &SafeBrowsingBlockingPage::kTypeForTesting;
99 100
100 SafeBrowsingBlockingPage::SafeBrowsingBlockingPage( 101 SafeBrowsingBlockingPage::SafeBrowsingBlockingPage(
101 BaseUIManager* ui_manager, 102 BaseUIManager* ui_manager,
102 WebContents* web_contents, 103 WebContents* web_contents,
103 const GURL& main_frame_url, 104 const GURL& main_frame_url,
104 const UnsafeResourceList& unsafe_resources, 105 const UnsafeResourceList& unsafe_resources,
105 const SafeBrowsingErrorUI::SBErrorDisplayOptions& display_options) 106 const BaseSafeBrowsingErrorUI::SBErrorDisplayOptions& display_options)
106 : BaseBlockingPage( 107 : BaseBlockingPage(
107 ui_manager, 108 ui_manager,
108 web_contents, 109 web_contents,
109 main_frame_url, 110 main_frame_url,
110 unsafe_resources, 111 unsafe_resources,
111 CreateControllerClient(web_contents, unsafe_resources, ui_manager), 112 CreateControllerClient(web_contents, unsafe_resources, ui_manager),
112 display_options) { 113 display_options) {
113 // Start computing threat details. They will be sent only 114 // Start computing threat details. They will be sent only
114 // if the user opts-in on the blocking page later. 115 // if the user opts-in on the blocking page later.
115 // If there's more than one malicious resources, it means the user 116 // If there's more than one malicious resources, it means the user
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 return SafeBrowsingBlockingPage::kTypeForTesting; 178 return SafeBrowsingBlockingPage::kTypeForTesting;
178 } 179 }
179 180
180 void SafeBrowsingBlockingPage::FinishThreatDetails(const base::TimeDelta& delay, 181 void SafeBrowsingBlockingPage::FinishThreatDetails(const base::TimeDelta& delay,
181 bool did_proceed, 182 bool did_proceed,
182 int num_visits) { 183 int num_visits) {
183 if (threat_details_.get() == NULL) 184 if (threat_details_.get() == NULL)
184 return; // Not all interstitials have threat details (eg., incognito mode). 185 return; // Not all interstitials have threat details (eg., incognito mode).
185 186
186 const bool enabled = 187 const bool enabled =
187 sb_error_ui()->is_extended_reporting_enabled() && 188 sb_error_ui()
188 sb_error_ui()->is_extended_reporting_opt_in_allowed(); 189 ->base_safe_browsing_error_ui.is_extended_reporting_enabled() &&
190 sb_error_ui()
191 ->base_safe_browsing_error_ui.is_extended_reporting_opt_in_allowed();
felt 2017/05/03 18:17:01 If sb_error_ui returned a BaseSafeBrowsingErrorUI,
189 if (!enabled) 192 if (!enabled)
190 return; 193 return;
191 194
192 controller()->metrics_helper()->RecordUserInteraction( 195 controller()->metrics_helper()->RecordUserInteraction(
193 security_interstitials::MetricsHelper::EXTENDED_REPORTING_IS_ENABLED); 196 security_interstitials::MetricsHelper::EXTENDED_REPORTING_IS_ENABLED);
194 // Finish the malware details collection, send it over. 197 // Finish the malware details collection, send it over.
195 BrowserThread::PostDelayedTask( 198 BrowserThread::PostDelayedTask(
196 BrowserThread::IO, FROM_HERE, 199 BrowserThread::IO, FROM_HERE,
197 base::BindOnce(&ThreatDetails::FinishCollection, threat_details_, 200 base::BindOnce(&ThreatDetails::FinishCollection, threat_details_,
198 did_proceed, num_visits), 201 did_proceed, num_visits),
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
234 unsafe_resource.GetNavigationEntryForResource(); 237 unsafe_resource.GetNavigationEntryForResource();
235 SafeBrowsingBlockingPage* blocking_page = 238 SafeBrowsingBlockingPage* blocking_page =
236 CreateBlockingPage(ui_manager, web_contents, 239 CreateBlockingPage(ui_manager, web_contents,
237 entry ? entry->GetURL() : GURL(), unsafe_resource); 240 entry ? entry->GetURL() : GURL(), unsafe_resource);
238 blocking_page->Show(); 241 blocking_page->Show();
239 } 242 }
240 } 243 }
241 244
242 // static 245 // static
243 std::string SafeBrowsingBlockingPage::GetSamplingEventName( 246 std::string SafeBrowsingBlockingPage::GetSamplingEventName(
244 SafeBrowsingErrorUI::SBInterstitialReason interstitial_reason) { 247 BaseSafeBrowsingErrorUI::SBInterstitialReason interstitial_reason) {
245 switch (interstitial_reason) { 248 switch (interstitial_reason) {
246 case SafeBrowsingErrorUI::SB_REASON_MALWARE: 249 case BaseSafeBrowsingErrorUI::SB_REASON_MALWARE:
247 return kEventNameMalware; 250 return kEventNameMalware;
248 case SafeBrowsingErrorUI::SB_REASON_HARMFUL: 251 case BaseSafeBrowsingErrorUI::SB_REASON_HARMFUL:
249 return kEventNameHarmful; 252 return kEventNameHarmful;
250 case SafeBrowsingErrorUI::SB_REASON_PHISHING: 253 case BaseSafeBrowsingErrorUI::SB_REASON_PHISHING:
251 return kEventNamePhishing; 254 return kEventNamePhishing;
252 default: 255 default:
253 return kEventNameOther; 256 return kEventNameOther;
254 } 257 }
255 } 258 }
256 259
257 // static 260 // static
258 std::unique_ptr<SecurityInterstitialControllerClient> 261 std::unique_ptr<SecurityInterstitialControllerClient>
259 SafeBrowsingBlockingPage::CreateControllerClient( 262 SafeBrowsingBlockingPage::CreateControllerClient(
260 WebContents* web_contents, 263 WebContents* web_contents,
261 const UnsafeResourceList& unsafe_resources, 264 const UnsafeResourceList& unsafe_resources,
262 const BaseUIManager* ui_manager) { 265 const BaseUIManager* ui_manager) {
263 Profile* profile = Profile::FromBrowserContext( 266 Profile* profile = Profile::FromBrowserContext(
264 web_contents->GetBrowserContext()); 267 web_contents->GetBrowserContext());
265 DCHECK(profile); 268 DCHECK(profile);
266 269
267 std::unique_ptr<ChromeMetricsHelper> metrics_helper = 270 std::unique_ptr<ChromeMetricsHelper> metrics_helper =
268 base::MakeUnique<ChromeMetricsHelper>( 271 base::MakeUnique<ChromeMetricsHelper>(
269 web_contents, unsafe_resources[0].url, 272 web_contents, unsafe_resources[0].url,
270 GetReportingInfo(unsafe_resources), 273 GetReportingInfo(unsafe_resources),
271 GetSamplingEventName(GetInterstitialReason(unsafe_resources))); 274 GetSamplingEventName(GetInterstitialReason(unsafe_resources)));
272 275
273 return base::MakeUnique<SecurityInterstitialControllerClient>( 276 return base::MakeUnique<SecurityInterstitialControllerClient>(
274 web_contents, std::move(metrics_helper), profile->GetPrefs(), 277 web_contents, std::move(metrics_helper), profile->GetPrefs(),
275 ui_manager->app_locale(), ui_manager->default_safe_page()); 278 ui_manager->app_locale(), ui_manager->default_safe_page());
276 } 279 }
277 280
278 } // namespace safe_browsing 281 } // namespace safe_browsing
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698