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

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

Issue 8573018: Convert to base::Callback in safe_browsing client-side-detection code. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: 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
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 backends for 5 // Helper class which handles communication with the SafeBrowsing backends for
6 // client-side phishing detection. This class is used to fetch the client-side 6 // client-side phishing detection. This class is used to fetch the client-side
7 // model and send it to all renderers. This class is also used to send a ping 7 // model and send it to all renderers. This class is also used to send a ping
8 // back to Google to verify if a particular site is really phishing or not. 8 // back to Google to verify if a particular site is really phishing or not.
9 // 9 //
10 // This class is not thread-safe and expects all calls to be made on the UI 10 // This class is not thread-safe and expects all calls to be made on the UI
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 } // namespace net 49 } // namespace net
50 50
51 namespace safe_browsing { 51 namespace safe_browsing {
52 class ClientPhishingRequest; 52 class ClientPhishingRequest;
53 class ClientPhishingResponse; 53 class ClientPhishingResponse;
54 class ClientSideModel; 54 class ClientSideModel;
55 55
56 class ClientSideDetectionService : public content::URLFetcherDelegate, 56 class ClientSideDetectionService : public content::URLFetcherDelegate,
57 public content::NotificationObserver { 57 public content::NotificationObserver {
58 public: 58 public:
59 typedef Callback2<GURL /* phishing URL */, bool /* is phishing */>::Type 59 // void(GURL phishing_url, bool is_phishing).
60 ClientReportPhishingRequestCallback; 60 typedef base::Callback<void(GURL, bool)> ClientReportPhishingRequestCallback;
61 61
62 virtual ~ClientSideDetectionService(); 62 virtual ~ClientSideDetectionService();
63 63
64 // Creates a client-side detection service. The service is initially 64 // Creates a client-side detection service. The service is initially
65 // disabled, use SetEnabledAndRefreshState() to start it. The caller takes 65 // disabled, use SetEnabledAndRefreshState() to start it. The caller takes
66 // ownership of the object. This function may return NULL. 66 // ownership of the object. This function may return NULL.
67 static ClientSideDetectionService* Create( 67 static ClientSideDetectionService* Create(
68 net::URLRequestContextGetter* request_context_getter); 68 net::URLRequestContextGetter* request_context_getter);
69 69
70 // Enables or disables the service, and refreshes the state of all renderers. 70 // Enables or disables the service, and refreshes the state of all renderers.
(...skipping 21 matching lines...) Expand all
92 // The URL scheme of the |url()| in the request should be HTTP. This method 92 // The URL scheme of the |url()| in the request should be HTTP. This method
93 // takes ownership of the |verdict| as well as the |callback| and calls the 93 // takes ownership of the |verdict| as well as the |callback| and calls the
94 // the callback once the result has come back from the server or if an error 94 // the callback once the result has come back from the server or if an error
95 // occurs during the fetch. If the service is disabled or an error occurs 95 // occurs during the fetch. If the service is disabled or an error occurs
96 // the phishing verdict will always be false. The callback is always called 96 // the phishing verdict will always be false. The callback is always called
97 // after SendClientReportPhishingRequest() returns and on the same thread as 97 // after SendClientReportPhishingRequest() returns and on the same thread as
98 // SendClientReportPhishingRequest() was called. You may set |callback| to 98 // SendClientReportPhishingRequest() was called. You may set |callback| to
99 // NULL if you don't care about the server verdict. 99 // NULL if you don't care about the server verdict.
100 virtual void SendClientReportPhishingRequest( 100 virtual void SendClientReportPhishingRequest(
101 ClientPhishingRequest* verdict, 101 ClientPhishingRequest* verdict,
102 ClientReportPhishingRequestCallback* callback); 102 const ClientReportPhishingRequestCallback& callback);
103 103
104 // Returns true if the given IP address string falls within a private 104 // Returns true if the given IP address string falls within a private
105 // (unroutable) network block. Pages which are hosted on these IP addresses 105 // (unroutable) network block. Pages which are hosted on these IP addresses
106 // are exempt from client-side phishing detection. This is called by the 106 // are exempt from client-side phishing detection. This is called by the
107 // ClientSideDetectionHost prior to sending the renderer a 107 // ClientSideDetectionHost prior to sending the renderer a
108 // SafeBrowsingMsg_StartPhishingDetection IPC. 108 // SafeBrowsingMsg_StartPhishingDetection IPC.
109 // 109 //
110 // ip_address should be a dotted IPv4 address, or an unbracketed IPv6 110 // ip_address should be a dotted IPv4 address, or an unbracketed IPv6
111 // address. 111 // address.
112 virtual bool IsPrivateIPAddress(const std::string& ip_address) const; 112 virtual bool IsPrivateIPAddress(const std::string& ip_address) const;
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 static const int kClientModelFetchIntervalMs; 196 static const int kClientModelFetchIntervalMs;
197 static const int kInitialClientModelFetchDelayMs; 197 static const int kInitialClientModelFetchDelayMs;
198 static const base::TimeDelta kReportsInterval; 198 static const base::TimeDelta kReportsInterval;
199 static const base::TimeDelta kNegativeCacheInterval; 199 static const base::TimeDelta kNegativeCacheInterval;
200 static const base::TimeDelta kPositiveCacheInterval; 200 static const base::TimeDelta kPositiveCacheInterval;
201 201
202 // Starts sending the request to the client-side detection frontends. 202 // Starts sending the request to the client-side detection frontends.
203 // This method takes ownership of both pointers. 203 // This method takes ownership of both pointers.
204 void StartClientReportPhishingRequest( 204 void StartClientReportPhishingRequest(
205 ClientPhishingRequest* verdict, 205 ClientPhishingRequest* verdict,
206 ClientReportPhishingRequestCallback* callback); 206 const ClientReportPhishingRequestCallback& callback);
207 207
208 // Called by OnURLFetchComplete to handle the response from fetching the 208 // Called by OnURLFetchComplete to handle the response from fetching the
209 // model. 209 // model.
210 void HandleModelResponse(const content::URLFetcher* source, 210 void HandleModelResponse(const content::URLFetcher* source,
211 const GURL& url, 211 const GURL& url,
212 const net::URLRequestStatus& status, 212 const net::URLRequestStatus& status,
213 int response_code, 213 int response_code,
214 const net::ResponseCookies& cookies, 214 const net::ResponseCookies& cookies,
215 const std::string& data); 215 const std::string& data);
216 216
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
298 // this map to speed up lookups. 298 // this map to speed up lookups.
299 BadSubnetMap bad_subnets_; 299 BadSubnetMap bad_subnets_;
300 300
301 content::NotificationRegistrar registrar_; 301 content::NotificationRegistrar registrar_;
302 302
303 DISALLOW_COPY_AND_ASSIGN(ClientSideDetectionService); 303 DISALLOW_COPY_AND_ASSIGN(ClientSideDetectionService);
304 }; 304 };
305 } // namepsace safe_browsing 305 } // namepsace safe_browsing
306 306
307 #endif // CHROME_BROWSER_SAFE_BROWSING_CLIENT_SIDE_DETECTION_SERVICE_H_ 307 #endif // CHROME_BROWSER_SAFE_BROWSING_CLIENT_SIDE_DETECTION_SERVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698