| 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/macros.h" | 15 #include "base/macros.h" |
| 16 #include "base/memory/ref_counted.h" | 16 #include "base/memory/ref_counted.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/permissions/permission_uma_util.h" | |
| 20 #include "components/safe_browsing_db/hit_report.h" | 19 #include "components/safe_browsing_db/hit_report.h" |
| 21 #include "components/safe_browsing_db/util.h" | 20 #include "components/safe_browsing_db/util.h" |
| 22 #include "content/public/browser/browser_thread.h" | 21 #include "content/public/browser/browser_thread.h" |
| 23 #include "content/public/browser/permission_type.h" | |
| 24 #include "url/gurl.h" | 22 #include "url/gurl.h" |
| 25 | 23 |
| 26 namespace base { | 24 namespace base { |
| 27 class Thread; | 25 class Thread; |
| 28 } // namespace base | 26 } // namespace base |
| 29 | 27 |
| 30 namespace content { | 28 namespace content { |
| 31 class NavigationEntry; | 29 class NavigationEntry; |
| 32 } // namespace content | 30 } // namespace content |
| 33 | 31 |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 143 // non-empty, the request will be sent as a POST instead of a GET. | 141 // non-empty, the request will be sent as a POST instead of a GET. |
| 144 // Will report only for UMA || is_extended_reporting. | 142 // Will report only for UMA || is_extended_reporting. |
| 145 virtual void MaybeReportSafeBrowsingHit( | 143 virtual void MaybeReportSafeBrowsingHit( |
| 146 const safe_browsing::HitReport& hit_report); | 144 const safe_browsing::HitReport& hit_report); |
| 147 | 145 |
| 148 // Report an invalid TLS/SSL certificate chain to the server. Can only | 146 // Report an invalid TLS/SSL certificate chain to the server. Can only |
| 149 // be called on UI thread. | 147 // be called on UI thread. |
| 150 void ReportInvalidCertificateChain(const std::string& serialized_report, | 148 void ReportInvalidCertificateChain(const std::string& serialized_report, |
| 151 const base::Closure& callback); | 149 const base::Closure& callback); |
| 152 | 150 |
| 153 // Report permission action to SafeBrowsing servers. Can only be called on UI | |
| 154 // thread. | |
| 155 void ReportPermissionAction(const GURL& origin, | |
| 156 content::PermissionType permission, | |
| 157 PermissionAction action); | |
| 158 | |
| 159 // Add and remove observers. These methods must be invoked on the UI thread. | 151 // Add and remove observers. These methods must be invoked on the UI thread. |
| 160 void AddObserver(Observer* observer); | 152 void AddObserver(Observer* observer); |
| 161 void RemoveObserver(Observer* remove); | 153 void RemoveObserver(Observer* remove); |
| 162 | 154 |
| 163 protected: | 155 protected: |
| 164 virtual ~SafeBrowsingUIManager(); | 156 virtual ~SafeBrowsingUIManager(); |
| 165 | 157 |
| 166 private: | 158 private: |
| 167 friend class base::RefCountedThreadSafe<SafeBrowsingUIManager>; | 159 friend class base::RefCountedThreadSafe<SafeBrowsingUIManager>; |
| 168 friend class SafeBrowsingUIManagerTest; | 160 friend class SafeBrowsingUIManagerTest; |
| 169 friend class TestSafeBrowsingUIManager; | 161 friend class TestSafeBrowsingUIManager; |
| 170 | 162 |
| 171 // Call protocol manager on IO thread to report hits of unsafe contents. | 163 // Call protocol manager on IO thread to report hits of unsafe contents. |
| 172 void ReportSafeBrowsingHitOnIOThread( | 164 void ReportSafeBrowsingHitOnIOThread( |
| 173 const safe_browsing::HitReport& hit_report); | 165 const safe_browsing::HitReport& hit_report); |
| 174 | 166 |
| 175 // Sends an invalid certificate chain report over the network. | 167 // Sends an invalid certificate chain report over the network. |
| 176 void ReportInvalidCertificateChainOnIOThread( | 168 void ReportInvalidCertificateChainOnIOThread( |
| 177 const std::string& serialized_report); | 169 const std::string& serialized_report); |
| 178 | 170 |
| 179 // Report permission action to SafeBrowsing servers. | |
| 180 void ReportPermissionActionOnIOThread(const GURL& origin, | |
| 181 content::PermissionType permission, | |
| 182 PermissionAction action); | |
| 183 | |
| 184 // Updates the whitelist state. Called on the UI thread. | 171 // Updates the whitelist state. Called on the UI thread. |
| 185 void AddToWhitelist(const UnsafeResource& resource); | 172 void AddToWhitelist(const UnsafeResource& resource); |
| 186 | 173 |
| 187 // Safebrowsing service. | 174 // Safebrowsing service. |
| 188 scoped_refptr<SafeBrowsingService> sb_service_; | 175 scoped_refptr<SafeBrowsingService> sb_service_; |
| 189 | 176 |
| 190 base::ObserverList<Observer> observer_list_; | 177 base::ObserverList<Observer> observer_list_; |
| 191 | 178 |
| 192 DISALLOW_COPY_AND_ASSIGN(SafeBrowsingUIManager); | 179 DISALLOW_COPY_AND_ASSIGN(SafeBrowsingUIManager); |
| 193 }; | 180 }; |
| 194 | 181 |
| 195 } // namespace safe_browsing | 182 } // namespace safe_browsing |
| 196 | 183 |
| 197 #endif // CHROME_BROWSER_SAFE_BROWSING_UI_MANAGER_H_ | 184 #endif // CHROME_BROWSER_SAFE_BROWSING_UI_MANAGER_H_ |
| OLD | NEW |