summaryrefslogtreecommitdiffstats
path: root/chrome/browser/safe_browsing/malware_details.h
diff options
context:
space:
mode:
authorpanayiotis@google.com <panayiotis@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2011-04-19 05:14:36 +0000
committerpanayiotis@google.com <panayiotis@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2011-04-19 05:14:36 +0000
commitca034a50e0e1f68212953c4b7795574747a32967 (patch)
tree3c74616346e6e1eb78768c1e2bf357dcb5b3ce85 /chrome/browser/safe_browsing/malware_details.h
parent857163eb100b1275a61d6ffe991846c34a61668f (diff)
downloadchromium_src-ca034a50e0e1f68212953c4b7795574747a32967.zip
chromium_src-ca034a50e0e1f68212953c4b7795574747a32967.tar.gz
chromium_src-ca034a50e0e1f68212953c4b7795574747a32967.tar.bz2
The optional Malware Details also collects HTTP cache information. See design doc for background (http://goo.gl/omvhq)
BUG=None TEST=None Review URL: http://codereview.chromium.org/6611023 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@82070 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/safe_browsing/malware_details.h')
-rw-r--r--chrome/browser/safe_browsing/malware_details.h55
1 files changed, 39 insertions, 16 deletions
diff --git a/chrome/browser/safe_browsing/malware_details.h b/chrome/browser/safe_browsing/malware_details.h
index 3cd6b55..494837e 100644
--- a/chrome/browser/safe_browsing/malware_details.h
+++ b/chrome/browser/safe_browsing/malware_details.h
@@ -10,29 +10,39 @@
// users opt-in to do so from the malware warning page.
// An instance of this class is generated when a malware warning page
-// is shown (SafeBrowsingBlockingPage). It is passed on to the
-// SafeBrowsing service when the warning goes away.
+// is shown (SafeBrowsingBlockingPage).
#include <string>
#include <vector>
#include "base/hash_tables.h"
#include "base/memory/linked_ptr.h"
+#include "base/memory/ref_counted.h"
#include "base/memory/scoped_ptr.h"
#include "chrome/browser/safe_browsing/report.pb.h"
#include "chrome/browser/safe_browsing/safe_browsing_service.h"
#include "content/browser/tab_contents/tab_contents_observer.h"
+#include "net/base/completion_callback.h"
class TabContents;
struct SafeBrowsingHostMsg_MalwareDOMDetails_Node;
+class MalwareDetailsCacheCollector;
class MalwareDetailsFactory;
+namespace safe_browsing {
+// Maps a URL to its Resource.
+typedef base::hash_map<
+ std::string,
+ linked_ptr<safe_browsing::ClientMalwareReportRequest::Resource> > ResourceMap;
+}
+
class MalwareDetails : public base::RefCountedThreadSafe<MalwareDetails>,
public TabContentsObserver {
public:
// Constructs a new MalwareDetails instance, using the factory.
static MalwareDetails* NewMalwareDetails(
+ SafeBrowsingService* sb_service,
TabContents* tab_contents,
const SafeBrowsingService::UnsafeResource& resource);
@@ -42,9 +52,13 @@ class MalwareDetails : public base::RefCountedThreadSafe<MalwareDetails>,
factory_ = factory;
}
- // The SafeBrowsingService calls this from the IO thread, to get the
- // serialized report as a string and send it over.
- const std::string* GetSerializedReport();
+ // The SafeBrowsingBlockingPage calls this from the IO thread when
+ // the user is leaving the blocking page and has opted-in to sending
+ // the report. We start the cache collection, and when we are done,
+ // we send the report.
+ void FinishCollection();
+
+ void OnCacheCollectionReady();
// TabContentsObserver implementation.
virtual bool OnMessageReceived(const IPC::Message& message);
@@ -52,24 +66,25 @@ class MalwareDetails : public base::RefCountedThreadSafe<MalwareDetails>,
protected:
friend class MalwareDetailsFactoryImpl;
- MalwareDetails(TabContents* tab_contents,
+ MalwareDetails(SafeBrowsingService* sb_service,
+ TabContents* tab_contents,
const SafeBrowsingService::UnsafeResource& resource);
+ virtual ~MalwareDetails();
+
// Called on the IO thread with the DOM details.
virtual void AddDOMDetails(
const std::vector<SafeBrowsingHostMsg_MalwareDOMDetails_Node>& params);
- virtual ~MalwareDetails();
+ // The report protocol buffer.
+ scoped_ptr<safe_browsing::ClientMalwareReportRequest> report_;
+
+ // Used to get a pointer to the HTTP cache.
+ scoped_refptr<net::URLRequestContextGetter> request_context_getter_;
private:
friend class base::RefCountedThreadSafe<MalwareDetails>;
- // Maps a URL to its Resource.
- typedef base::hash_map<
- std::string,
- linked_ptr<safe_browsing::ClientMalwareReportRequest::Resource> >
- ResourceMap;
-
// Starts the collection of the report.
void StartCollection();
@@ -93,21 +108,28 @@ class MalwareDetails : public base::RefCountedThreadSafe<MalwareDetails>,
void OnReceivedMalwareDOMDetails(
const std::vector<SafeBrowsingHostMsg_MalwareDOMDetails_Node>& params);
+ scoped_refptr<SafeBrowsingService> sb_service_;
+
const SafeBrowsingService::UnsafeResource resource_;
// For every Url we collect we create a Resource message. We keep
// them in a map so we can avoid duplicates.
- ResourceMap resources_;
+ safe_browsing::ResourceMap resources_;
- // The report protocol buffer.
- scoped_ptr<safe_browsing::ClientMalwareReportRequest> report_;
+ // Result from the cache extractor.
+ bool cache_result_;
// The factory used to instanciate SafeBrowsingBlockingPage objects.
// Usefull for tests, so they can provide their own implementation of
// SafeBrowsingBlockingPage.
static MalwareDetailsFactory* factory_;
+ // Used to collect details from the HTTP Cache.
+ scoped_refptr<MalwareDetailsCacheCollector> cache_collector_;
+
FRIEND_TEST_ALL_PREFIXES(MalwareDetailsTest, MalwareDOMDetails);
+ FRIEND_TEST_ALL_PREFIXES(MalwareDetailsTest, HTTPCache);
+ FRIEND_TEST_ALL_PREFIXES(MalwareDetailsTest, HTTPCacheNoEntries);
DISALLOW_COPY_AND_ASSIGN(MalwareDetails);
};
@@ -118,6 +140,7 @@ class MalwareDetailsFactory {
virtual ~MalwareDetailsFactory() { }
virtual MalwareDetails* CreateMalwareDetails(
+ SafeBrowsingService* sb_service,
TabContents* tab_contents,
const SafeBrowsingService::UnsafeResource& unsafe_resource) = 0;
};