| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_DOWNLOAD_DOWNLOAD_SAFE_BROWSING_CLIENT_H_ | 5 #ifndef CHROME_BROWSER_DOWNLOAD_DOWNLOAD_SAFE_BROWSING_CLIENT_H_ |
| 6 #define CHROME_BROWSER_DOWNLOAD_DOWNLOAD_SAFE_BROWSING_CLIENT_H_ | 6 #define CHROME_BROWSER_DOWNLOAD_DOWNLOAD_SAFE_BROWSING_CLIENT_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include "base/callback_old.h" | 9 #include "base/callback_old.h" |
| 10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 // } | 28 // } |
| 29 class DownloadSBClient | 29 class DownloadSBClient |
| 30 : public SafeBrowsingService::Client, | 30 : public SafeBrowsingService::Client, |
| 31 public base::RefCountedThreadSafe<DownloadSBClient> { | 31 public base::RefCountedThreadSafe<DownloadSBClient> { |
| 32 public: | 32 public: |
| 33 typedef Callback2<int32, bool>::Type UrlDoneCallback; | 33 typedef Callback2<int32, bool>::Type UrlDoneCallback; |
| 34 typedef Callback2<int32, bool>::Type HashDoneCallback; | 34 typedef Callback2<int32, bool>::Type HashDoneCallback; |
| 35 | 35 |
| 36 DownloadSBClient(int32 download_id, | 36 DownloadSBClient(int32 download_id, |
| 37 const std::vector<GURL>& url_chain, | 37 const std::vector<GURL>& url_chain, |
| 38 const GURL& referrer_url); | 38 const GURL& referrer_url, |
| 39 bool safe_browsing_enabled); |
| 39 | 40 |
| 40 // Call safebrowsing service to verifiy the download. | 41 // Call safebrowsing service to verify the download. |
| 41 // For each DownloadSBClient instance, either CheckDownloadUrl or | 42 // For each DownloadSBClient instance, either CheckDownloadUrl or |
| 42 // CheckDownloadHash can be called, and be called only once. | 43 // CheckDownloadHash can be called, and be called only once. |
| 43 // DownloadSBClient instance. | 44 // DownloadSBClient instance. |
| 44 void CheckDownloadUrl(UrlDoneCallback* callback); | 45 void CheckDownloadUrl(UrlDoneCallback* callback); |
| 45 void CheckDownloadHash(const std::string& hash, HashDoneCallback* callback); | 46 void CheckDownloadHash(const std::string& hash, HashDoneCallback* callback); |
| 46 | 47 |
| 47 private: | 48 private: |
| 48 // Call SafeBrowsingService on IO thread to verify the download URL or | 49 // Call SafeBrowsingService on IO thread to verify the download URL or |
| 49 // hash of downloaded file. | 50 // hash of downloaded file. |
| 50 void CheckDownloadUrlOnIOThread(const std::vector<GURL>& url_chain); | 51 void CheckDownloadUrlOnIOThread(const std::vector<GURL>& url_chain); |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 int32 download_id_; | 104 int32 download_id_; |
| 104 scoped_refptr<SafeBrowsingService> sb_service_; | 105 scoped_refptr<SafeBrowsingService> sb_service_; |
| 105 | 106 |
| 106 // These URLs are used to report malware to safe browsing service. | 107 // These URLs are used to report malware to safe browsing service. |
| 107 std::vector<GURL> url_chain_; | 108 std::vector<GURL> url_chain_; |
| 108 GURL referrer_url_; | 109 GURL referrer_url_; |
| 109 | 110 |
| 110 // When a safebrowsing check starts, for stats purpose. | 111 // When a safebrowsing check starts, for stats purpose. |
| 111 base::TimeTicks start_time_; | 112 base::TimeTicks start_time_; |
| 112 | 113 |
| 114 // Whether the profile from which this client was created has enabled the |
| 115 // safe browsing service. |
| 116 bool safe_browsing_enabled_; |
| 117 |
| 113 DISALLOW_COPY_AND_ASSIGN(DownloadSBClient); | 118 DISALLOW_COPY_AND_ASSIGN(DownloadSBClient); |
| 114 }; | 119 }; |
| 115 | 120 |
| 116 #endif // CHROME_BROWSER_DOWNLOAD_DOWNLOAD_SAFE_BROWSING_CLIENT_H_ | 121 #endif // CHROME_BROWSER_DOWNLOAD_DOWNLOAD_SAFE_BROWSING_CLIENT_H_ |
| OLD | NEW |