| 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 // 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 |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 scoped_ptr<SBFullHash> full_hash; | 95 scoped_ptr<SBFullHash> full_hash; |
| 96 | 96 |
| 97 Client* client; | 97 Client* client; |
| 98 bool need_get_hash; | 98 bool need_get_hash; |
| 99 base::TimeTicks start; // When check was sent to SB service. | 99 base::TimeTicks start; // When check was sent to SB service. |
| 100 UrlCheckResult result; | 100 UrlCheckResult result; |
| 101 bool is_download; // If this check for download url or hash. | 101 bool is_download; // If this check for download url or hash. |
| 102 std::vector<SBPrefix> prefix_hits; | 102 std::vector<SBPrefix> prefix_hits; |
| 103 std::vector<SBFullHashResult> full_hits; | 103 std::vector<SBFullHashResult> full_hits; |
| 104 | 104 |
| 105 // Task to make the callback to safebrowsing clients in case | 105 // Vends weak pointers for TimeoutCallback(). If the response is |
| 106 // safebrowsing check takes too long to finish. Not owned by | 106 // received before the timeout fires, factory is destructed and |
| 107 // this class. | 107 // the timeout won't be fired. |
| 108 // TODO(lzheng): We should consider to use this time out check | 108 // TODO(lzheng): We should consider to use this time out check |
| 109 // for browsing too (instead of implementin in | 109 // for browsing too (instead of implementin in |
| 110 // safe_browsing_resource_handler.cc). | 110 // safe_browsing_resource_handler.cc). |
| 111 CancelableTask* timeout_task; | 111 scoped_ptr<base::WeakPtrFactory<SafeBrowsingService> > timeout_factory_; |
| 112 | 112 |
| 113 private: | 113 private: |
| 114 DISALLOW_COPY_AND_ASSIGN(SafeBrowsingCheck); | 114 DISALLOW_COPY_AND_ASSIGN(SafeBrowsingCheck); |
| 115 }; | 115 }; |
| 116 | 116 |
| 117 // Observer class can be used to get notified when a SafeBrowsing hit | 117 // Observer class can be used to get notified when a SafeBrowsing hit |
| 118 // was found. | 118 // was found. |
| 119 class Observer { | 119 class Observer { |
| 120 public: | 120 public: |
| 121 // The |resource| must not be accessed after OnSafeBrowsingHit returns. | 121 // The |resource| must not be accessed after OnSafeBrowsingHit returns. |
| (...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 451 void CheckDownloadHashDone(SafeBrowsingCheck* check); | 451 void CheckDownloadHashDone(SafeBrowsingCheck* check); |
| 452 | 452 |
| 453 // Helper function that calls safe browsing client and cleans up |checks_|. | 453 // Helper function that calls safe browsing client and cleans up |checks_|. |
| 454 void SafeBrowsingCheckDone(SafeBrowsingCheck* check); | 454 void SafeBrowsingCheckDone(SafeBrowsingCheck* check); |
| 455 | 455 |
| 456 // Helper function to set |check| with default values and start a safe | 456 // Helper function to set |check| with default values and start a safe |
| 457 // browsing check with timeout of |timeout_ms|. |task| will be called upon | 457 // browsing check with timeout of |timeout_ms|. |task| will be called upon |
| 458 // success, otherwise TimeoutCallback will be called. | 458 // success, otherwise TimeoutCallback will be called. |
| 459 void StartDownloadCheck(SafeBrowsingCheck* check, | 459 void StartDownloadCheck(SafeBrowsingCheck* check, |
| 460 Client* client, | 460 Client* client, |
| 461 CancelableTask* task, | 461 const base::Closure& task, |
| 462 int64 timeout_ms); | 462 int64 timeout_ms); |
| 463 | 463 |
| 464 // Adds the given entry to the whitelist. Called on the UI thread. | 464 // Adds the given entry to the whitelist. Called on the UI thread. |
| 465 void UpdateWhitelist(const UnsafeResource& resource); | 465 void UpdateWhitelist(const UnsafeResource& resource); |
| 466 | 466 |
| 467 // content::NotificationObserver override | 467 // content::NotificationObserver override |
| 468 virtual void Observe(int type, | 468 virtual void Observe(int type, |
| 469 const content::NotificationSource& source, | 469 const content::NotificationSource& source, |
| 470 const content::NotificationDetails& details) OVERRIDE; | 470 const content::NotificationDetails& details) OVERRIDE; |
| 471 | 471 |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 572 class SafeBrowsingServiceFactory { | 572 class SafeBrowsingServiceFactory { |
| 573 public: | 573 public: |
| 574 SafeBrowsingServiceFactory() { } | 574 SafeBrowsingServiceFactory() { } |
| 575 virtual ~SafeBrowsingServiceFactory() { } | 575 virtual ~SafeBrowsingServiceFactory() { } |
| 576 virtual SafeBrowsingService* CreateSafeBrowsingService() = 0; | 576 virtual SafeBrowsingService* CreateSafeBrowsingService() = 0; |
| 577 private: | 577 private: |
| 578 DISALLOW_COPY_AND_ASSIGN(SafeBrowsingServiceFactory); | 578 DISALLOW_COPY_AND_ASSIGN(SafeBrowsingServiceFactory); |
| 579 }; | 579 }; |
| 580 | 580 |
| 581 #endif // CHROME_BROWSER_SAFE_BROWSING_SAFE_BROWSING_SERVICE_H_ | 581 #endif // CHROME_BROWSER_SAFE_BROWSING_SAFE_BROWSING_SERVICE_H_ |
| OLD | NEW |