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 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
152 if (malware) | 152 if (malware) |
153 interstitial_reason_ = SB_REASON_MALWARE; | 153 interstitial_reason_ = SB_REASON_MALWARE; |
154 else if (harmful) | 154 else if (harmful) |
155 interstitial_reason_ = SB_REASON_HARMFUL; | 155 interstitial_reason_ = SB_REASON_HARMFUL; |
156 else | 156 else |
157 interstitial_reason_ = SB_REASON_PHISHING; | 157 interstitial_reason_ = SB_REASON_PHISHING; |
158 | 158 |
159 // This must be done after calculating |interstitial_reason_| above. | 159 // This must be done after calculating |interstitial_reason_| above. |
160 // Use same prefix for UMA as for Rappor. | 160 // Use same prefix for UMA as for Rappor. |
161 set_metrics_helper(new SecurityInterstitialMetricsHelper( | 161 set_metrics_helper(new SecurityInterstitialMetricsHelper( |
162 web_contents, request_url(), GetMetricPrefix(), GetMetricPrefix(), | 162 web_contents, request_url(), GetMetricPrefix(), GetRapporPrefix(), |
163 SecurityInterstitialMetricsHelper::REPORT_RAPPOR, | 163 SecurityInterstitialMetricsHelper::REPORT_RAPPOR, |
164 GetSamplingEventName())); | 164 GetSamplingEventName())); |
165 metrics_helper()->RecordUserDecision(SecurityInterstitialMetricsHelper::SHOW); | 165 metrics_helper()->RecordUserDecision(SecurityInterstitialMetricsHelper::SHOW); |
166 metrics_helper()->RecordUserInteraction( | 166 metrics_helper()->RecordUserInteraction( |
167 SecurityInterstitialMetricsHelper::TOTAL_VISITS); | 167 SecurityInterstitialMetricsHelper::TOTAL_VISITS); |
168 if (IsPrefEnabled(prefs::kSafeBrowsingProceedAnywayDisabled)) { | 168 if (IsPrefEnabled(prefs::kSafeBrowsingProceedAnywayDisabled)) { |
169 metrics_helper()->RecordUserDecision( | 169 metrics_helper()->RecordUserDecision( |
170 SecurityInterstitialMetricsHelper::PROCEEDING_DISABLED); | 170 SecurityInterstitialMetricsHelper::PROCEEDING_DISABLED); |
171 } | 171 } |
172 | 172 |
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
486 if (unsafe_resources[0].threat_type == | 486 if (unsafe_resources[0].threat_type == |
487 SB_THREAT_TYPE_CLIENT_SIDE_PHISHING_URL) { | 487 SB_THREAT_TYPE_CLIENT_SIDE_PHISHING_URL) { |
488 return false; | 488 return false; |
489 } | 489 } |
490 | 490 |
491 // Otherwise, check the threat type. | 491 // Otherwise, check the threat type. |
492 return unsafe_resources.size() == 1 && !unsafe_resources[0].is_subresource; | 492 return unsafe_resources.size() == 1 && !unsafe_resources[0].is_subresource; |
493 } | 493 } |
494 | 494 |
495 std::string SafeBrowsingBlockingPage::GetMetricPrefix() const { | 495 std::string SafeBrowsingBlockingPage::GetMetricPrefix() const { |
496 bool primary_subresource = false; | |
Nathan Parker
2015/05/13 16:18:45
nit:
bool primary_subresource = unsafe_resources_
felt
2015/05/13 18:39:11
whoops, side effect of earlier testing. fixed
| |
497 if (unsafe_resources_[0].is_subresource) | |
498 primary_subresource = true; | |
499 | |
500 switch (interstitial_reason_) { | |
501 case SB_REASON_MALWARE: | |
502 return primary_subresource ? "malware_subresource" : "malware"; | |
503 case SB_REASON_HARMFUL: | |
504 return primary_subresource ? "harmful_subresource" : "harmful"; | |
505 case SB_REASON_PHISHING: | |
506 return primary_subresource ? "phishing_subresource" : "phishing"; | |
507 } | |
508 NOTREACHED(); | |
509 return std::string(); | |
510 } | |
511 | |
512 std::string SafeBrowsingBlockingPage::GetRapporPrefix() const { | |
496 switch (interstitial_reason_) { | 513 switch (interstitial_reason_) { |
497 case SB_REASON_MALWARE: | 514 case SB_REASON_MALWARE: |
498 return "malware"; | 515 return "malware"; |
499 case SB_REASON_HARMFUL: | 516 case SB_REASON_HARMFUL: |
500 return "harmful"; | 517 return "harmful"; |
501 case SB_REASON_PHISHING: | 518 case SB_REASON_PHISHING: |
502 return "phishing"; | 519 return "phishing"; |
503 } | 520 } |
504 NOTREACHED(); | 521 NOTREACHED(); |
505 return std::string(); | 522 return std::string(); |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
635 load_time_data->SetString( | 652 load_time_data->SetString( |
636 "explanationParagraph", | 653 "explanationParagraph", |
637 l10n_util::GetStringFUTF16(IDS_PHISHING_V3_EXPLANATION_PARAGRAPH, | 654 l10n_util::GetStringFUTF16(IDS_PHISHING_V3_EXPLANATION_PARAGRAPH, |
638 GetFormattedHostName())); | 655 GetFormattedHostName())); |
639 load_time_data->SetString( | 656 load_time_data->SetString( |
640 "finalParagraph", | 657 "finalParagraph", |
641 l10n_util::GetStringUTF16(IDS_PHISHING_V3_PROCEED_PARAGRAPH)); | 658 l10n_util::GetStringUTF16(IDS_PHISHING_V3_PROCEED_PARAGRAPH)); |
642 | 659 |
643 PopulateExtendedReportingOption(load_time_data); | 660 PopulateExtendedReportingOption(load_time_data); |
644 } | 661 } |
OLD | NEW |