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 #include "chrome/browser/safe_browsing/protocol_manager.h" | 5 #include "chrome/browser/safe_browsing/protocol_manager.h" |
6 | 6 |
7 #include "base/environment.h" | 7 #include "base/environment.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/memory/scoped_vector.h" | 9 #include "base/memory/scoped_vector.h" |
10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
116 update_state_(FIRST_REQUEST), | 116 update_state_(FIRST_REQUEST), |
117 chunk_pending_to_write_(false), | 117 chunk_pending_to_write_(false), |
118 version_(config.version), | 118 version_(config.version), |
119 update_size_(0), | 119 update_size_(0), |
120 client_name_(config.client_name), | 120 client_name_(config.client_name), |
121 request_context_getter_(request_context_getter), | 121 request_context_getter_(request_context_getter), |
122 url_prefix_(config.url_prefix), | 122 url_prefix_(config.url_prefix), |
123 backup_update_reason_(BACKUP_UPDATE_REASON_MAX), | 123 backup_update_reason_(BACKUP_UPDATE_REASON_MAX), |
124 disable_auto_update_(config.disable_auto_update), | 124 disable_auto_update_(config.disable_auto_update), |
125 url_fetcher_id_(0), | 125 url_fetcher_id_(0), |
| 126 #if defined(OS_ANDROID) |
| 127 disable_connection_check_(config.disable_connection_check), |
| 128 #endif |
126 app_in_foreground_(true) { | 129 app_in_foreground_(true) { |
127 DCHECK(!url_prefix_.empty()); | 130 DCHECK(!url_prefix_.empty()); |
128 | 131 |
129 backup_url_prefixes_[BACKUP_UPDATE_REASON_CONNECT] = | 132 backup_url_prefixes_[BACKUP_UPDATE_REASON_CONNECT] = |
130 config.backup_connect_error_url_prefix; | 133 config.backup_connect_error_url_prefix; |
131 backup_url_prefixes_[BACKUP_UPDATE_REASON_HTTP] = | 134 backup_url_prefixes_[BACKUP_UPDATE_REASON_HTTP] = |
132 config.backup_http_error_url_prefix; | 135 config.backup_http_error_url_prefix; |
133 backup_url_prefixes_[BACKUP_UPDATE_REASON_NETWORK] = | 136 backup_url_prefixes_[BACKUP_UPDATE_REASON_NETWORK] = |
134 config.backup_network_error_url_prefix; | 137 config.backup_network_error_url_prefix; |
135 | 138 |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
191 fetcher->SetUploadData("text/plain", get_hash); | 194 fetcher->SetUploadData("text/plain", get_hash); |
192 fetcher->Start(); | 195 fetcher->Start(); |
193 } | 196 } |
194 | 197 |
195 void SafeBrowsingProtocolManager::GetNextUpdate() { | 198 void SafeBrowsingProtocolManager::GetNextUpdate() { |
196 DCHECK(CalledOnValidThread()); | 199 DCHECK(CalledOnValidThread()); |
197 if (request_.get() || request_type_ != NO_REQUEST) | 200 if (request_.get() || request_type_ != NO_REQUEST) |
198 return; | 201 return; |
199 | 202 |
200 #if defined(OS_ANDROID) | 203 #if defined(OS_ANDROID) |
201 net::NetworkChangeNotifier::ConnectionType type = | 204 if (!disable_connection_check_) { |
202 net::NetworkChangeNotifier::GetConnectionType(); | 205 net::NetworkChangeNotifier::ConnectionType type = |
203 if (type != net::NetworkChangeNotifier::CONNECTION_WIFI) { | 206 net::NetworkChangeNotifier::GetConnectionType(); |
204 ScheduleNextUpdate(false /* no back off */); | 207 if (type != net::NetworkChangeNotifier::CONNECTION_WIFI) { |
205 return; | 208 ScheduleNextUpdate(false /* no back off */); |
| 209 return; |
| 210 } |
206 } | 211 } |
207 #endif | 212 #endif |
208 | 213 |
209 IssueUpdateRequest(); | 214 IssueUpdateRequest(); |
210 } | 215 } |
211 | 216 |
212 // net::URLFetcherDelegate implementation ---------------------------------- | 217 // net::URLFetcherDelegate implementation ---------------------------------- |
213 | 218 |
214 // All SafeBrowsing request responses are handled here. | 219 // All SafeBrowsing request responses are handled here. |
215 // TODO(paulg): Clarify with the SafeBrowsing team whether a failed parse of a | 220 // TODO(paulg): Clarify with the SafeBrowsing team whether a failed parse of a |
(...skipping 549 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
765 FullHashCallback callback, bool is_download) | 770 FullHashCallback callback, bool is_download) |
766 : callback(callback), | 771 : callback(callback), |
767 is_download(is_download) { | 772 is_download(is_download) { |
768 } | 773 } |
769 | 774 |
770 SafeBrowsingProtocolManager::FullHashDetails::~FullHashDetails() { | 775 SafeBrowsingProtocolManager::FullHashDetails::~FullHashDetails() { |
771 } | 776 } |
772 | 777 |
773 SafeBrowsingProtocolManagerDelegate::~SafeBrowsingProtocolManagerDelegate() { | 778 SafeBrowsingProtocolManagerDelegate::~SafeBrowsingProtocolManagerDelegate() { |
774 } | 779 } |
OLD | NEW |