#include "base/basictypes.h"
#include "base/callback.h"
+#include "base/callback_list.h"
#include "base/files/file_path.h"
#include "base/gtest_prod_util.h"
#include "base/memory/ref_counted.h"
+#include "base/memory/scoped_ptr.h"
#include "chrome/browser/safe_browsing/database_manager.h"
#include "chrome/browser/safe_browsing/ui_manager.h"
#include "url/gurl.h"
} // namespace net
namespace safe_browsing {
-class DownloadFeedbackService;
class BinaryFeatureExtractor;
+class ClientDownloadRequest;
+class DownloadFeedbackService;
// This class provides an asynchronous API to check whether a particular
// client download is malicious or not.
// Callback type which is invoked once the download request is done.
typedef base::Callback<void(DownloadCheckResult)> CheckDownloadCallback;
+ // A type of callback run on the main thread when a ClientDownloadRequest has
+ // been formed for a download, or when one has not been formed for a supported
+ // download.
+ typedef base::Callback<void(content::DownloadItem*,
+ const ClientDownloadRequest*)>
+ ClientDownloadRequestCallback;
+
+ // A list of ClientDownloadRequest callbacks.
+ typedef base::CallbackList<void(content::DownloadItem*,
+ const ClientDownloadRequest*)>
+ ClientDownloadRequestCallbackList;
+
+ // A subscription to a registered ClientDownloadRequest callback.
+ typedef scoped_ptr<ClientDownloadRequestCallbackList::Subscription>
+ ClientDownloadRequestSubscription;
+
// Creates a download service. The service is initially disabled. You need
// to call SetEnabled() to start it. |sb_service| owns this object; we
// keep a reference to |request_context_getter|.
return feedback_service_.get();
}
+ // Registers a callback that will be run when a ClientDownloadRequest has
+ // been formed.
+ ClientDownloadRequestSubscription RegisterClientDownloadRequestCallback(
+ const ClientDownloadRequestCallback& callback);
+
protected:
// Enum to keep track why a particular download verdict was chosen.
// This is used to keep some stats around.
scoped_ptr<DownloadFeedbackService> feedback_service_;
+ // A list of callbacks to be run on the main thread when a
+ // ClientDownloadRequest has been formed.
+ ClientDownloadRequestCallbackList client_download_request_callbacks_;
+
DISALLOW_COPY_AND_ASSIGN(DownloadProtectionService);
};
} // namespace safe_browsing