Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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 Loading... | |
| 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 Loading... | |
| 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 392 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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( | 914 Profile* profile = Profile::FromBrowserContext( |
| 937 web_contents_->GetBrowserContext()); | 915 web_contents_->GetBrowserContext()); |
| 938 if (profile->GetPrefs()->HasPrefPath( | 916 if (profile->GetPrefs()->HasPrefPath( |
| 939 prefs::kSafeBrowsingExtendedReportingEnabled)) { | 917 prefs::kSafeBrowsingExtendedReportingEnabled)) { |
|
mattm
2014/08/28 20:57:01
This HasPrefPath shouldn't be needed anymore
felt
2014/08/28 21:43:30
you're right. re-tested with both clean and dirty
| |
| 940 reporting_checkbox_checked_ = | 918 load_time_data->SetBoolean( |
| 941 IsPrefEnabled(prefs::kSafeBrowsingExtendedReportingEnabled); | 919 kBoxChecked, |
| 942 } else if (IsPrefEnabled(prefs::kSafeBrowsingReportingEnabled) || | 920 IsPrefEnabled(prefs::kSafeBrowsingExtendedReportingEnabled)); |
| 943 IsPrefEnabled(prefs::kSafeBrowsingDownloadFeedbackEnabled)) { | |
| 944 reporting_checkbox_checked_ = true; | |
| 945 } | 921 } |
| 946 load_time_data->SetBoolean( | 922 |
| 947 kBoxChecked, reporting_checkbox_checked_); | |
| 948 } | 923 } |
| 949 } | 924 } |
| 950 | 925 |
| 951 void SafeBrowsingBlockingPage::PopulatePhishingLoadTimeData( | 926 void SafeBrowsingBlockingPage::PopulatePhishingLoadTimeData( |
| 952 base::DictionaryValue* load_time_data) { | 927 base::DictionaryValue* load_time_data) { |
| 953 load_time_data->SetBoolean("phishing", true); | 928 load_time_data->SetBoolean("phishing", true); |
| 954 load_time_data->SetString( | 929 load_time_data->SetString( |
| 955 "heading", | 930 "heading", |
| 956 l10n_util::GetStringUTF16(IDS_PHISHING_V3_HEADING)); | 931 l10n_util::GetStringUTF16(IDS_PHISHING_V3_HEADING)); |
| 957 load_time_data->SetString( | 932 load_time_data->SetString( |
| 958 "primaryParagraph", | 933 "primaryParagraph", |
| 959 l10n_util::GetStringFUTF16( | 934 l10n_util::GetStringFUTF16( |
| 960 IDS_PHISHING_V3_PRIMARY_PARAGRAPH, | 935 IDS_PHISHING_V3_PRIMARY_PARAGRAPH, |
| 961 base::UTF8ToUTF16(url_.host()))); | 936 base::UTF8ToUTF16(url_.host()))); |
| 962 load_time_data->SetString( | 937 load_time_data->SetString( |
| 963 "explanationParagraph", | 938 "explanationParagraph", |
| 964 l10n_util::GetStringFUTF16(IDS_PHISHING_V3_EXPLANATION_PARAGRAPH, | 939 l10n_util::GetStringFUTF16(IDS_PHISHING_V3_EXPLANATION_PARAGRAPH, |
| 965 base::UTF8ToUTF16(url_.host()))); | 940 base::UTF8ToUTF16(url_.host()))); |
| 966 load_time_data->SetString( | 941 load_time_data->SetString( |
| 967 "finalParagraph", | 942 "finalParagraph", |
| 968 l10n_util::GetStringUTF16(IDS_PHISHING_V3_PROCEED_PARAGRAPH)); | 943 l10n_util::GetStringUTF16(IDS_PHISHING_V3_PROCEED_PARAGRAPH)); |
| 969 } | 944 } |
| OLD | NEW |