OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CHROME_BROWSER_SAFE_BROWSING_MALWARE_DETAILS_H_ |
| 6 #define CHROME_BROWSER_SAFE_BROWSING_MALWARE_DETAILS_H_ |
| 7 #pragma once |
| 8 |
| 9 // A class that encapsulates the detailed malware reports sent when |
| 10 // users opt-in to do so from the malware warning page. |
| 11 |
| 12 // An instance of this class is generated when a malware warning page |
| 13 // is shown (SafeBrowsingBlockingPage). It is passed on to the |
| 14 // SafeBrowsing service when the warning goes away. |
| 15 |
| 16 #include <string> |
| 17 #include <vector> |
| 18 |
| 19 #include "base/hash_tables.h" |
| 20 #include "base/linked_ptr.h" |
| 21 #include "base/scoped_ptr.h" |
| 22 #include "chrome/browser/safe_browsing/report.pb.h" |
| 23 #include "chrome/browser/safe_browsing/safe_browsing_service.h" |
| 24 |
| 25 class TabContents; |
| 26 |
| 27 class MalwareDetails : public base::RefCountedThreadSafe<MalwareDetails> { |
| 28 public: |
| 29 MalwareDetails(TabContents* tab_contents, |
| 30 const SafeBrowsingService::UnsafeResource resource); |
| 31 |
| 32 // The SafeBrowsingService calls this from the IO thread, to get the |
| 33 // serialized report as a string and send it over. |
| 34 const std::string* GetSerializedReport(); |
| 35 |
| 36 private: |
| 37 friend class base::RefCountedThreadSafe<MalwareDetails>; |
| 38 |
| 39 typedef base::hash_map< |
| 40 std::string, |
| 41 linked_ptr<safe_browsing::ClientMalwareReportRequest::Resource> > |
| 42 ResourceMap; |
| 43 |
| 44 // Starts the collection of the report. |
| 45 void StartCollection(); |
| 46 |
| 47 // Whether the url is "public" so we can add it to the report. |
| 48 bool IsPublicUrl(const GURL& url) const; |
| 49 |
| 50 // Adds a node to |urls_|. |parent| can be empty. |
| 51 void AddNode(const std::string& url, const std::string& parent); |
| 52 |
| 53 ~MalwareDetails(); |
| 54 |
| 55 TabContents* tab_contents_; |
| 56 const SafeBrowsingService::UnsafeResource resource_; |
| 57 |
| 58 // The urls that we collect. We first add them into this map and then |
| 59 // generate a protocol buffer from it. |
| 60 ResourceMap urls_; |
| 61 |
| 62 // The report protocol buffer. |
| 63 scoped_ptr<safe_browsing::ClientMalwareReportRequest> report_; |
| 64 |
| 65 DISALLOW_COPY_AND_ASSIGN(MalwareDetails); |
| 66 }; |
| 67 |
| 68 #endif // CHROME_BROWSER_SAFE_BROWSING_MALWARE_DETAILS_H_ |
OLD | NEW |