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 MalwareDetails class. | 5 // Implementation of the MalwareDetails class. |
6 | 6 |
7 #include "chrome/browser/safe_browsing/malware_details.h" | 7 #include "chrome/browser/safe_browsing/malware_details.h" |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/lazy_instance.h" | 10 #include "base/lazy_instance.h" |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
122 new_resource->set_url(url.spec()); | 122 new_resource->set_url(url.spec()); |
123 new_resource->set_id(id); | 123 new_resource->set_id(id); |
124 resources_[url.spec()] = new_resource; | 124 resources_[url.spec()] = new_resource; |
125 return new_resource.get(); | 125 return new_resource.get(); |
126 } | 126 } |
127 | 127 |
128 void MalwareDetails::AddUrl(const GURL& url, | 128 void MalwareDetails::AddUrl(const GURL& url, |
129 const GURL& parent, | 129 const GURL& parent, |
130 const std::string& tagname, | 130 const std::string& tagname, |
131 const std::vector<GURL>* children) { | 131 const std::vector<GURL>* children) { |
132 if (!IsPublicUrl(url)) | 132 if (!url.is_valid() || !IsPublicUrl(url)) |
133 return; | 133 return; |
134 | 134 |
135 // Find (or create) the resource for the url. | 135 // Find (or create) the resource for the url. |
136 ClientMalwareReportRequest::Resource* url_resource = | 136 ClientMalwareReportRequest::Resource* url_resource = |
137 FindOrCreateResource(url); | 137 FindOrCreateResource(url); |
138 if (!tagname.empty()) { | 138 if (!tagname.empty()) { |
139 url_resource->set_tag_name(tagname); | 139 url_resource->set_tag_name(tagname); |
140 } | 140 } |
141 if (!parent.is_empty() && IsPublicUrl(parent)) { | 141 if (!parent.is_empty() && IsPublicUrl(parent)) { |
142 // Add the resource for the parent. | 142 // Add the resource for the parent. |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
305 | 305 |
306 // Send the report, using the SafeBrowsingService. | 306 // Send the report, using the SafeBrowsingService. |
307 std::string serialized; | 307 std::string serialized; |
308 if (!report_->SerializeToString(&serialized)) { | 308 if (!report_->SerializeToString(&serialized)) { |
309 DLOG(ERROR) << "Unable to serialize the malware report."; | 309 DLOG(ERROR) << "Unable to serialize the malware report."; |
310 return; | 310 return; |
311 } | 311 } |
312 | 312 |
313 ui_manager_->SendSerializedMalwareDetails(serialized); | 313 ui_manager_->SendSerializedMalwareDetails(serialized); |
314 } | 314 } |
OLD | NEW |