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

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

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

Powered by Google App Engine
This is Rietveld 408576698