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

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

Issue 6014003: Intergration of the client-side phishing detection. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove comment Created 9 years, 10 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 can be used to get a file 6 // client-side phishing detection. This class can be used to get a file
7 // descriptor to the client-side phishing model and also to send a ping back to 7 // descriptor to the client-side phishing model and also to send a ping back to
8 // Google to verify if a particular site is really phishing or not. 8 // 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 GetModelFile() and 10 // This class is not thread-safe and expects all calls to GetModelFile() and
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 // same thread as GetModelFile() was called. 84 // same thread as GetModelFile() was called.
85 void GetModelFile(OpenModelDoneCallback* callback); 85 void GetModelFile(OpenModelDoneCallback* callback);
86 86
87 // Sends a request to the SafeBrowsing servers with the potentially phishing 87 // Sends a request to the SafeBrowsing servers with the potentially phishing
88 // URL and the client-side phishing score. The |phishing_url| scheme should 88 // URL and the client-side phishing score. The |phishing_url| scheme should
89 // be HTTP. This method takes ownership of the |callback| and calls it once 89 // be HTTP. This method takes ownership of the |callback| and calls it once
90 // the result has come back from the server or if an error occurs during the 90 // the result has come back from the server or if an error occurs during the
91 // fetch. If an error occurs the phishing verdict will always be false. The 91 // fetch. If an error occurs the phishing verdict will always be false. The
92 // callback is always called after SendClientReportPhishingRequest() returns 92 // callback is always called after SendClientReportPhishingRequest() returns
93 // and on the same thread as SendClientReportPhishingRequest() was called. 93 // and on the same thread as SendClientReportPhishingRequest() was called.
94 void SendClientReportPhishingRequest( 94 virtual void SendClientReportPhishingRequest(
95 const GURL& phishing_url, 95 const GURL& phishing_url,
96 double score, 96 double score,
97 ClientReportPhishingRequestCallback* callback); 97 ClientReportPhishingRequestCallback* callback);
98 98
99 protected:
100 // Use Create() method to create an instance of this object.
101 ClientSideDetectionService(const FilePath& model_path,
102 URLRequestContextGetter* request_context_getter);
103
99 private: 104 private:
100 friend class ClientSideDetectionServiceTest; 105 friend class ClientSideDetectionServiceTest;
101 friend class ClientSideDetectionServiceHooksTest; 106 friend class ClientSideDetectionServiceHooksTest;
102 class ShouldClassifyUrlRequest; 107 class ShouldClassifyUrlRequest;
103 108
104 enum ModelStatus { 109 enum ModelStatus {
105 // It's unclear whether or not the model was already fetched. 110 // It's unclear whether or not the model was already fetched.
106 UNKNOWN_STATUS, 111 UNKNOWN_STATUS,
107 // Model is fetched and is stored on disk. 112 // Model is fetched and is stored on disk.
108 READY_STATUS, 113 READY_STATUS,
(...skipping 11 matching lines...) Expand all
120 }; 125 };
121 typedef std::map<GURL, linked_ptr<CacheState> > PhishingCache; 126 typedef std::map<GURL, linked_ptr<CacheState> > PhishingCache;
122 127
123 static const char kClientReportPhishingUrl[]; 128 static const char kClientReportPhishingUrl[];
124 static const char kClientModelUrl[]; 129 static const char kClientModelUrl[];
125 static const int kMaxReportsPerInterval; 130 static const int kMaxReportsPerInterval;
126 static const base::TimeDelta kReportsInterval; 131 static const base::TimeDelta kReportsInterval;
127 static const base::TimeDelta kNegativeCacheInterval; 132 static const base::TimeDelta kNegativeCacheInterval;
128 static const base::TimeDelta kPositiveCacheInterval; 133 static const base::TimeDelta kPositiveCacheInterval;
129 134
130 // Use Create() method to create an instance of this object.
131 ClientSideDetectionService(const FilePath& model_path,
132 URLRequestContextGetter* request_context_getter);
133
134 // Sets the model status and invokes all the pending callbacks in 135 // Sets the model status and invokes all the pending callbacks in
135 // |open_callbacks_| with the current |model_file_| as parameter. 136 // |open_callbacks_| with the current |model_file_| as parameter.
136 void SetModelStatus(ModelStatus status); 137 void SetModelStatus(ModelStatus status);
137 138
138 // Called once the initial open() of the model file is done. If the file 139 // Called once the initial open() of the model file is done. If the file
139 // exists we're done and we can call all the pending callbacks. If the 140 // exists we're done and we can call all the pending callbacks. If the
140 // file doesn't exist this method will asynchronously fetch the model 141 // file doesn't exist this method will asynchronously fetch the model
141 // from the server by invoking StartFetchingModel(). 142 // from the server by invoking StartFetchingModel().
142 void OpenModelFileDone(base::PlatformFileError error_code, 143 void OpenModelFileDone(base::PlatformFileError error_code,
143 base::PassPlatformFile file, 144 base::PassPlatformFile file,
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
238 239
239 // Used to register for page load notifications. 240 // Used to register for page load notifications.
240 NotificationRegistrar registrar_; 241 NotificationRegistrar registrar_;
241 242
242 DISALLOW_COPY_AND_ASSIGN(ClientSideDetectionService); 243 DISALLOW_COPY_AND_ASSIGN(ClientSideDetectionService);
243 }; 244 };
244 245
245 } // namepsace safe_browsing 246 } // namepsace safe_browsing
246 247
247 #endif // CHROME_BROWSER_SAFE_BROWSING_CLIENT_SIDE_DETECTION_SERVICE_H_ 248 #endif // CHROME_BROWSER_SAFE_BROWSING_CLIENT_SIDE_DETECTION_SERVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698