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

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

Issue 512083002: Deprecate old Safe Browsing reporting opt-ins (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Removed unneeded variable Created 6 years, 3 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 <string> 9 #include <string>
10 10
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 kMalwareDetailsProceedDelayMilliSeconds), 182 kMalwareDetailsProceedDelayMilliSeconds),
183 ui_manager_(ui_manager), 183 ui_manager_(ui_manager),
184 report_loop_(NULL), 184 report_loop_(NULL),
185 is_main_frame_load_blocked_(IsMainPageLoadBlocked(unsafe_resources)), 185 is_main_frame_load_blocked_(IsMainPageLoadBlocked(unsafe_resources)),
186 unsafe_resources_(unsafe_resources), 186 unsafe_resources_(unsafe_resources),
187 proceeded_(false), 187 proceeded_(false),
188 web_contents_(web_contents), 188 web_contents_(web_contents),
189 url_(unsafe_resources[0].url), 189 url_(unsafe_resources[0].url),
190 interstitial_page_(NULL), 190 interstitial_page_(NULL),
191 has_expanded_see_more_section_(false), 191 has_expanded_see_more_section_(false),
192 reporting_checkbox_checked_(false),
193 create_view_(true), 192 create_view_(true),
194 num_visits_(-1) { 193 num_visits_(-1) {
195 bool malware = false; 194 bool malware = false;
196 bool phishing = false; 195 bool phishing = false;
197 for (UnsafeResourceList::const_iterator iter = unsafe_resources_.begin(); 196 for (UnsafeResourceList::const_iterator iter = unsafe_resources_.begin();
198 iter != unsafe_resources_.end(); ++iter) { 197 iter != unsafe_resources_.end(); ++iter) {
199 const UnsafeResource& resource = *iter; 198 const UnsafeResource& resource = *iter;
200 SBThreatType threat_type = resource.threat_type; 199 SBThreatType threat_type = resource.threat_type;
201 if (threat_type == SB_THREAT_TYPE_URL_MALWARE || 200 if (threat_type == SB_THREAT_TYPE_URL_MALWARE ||
202 threat_type == SB_THREAT_TYPE_CLIENT_SIDE_MALWARE_URL) { 201 threat_type == SB_THREAT_TYPE_CLIENT_SIDE_MALWARE_URL) {
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
439 web_contents_->GetBrowserContext()); 438 web_contents_->GetBrowserContext());
440 renderer_preferences_util::UpdateFromSystemSettings(prefs, profile); 439 renderer_preferences_util::UpdateFromSystemSettings(prefs, profile);
441 } 440 }
442 441
443 void SafeBrowsingBlockingPage::SetReportingPreference(bool report) { 442 void SafeBrowsingBlockingPage::SetReportingPreference(bool report) {
444 Profile* profile = Profile::FromBrowserContext( 443 Profile* profile = Profile::FromBrowserContext(
445 web_contents_->GetBrowserContext()); 444 web_contents_->GetBrowserContext());
446 PrefService* pref = profile->GetPrefs(); 445 PrefService* pref = profile->GetPrefs();
447 pref->SetBoolean(prefs::kSafeBrowsingExtendedReportingEnabled, report); 446 pref->SetBoolean(prefs::kSafeBrowsingExtendedReportingEnabled, report);
448 UMA_HISTOGRAM_BOOLEAN("SB2.SetExtendedReportingEnabled", report); 447 UMA_HISTOGRAM_BOOLEAN("SB2.SetExtendedReportingEnabled", report);
449 reporting_checkbox_checked_ = report;
450 pref->ClearPref(prefs::kSafeBrowsingReportingEnabled);
451 pref->ClearPref(prefs::kSafeBrowsingDownloadFeedbackEnabled);
452 }
453
454 // If the reporting checkbox was left checked on close, the new pref
455 // kSafeBrowsingExtendedReportingEnabled should be updated.
456 // TODO(felt): Remove this in M-39. crbug.com/384668
457 void SafeBrowsingBlockingPage::UpdateReportingPref() {
458 if (!reporting_checkbox_checked_)
459 return;
460 if (IsPrefEnabled(prefs::kSafeBrowsingExtendedReportingEnabled))
461 return;
462 Profile* profile = Profile::FromBrowserContext(
463 web_contents_->GetBrowserContext());
464 if (profile->GetPrefs()->HasPrefPath(
465 prefs::kSafeBrowsingExtendedReportingEnabled))
466 return;
467 SetReportingPreference(true);
468 } 448 }
469 449
470 void SafeBrowsingBlockingPage::OnProceed() { 450 void SafeBrowsingBlockingPage::OnProceed() {
471 proceeded_ = true; 451 proceeded_ = true;
472 RecordUserAction(PROCEED); 452 RecordUserAction(PROCEED);
473 UpdateReportingPref();
474 // Send the malware details, if we opted to. 453 // Send the malware details, if we opted to.
475 FinishMalwareDetails(malware_details_proceed_delay_ms_); 454 FinishMalwareDetails(malware_details_proceed_delay_ms_);
476 455
477 NotifySafeBrowsingUIManager(ui_manager_, unsafe_resources_, true); 456 NotifySafeBrowsingUIManager(ui_manager_, unsafe_resources_, true);
478 457
479 // Check to see if some new notifications of unsafe resources have been 458 // Check to see if some new notifications of unsafe resources have been
480 // received while we were showing the interstitial. 459 // received while we were showing the interstitial.
481 UnsafeResourceMap* unsafe_resource_map = GetUnsafeResourcesMap(); 460 UnsafeResourceMap* unsafe_resource_map = GetUnsafeResourcesMap();
482 UnsafeResourceMap::iterator iter = unsafe_resource_map->find(web_contents_); 461 UnsafeResourceMap::iterator iter = unsafe_resource_map->find(web_contents_);
483 SafeBrowsingBlockingPage* blocking_page = NULL; 462 SafeBrowsingBlockingPage* blocking_page = NULL;
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
516 495
517 void SafeBrowsingBlockingPage::OnDontProceed() { 496 void SafeBrowsingBlockingPage::OnDontProceed() {
518 // Calling this method twice will not double-count. 497 // Calling this method twice will not double-count.
519 RecordUserReactionTime(kNavigatedAwayMetaCommand); 498 RecordUserReactionTime(kNavigatedAwayMetaCommand);
520 // We could have already called Proceed(), in which case we must not notify 499 // We could have already called Proceed(), in which case we must not notify
521 // the SafeBrowsingUIManager again, as the client has been deleted. 500 // the SafeBrowsingUIManager again, as the client has been deleted.
522 if (proceeded_) 501 if (proceeded_)
523 return; 502 return;
524 503
525 RecordUserAction(DONT_PROCEED); 504 RecordUserAction(DONT_PROCEED);
526 UpdateReportingPref();
527 // Send the malware details, if we opted to. 505 // Send the malware details, if we opted to.
528 FinishMalwareDetails(0); // No delay 506 FinishMalwareDetails(0); // No delay
529 507
530 NotifySafeBrowsingUIManager(ui_manager_, unsafe_resources_, false); 508 NotifySafeBrowsingUIManager(ui_manager_, unsafe_resources_, false);
531 509
532 // The user does not want to proceed, clear the queued unsafe resources 510 // The user does not want to proceed, clear the queued unsafe resources
533 // notifications we received while the interstitial was showing. 511 // notifications we received while the interstitial was showing.
534 UnsafeResourceMap* unsafe_resource_map = GetUnsafeResourcesMap(); 512 UnsafeResourceMap* unsafe_resource_map = GetUnsafeResourcesMap();
535 UnsafeResourceMap::iterator iter = unsafe_resource_map->find(web_contents_); 513 UnsafeResourceMap::iterator iter = unsafe_resource_map->find(web_contents_);
536 if (iter != unsafe_resource_map->end() && !iter->second.empty()) { 514 if (iter != unsafe_resource_map->end() && !iter->second.empty()) {
(...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after
926 load_time_data->SetBoolean(kDisplayCheckBox, CanShowMalwareDetailsOption()); 904 load_time_data->SetBoolean(kDisplayCheckBox, CanShowMalwareDetailsOption());
927 if (CanShowMalwareDetailsOption()) { 905 if (CanShowMalwareDetailsOption()) {
928 std::string privacy_link = base::StringPrintf( 906 std::string privacy_link = base::StringPrintf(
929 kPrivacyLinkHtml, 907 kPrivacyLinkHtml,
930 l10n_util::GetStringUTF8( 908 l10n_util::GetStringUTF8(
931 IDS_SAFE_BROWSING_PRIVACY_POLICY_PAGE).c_str()); 909 IDS_SAFE_BROWSING_PRIVACY_POLICY_PAGE).c_str());
932 load_time_data->SetString( 910 load_time_data->SetString(
933 "optInLink", 911 "optInLink",
934 l10n_util::GetStringFUTF16(IDS_SAFE_BROWSING_MALWARE_REPORTING_AGREE, 912 l10n_util::GetStringFUTF16(IDS_SAFE_BROWSING_MALWARE_REPORTING_AGREE,
935 base::UTF8ToUTF16(privacy_link))); 913 base::UTF8ToUTF16(privacy_link)));
936 Profile* profile = Profile::FromBrowserContext(
937 web_contents_->GetBrowserContext());
938 if (profile->GetPrefs()->HasPrefPath(
939 prefs::kSafeBrowsingExtendedReportingEnabled)) {
940 reporting_checkbox_checked_ =
941 IsPrefEnabled(prefs::kSafeBrowsingExtendedReportingEnabled);
942 } else if (IsPrefEnabled(prefs::kSafeBrowsingReportingEnabled) ||
943 IsPrefEnabled(prefs::kSafeBrowsingDownloadFeedbackEnabled)) {
944 reporting_checkbox_checked_ = true;
945 }
946 load_time_data->SetBoolean( 914 load_time_data->SetBoolean(
947 kBoxChecked, reporting_checkbox_checked_); 915 kBoxChecked,
916 IsPrefEnabled(prefs::kSafeBrowsingExtendedReportingEnabled));
948 } 917 }
949 } 918 }
950 919
951 void SafeBrowsingBlockingPage::PopulatePhishingLoadTimeData( 920 void SafeBrowsingBlockingPage::PopulatePhishingLoadTimeData(
952 base::DictionaryValue* load_time_data) { 921 base::DictionaryValue* load_time_data) {
953 load_time_data->SetBoolean("phishing", true); 922 load_time_data->SetBoolean("phishing", true);
954 load_time_data->SetString( 923 load_time_data->SetString(
955 "heading", 924 "heading",
956 l10n_util::GetStringUTF16(IDS_PHISHING_V3_HEADING)); 925 l10n_util::GetStringUTF16(IDS_PHISHING_V3_HEADING));
957 load_time_data->SetString( 926 load_time_data->SetString(
958 "primaryParagraph", 927 "primaryParagraph",
959 l10n_util::GetStringFUTF16( 928 l10n_util::GetStringFUTF16(
960 IDS_PHISHING_V3_PRIMARY_PARAGRAPH, 929 IDS_PHISHING_V3_PRIMARY_PARAGRAPH,
961 base::UTF8ToUTF16(url_.host()))); 930 base::UTF8ToUTF16(url_.host())));
962 load_time_data->SetString( 931 load_time_data->SetString(
963 "explanationParagraph", 932 "explanationParagraph",
964 l10n_util::GetStringFUTF16(IDS_PHISHING_V3_EXPLANATION_PARAGRAPH, 933 l10n_util::GetStringFUTF16(IDS_PHISHING_V3_EXPLANATION_PARAGRAPH,
965 base::UTF8ToUTF16(url_.host()))); 934 base::UTF8ToUTF16(url_.host())));
966 load_time_data->SetString( 935 load_time_data->SetString(
967 "finalParagraph", 936 "finalParagraph",
968 l10n_util::GetStringUTF16(IDS_PHISHING_V3_PROCEED_PARAGRAPH)); 937 l10n_util::GetStringUTF16(IDS_PHISHING_V3_PROCEED_PARAGRAPH));
969 } 938 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698