| 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_UI_MANAGER_H_ | 8 #ifndef CHROME_BROWSER_SAFE_BROWSING_UI_MANAGER_H_ |
| 9 #define CHROME_BROWSER_SAFE_BROWSING_UI_MANAGER_H_ | 9 #define CHROME_BROWSER_SAFE_BROWSING_UI_MANAGER_H_ |
| 10 | 10 |
| 11 #include <string> | 11 #include <string> |
| 12 #include <vector> | 12 #include <vector> |
| 13 | 13 |
| 14 #include "base/callback.h" | 14 #include "base/callback.h" |
| 15 #include "base/memory/ref_counted.h" | 15 #include "base/memory/ref_counted.h" |
| 16 #include "base/memory/scoped_ptr.h" | 16 #include "base/memory/scoped_ptr.h" |
| 17 #include "base/observer_list.h" | 17 #include "base/observer_list.h" |
| 18 #include "base/time/time.h" | 18 #include "base/time/time.h" |
| 19 #include "chrome/browser/safe_browsing/safe_browsing_util.h" | 19 #include "chrome/browser/safe_browsing/safe_browsing_util.h" |
| 20 #include "content/public/browser/notification_observer.h" | 20 #include "content/public/browser/notification_observer.h" |
| 21 #include "url/gurl.h" | 21 #include "url/gurl.h" |
| 22 | 22 |
| 23 class SafeBrowsingService; | 23 class SafeBrowsingService; |
| 24 | 24 |
| 25 namespace base { | 25 namespace base { |
| 26 class Thread; | 26 class Thread; |
| 27 } | 27 } // namespace base |
| 28 |
| 29 namespace net { |
| 30 class SSLInfo; |
| 31 } // namespace net |
| 28 | 32 |
| 29 // Construction needs to happen on the main thread. | 33 // Construction needs to happen on the main thread. |
| 30 class SafeBrowsingUIManager | 34 class SafeBrowsingUIManager |
| 31 : public base::RefCountedThreadSafe<SafeBrowsingUIManager> { | 35 : public base::RefCountedThreadSafe<SafeBrowsingUIManager> { |
| 32 public: | 36 public: |
| 33 // Passed a boolean indicating whether or not it is OK to proceed with | 37 // Passed a boolean indicating whether or not it is OK to proceed with |
| 34 // loading an URL. | 38 // loading an URL. |
| 35 typedef base::Callback<void(bool /*proceed*/)> UrlCheckCallback; | 39 typedef base::Callback<void(bool /*proceed*/)> UrlCheckCallback; |
| 36 | 40 |
| 37 // Structure used to pass parameters between the IO and UI thread when | 41 // Structure used to pass parameters between the IO and UI thread when |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 117 // Report hits to the unsafe contents (malware, phishing, unsafe download URL) | 121 // Report hits to the unsafe contents (malware, phishing, unsafe download URL) |
| 118 // to the server. Can only be called on UI thread. If |post_data| is | 122 // to the server. Can only be called on UI thread. If |post_data| is |
| 119 // non-empty, the request will be sent as a POST instead of a GET. | 123 // non-empty, the request will be sent as a POST instead of a GET. |
| 120 virtual void ReportSafeBrowsingHit(const GURL& malicious_url, | 124 virtual void ReportSafeBrowsingHit(const GURL& malicious_url, |
| 121 const GURL& page_url, | 125 const GURL& page_url, |
| 122 const GURL& referrer_url, | 126 const GURL& referrer_url, |
| 123 bool is_subresource, | 127 bool is_subresource, |
| 124 SBThreatType threat_type, | 128 SBThreatType threat_type, |
| 125 const std::string& post_data); | 129 const std::string& post_data); |
| 126 | 130 |
| 131 // Report an invalid TLS/SSL certificate chain to the server. Can only |
| 132 // be called on UI thread. |
| 133 void ReportInvalidCertificateChain(const std::string& hostname, |
| 134 const net::SSLInfo& ssl_info, |
| 135 const base::Closure& callback); |
| 136 |
| 127 // Add and remove observers. These methods must be invoked on the UI thread. | 137 // Add and remove observers. These methods must be invoked on the UI thread. |
| 128 void AddObserver(Observer* observer); | 138 void AddObserver(Observer* observer); |
| 129 void RemoveObserver(Observer* remove); | 139 void RemoveObserver(Observer* remove); |
| 130 | 140 |
| 131 protected: | 141 protected: |
| 132 virtual ~SafeBrowsingUIManager(); | 142 virtual ~SafeBrowsingUIManager(); |
| 133 | 143 |
| 134 private: | 144 private: |
| 135 friend class base::RefCountedThreadSafe<SafeBrowsingUIManager>; | 145 friend class base::RefCountedThreadSafe<SafeBrowsingUIManager>; |
| 136 | 146 |
| 137 // Used for whitelisting a render view when the user ignores our warning. | 147 // Used for whitelisting a render view when the user ignores our warning. |
| 138 struct WhiteListedEntry; | 148 struct WhiteListedEntry; |
| 139 | 149 |
| 140 // Call protocol manager on IO thread to report hits of unsafe contents. | 150 // Call protocol manager on IO thread to report hits of unsafe contents. |
| 141 void ReportSafeBrowsingHitOnIOThread(const GURL& malicious_url, | 151 void ReportSafeBrowsingHitOnIOThread(const GURL& malicious_url, |
| 142 const GURL& page_url, | 152 const GURL& page_url, |
| 143 const GURL& referrer_url, | 153 const GURL& referrer_url, |
| 144 bool is_subresource, | 154 bool is_subresource, |
| 145 SBThreatType threat_type, | 155 SBThreatType threat_type, |
| 146 const std::string& post_data); | 156 const std::string& post_data); |
| 147 | 157 |
| 158 // Sends an invalid certificate chain report over the network. |
| 159 void ReportInvalidCertificateChainOnIOThread(const std::string& hostname, |
| 160 const net::SSLInfo& ssl_info); |
| 161 |
| 148 // Adds the given entry to the whitelist. Called on the UI thread. | 162 // Adds the given entry to the whitelist. Called on the UI thread. |
| 149 void UpdateWhitelist(const UnsafeResource& resource); | 163 void UpdateWhitelist(const UnsafeResource& resource); |
| 150 | 164 |
| 151 // Safebrowsing service. | 165 // Safebrowsing service. |
| 152 scoped_refptr<SafeBrowsingService> sb_service_; | 166 scoped_refptr<SafeBrowsingService> sb_service_; |
| 153 | 167 |
| 154 // Only access this whitelist from the UI thread. | 168 // Only access this whitelist from the UI thread. |
| 155 std::vector<WhiteListedEntry> white_listed_entries_; | 169 std::vector<WhiteListedEntry> white_listed_entries_; |
| 156 | 170 |
| 157 ObserverList<Observer> observer_list_; | 171 ObserverList<Observer> observer_list_; |
| 158 | 172 |
| 159 DISALLOW_COPY_AND_ASSIGN(SafeBrowsingUIManager); | 173 DISALLOW_COPY_AND_ASSIGN(SafeBrowsingUIManager); |
| 160 }; | 174 }; |
| 161 | 175 |
| 162 #endif // CHROME_BROWSER_SAFE_BROWSING_UI_MANAGER_H_ | 176 #endif // CHROME_BROWSER_SAFE_BROWSING_UI_MANAGER_H_ |
| OLD | NEW |