| 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/hit_report.h" | 19 #include "chrome/browser/safe_browsing/hit_report.h" |
| 20 #include "chrome/browser/safe_browsing/safe_browsing_util.h" | 20 #include "chrome/browser/safe_browsing/safe_browsing_util.h" |
| 21 #include "content/public/browser/browser_thread.h" | 21 #include "content/public/browser/browser_thread.h" |
| 22 #include "url/gurl.h" | 22 #include "url/gurl.h" |
| 23 | 23 |
| 24 namespace base { | 24 namespace base { |
| 25 class Thread; | 25 class Thread; |
| 26 } // namespace base | 26 } // namespace base |
| 27 | 27 |
| 28 namespace content { |
| 29 class NavigationEntry; |
| 30 } // namespace content |
| 31 |
| 28 namespace net { | 32 namespace net { |
| 29 class SSLInfo; | 33 class SSLInfo; |
| 30 } // namespace net | 34 } // namespace net |
| 31 | 35 |
| 32 namespace safe_browsing { | 36 namespace safe_browsing { |
| 33 | 37 |
| 34 class SafeBrowsingService; | 38 class SafeBrowsingService; |
| 35 | 39 |
| 36 // Construction needs to happen on the main thread. | 40 // Construction needs to happen on the main thread. |
| 37 class SafeBrowsingUIManager | 41 class SafeBrowsingUIManager |
| 38 : public base::RefCountedThreadSafe<SafeBrowsingUIManager> { | 42 : public base::RefCountedThreadSafe<SafeBrowsingUIManager> { |
| 39 public: | 43 public: |
| 40 // Passed a boolean indicating whether or not it is OK to proceed with | 44 // Passed a boolean indicating whether or not it is OK to proceed with |
| 41 // loading an URL. | 45 // loading an URL. |
| 42 typedef base::Callback<void(bool /*proceed*/)> UrlCheckCallback; | 46 typedef base::Callback<void(bool /*proceed*/)> UrlCheckCallback; |
| 43 | 47 |
| 44 // Structure used to pass parameters between the IO and UI thread when | 48 // Structure used to pass parameters between the IO and UI thread when |
| 45 // interacting with the blocking page. | 49 // interacting with the blocking page. |
| 46 struct UnsafeResource { | 50 struct UnsafeResource { |
| 47 UnsafeResource(); | 51 UnsafeResource(); |
| 48 ~UnsafeResource(); | 52 ~UnsafeResource(); |
| 49 | 53 |
| 54 // Returns true if this UnsafeResource is a main frame load that was blocked |
| 55 // while the navigation is still pending. Note that a main frame hit may not |
| 56 // be blocking, eg. client side detection happens after the load is |
| 57 // committed. |
| 50 bool IsMainPageLoadBlocked() const; | 58 bool IsMainPageLoadBlocked() const; |
| 51 | 59 |
| 60 // Returns the NavigationEntry for this resource (for a main frame hit) or |
| 61 // for the page which contains this resource (for a subresource hit). |
| 62 // This method must only be called while the UnsafeResource is still |
| 63 // "valid". |
| 64 // I.e, |
| 65 // For MainPageLoadBlocked resources, it must not be called if the load |
| 66 // was aborted (going back or replaced with a different navigation), |
| 67 // or resumed (proceeded through warning or matched whitelist). |
| 68 // For non-MainPageLoadBlocked resources, it must not be called if any |
| 69 // other navigation has committed (whether by going back or unrelated |
| 70 // navigations), though a pending navigation is okay. |
| 71 content::NavigationEntry* GetNavigationEntryForResource() const; |
| 72 |
| 52 GURL url; | 73 GURL url; |
| 53 GURL original_url; | 74 GURL original_url; |
| 54 std::vector<GURL> redirect_urls; | 75 std::vector<GURL> redirect_urls; |
| 55 bool is_subresource; | 76 bool is_subresource; |
| 56 bool is_subframe; | 77 bool is_subframe; |
| 57 SBThreatType threat_type; | 78 SBThreatType threat_type; |
| 58 std::string threat_metadata; | 79 std::string threat_metadata; |
| 59 UrlCheckCallback callback; // This is called back on |callback_thread|. | 80 UrlCheckCallback callback; // This is called back on |callback_thread|. |
| 60 scoped_refptr<base::SingleThreadTaskRunner> callback_thread; | 81 scoped_refptr<base::SingleThreadTaskRunner> callback_thread; |
| 61 int render_process_host_id; | 82 int render_process_host_id; |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 152 scoped_refptr<SafeBrowsingService> sb_service_; | 173 scoped_refptr<SafeBrowsingService> sb_service_; |
| 153 | 174 |
| 154 base::ObserverList<Observer> observer_list_; | 175 base::ObserverList<Observer> observer_list_; |
| 155 | 176 |
| 156 DISALLOW_COPY_AND_ASSIGN(SafeBrowsingUIManager); | 177 DISALLOW_COPY_AND_ASSIGN(SafeBrowsingUIManager); |
| 157 }; | 178 }; |
| 158 | 179 |
| 159 } // namespace safe_browsing | 180 } // namespace safe_browsing |
| 160 | 181 |
| 161 #endif // CHROME_BROWSER_SAFE_BROWSING_UI_MANAGER_H_ | 182 #endif // CHROME_BROWSER_SAFE_BROWSING_UI_MANAGER_H_ |
| OLD | NEW |