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 } |
28 | 28 |
29 namespace net { | |
30 class SSLInfo; | |
31 } | |
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 |
38 // interacting with the blocking page. | 42 // interacting with the blocking page. |
(...skipping 78 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 void ReportInvalidCertificateChain(const std::string& hostname, | |
mattm
2015/03/23 05:31:17
Add comment
estark
2015/03/23 16:42:13
Done.
| |
132 const net::SSLInfo& ssl_info, | |
133 const base::Closure& callback); | |
134 | |
127 // Add and remove observers. These methods must be invoked on the UI thread. | 135 // Add and remove observers. These methods must be invoked on the UI thread. |
128 void AddObserver(Observer* observer); | 136 void AddObserver(Observer* observer); |
129 void RemoveObserver(Observer* remove); | 137 void RemoveObserver(Observer* remove); |
130 | 138 |
131 protected: | 139 protected: |
132 virtual ~SafeBrowsingUIManager(); | 140 virtual ~SafeBrowsingUIManager(); |
133 | 141 |
134 private: | 142 private: |
135 friend class base::RefCountedThreadSafe<SafeBrowsingUIManager>; | 143 friend class base::RefCountedThreadSafe<SafeBrowsingUIManager>; |
136 | 144 |
137 // Used for whitelisting a render view when the user ignores our warning. | 145 // Used for whitelisting a render view when the user ignores our warning. |
138 struct WhiteListedEntry; | 146 struct WhiteListedEntry; |
139 | 147 |
140 // Call protocol manager on IO thread to report hits of unsafe contents. | 148 // Call protocol manager on IO thread to report hits of unsafe contents. |
141 void ReportSafeBrowsingHitOnIOThread(const GURL& malicious_url, | 149 void ReportSafeBrowsingHitOnIOThread(const GURL& malicious_url, |
142 const GURL& page_url, | 150 const GURL& page_url, |
143 const GURL& referrer_url, | 151 const GURL& referrer_url, |
144 bool is_subresource, | 152 bool is_subresource, |
145 SBThreatType threat_type, | 153 SBThreatType threat_type, |
146 const std::string& post_data); | 154 const std::string& post_data); |
147 | 155 |
156 void ReportInvalidCertificateChainOnIOThread(const std::string& hostname, | |
157 const net::SSLInfo& ssl_info); | |
158 | |
148 // Adds the given entry to the whitelist. Called on the UI thread. | 159 // Adds the given entry to the whitelist. Called on the UI thread. |
149 void UpdateWhitelist(const UnsafeResource& resource); | 160 void UpdateWhitelist(const UnsafeResource& resource); |
150 | 161 |
151 // Safebrowsing service. | 162 // Safebrowsing service. |
152 scoped_refptr<SafeBrowsingService> sb_service_; | 163 scoped_refptr<SafeBrowsingService> sb_service_; |
153 | 164 |
154 // Only access this whitelist from the UI thread. | 165 // Only access this whitelist from the UI thread. |
155 std::vector<WhiteListedEntry> white_listed_entries_; | 166 std::vector<WhiteListedEntry> white_listed_entries_; |
156 | 167 |
157 ObserverList<Observer> observer_list_; | 168 ObserverList<Observer> observer_list_; |
158 | 169 |
159 DISALLOW_COPY_AND_ASSIGN(SafeBrowsingUIManager); | 170 DISALLOW_COPY_AND_ASSIGN(SafeBrowsingUIManager); |
160 }; | 171 }; |
161 | 172 |
162 #endif // CHROME_BROWSER_SAFE_BROWSING_UI_MANAGER_H_ | 173 #endif // CHROME_BROWSER_SAFE_BROWSING_UI_MANAGER_H_ |
OLD | NEW |