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

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

Issue 2852333003: Rename SafeBrowsingErrorUI to SafeBrowsingLoudErrorUI (Closed)
Patch Set: Add safe_browsing_blocking_page.cc 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 "components/security_interstitials/core/safe_browsing_loud_error_ui.h"
felt 2017/05/05 00:28:29 Is this the right include? Do you need an include
edwardjung 2017/05/08 20:43:00 Removed.
19 #include "content/public/browser/browser_thread.h" 20 #include "content/public/browser/browser_thread.h"
20 #include "content/public/browser/interstitial_page.h" 21 #include "content/public/browser/interstitial_page.h"
21 #include "content/public/browser/navigation_entry.h" 22 #include "content/public/browser/navigation_entry.h"
22 #include "content/public/browser/web_contents.h" 23 #include "content/public/browser/web_contents.h"
23 24
24 using content::BrowserThread; 25 using content::BrowserThread;
25 using content::InterstitialPage; 26 using content::InterstitialPage;
26 using content::WebContents; 27 using content::WebContents;
27 using security_interstitials::SafeBrowsingErrorUI; 28 using security_interstitials::BaseSafeBrowsingErrorUI;
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 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 SafeBrowsingBlockingPage::GetTypeForTesting() const { 177 SafeBrowsingBlockingPage::GetTypeForTesting() const {
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 = sb_error_ui()->is_extended_reporting_enabled() &&
187 sb_error_ui()->is_extended_reporting_enabled() && 188 sb_error_ui()->is_extended_reporting_opt_in_allowed();
188 sb_error_ui()->is_extended_reporting_opt_in_allowed();
189 if (!enabled) 189 if (!enabled)
190 return; 190 return;
191 191
192 controller()->metrics_helper()->RecordUserInteraction( 192 controller()->metrics_helper()->RecordUserInteraction(
193 security_interstitials::MetricsHelper::EXTENDED_REPORTING_IS_ENABLED); 193 security_interstitials::MetricsHelper::EXTENDED_REPORTING_IS_ENABLED);
194 // Finish the malware details collection, send it over. 194 // Finish the malware details collection, send it over.
195 BrowserThread::PostDelayedTask( 195 BrowserThread::PostDelayedTask(
196 BrowserThread::IO, FROM_HERE, 196 BrowserThread::IO, FROM_HERE,
197 base::BindOnce(&ThreatDetails::FinishCollection, threat_details_, 197 base::BindOnce(&ThreatDetails::FinishCollection, threat_details_,
198 did_proceed, num_visits), 198 did_proceed, num_visits),
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
234 unsafe_resource.GetNavigationEntryForResource(); 234 unsafe_resource.GetNavigationEntryForResource();
235 SafeBrowsingBlockingPage* blocking_page = 235 SafeBrowsingBlockingPage* blocking_page =
236 CreateBlockingPage(ui_manager, web_contents, 236 CreateBlockingPage(ui_manager, web_contents,
237 entry ? entry->GetURL() : GURL(), unsafe_resource); 237 entry ? entry->GetURL() : GURL(), unsafe_resource);
238 blocking_page->Show(); 238 blocking_page->Show();
239 } 239 }
240 } 240 }
241 241
242 // static 242 // static
243 std::string SafeBrowsingBlockingPage::GetSamplingEventName( 243 std::string SafeBrowsingBlockingPage::GetSamplingEventName(
244 SafeBrowsingErrorUI::SBInterstitialReason interstitial_reason) { 244 BaseSafeBrowsingErrorUI::SBInterstitialReason interstitial_reason) {
245 switch (interstitial_reason) { 245 switch (interstitial_reason) {
246 case SafeBrowsingErrorUI::SB_REASON_MALWARE: 246 case BaseSafeBrowsingErrorUI::SB_REASON_MALWARE:
247 return kEventNameMalware; 247 return kEventNameMalware;
248 case SafeBrowsingErrorUI::SB_REASON_HARMFUL: 248 case BaseSafeBrowsingErrorUI::SB_REASON_HARMFUL:
249 return kEventNameHarmful; 249 return kEventNameHarmful;
250 case SafeBrowsingErrorUI::SB_REASON_PHISHING: 250 case BaseSafeBrowsingErrorUI::SB_REASON_PHISHING:
251 return kEventNamePhishing; 251 return kEventNamePhishing;
252 default: 252 default:
253 return kEventNameOther; 253 return kEventNameOther;
254 } 254 }
255 } 255 }
256 256
257 // static 257 // static
258 std::unique_ptr<SecurityInterstitialControllerClient> 258 std::unique_ptr<SecurityInterstitialControllerClient>
259 SafeBrowsingBlockingPage::CreateControllerClient( 259 SafeBrowsingBlockingPage::CreateControllerClient(
260 WebContents* web_contents, 260 WebContents* web_contents,
261 const UnsafeResourceList& unsafe_resources, 261 const UnsafeResourceList& unsafe_resources,
262 const BaseUIManager* ui_manager) { 262 const BaseUIManager* ui_manager) {
263 Profile* profile = Profile::FromBrowserContext( 263 Profile* profile = Profile::FromBrowserContext(
264 web_contents->GetBrowserContext()); 264 web_contents->GetBrowserContext());
265 DCHECK(profile); 265 DCHECK(profile);
266 266
267 std::unique_ptr<ChromeMetricsHelper> metrics_helper = 267 std::unique_ptr<ChromeMetricsHelper> metrics_helper =
268 base::MakeUnique<ChromeMetricsHelper>( 268 base::MakeUnique<ChromeMetricsHelper>(
269 web_contents, unsafe_resources[0].url, 269 web_contents, unsafe_resources[0].url,
270 GetReportingInfo(unsafe_resources), 270 GetReportingInfo(unsafe_resources),
271 GetSamplingEventName(GetInterstitialReason(unsafe_resources))); 271 GetSamplingEventName(GetInterstitialReason(unsafe_resources)));
272 272
273 return base::MakeUnique<SecurityInterstitialControllerClient>( 273 return base::MakeUnique<SecurityInterstitialControllerClient>(
274 web_contents, std::move(metrics_helper), profile->GetPrefs(), 274 web_contents, std::move(metrics_helper), profile->GetPrefs(),
275 ui_manager->app_locale(), ui_manager->default_safe_page()); 275 ui_manager->app_locale(), ui_manager->default_safe_page());
276 } 276 }
277 277
278 } // namespace safe_browsing 278 } // namespace safe_browsing
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698