| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 #ifndef COMPONENTS_SAFE_BROWSING_BASE_UI_MANAGER_H_ | 5 #ifndef COMPONENTS_SAFE_BROWSING_BASE_UI_MANAGER_H_ |
| 6 #define COMPONENTS_SAFE_BROWSING_BASE_UI_MANAGER_H_ | 6 #define COMPONENTS_SAFE_BROWSING_BASE_UI_MANAGER_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 class BaseUIManager | 31 class BaseUIManager |
| 32 : public base::RefCountedThreadSafe<BaseUIManager> { | 32 : public base::RefCountedThreadSafe<BaseUIManager> { |
| 33 public: | 33 public: |
| 34 typedef security_interstitials::UnsafeResource UnsafeResource; | 34 typedef security_interstitials::UnsafeResource UnsafeResource; |
| 35 | 35 |
| 36 BaseUIManager(); | 36 BaseUIManager(); |
| 37 | 37 |
| 38 // Called to stop or shutdown operations on the io_thread. This may be called | 38 // Called to stop or shutdown operations on the io_thread. This may be called |
| 39 // multiple times during the life of the UIManager. Should be called | 39 // multiple times during the life of the UIManager. Should be called |
| 40 // on IO thread. If shutdown is true, the manager is disabled permanently. | 40 // on IO thread. If shutdown is true, the manager is disabled permanently. |
| 41 // This currently is a no-op in the base class. |
| 41 virtual void StopOnIOThread(bool shutdown); | 42 virtual void StopOnIOThread(bool shutdown); |
| 42 | 43 |
| 43 // Called on the UI thread to display an interstitial page. | 44 // Called on the UI thread to display an interstitial page. |
| 44 // |url| is the url of the resource that matches a safe browsing list. | 45 // |url| is the url of the resource that matches a safe browsing list. |
| 45 // If the request contained a chain of redirects, |url| is the last url | 46 // If the request contained a chain of redirects, |url| is the last url |
| 46 // in the chain, and |original_url| is the first one (the root of the | 47 // in the chain, and |original_url| is the first one (the root of the |
| 47 // chain). Otherwise, |original_url| = |url|. | 48 // chain). Otherwise, |original_url| = |url|. |
| 48 virtual void DisplayBlockingPage(const UnsafeResource& resource); | 49 virtual void DisplayBlockingPage(const UnsafeResource& resource); |
| 49 | 50 |
| 50 // Log the user perceived delay caused by SafeBrowsing. This delay is the time | 51 // Log the user perceived delay caused by SafeBrowsing. This delay is the time |
| 51 // delta starting from when we would have started reading data from the | 52 // delta starting from when we would have started reading data from the |
| 52 // network, and ending when the SafeBrowsing check completes indicating that | 53 // network, and ending when the SafeBrowsing check completes indicating that |
| 53 // the current page is 'safe'. | 54 // the current page is 'safe'. |
| 54 virtual void LogPauseDelay(base::TimeDelta time); | 55 virtual void LogPauseDelay(base::TimeDelta time); |
| 55 | 56 |
| 56 // Called on the IO thread by the ThreatDetails with the serialized | 57 // This is a no-op in the base class, but should be overridden to send threat |
| 57 // protocol buffer, so the service can send it over. | 58 // details. Called on the IO thread by the ThreatDetails with the serialized |
| 59 // protocol buffer. |
| 58 virtual void SendSerializedThreatDetails(const std::string& serialized); | 60 virtual void SendSerializedThreatDetails(const std::string& serialized); |
| 59 | 61 |
| 60 // Report hits to the unsafe contents (malware, phishing, unsafe download URL) | 62 // This is a no-op in the base class, but should be overridden to report hits |
| 61 // to the server. Can only be called on UI thread. If |post_data| is | 63 // to the unsafe contents (malware, phishing, unsafe download URL) |
| 62 // non-empty, the request will be sent as a POST instead of a GET. | 64 // to the server. Can only be called on UI thread. |
| 63 // Will report only for UMA || is_extended_reporting. | |
| 64 virtual void MaybeReportSafeBrowsingHit( | 65 virtual void MaybeReportSafeBrowsingHit( |
| 65 const safe_browsing::HitReport& hit_report); | 66 const safe_browsing::HitReport& hit_report); |
| 66 | 67 |
| 67 // A convenience wrapper method for IsUrlWhitelistedOrPendingForWebContents. | 68 // A convenience wrapper method for IsUrlWhitelistedOrPendingForWebContents. |
| 68 virtual bool IsWhitelisted(const UnsafeResource& resource); | 69 virtual bool IsWhitelisted(const UnsafeResource& resource); |
| 69 | 70 |
| 70 // Checks if we already displayed or are displaying an interstitial | 71 // Checks if we already displayed or are displaying an interstitial |
| 71 // for the top-level site |url| in a given WebContents. If | 72 // for the top-level site |url| in a given WebContents. If |
| 72 // |whitelist_only|, it returns true only if the user chose to ignore | 73 // |whitelist_only|, it returns true only if the user chose to ignore |
| 73 // the interstitial. Otherwise, it returns true if an interstitial for | 74 // the interstitial. Otherwise, it returns true if an interstitial for |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 | 111 |
| 111 protected: | 112 protected: |
| 112 virtual ~BaseUIManager(); | 113 virtual ~BaseUIManager(); |
| 113 | 114 |
| 114 // Updates the whitelist URL set for |web_contents|. Called on the UI thread. | 115 // Updates the whitelist URL set for |web_contents|. Called on the UI thread. |
| 115 void AddToWhitelistUrlSet(const GURL& whitelist_url, | 116 void AddToWhitelistUrlSet(const GURL& whitelist_url, |
| 116 content::WebContents* web_contents, | 117 content::WebContents* web_contents, |
| 117 bool is_pending, | 118 bool is_pending, |
| 118 SBThreatType threat_type); | 119 SBThreatType threat_type); |
| 119 | 120 |
| 120 // Call protocol manager on IO thread to report hits of unsafe contents. | 121 // This is a no-op that should be overridden to call protocol manager on IO |
| 122 // thread to report hits of unsafe contents. |
| 121 virtual void ReportSafeBrowsingHitOnIOThread( | 123 virtual void ReportSafeBrowsingHitOnIOThread( |
| 122 const safe_browsing::HitReport& hit_report); | 124 const safe_browsing::HitReport& hit_report); |
| 123 | 125 |
| 124 // Removes |whitelist_url| from the pending whitelist for | 126 // Removes |whitelist_url| from the pending whitelist for |
| 125 // |web_contents|. Called on the UI thread. | 127 // |web_contents|. Called on the UI thread. |
| 126 void RemoveFromPendingWhitelistUrlSet(const GURL& whitelist_url, | 128 void RemoveFromPendingWhitelistUrlSet(const GURL& whitelist_url, |
| 127 content::WebContents* web_contents); | 129 content::WebContents* web_contents); |
| 128 | 130 |
| 129 // Ensures that |web_contents| has its whitelist set in its userdata | 131 // Ensures that |web_contents| has its whitelist set in its userdata |
| 130 static void EnsureWhitelistCreated(content::WebContents* web_contents); | 132 static void EnsureWhitelistCreated(content::WebContents* web_contents); |
| 131 | 133 |
| 132 // Returns the URL that should be used in a WhitelistUrlSet for the given | 134 // Returns the URL that should be used in a WhitelistUrlSet for the given |
| 133 // |resource|. | 135 // |resource|. |
| 134 static GURL GetMainFrameWhitelistUrlForResource( | 136 static GURL GetMainFrameWhitelistUrlForResource( |
| 135 const security_interstitials::UnsafeResource& resource); | 137 const security_interstitials::UnsafeResource& resource); |
| 136 | 138 |
| 137 private: | 139 private: |
| 138 friend class base::RefCountedThreadSafe<BaseUIManager>; | 140 friend class base::RefCountedThreadSafe<BaseUIManager>; |
| 139 | 141 |
| 140 DISALLOW_COPY_AND_ASSIGN(BaseUIManager); | 142 DISALLOW_COPY_AND_ASSIGN(BaseUIManager); |
| 141 }; | 143 }; |
| 142 | 144 |
| 143 } // namespace safe_browsing | 145 } // namespace safe_browsing |
| 144 | 146 |
| 145 #endif // COMPONENTS_SAFE_BROWSING_BASE_UI_MANAGER_H_ | 147 #endif // COMPONENTS_SAFE_BROWSING_BASE_UI_MANAGER_H_ |
| OLD | NEW |