| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #ifndef NDEBUG | 7 #ifndef NDEBUG |
| 8 #include "base/base64.h" | 8 #include "base/base64.h" |
| 9 #endif | 9 #endif |
| 10 #include "base/environment.h" | 10 #include "base/environment.h" |
| 11 #include "base/logging.h" | 11 #include "base/logging.h" |
| 12 #include "base/metrics/histogram.h" | 12 #include "base/metrics/histogram.h" |
| 13 #include "base/rand_util.h" | 13 #include "base/rand_util.h" |
| 14 #include "base/stl_util.h" | 14 #include "base/stl_util.h" |
| 15 #include "base/string_util.h" |
| 15 #include "base/stringprintf.h" | 16 #include "base/stringprintf.h" |
| 16 #include "base/string_util.h" | |
| 17 #include "base/task.h" | 17 #include "base/task.h" |
| 18 #include "base/timer.h" | 18 #include "base/timer.h" |
| 19 #include "chrome/browser/safe_browsing/protocol_parser.h" | 19 #include "chrome/browser/safe_browsing/protocol_parser.h" |
| 20 #include "chrome/browser/safe_browsing/safe_browsing_service.h" | 20 #include "chrome/browser/safe_browsing/safe_browsing_service.h" |
| 21 #include "chrome/common/chrome_version_info.h" | 21 #include "chrome/common/chrome_version_info.h" |
| 22 #include "chrome/common/env_vars.h" | 22 #include "chrome/common/env_vars.h" |
| 23 #include "content/browser/browser_thread.h" | 23 #include "content/browser/browser_thread.h" |
| 24 #include "net/base/escape.h" | 24 #include "net/base/escape.h" |
| 25 #include "net/base/load_flags.h" | 25 #include "net/base/load_flags.h" |
| 26 #include "net/url_request/url_request_context_getter.h" | 26 #include "net/url_request/url_request_context_getter.h" |
| (...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 257 // what to do at that point though! | 257 // what to do at that point though! |
| 258 full_hashes.clear(); | 258 full_hashes.clear(); |
| 259 } else { | 259 } else { |
| 260 if (re_key) | 260 if (re_key) |
| 261 HandleReKey(); | 261 HandleReKey(); |
| 262 } | 262 } |
| 263 } else { | 263 } else { |
| 264 HandleGetHashError(Time::Now()); | 264 HandleGetHashError(Time::Now()); |
| 265 if (status.status() == net::URLRequestStatus::FAILED) { | 265 if (status.status() == net::URLRequestStatus::FAILED) { |
| 266 VLOG(1) << "SafeBrowsing GetHash request for: " << source->url() | 266 VLOG(1) << "SafeBrowsing GetHash request for: " << source->url() |
| 267 << " failed with os error: " << status.os_error(); | 267 << " failed with error: " << status.error(); |
| 268 } else { | 268 } else { |
| 269 VLOG(1) << "SafeBrowsing GetHash request for: " << source->url() | 269 VLOG(1) << "SafeBrowsing GetHash request for: " << source->url() |
| 270 << " failed with error: " << response_code; | 270 << " failed with error: " << response_code; |
| 271 } | 271 } |
| 272 } | 272 } |
| 273 | 273 |
| 274 // Call back the SafeBrowsingService with full_hashes, even if there was a | 274 // Call back the SafeBrowsingService with full_hashes, even if there was a |
| 275 // parse error or an error response code (in which case full_hashes will be | 275 // parse error or an error response code (in which case full_hashes will be |
| 276 // empty). We can't block the user regardless of the error status. | 276 // empty). We can't block the user regardless of the error status. |
| 277 sb_service_->HandleGetHashResults(check, full_hashes, can_cache); | 277 sb_service_->HandleGetHashResults(check, full_hashes, can_cache); |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 331 break; | 331 break; |
| 332 } | 332 } |
| 333 } else { | 333 } else { |
| 334 // The SafeBrowsing service error, or very bad response code: back off. | 334 // The SafeBrowsing service error, or very bad response code: back off. |
| 335 must_back_off = true; | 335 must_back_off = true; |
| 336 if (request_type_ == CHUNK_REQUEST) | 336 if (request_type_ == CHUNK_REQUEST) |
| 337 chunk_request_urls_.clear(); | 337 chunk_request_urls_.clear(); |
| 338 UpdateFinished(false); | 338 UpdateFinished(false); |
| 339 if (status.status() == net::URLRequestStatus::FAILED) { | 339 if (status.status() == net::URLRequestStatus::FAILED) { |
| 340 VLOG(1) << "SafeBrowsing request for: " << source->url() | 340 VLOG(1) << "SafeBrowsing request for: " << source->url() |
| 341 << " failed with os error: " << status.os_error(); | 341 << " failed with error: " << status.error(); |
| 342 } else { | 342 } else { |
| 343 VLOG(1) << "SafeBrowsing request for: " << source->url() | 343 VLOG(1) << "SafeBrowsing request for: " << source->url() |
| 344 << " failed with error: " << response_code; | 344 << " failed with error: " << response_code; |
| 345 } | 345 } |
| 346 } | 346 } |
| 347 } | 347 } |
| 348 | 348 |
| 349 // Schedule a new update request if we've finished retrieving all the chunks | 349 // Schedule a new update request if we've finished retrieving all the chunks |
| 350 // from the previous update. We treat the update request and the chunk URLs it | 350 // from the previous update. We treat the update request and the chunk URLs it |
| 351 // contains as an atomic unit as far as back off is concerned. | 351 // contains as an atomic unit as far as back off is concerned. |
| (...skipping 473 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 825 if (!additional_query_.empty()) { | 825 if (!additional_query_.empty()) { |
| 826 if (next_url.find("?") != std::string::npos) { | 826 if (next_url.find("?") != std::string::npos) { |
| 827 next_url.append("&"); | 827 next_url.append("&"); |
| 828 } else { | 828 } else { |
| 829 next_url.append("?"); | 829 next_url.append("?"); |
| 830 } | 830 } |
| 831 next_url.append(additional_query_); | 831 next_url.append(additional_query_); |
| 832 } | 832 } |
| 833 return GURL(next_url); | 833 return GURL(next_url); |
| 834 } | 834 } |
| OLD | NEW |