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 } // namespace base | 27 } // namespace base |
28 | 28 |
| 29 namespace chrome_browser_net { |
| 30 class CertLoggerRequest; |
| 31 } |
| 32 |
29 namespace net { | 33 namespace net { |
30 class SSLInfo; | 34 class SSLInfo; |
31 } // namespace net | 35 } // namespace net |
32 | 36 |
33 // Construction needs to happen on the main thread. | 37 // Construction needs to happen on the main thread. |
34 class SafeBrowsingUIManager | 38 class SafeBrowsingUIManager |
35 : public base::RefCountedThreadSafe<SafeBrowsingUIManager> { | 39 : public base::RefCountedThreadSafe<SafeBrowsingUIManager> { |
36 public: | 40 public: |
37 // Passed a boolean indicating whether or not it is OK to proceed with | 41 // Passed a boolean indicating whether or not it is OK to proceed with |
38 // loading an URL. | 42 // loading an URL. |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 // non-empty, the request will be sent as a POST instead of a GET. | 127 // non-empty, the request will be sent as a POST instead of a GET. |
124 virtual void ReportSafeBrowsingHit(const GURL& malicious_url, | 128 virtual void ReportSafeBrowsingHit(const GURL& malicious_url, |
125 const GURL& page_url, | 129 const GURL& page_url, |
126 const GURL& referrer_url, | 130 const GURL& referrer_url, |
127 bool is_subresource, | 131 bool is_subresource, |
128 SBThreatType threat_type, | 132 SBThreatType threat_type, |
129 const std::string& post_data); | 133 const std::string& post_data); |
130 | 134 |
131 // Report an invalid TLS/SSL certificate chain to the server. Can only | 135 // Report an invalid TLS/SSL certificate chain to the server. Can only |
132 // be called on UI thread. | 136 // be called on UI thread. |
133 void ReportInvalidCertificateChain(const std::string& hostname, | 137 void ReportInvalidCertificateChain( |
134 const net::SSLInfo& ssl_info, | 138 const chrome_browser_net::CertLoggerRequest& report, |
135 const base::Closure& callback); | 139 const base::Closure& callback); |
136 | 140 |
137 // Add and remove observers. These methods must be invoked on the UI thread. | 141 // Add and remove observers. These methods must be invoked on the UI thread. |
138 void AddObserver(Observer* observer); | 142 void AddObserver(Observer* observer); |
139 void RemoveObserver(Observer* remove); | 143 void RemoveObserver(Observer* remove); |
140 | 144 |
141 protected: | 145 protected: |
142 virtual ~SafeBrowsingUIManager(); | 146 virtual ~SafeBrowsingUIManager(); |
143 | 147 |
144 private: | 148 private: |
145 friend class base::RefCountedThreadSafe<SafeBrowsingUIManager>; | 149 friend class base::RefCountedThreadSafe<SafeBrowsingUIManager>; |
146 | 150 |
147 // Used for whitelisting a render view when the user ignores our warning. | 151 // Used for whitelisting a render view when the user ignores our warning. |
148 struct WhiteListedEntry; | 152 struct WhiteListedEntry; |
149 | 153 |
150 // Call protocol manager on IO thread to report hits of unsafe contents. | 154 // Call protocol manager on IO thread to report hits of unsafe contents. |
151 void ReportSafeBrowsingHitOnIOThread(const GURL& malicious_url, | 155 void ReportSafeBrowsingHitOnIOThread(const GURL& malicious_url, |
152 const GURL& page_url, | 156 const GURL& page_url, |
153 const GURL& referrer_url, | 157 const GURL& referrer_url, |
154 bool is_subresource, | 158 bool is_subresource, |
155 SBThreatType threat_type, | 159 SBThreatType threat_type, |
156 const std::string& post_data); | 160 const std::string& post_data); |
157 | 161 |
158 // Sends an invalid certificate chain report over the network. | 162 // Sends an invalid certificate chain report over the network. |
159 void ReportInvalidCertificateChainOnIOThread(const std::string& hostname, | 163 void ReportInvalidCertificateChainOnIOThread( |
160 const net::SSLInfo& ssl_info); | 164 const chrome_browser_net::CertLoggerRequest& report); |
161 | 165 |
162 // Adds the given entry to the whitelist. Called on the UI thread. | 166 // Adds the given entry to the whitelist. Called on the UI thread. |
163 void UpdateWhitelist(const UnsafeResource& resource); | 167 void UpdateWhitelist(const UnsafeResource& resource); |
164 | 168 |
165 // Safebrowsing service. | 169 // Safebrowsing service. |
166 scoped_refptr<SafeBrowsingService> sb_service_; | 170 scoped_refptr<SafeBrowsingService> sb_service_; |
167 | 171 |
168 // Only access this whitelist from the UI thread. | 172 // Only access this whitelist from the UI thread. |
169 std::vector<WhiteListedEntry> white_listed_entries_; | 173 std::vector<WhiteListedEntry> white_listed_entries_; |
170 | 174 |
171 ObserverList<Observer> observer_list_; | 175 ObserverList<Observer> observer_list_; |
172 | 176 |
173 DISALLOW_COPY_AND_ASSIGN(SafeBrowsingUIManager); | 177 DISALLOW_COPY_AND_ASSIGN(SafeBrowsingUIManager); |
174 }; | 178 }; |
175 | 179 |
176 #endif // CHROME_BROWSER_SAFE_BROWSING_UI_MANAGER_H_ | 180 #endif // CHROME_BROWSER_SAFE_BROWSING_UI_MANAGER_H_ |
OLD | NEW |