OLD | NEW |
---|---|
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 // The Safe Browsing service is responsible for downloading anti-phishing and | 5 // The Safe Browsing service is responsible for downloading anti-phishing and |
6 // anti-malware tables and checking urls against them. | 6 // anti-malware tables and checking urls against them. |
7 | 7 |
8 #ifndef CHROME_BROWSER_SAFE_BROWSING_SAFE_BROWSING_SERVICE_H_ | 8 #ifndef CHROME_BROWSER_SAFE_BROWSING_SAFE_BROWSING_SERVICE_H_ |
9 #define CHROME_BROWSER_SAFE_BROWSING_SAFE_BROWSING_SERVICE_H_ | 9 #define CHROME_BROWSER_SAFE_BROWSING_SAFE_BROWSING_SERVICE_H_ |
10 #pragma once | 10 #pragma once |
11 | 11 |
12 #include <deque> | 12 #include <deque> |
13 #include <set> | 13 #include <set> |
14 #include <string> | 14 #include <string> |
15 #include <vector> | 15 #include <vector> |
16 | 16 |
17 #include "base/hash_tables.h" | 17 #include "base/hash_tables.h" |
18 #include "base/lock.h" | 18 #include "base/lock.h" |
19 #include "base/ref_counted.h" | 19 #include "base/ref_counted.h" |
20 #include "base/scoped_ptr.h" | 20 #include "base/scoped_ptr.h" |
21 #include "base/time.h" | 21 #include "base/time.h" |
22 #include "chrome/browser/safe_browsing/safe_browsing_util.h" | 22 #include "chrome/browser/safe_browsing/safe_browsing_util.h" |
23 #include "googleurl/src/gurl.h" | 23 #include "googleurl/src/gurl.h" |
24 #include "webkit/glue/resource_type.h" | 24 #include "webkit/glue/resource_type.h" |
25 | 25 |
26 class PrefService; | 26 class PrefService; |
27 class SafeBrowsingDatabase; | 27 class SafeBrowsingDatabase; |
28 class SafeBrowsingMalwareReport; | |
28 class SafeBrowsingProtocolManager; | 29 class SafeBrowsingProtocolManager; |
29 class URLRequestContextGetter; | 30 class URLRequestContextGetter; |
30 | 31 |
31 namespace base { | 32 namespace base { |
32 class Thread; | 33 class Thread; |
33 } | 34 } |
34 | 35 |
35 // Construction needs to happen on the main thread. | 36 // Construction needs to happen on the main thread. |
36 class SafeBrowsingService | 37 class SafeBrowsingService |
37 : public base::RefCountedThreadSafe<SafeBrowsingService> { | 38 : public base::RefCountedThreadSafe<SafeBrowsingService> { |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
167 | 168 |
168 // Called on the IO thread to reset the database. | 169 // Called on the IO thread to reset the database. |
169 void ResetDatabase(); | 170 void ResetDatabase(); |
170 | 171 |
171 // Log the user perceived delay caused by SafeBrowsing. This delay is the time | 172 // Log the user perceived delay caused by SafeBrowsing. This delay is the time |
172 // delta starting from when we would have started reading data from the | 173 // delta starting from when we would have started reading data from the |
173 // network, and ending when the SafeBrowsing check completes indicating that | 174 // network, and ending when the SafeBrowsing check completes indicating that |
174 // the current page is 'safe'. | 175 // the current page is 'safe'. |
175 void LogPauseDelay(base::TimeDelta time); | 176 void LogPauseDelay(base::TimeDelta time); |
176 | 177 |
178 // Send the given malware report. | |
179 virtual void SendMalwareReport( | |
lzheng
2010/11/30 23:14:49
Call this ReprotMalwareDetails and explain the dif
panayiotis
2010/12/01 22:34:52
Done.
| |
180 scoped_refptr<SafeBrowsingMalwareReport> report); | |
181 | |
182 protected: | |
183 virtual ~SafeBrowsingService(); // For the unittest. | |
184 | |
177 private: | 185 private: |
178 typedef std::set<SafeBrowsingCheck*> CurrentChecks; | 186 typedef std::set<SafeBrowsingCheck*> CurrentChecks; |
179 typedef std::vector<SafeBrowsingCheck*> GetHashRequestors; | 187 typedef std::vector<SafeBrowsingCheck*> GetHashRequestors; |
180 typedef base::hash_map<SBPrefix, GetHashRequestors> GetHashRequests; | 188 typedef base::hash_map<SBPrefix, GetHashRequestors> GetHashRequests; |
181 | 189 |
182 // Used for whitelisting a render view when the user ignores our warning. | 190 // Used for whitelisting a render view when the user ignores our warning. |
183 struct WhiteListedEntry; | 191 struct WhiteListedEntry; |
184 | 192 |
185 // Clients that we've queued up for checking later once the database is ready. | 193 // Clients that we've queued up for checking later once the database is ready. |
186 struct QueuedCheck { | 194 struct QueuedCheck { |
187 Client* client; | 195 Client* client; |
188 GURL url; | 196 GURL url; |
189 base::Time start; | 197 base::Time start; |
190 }; | 198 }; |
191 | 199 |
192 friend class base::RefCountedThreadSafe<SafeBrowsingService>; | 200 friend class base::RefCountedThreadSafe<SafeBrowsingService>; |
193 friend class SafeBrowsingServiceTest; | 201 friend class SafeBrowsingServiceTest; |
194 | 202 |
195 ~SafeBrowsingService(); | |
196 | |
197 // Called to initialize objects that are used on the io_thread. | 203 // Called to initialize objects that are used on the io_thread. |
198 void OnIOInitialize(const std::string& client_key, | 204 void OnIOInitialize(const std::string& client_key, |
199 const std::string& wrapped_key, | 205 const std::string& wrapped_key, |
200 URLRequestContextGetter* request_context_getter); | 206 URLRequestContextGetter* request_context_getter); |
201 | 207 |
202 // Called to shutdown operations on the io_thread. | 208 // Called to shutdown operations on the io_thread. |
203 void OnIOShutdown(); | 209 void OnIOShutdown(); |
204 | 210 |
205 // Returns whether |database_| exists and is accessible. | 211 // Returns whether |database_| exists and is accessible. |
206 bool DatabaseAvailable() const; | 212 bool DatabaseAvailable() const; |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
319 // Indicates if we're in the midst of trying to close the database. If this | 325 // Indicates if we're in the midst of trying to close the database. If this |
320 // is true, nothing on the IO thread should access the database. | 326 // is true, nothing on the IO thread should access the database. |
321 bool closing_database_; | 327 bool closing_database_; |
322 | 328 |
323 std::deque<QueuedCheck> queued_checks_; | 329 std::deque<QueuedCheck> queued_checks_; |
324 | 330 |
325 DISALLOW_COPY_AND_ASSIGN(SafeBrowsingService); | 331 DISALLOW_COPY_AND_ASSIGN(SafeBrowsingService); |
326 }; | 332 }; |
327 | 333 |
328 #endif // CHROME_BROWSER_SAFE_BROWSING_SAFE_BROWSING_SERVICE_H_ | 334 #endif // CHROME_BROWSER_SAFE_BROWSING_SAFE_BROWSING_SERVICE_H_ |
OLD | NEW |