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 ThreatDetails class. | 5 // Implementation of the ThreatDetails class. |
6 | 6 |
7 #include "components/safe_browsing/browser/threat_details.h" | 7 #include "components/safe_browsing/browser/threat_details.h" |
8 | 8 |
9 #include <stddef.h> | 9 #include <stddef.h> |
10 #include <stdint.h> | 10 #include <stdint.h> |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 // ClientSafeBrowsingReportRequest::ReportType. | 65 // ClientSafeBrowsingReportRequest::ReportType. |
66 ClientSafeBrowsingReportRequest::ReportType GetReportTypeFromSBThreatType( | 66 ClientSafeBrowsingReportRequest::ReportType GetReportTypeFromSBThreatType( |
67 SBThreatType threat_type) { | 67 SBThreatType threat_type) { |
68 switch (threat_type) { | 68 switch (threat_type) { |
69 case SB_THREAT_TYPE_URL_PHISHING: | 69 case SB_THREAT_TYPE_URL_PHISHING: |
70 return ClientSafeBrowsingReportRequest::URL_PHISHING; | 70 return ClientSafeBrowsingReportRequest::URL_PHISHING; |
71 case SB_THREAT_TYPE_URL_MALWARE: | 71 case SB_THREAT_TYPE_URL_MALWARE: |
72 return ClientSafeBrowsingReportRequest::URL_MALWARE; | 72 return ClientSafeBrowsingReportRequest::URL_MALWARE; |
73 case SB_THREAT_TYPE_URL_UNWANTED: | 73 case SB_THREAT_TYPE_URL_UNWANTED: |
74 return ClientSafeBrowsingReportRequest::URL_UNWANTED; | 74 return ClientSafeBrowsingReportRequest::URL_UNWANTED; |
75 case SB_THREAT_TYPE_CLIENT_SIDE_PHISHING_URL: | 75 case SB_THREAT_TYPE_URL_CLIENT_SIDE_PHISHING: |
76 return ClientSafeBrowsingReportRequest::CLIENT_SIDE_PHISHING_URL; | 76 return ClientSafeBrowsingReportRequest::URL_CLIENT_SIDE_PHISHING; |
77 case SB_THREAT_TYPE_CLIENT_SIDE_MALWARE_URL: | 77 case SB_THREAT_TYPE_URL_CLIENT_SIDE_MALWARE: |
78 return ClientSafeBrowsingReportRequest::CLIENT_SIDE_MALWARE_URL; | 78 return ClientSafeBrowsingReportRequest::URL_CLIENT_SIDE_MALWARE; |
79 case SB_THREAT_TYPE_PASSWORD_PROTECTION_PHISHING_URL: | 79 case SB_THREAT_TYPE_URL_PASSWORD_PROTECTION_PHISHING: |
80 return ClientSafeBrowsingReportRequest::PASSWORD_PROTECTION_PHISHING_URL; | 80 return ClientSafeBrowsingReportRequest::URL_PASSWORD_PROTECTION_PHISHING; |
81 default: // Gated by SafeBrowsingBlockingPage::ShouldReportThreatDetails. | 81 default: // Gated by SafeBrowsingBlockingPage::ShouldReportThreatDetails. |
82 NOTREACHED() << "We should not send report for threat type " | 82 NOTREACHED() << "We should not send report for threat type " |
83 << threat_type; | 83 << threat_type; |
84 return ClientSafeBrowsingReportRequest::UNKNOWN; | 84 return ClientSafeBrowsingReportRequest::UNKNOWN; |
85 } | 85 } |
86 } | 86 } |
87 | 87 |
88 // Clears the specified HTTPS resource of any sensitive data, only retaining | 88 // Clears the specified HTTPS resource of any sensitive data, only retaining |
89 // data that is whitelisted for collection. | 89 // data that is whitelisted for collection. |
90 void ClearHttpsResource(ClientSafeBrowsingReportRequest::Resource* resource) { | 90 void ClearHttpsResource(ClientSafeBrowsingReportRequest::Resource* resource) { |
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
354 | 354 |
355 void ThreatDetails::StartCollection() { | 355 void ThreatDetails::StartCollection() { |
356 DVLOG(1) << "Starting to compute threat details."; | 356 DVLOG(1) << "Starting to compute threat details."; |
357 report_.reset(new ClientSafeBrowsingReportRequest()); | 357 report_.reset(new ClientSafeBrowsingReportRequest()); |
358 | 358 |
359 if (IsReportableUrl(resource_.url)) { | 359 if (IsReportableUrl(resource_.url)) { |
360 report_->set_url(resource_.url.spec()); | 360 report_->set_url(resource_.url.spec()); |
361 report_->set_type(GetReportTypeFromSBThreatType(resource_.threat_type)); | 361 report_->set_type(GetReportTypeFromSBThreatType(resource_.threat_type)); |
362 } | 362 } |
363 | 363 |
364 if (resource_.threat_type == SB_THREAT_TYPE_PASSWORD_PROTECTION_PHISHING_URL) | 364 if (resource_.threat_type == SB_THREAT_TYPE_URL_PASSWORD_PROTECTION_PHISHING) |
365 report_->set_token(resource_.token); | 365 report_->set_token(resource_.token); |
366 | 366 |
367 GURL referrer_url; | 367 GURL referrer_url; |
368 NavigationEntry* nav_entry = resource_.GetNavigationEntryForResource(); | 368 NavigationEntry* nav_entry = resource_.GetNavigationEntryForResource(); |
369 if (nav_entry) { | 369 if (nav_entry) { |
370 GURL page_url = nav_entry->GetURL(); | 370 GURL page_url = nav_entry->GetURL(); |
371 if (IsReportableUrl(page_url)) | 371 if (IsReportableUrl(page_url)) |
372 report_->set_page_url(page_url.spec()); | 372 report_->set_page_url(page_url.spec()); |
373 | 373 |
374 referrer_url = nav_entry->GetReferrer().url; | 374 referrer_url = nav_entry->GetReferrer().url; |
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
586 // Send the report, using the SafeBrowsingService. | 586 // Send the report, using the SafeBrowsingService. |
587 std::string serialized; | 587 std::string serialized; |
588 if (!report_->SerializeToString(&serialized)) { | 588 if (!report_->SerializeToString(&serialized)) { |
589 DLOG(ERROR) << "Unable to serialize the threat report."; | 589 DLOG(ERROR) << "Unable to serialize the threat report."; |
590 return; | 590 return; |
591 } | 591 } |
592 ui_manager_->SendSerializedThreatDetails(serialized); | 592 ui_manager_->SendSerializedThreatDetails(serialized); |
593 } | 593 } |
594 | 594 |
595 } // namespace safe_browsing | 595 } // namespace safe_browsing |
OLD | NEW |