Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(80)

Side by Side Diff: chrome/browser/safe_browsing/download_protection_service.h

Issue 8373021: Convert URLFetcher::Delegates to use an interface in content/public/common. Also remove the old U... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: sync and remove unncessary forward declares Created 9 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 // Helper class which handles communication with the SafeBrowsing servers for 5 // Helper class which handles communication with the SafeBrowsing servers for
6 // improved binary download protection. 6 // improved binary download protection.
7 7
8 #ifndef CHROME_BROWSER_SAFE_BROWSING_DOWNLOAD_PROTECTION_SERVICE_H_ 8 #ifndef CHROME_BROWSER_SAFE_BROWSING_DOWNLOAD_PROTECTION_SERVICE_H_
9 #define CHROME_BROWSER_SAFE_BROWSING_DOWNLOAD_PROTECTION_SERVICE_H_ 9 #define CHROME_BROWSER_SAFE_BROWSING_DOWNLOAD_PROTECTION_SERVICE_H_
10 #pragma once 10 #pragma once
11 11
12 #include <map> 12 #include <map>
13 #include <string> 13 #include <string>
14 #include <vector> 14 #include <vector>
15 15
16 #include "base/basictypes.h" 16 #include "base/basictypes.h"
17 #include "base/callback.h" 17 #include "base/callback.h"
18 #include "base/gtest_prod_util.h" 18 #include "base/gtest_prod_util.h"
19 #include "base/memory/ref_counted.h" 19 #include "base/memory/ref_counted.h"
20 #include "base/memory/scoped_ptr.h" 20 #include "base/memory/scoped_ptr.h"
21 #include "base/time.h" 21 #include "base/time.h"
22 #include "content/common/net/url_fetcher.h" 22 #include "content/public/common/url_fetcher_delegate.h"
23 #include "googleurl/src/gurl.h" 23 #include "googleurl/src/gurl.h"
24 24
25 namespace net { 25 namespace net {
26 class URLRequestContextGetter; 26 class URLRequestContextGetter;
27 class URLRequestStatus; 27 class URLRequestStatus;
28 } // namespace net 28 } // namespace net
29 class SafeBrowsingService; 29 class SafeBrowsingService;
30 30
31 namespace safe_browsing { 31 namespace safe_browsing {
32 32
33 // This class provides an asynchronous API to check whether a particular 33 // This class provides an asynchronous API to check whether a particular
34 // client download is malicious or not. 34 // client download is malicious or not.
35 class DownloadProtectionService 35 class DownloadProtectionService
36 : public base::RefCountedThreadSafe<DownloadProtectionService>, 36 : public base::RefCountedThreadSafe<DownloadProtectionService>,
37 public URLFetcher::Delegate { 37 public content::URLFetcherDelegate {
38 public: 38 public:
39 // TODO(noelutz): we're missing some fields here: filename to get 39 // TODO(noelutz): we're missing some fields here: filename to get
40 // the signature, server IPs, tab URL redirect chain, ... 40 // the signature, server IPs, tab URL redirect chain, ...
41 struct DownloadInfo { 41 struct DownloadInfo {
42 std::vector<GURL> download_url_chain; 42 std::vector<GURL> download_url_chain;
43 GURL referrer_url; 43 GURL referrer_url;
44 std::string sha256_hash; 44 std::string sha256_hash;
45 int64 total_bytes; 45 int64 total_bytes;
46 bool user_initiated; 46 bool user_initiated;
47 DownloadInfo(); 47 DownloadInfo();
(...skipping 10 matching lines...) Expand all
58 // Callback type which is invoked once the download request is done. 58 // Callback type which is invoked once the download request is done.
59 typedef base::Callback<void(DownloadCheckResult)> CheckDownloadCallback; 59 typedef base::Callback<void(DownloadCheckResult)> CheckDownloadCallback;
60 60
61 // Creates a download service. The service is initially disabled. You need 61 // Creates a download service. The service is initially disabled. You need
62 // to call SetEnabled() to start it. We keep scoped references to both of 62 // to call SetEnabled() to start it. We keep scoped references to both of
63 // these objects. 63 // these objects.
64 DownloadProtectionService( 64 DownloadProtectionService(
65 SafeBrowsingService* sb_service, 65 SafeBrowsingService* sb_service,
66 net::URLRequestContextGetter* request_context_getter); 66 net::URLRequestContextGetter* request_context_getter);
67 67
68 // From the URLFetcher::Delegate interface. 68 // From the content::URLFetcherDelegate interface.
69 virtual void OnURLFetchComplete(const URLFetcher* source, 69 virtual void OnURLFetchComplete(const URLFetcher* source) OVERRIDE;
70 const GURL& url,
71 const net::URLRequestStatus& status,
72 int response_code,
73 const net::ResponseCookies& cookies,
74 const std::string& data) OVERRIDE;
75 70
76 // Checks whether the given client download is likely to be 71 // Checks whether the given client download is likely to be
77 // malicious or not. If this method returns true it means the 72 // malicious or not. If this method returns true it means the
78 // download is safe or we're unable to tell whether it is safe or 73 // download is safe or we're unable to tell whether it is safe or
79 // not. In this case the callback will never be called. If this 74 // not. In this case the callback will never be called. If this
80 // method returns false we will asynchronously check whether the 75 // method returns false we will asynchronously check whether the
81 // download is safe and call the callback when we have the response. 76 // download is safe and call the callback when we have the response.
82 // This method should be called on the UI thread. The callback will 77 // This method should be called on the UI thread. The callback will
83 // be called on the UI thread and will always be called asynchronously. 78 // be called on the UI thread and will always be called asynchronously.
84 virtual bool CheckClientDownload(const DownloadInfo& info, 79 virtual bool CheckClientDownload(const DownloadInfo& info,
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 std::map<const URLFetcher*, CheckDownloadCallback> download_requests_; 148 std::map<const URLFetcher*, CheckDownloadCallback> download_requests_;
154 149
155 // Keeps track of the state of the service. 150 // Keeps track of the state of the service.
156 bool enabled_; 151 bool enabled_;
157 152
158 DISALLOW_COPY_AND_ASSIGN(DownloadProtectionService); 153 DISALLOW_COPY_AND_ASSIGN(DownloadProtectionService);
159 }; 154 };
160 } // namespace safe_browsing 155 } // namespace safe_browsing
161 156
162 #endif // CHROME_BROWSER_SAFE_BROWSING_DOWNLOAD_PROTECTION_SERVICE_H_ 157 #endif // CHROME_BROWSER_SAFE_BROWSING_DOWNLOAD_PROTECTION_SERVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698