| 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 #ifndef CHROME_BROWSER_RENDERER_HOST_SAFE_BROWSING_RESOURCE_THROTTLE_H_ | 5 #ifndef CHROME_BROWSER_RENDERER_HOST_SAFE_BROWSING_RESOURCE_THROTTLE_H_ |
| 6 #define CHROME_BROWSER_RENDERER_HOST_SAFE_BROWSING_RESOURCE_THROTTLE_H_ | 6 #define CHROME_BROWSER_RENDERER_HOST_SAFE_BROWSING_RESOURCE_THROTTLE_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 void WillProcessResponse(bool* defer) override; | 79 void WillProcessResponse(bool* defer) override; |
| 80 | 80 |
| 81 const char* GetNameForLogging() const override; | 81 const char* GetNameForLogging() const override; |
| 82 | 82 |
| 83 // SafeBrowsingDabaseManager::Client implementation (called on IO thread): | 83 // SafeBrowsingDabaseManager::Client implementation (called on IO thread): |
| 84 void OnCheckBrowseUrlResult(const GURL& url, | 84 void OnCheckBrowseUrlResult(const GURL& url, |
| 85 SBThreatType result, | 85 SBThreatType result, |
| 86 const std::string& metadata) override; | 86 const std::string& metadata) override; |
| 87 | 87 |
| 88 protected: | 88 protected: |
| 89 enum DeferAtStartSetting { | 89 SafeBrowsingResourceThrottle(const net::URLRequest* request, |
| 90 DEFER_AT_START, | 90 content::ResourceType resource_type, |
| 91 DONT_DEFER_AT_START | 91 SafeBrowsingService* sb_service); |
| 92 }; | |
| 93 | |
| 94 SafeBrowsingResourceThrottle( | |
| 95 const net::URLRequest* request, | |
| 96 content::ResourceType resource_type, | |
| 97 SafeBrowsingService* sb_service, | |
| 98 DeferAtStartSetting defer_setting, | |
| 99 SafeBrowsingService::ResourceTypesToCheck types_to_check); | |
| 100 | 92 |
| 101 private: | 93 private: |
| 102 // Describes what phase of the check a throttle is in. | 94 // Describes what phase of the check a throttle is in. |
| 103 enum State { | 95 enum State { |
| 104 // Haven't started checking or checking is complete. Not deferred. | 96 // Haven't started checking or checking is complete. Not deferred. |
| 105 STATE_NONE, | 97 STATE_NONE, |
| 106 // We have one outstanding URL-check. Could be deferred. | 98 // We have one outstanding URL-check. Could be deferred. |
| 107 STATE_CHECKING_URL, | 99 STATE_CHECKING_URL, |
| 108 // We're displaying a blocking page. Could be deferred. | 100 // We're displaying a blocking page. Could be deferred. |
| 109 STATE_DISPLAYING_BLOCKING_PAGE, | 101 STATE_DISPLAYING_BLOCKING_PAGE, |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 149 | 141 |
| 150 // For marking network events. |name| and |value| can be null. | 142 // For marking network events. |name| and |value| can be null. |
| 151 void BeginNetLogEvent(net::NetLog::EventType type, | 143 void BeginNetLogEvent(net::NetLog::EventType type, |
| 152 const GURL& url, | 144 const GURL& url, |
| 153 const char* name, | 145 const char* name, |
| 154 const char* value); | 146 const char* value); |
| 155 void EndNetLogEvent(net::NetLog::EventType type, | 147 void EndNetLogEvent(net::NetLog::EventType type, |
| 156 const char* name, | 148 const char* name, |
| 157 const char* value); | 149 const char* value); |
| 158 | 150 |
| 159 // True if we want to block the starting of requests until they're | |
| 160 // deemed safe. Otherwise we let the resource partially load. | |
| 161 const bool defer_at_start_; | |
| 162 | |
| 163 // Check all types, or just the dangerous ones? | |
| 164 const SafeBrowsingService::ResourceTypesToCheck resource_types_to_check_; | |
| 165 | |
| 166 State state_; | 151 State state_; |
| 167 DeferState defer_state_; | 152 DeferState defer_state_; |
| 168 | 153 |
| 169 // The result of the most recent safe browsing check. Only valid to read this | 154 // The result of the most recent safe browsing check. Only valid to read this |
| 170 // when state_ != STATE_CHECKING_URL. | 155 // when state_ != STATE_CHECKING_URL. |
| 171 SBThreatType threat_type_; | 156 SBThreatType threat_type_; |
| 172 | 157 |
| 173 // The time when we started deferring the request. | 158 // The time when we started deferring the request. |
| 174 base::TimeTicks defer_start_time_; | 159 base::TimeTicks defer_start_time_; |
| 175 | 160 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 186 | 171 |
| 187 scoped_refptr<SafeBrowsingDatabaseManager> database_manager_; | 172 scoped_refptr<SafeBrowsingDatabaseManager> database_manager_; |
| 188 scoped_refptr<SafeBrowsingUIManager> ui_manager_; | 173 scoped_refptr<SafeBrowsingUIManager> ui_manager_; |
| 189 const net::URLRequest* request_; | 174 const net::URLRequest* request_; |
| 190 const content::ResourceType resource_type_; | 175 const content::ResourceType resource_type_; |
| 191 net::BoundNetLog bound_net_log_; | 176 net::BoundNetLog bound_net_log_; |
| 192 | 177 |
| 193 DISALLOW_COPY_AND_ASSIGN(SafeBrowsingResourceThrottle); | 178 DISALLOW_COPY_AND_ASSIGN(SafeBrowsingResourceThrottle); |
| 194 }; | 179 }; |
| 195 #endif // CHROME_BROWSER_RENDERER_HOST_SAFE_BROWSING_RESOURCE_THROTTLE_H_ | 180 #endif // CHROME_BROWSER_RENDERER_HOST_SAFE_BROWSING_RESOURCE_THROTTLE_H_ |
| OLD | NEW |