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

Side by Side Diff: chrome/browser/safe_browsing/client_side_detection_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, 2 months 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 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 11 matching lines...) Expand all
22 #include <vector> 22 #include <vector>
23 23
24 #include "base/basictypes.h" 24 #include "base/basictypes.h"
25 #include "base/callback_old.h" 25 #include "base/callback_old.h"
26 #include "base/gtest_prod_util.h" 26 #include "base/gtest_prod_util.h"
27 #include "base/memory/linked_ptr.h" 27 #include "base/memory/linked_ptr.h"
28 #include "base/memory/ref_counted.h" 28 #include "base/memory/ref_counted.h"
29 #include "base/memory/scoped_ptr.h" 29 #include "base/memory/scoped_ptr.h"
30 #include "base/task.h" 30 #include "base/task.h"
31 #include "base/time.h" 31 #include "base/time.h"
32 #include "content/common/net/url_fetcher.h" 32 #include "content/public/common/url_fetcher_delegate.h"
33 #include "content/public/browser/notification_observer.h" 33 #include "content/public/browser/notification_observer.h"
34 #include "content/public/browser/notification_registrar.h" 34 #include "content/public/browser/notification_registrar.h"
35 #include "googleurl/src/gurl.h" 35 #include "googleurl/src/gurl.h"
36 #include "net/base/net_util.h" 36 #include "net/base/net_util.h"
37 37
38 class RenderProcessHost; 38 class RenderProcessHost;
39 class SafeBrowsingService; 39 class SafeBrowsingService;
40 40
41 namespace base { 41 namespace base {
42 class TimeDelta; 42 class TimeDelta;
43 } 43 }
44 44
45 namespace net { 45 namespace net {
46 class URLRequestContextGetter; 46 class URLRequestContextGetter;
47 class URLRequestStatus; 47 class URLRequestStatus;
48 typedef std::vector<std::string> ResponseCookies;
48 } // namespace net 49 } // namespace net
49 50
50 namespace safe_browsing { 51 namespace safe_browsing {
51 class ClientPhishingRequest; 52 class ClientPhishingRequest;
52 class ClientPhishingResponse; 53 class ClientPhishingResponse;
53 class ClientSideModel; 54 class ClientSideModel;
54 55
55 class ClientSideDetectionService : public URLFetcher::Delegate, 56 class ClientSideDetectionService : public content::URLFetcherDelegate,
56 public content::NotificationObserver { 57 public content::NotificationObserver {
57 public: 58 public:
58 typedef Callback2<GURL /* phishing URL */, bool /* is phishing */>::Type 59 typedef Callback2<GURL /* phishing URL */, bool /* is phishing */>::Type
59 ClientReportPhishingRequestCallback; 60 ClientReportPhishingRequestCallback;
60 61
61 virtual ~ClientSideDetectionService(); 62 virtual ~ClientSideDetectionService();
62 63
63 // Creates a client-side detection service. The service is initially 64 // Creates a client-side detection service. The service is initially
64 // disabled, use SetEnabledAndRefreshState() to start it. The caller takes 65 // disabled, use SetEnabledAndRefreshState() to start it. The caller takes
65 // ownership of the object. This function may return NULL. 66 // ownership of the object. This function may return NULL.
66 static ClientSideDetectionService* Create( 67 static ClientSideDetectionService* Create(
67 net::URLRequestContextGetter* request_context_getter); 68 net::URLRequestContextGetter* request_context_getter);
68 69
69 // 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.
70 // This is usually called by the SafeBrowsingService, which tracks whether 71 // This is usually called by the SafeBrowsingService, which tracks whether
71 // any profile uses these services at all. Disabling cancels any pending 72 // any profile uses these services at all. Disabling cancels any pending
72 // requests; existing ClientSideDetectionHosts will have their callbacks 73 // requests; existing ClientSideDetectionHosts will have their callbacks
73 // called with "false" verdicts. Enabling starts downloading the model after 74 // called with "false" verdicts. Enabling starts downloading the model after
74 // a delay. In all cases, each render process is updated to match the state 75 // a delay. In all cases, each render process is updated to match the state
75 // of the SafeBrowsing preference for that profile. 76 // of the SafeBrowsing preference for that profile.
76 void SetEnabledAndRefreshState(bool enabled); 77 void SetEnabledAndRefreshState(bool enabled);
77 78
78 bool enabled() const { 79 bool enabled() const {
79 return enabled_; 80 return enabled_;
80 } 81 }
81 82
82 // From the URLFetcher::Delegate interface. 83 // From the content::URLFetcherDelegate interface.
83 virtual void OnURLFetchComplete(const URLFetcher* source, 84 virtual void OnURLFetchComplete(const URLFetcher* source) OVERRIDE;
84 const GURL& url,
85 const net::URLRequestStatus& status,
86 int response_code,
87 const net::ResponseCookies& cookies,
88 const std::string& data) OVERRIDE;
89 85
90 // content::NotificationObserver overrides: 86 // content::NotificationObserver overrides:
91 virtual void Observe(int type, 87 virtual void Observe(int type,
92 const content::NotificationSource& source, 88 const content::NotificationSource& source,
93 const content::NotificationDetails& details) OVERRIDE; 89 const content::NotificationDetails& details) OVERRIDE;
94 90
95 // Sends a request to the SafeBrowsing servers with the ClientPhishingRequest. 91 // Sends a request to the SafeBrowsing servers with the ClientPhishingRequest.
96 // 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
97 // 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
98 // 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
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
301 // this map to speed up lookups. 297 // this map to speed up lookups.
302 BadSubnetMap bad_subnets_; 298 BadSubnetMap bad_subnets_;
303 299
304 content::NotificationRegistrar registrar_; 300 content::NotificationRegistrar registrar_;
305 301
306 DISALLOW_COPY_AND_ASSIGN(ClientSideDetectionService); 302 DISALLOW_COPY_AND_ASSIGN(ClientSideDetectionService);
307 }; 303 };
308 } // namepsace safe_browsing 304 } // namepsace safe_browsing
309 305
310 #endif // CHROME_BROWSER_SAFE_BROWSING_CLIENT_SIDE_DETECTION_SERVICE_H_ 306 #endif // CHROME_BROWSER_SAFE_BROWSING_CLIENT_SIDE_DETECTION_SERVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698