| OLD | NEW | 
|    1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |    1 // Copyright (c) 2012 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  |   10  | 
|   11 #include <deque> |   11 #include <deque> | 
|   12 #include <map> |   12 #include <map> | 
|   13 #include <set> |   13 #include <set> | 
|   14 #include <string> |   14 #include <string> | 
|   15 #include <vector> |   15 #include <vector> | 
|   16  |   16  | 
|   17 #include "base/callback.h" |   17 #include "base/callback.h" | 
|   18 #include "base/file_path.h" |   18 #include "base/file_path.h" | 
|   19 #include "base/hash_tables.h" |   19 #include "base/hash_tables.h" | 
|   20 #include "base/memory/ref_counted.h" |   20 #include "base/memory/ref_counted.h" | 
|   21 #include "base/memory/scoped_ptr.h" |   21 #include "base/memory/scoped_ptr.h" | 
|   22 #include "base/observer_list.h" |   22 #include "base/observer_list.h" | 
|   23 #include "base/prefs/public/pref_observer.h" |  | 
|   24 #include "base/sequenced_task_runner_helpers.h" |   23 #include "base/sequenced_task_runner_helpers.h" | 
|   25 #include "base/synchronization/lock.h" |   24 #include "base/synchronization/lock.h" | 
|   26 #include "base/time.h" |   25 #include "base/time.h" | 
|   27 #include "chrome/browser/safe_browsing/protocol_manager.h" |   26 #include "chrome/browser/safe_browsing/protocol_manager.h" | 
|   28 #include "chrome/browser/safe_browsing/safe_browsing_util.h" |   27 #include "chrome/browser/safe_browsing/safe_browsing_util.h" | 
|   29 #include "content/public/browser/browser_thread.h" |   28 #include "content/public/browser/browser_thread.h" | 
|   30 #include "content/public/browser/notification_observer.h" |   29 #include "content/public/browser/notification_observer.h" | 
|   31 #include "content/public/browser/notification_registrar.h" |   30 #include "content/public/browser/notification_registrar.h" | 
|   32 #include "googleurl/src/gurl.h" |   31 #include "googleurl/src/gurl.h" | 
|   33  |   32  | 
| (...skipping 17 matching lines...) Expand all  Loading... | 
|   51 namespace safe_browsing { |   50 namespace safe_browsing { | 
|   52 class ClientSideDetectionService; |   51 class ClientSideDetectionService; | 
|   53 class DownloadProtectionService; |   52 class DownloadProtectionService; | 
|   54 } |   53 } | 
|   55  |   54  | 
|   56 // Construction needs to happen on the main thread. |   55 // Construction needs to happen on the main thread. | 
|   57 class SafeBrowsingService |   56 class SafeBrowsingService | 
|   58     : public base::RefCountedThreadSafe< |   57     : public base::RefCountedThreadSafe< | 
|   59           SafeBrowsingService, content::BrowserThread::DeleteOnUIThread>, |   58           SafeBrowsingService, content::BrowserThread::DeleteOnUIThread>, | 
|   60       public content::NotificationObserver, |   59       public content::NotificationObserver, | 
|   61       public PrefObserver, |  | 
|   62       public SafeBrowsingProtocolManagerDelegate { |   60       public SafeBrowsingProtocolManagerDelegate { | 
|   63  public: |   61  public: | 
|   64   class Client; |   62   class Client; | 
|   65   // Passed a boolean indicating whether or not it is OK to proceed with |   63   // Passed a boolean indicating whether or not it is OK to proceed with | 
|   66   // loading an URL. |   64   // loading an URL. | 
|   67   typedef base::Callback<void(bool /*proceed*/)> UrlCheckCallback; |   65   typedef base::Callback<void(bool /*proceed*/)> UrlCheckCallback; | 
|   68  |   66  | 
|   69   // Structure used to pass parameters between the IO and UI thread when |   67   // Structure used to pass parameters between the IO and UI thread when | 
|   70   // interacting with the blocking page. |   68   // interacting with the blocking page. | 
|   71   struct UnsafeResource { |   69   struct UnsafeResource { | 
| (...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  458                           int64 timeout_ms); |  456                           int64 timeout_ms); | 
|  459  |  457  | 
|  460   // Adds the given entry to the whitelist.  Called on the UI thread. |  458   // Adds the given entry to the whitelist.  Called on the UI thread. | 
|  461   void UpdateWhitelist(const UnsafeResource& resource); |  459   void UpdateWhitelist(const UnsafeResource& resource); | 
|  462  |  460  | 
|  463   // content::NotificationObserver override |  461   // content::NotificationObserver override | 
|  464   virtual void Observe(int type, |  462   virtual void Observe(int type, | 
|  465                        const content::NotificationSource& source, |  463                        const content::NotificationSource& source, | 
|  466                        const content::NotificationDetails& details) OVERRIDE; |  464                        const content::NotificationDetails& details) OVERRIDE; | 
|  467  |  465  | 
|  468   // PrefObserver override |  | 
|  469   virtual void OnPreferenceChanged(PrefServiceBase* service, |  | 
|  470                                    const std::string& pref_name) OVERRIDE; |  | 
|  471  |  | 
|  472   // SafeBrowsingProtocolManageDelegate override |  466   // SafeBrowsingProtocolManageDelegate override | 
|  473   virtual void ResetDatabase() OVERRIDE; |  467   virtual void ResetDatabase() OVERRIDE; | 
|  474   virtual void UpdateStarted() OVERRIDE; |  468   virtual void UpdateStarted() OVERRIDE; | 
|  475   virtual void UpdateFinished(bool success) OVERRIDE; |  469   virtual void UpdateFinished(bool success) OVERRIDE; | 
|  476   virtual void GetChunks(GetChunksCallback callback) OVERRIDE; |  470   virtual void GetChunks(GetChunksCallback callback) OVERRIDE; | 
|  477   virtual void AddChunks(const std::string& list, SBChunkList* chunks) OVERRIDE; |  471   virtual void AddChunks(const std::string& list, SBChunkList* chunks) OVERRIDE; | 
|  478   virtual void DeleteChunks( |  472   virtual void DeleteChunks( | 
|  479       std::vector<SBChunkDelete>* delete_chunks) OVERRIDE; |  473       std::vector<SBChunkDelete>* delete_chunks) OVERRIDE; | 
|  480  |  474  | 
|  481   // Starts following the safe browsing preference on |pref_service|. |  475   // Starts following the safe browsing preference on |pref_service|. | 
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  592 class SafeBrowsingServiceFactory { |  586 class SafeBrowsingServiceFactory { | 
|  593  public: |  587  public: | 
|  594   SafeBrowsingServiceFactory() { } |  588   SafeBrowsingServiceFactory() { } | 
|  595   virtual ~SafeBrowsingServiceFactory() { } |  589   virtual ~SafeBrowsingServiceFactory() { } | 
|  596   virtual SafeBrowsingService* CreateSafeBrowsingService() = 0; |  590   virtual SafeBrowsingService* CreateSafeBrowsingService() = 0; | 
|  597  private: |  591  private: | 
|  598   DISALLOW_COPY_AND_ASSIGN(SafeBrowsingServiceFactory); |  592   DISALLOW_COPY_AND_ASSIGN(SafeBrowsingServiceFactory); | 
|  599 }; |  593 }; | 
|  600  |  594  | 
|  601 #endif  // CHROME_BROWSER_SAFE_BROWSING_SAFE_BROWSING_SERVICE_H_ |  595 #endif  // CHROME_BROWSER_SAFE_BROWSING_SAFE_BROWSING_SERVICE_H_ | 
| OLD | NEW |