| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 #ifndef CHROME_BROWSER_SAFE_BROWSING_MALWARE_DETAILS_H_ | 5 #ifndef CHROME_BROWSER_SAFE_BROWSING_MALWARE_DETAILS_H_ |
| 6 #define CHROME_BROWSER_SAFE_BROWSING_MALWARE_DETAILS_H_ | 6 #define CHROME_BROWSER_SAFE_BROWSING_MALWARE_DETAILS_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 // A class that encapsulates the detailed malware reports sent when | 9 // A class that encapsulates the detailed malware reports sent when |
| 10 // users opt-in to do so from the malware warning page. | 10 // users opt-in to do so from the malware warning page. |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 MalwareDetails(TabContents* tab_contents, | 29 MalwareDetails(TabContents* tab_contents, |
| 30 const SafeBrowsingService::UnsafeResource resource); | 30 const SafeBrowsingService::UnsafeResource resource); |
| 31 | 31 |
| 32 // The SafeBrowsingService calls this from the IO thread, to get the | 32 // The SafeBrowsingService calls this from the IO thread, to get the |
| 33 // serialized report as a string and send it over. | 33 // serialized report as a string and send it over. |
| 34 const std::string* GetSerializedReport(); | 34 const std::string* GetSerializedReport(); |
| 35 | 35 |
| 36 private: | 36 private: |
| 37 friend class base::RefCountedThreadSafe<MalwareDetails>; | 37 friend class base::RefCountedThreadSafe<MalwareDetails>; |
| 38 | 38 |
| 39 // Maps a URL to its Resource. |
| 39 typedef base::hash_map< | 40 typedef base::hash_map< |
| 40 std::string, | 41 std::string, |
| 41 linked_ptr<safe_browsing::ClientMalwareReportRequest::Resource> > | 42 linked_ptr<safe_browsing::ClientMalwareReportRequest::Resource> > |
| 42 ResourceMap; | 43 ResourceMap; |
| 43 | 44 |
| 44 // Starts the collection of the report. | 45 // Starts the collection of the report. |
| 45 void StartCollection(); | 46 void StartCollection(); |
| 46 | 47 |
| 47 // Whether the url is "public" so we can add it to the report. | 48 // Whether the url is "public" so we can add it to the report. |
| 48 bool IsPublicUrl(const GURL& url) const; | 49 bool IsPublicUrl(const GURL& url) const; |
| 49 | 50 |
| 50 // Adds a node to |urls_|. |parent| can be empty. | 51 // Finds an existing Resource for the given url, or creates a new |
| 51 void AddNode(const std::string& url, const std::string& parent); | 52 // one if not found, and adds it to |resources_|. Returns the |
| 53 // found/created resource. |
| 54 safe_browsing::ClientMalwareReportRequest::Resource* FindOrCreateResource( |
| 55 const std::string& url); |
| 56 |
| 57 // Adds a Resource to resources_ with the given parent |
| 58 // relationship. |parent| can be empty. |
| 59 void AddUrl(const std::string& url, const std::string& parent); |
| 52 | 60 |
| 53 ~MalwareDetails(); | 61 ~MalwareDetails(); |
| 54 | 62 |
| 55 TabContents* tab_contents_; | 63 TabContents* tab_contents_; |
| 56 const SafeBrowsingService::UnsafeResource resource_; | 64 const SafeBrowsingService::UnsafeResource resource_; |
| 57 | 65 |
| 58 // The urls that we collect. We first add them into this map and then | 66 // For every Url we collect we create a Resource message. We keep |
| 59 // generate a protocol buffer from it. | 67 // them in a map so we can avoid duplicates. |
| 60 ResourceMap urls_; | 68 ResourceMap resources_; |
| 61 | 69 |
| 62 // The report protocol buffer. | 70 // The report protocol buffer. |
| 63 scoped_ptr<safe_browsing::ClientMalwareReportRequest> report_; | 71 scoped_ptr<safe_browsing::ClientMalwareReportRequest> report_; |
| 64 | 72 |
| 65 DISALLOW_COPY_AND_ASSIGN(MalwareDetails); | 73 DISALLOW_COPY_AND_ASSIGN(MalwareDetails); |
| 66 }; | 74 }; |
| 67 | 75 |
| 68 #endif // CHROME_BROWSER_SAFE_BROWSING_MALWARE_DETAILS_H_ | 76 #endif // CHROME_BROWSER_SAFE_BROWSING_MALWARE_DETAILS_H_ |
| OLD | NEW |