summaryrefslogtreecommitdiffstats
path: root/chrome/browser/safe_browsing/malware_details.cc
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/browser/safe_browsing/malware_details.cc')
-rw-r--r--chrome/browser/safe_browsing/malware_details.cc35
1 files changed, 34 insertions, 1 deletions
diff --git a/chrome/browser/safe_browsing/malware_details.cc b/chrome/browser/safe_browsing/malware_details.cc
index 63d3f3a..bc35cec 100644
--- a/chrome/browser/safe_browsing/malware_details.cc
+++ b/chrome/browser/safe_browsing/malware_details.cc
@@ -11,6 +11,7 @@
#include "chrome/browser/net/chrome_url_request_context.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/safe_browsing/malware_details_cache.h"
+#include "chrome/browser/safe_browsing/malware_details_history.h"
#include "chrome/browser/safe_browsing/report.pb.h"
#include "chrome/browser/safe_browsing/safe_browsing_service.h"
#include "chrome/common/safe_browsing/safebrowsing_messages.h"
@@ -76,7 +77,8 @@ MalwareDetails::MalwareDetails(
request_context_getter_(tab_contents->profile()->GetRequestContext()),
sb_service_(sb_service),
resource_(resource),
- cache_collector_(new MalwareDetailsCacheCollector) {
+ cache_collector_(new MalwareDetailsCacheCollector),
+ redirects_collector_(new MalwareDetailsRedirectsCollector) {
StartCollection();
}
@@ -224,6 +226,11 @@ void MalwareDetails::AddDOMDetails(
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
DVLOG(1) << "Nodes from the DOM: " << params.size();
+ // If we have already started getting redirects from history service,
+ // don't modify state, otherwise will invalidate the iterators.
+ if (redirects_collector_->HasStarted())
+ return;
+
// If we have already started collecting data from the HTTP cache, don't
// modify our state.
if (cache_collector_->HasStarted())
@@ -246,6 +253,25 @@ void MalwareDetails::AddDOMDetails(
void MalwareDetails::FinishCollection() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
+ std::vector<GURL> urls;
+ for (safe_browsing::ResourceMap::const_iterator it = resources_.begin();
+ it != resources_.end(); it++) {
+ urls.push_back(GURL(it->first));
+ }
+ redirects_collector_->StartHistoryCollection(
+ urls, tab_contents(),
+ NewRunnableMethod(this, &MalwareDetails::OnRedirectionCollectionReady));
+}
+
+void MalwareDetails::OnRedirectionCollectionReady() {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
+ const std::vector<safe_browsing::RedirectChain>& redirects =
+ redirects_collector_->GetCollectedUrls();
+
+ for (size_t i = 0; i < redirects.size(); ++i)
+ AddRedirectUrlList(redirects[i]);
+
+ // Call the cache collector
cache_collector_->StartCacheCollection(
request_context_getter_,
&resources_,
@@ -253,6 +279,13 @@ void MalwareDetails::FinishCollection() {
NewRunnableMethod(this, &MalwareDetails::OnCacheCollectionReady));
}
+void MalwareDetails::AddRedirectUrlList(const std::vector<GURL>& urls) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
+ for (size_t i = 0; i < urls.size()-1; ++i) {
+ AddUrl(urls[i], urls[i+1], "", NULL);
+ }
+}
+
void MalwareDetails::OnCacheCollectionReady() {
DVLOG(1) << "OnCacheCollectionReady.";
// Add all the urls in our |resources_| maps to the |report_| protocol buffer.