| 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 // 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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 52 } // namespace net | 52 } // namespace net |
| 53 | 53 |
| 54 namespace safe_browsing { | 54 namespace safe_browsing { |
| 55 class ClientPhishingRequest; | 55 class ClientPhishingRequest; |
| 56 class ClientPhishingResponse; | 56 class ClientPhishingResponse; |
| 57 class ClientSideModel; | 57 class ClientSideModel; |
| 58 | 58 |
| 59 class ClientSideDetectionService : public content::URLFetcherDelegate, | 59 class ClientSideDetectionService : public content::URLFetcherDelegate, |
| 60 public content::NotificationObserver { | 60 public content::NotificationObserver { |
| 61 public: | 61 public: |
| 62 typedef Callback2<GURL /* phishing URL */, bool /* is phishing */>::Type | 62 // void(GURL phishing_url, bool is_phishing). |
| 63 ClientReportPhishingRequestCallback; | 63 typedef base::Callback<void(GURL, bool)> ClientReportPhishingRequestCallback; |
| 64 | 64 |
| 65 virtual ~ClientSideDetectionService(); | 65 virtual ~ClientSideDetectionService(); |
| 66 | 66 |
| 67 // Creates a client-side detection service. The service is initially | 67 // Creates a client-side detection service. The service is initially |
| 68 // disabled, use SetEnabledAndRefreshState() to start it. The caller takes | 68 // disabled, use SetEnabledAndRefreshState() to start it. The caller takes |
| 69 // ownership of the object. This function may return NULL. | 69 // ownership of the object. This function may return NULL. |
| 70 static ClientSideDetectionService* Create( | 70 static ClientSideDetectionService* Create( |
| 71 net::URLRequestContextGetter* request_context_getter); | 71 net::URLRequestContextGetter* request_context_getter); |
| 72 | 72 |
| 73 // Enables or disables the service, and refreshes the state of all renderers. | 73 // Enables or disables the service, and refreshes the state of all renderers. |
| (...skipping 21 matching lines...) Expand all Loading... |
| 95 // The URL scheme of the |url()| in the request should be HTTP. This method | 95 // The URL scheme of the |url()| in the request should be HTTP. This method |
| 96 // takes ownership of the |verdict| as well as the |callback| and calls the | 96 // takes ownership of the |verdict| as well as the |callback| and calls the |
| 97 // the callback once the result has come back from the server or if an error | 97 // the callback once the result has come back from the server or if an error |
| 98 // occurs during the fetch. If the service is disabled or an error occurs | 98 // occurs during the fetch. If the service is disabled or an error occurs |
| 99 // the phishing verdict will always be false. The callback is always called | 99 // the phishing verdict will always be false. The callback is always called |
| 100 // after SendClientReportPhishingRequest() returns and on the same thread as | 100 // after SendClientReportPhishingRequest() returns and on the same thread as |
| 101 // SendClientReportPhishingRequest() was called. You may set |callback| to | 101 // SendClientReportPhishingRequest() was called. You may set |callback| to |
| 102 // NULL if you don't care about the server verdict. | 102 // NULL if you don't care about the server verdict. |
| 103 virtual void SendClientReportPhishingRequest( | 103 virtual void SendClientReportPhishingRequest( |
| 104 ClientPhishingRequest* verdict, | 104 ClientPhishingRequest* verdict, |
| 105 ClientReportPhishingRequestCallback* callback); | 105 const ClientReportPhishingRequestCallback& callback); |
| 106 | 106 |
| 107 // Returns true if the given IP address string falls within a private | 107 // Returns true if the given IP address string falls within a private |
| 108 // (unroutable) network block. Pages which are hosted on these IP addresses | 108 // (unroutable) network block. Pages which are hosted on these IP addresses |
| 109 // are exempt from client-side phishing detection. This is called by the | 109 // are exempt from client-side phishing detection. This is called by the |
| 110 // ClientSideDetectionHost prior to sending the renderer a | 110 // ClientSideDetectionHost prior to sending the renderer a |
| 111 // SafeBrowsingMsg_StartPhishingDetection IPC. | 111 // SafeBrowsingMsg_StartPhishingDetection IPC. |
| 112 // | 112 // |
| 113 // ip_address should be a dotted IPv4 address, or an unbracketed IPv6 | 113 // ip_address should be a dotted IPv4 address, or an unbracketed IPv6 |
| 114 // address. | 114 // address. |
| 115 virtual bool IsPrivateIPAddress(const std::string& ip_address) const; | 115 virtual bool IsPrivateIPAddress(const std::string& ip_address) const; |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 199 static const int kClientModelFetchIntervalMs; | 199 static const int kClientModelFetchIntervalMs; |
| 200 static const int kInitialClientModelFetchDelayMs; | 200 static const int kInitialClientModelFetchDelayMs; |
| 201 static const base::TimeDelta kReportsInterval; | 201 static const base::TimeDelta kReportsInterval; |
| 202 static const base::TimeDelta kNegativeCacheInterval; | 202 static const base::TimeDelta kNegativeCacheInterval; |
| 203 static const base::TimeDelta kPositiveCacheInterval; | 203 static const base::TimeDelta kPositiveCacheInterval; |
| 204 | 204 |
| 205 // Starts sending the request to the client-side detection frontends. | 205 // Starts sending the request to the client-side detection frontends. |
| 206 // This method takes ownership of both pointers. | 206 // This method takes ownership of both pointers. |
| 207 void StartClientReportPhishingRequest( | 207 void StartClientReportPhishingRequest( |
| 208 ClientPhishingRequest* verdict, | 208 ClientPhishingRequest* verdict, |
| 209 ClientReportPhishingRequestCallback* callback); | 209 const ClientReportPhishingRequestCallback& callback); |
| 210 | 210 |
| 211 // Called by OnURLFetchComplete to handle the response from fetching the | 211 // Called by OnURLFetchComplete to handle the response from fetching the |
| 212 // model. | 212 // model. |
| 213 void HandleModelResponse(const content::URLFetcher* source, | 213 void HandleModelResponse(const content::URLFetcher* source, |
| 214 const GURL& url, | 214 const GURL& url, |
| 215 const net::URLRequestStatus& status, | 215 const net::URLRequestStatus& status, |
| 216 int response_code, | 216 int response_code, |
| 217 const net::ResponseCookies& cookies, | 217 const net::ResponseCookies& cookies, |
| 218 const std::string& data); | 218 const std::string& data); |
| 219 | 219 |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 301 // this map to speed up lookups. | 301 // this map to speed up lookups. |
| 302 BadSubnetMap bad_subnets_; | 302 BadSubnetMap bad_subnets_; |
| 303 | 303 |
| 304 content::NotificationRegistrar registrar_; | 304 content::NotificationRegistrar registrar_; |
| 305 | 305 |
| 306 DISALLOW_COPY_AND_ASSIGN(ClientSideDetectionService); | 306 DISALLOW_COPY_AND_ASSIGN(ClientSideDetectionService); |
| 307 }; | 307 }; |
| 308 } // namepsace safe_browsing | 308 } // namepsace safe_browsing |
| 309 | 309 |
| 310 #endif // CHROME_BROWSER_SAFE_BROWSING_CLIENT_SIDE_DETECTION_SERVICE_H_ | 310 #endif // CHROME_BROWSER_SAFE_BROWSING_CLIENT_SIDE_DETECTION_SERVICE_H_ |
| OLD | NEW |