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 = unsafe_resources_[0].is_subresource; |
| 497 switch (interstitial_reason_) { |
| 498 case SB_REASON_MALWARE: |
| 499 return primary_subresource ? "malware_subresource" : "malware"; |
| 500 case SB_REASON_HARMFUL: |
| 501 return primary_subresource ? "harmful_subresource" : "harmful"; |
| 502 case SB_REASON_PHISHING: |
| 503 return primary_subresource ? "phishing_subresource" : "phishing"; |
| 504 } |
| 505 NOTREACHED(); |
| 506 return std::string(); |
| 507 } |
| 508 |
| 509 std::string SafeBrowsingBlockingPage::GetRapporPrefix() const { |
496 switch (interstitial_reason_) { | 510 switch (interstitial_reason_) { |
497 case SB_REASON_MALWARE: | 511 case SB_REASON_MALWARE: |
498 return "malware"; | 512 return "malware"; |
499 case SB_REASON_HARMFUL: | 513 case SB_REASON_HARMFUL: |
500 return "harmful"; | 514 return "harmful"; |
501 case SB_REASON_PHISHING: | 515 case SB_REASON_PHISHING: |
502 return "phishing"; | 516 return "phishing"; |
503 } | 517 } |
504 NOTREACHED(); | 518 NOTREACHED(); |
505 return std::string(); | 519 return std::string(); |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
635 load_time_data->SetString( | 649 load_time_data->SetString( |
636 "explanationParagraph", | 650 "explanationParagraph", |
637 l10n_util::GetStringFUTF16(IDS_PHISHING_V3_EXPLANATION_PARAGRAPH, | 651 l10n_util::GetStringFUTF16(IDS_PHISHING_V3_EXPLANATION_PARAGRAPH, |
638 GetFormattedHostName())); | 652 GetFormattedHostName())); |
639 load_time_data->SetString( | 653 load_time_data->SetString( |
640 "finalParagraph", | 654 "finalParagraph", |
641 l10n_util::GetStringUTF16(IDS_PHISHING_V3_PROCEED_PARAGRAPH)); | 655 l10n_util::GetStringUTF16(IDS_PHISHING_V3_PROCEED_PARAGRAPH)); |
642 | 656 |
643 PopulateExtendedReportingOption(load_time_data); | 657 PopulateExtendedReportingOption(load_time_data); |
644 } | 658 } |
OLD | NEW |