| 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 // Implementation of the SafeBrowsingBlockingPage class. | 5 // Implementation of the SafeBrowsingBlockingPage class. |
| 6 | 6 |
| 7 #include "chrome/browser/safe_browsing/safe_browsing_blocking_page.h" | 7 #include "chrome/browser/safe_browsing/safe_browsing_blocking_page.h" |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| 11 #include "base/bind.h" | 11 #include "base/bind.h" |
| 12 #include "base/i18n/rtl.h" | 12 #include "base/i18n/rtl.h" |
| 13 #include "base/lazy_instance.h" | 13 #include "base/lazy_instance.h" |
| 14 #include "base/string_number_conversions.h" | 14 #include "base/string_number_conversions.h" |
| 15 #include "base/string_piece.h" |
| 15 #include "base/stringprintf.h" | 16 #include "base/stringprintf.h" |
| 16 #include "base/utf_string_conversions.h" | 17 #include "base/utf_string_conversions.h" |
| 17 #include "base/values.h" | 18 #include "base/values.h" |
| 18 #include "chrome/browser/browser_process.h" | 19 #include "chrome/browser/browser_process.h" |
| 19 #include "chrome/browser/dom_operation_notification_details.h" | 20 #include "chrome/browser/dom_operation_notification_details.h" |
| 20 #include "chrome/browser/google/google_util.h" | 21 #include "chrome/browser/google/google_util.h" |
| 21 #include "chrome/browser/prefs/pref_service.h" | 22 #include "chrome/browser/prefs/pref_service.h" |
| 22 #include "chrome/browser/profiles/profile.h" | 23 #include "chrome/browser/profiles/profile.h" |
| 23 #include "chrome/browser/safe_browsing/malware_details.h" | 24 #include "chrome/browser/safe_browsing/malware_details.h" |
| 24 #include "chrome/browser/safe_browsing/safe_browsing_service.h" | 25 #include "chrome/browser/safe_browsing/safe_browsing_service.h" |
| (...skipping 435 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 460 // We are deleted after this. | 461 // We are deleted after this. |
| 461 return; | 462 return; |
| 462 } | 463 } |
| 463 | 464 |
| 464 // The "report error" and "show diagnostic" commands can have a number | 465 // The "report error" and "show diagnostic" commands can have a number |
| 465 // appended to them, which is the index of the element they apply to. | 466 // appended to them, which is the index of the element they apply to. |
| 466 int element_index = 0; | 467 int element_index = 0; |
| 467 size_t colon_index = command.find(':'); | 468 size_t colon_index = command.find(':'); |
| 468 if (colon_index != std::string::npos) { | 469 if (colon_index != std::string::npos) { |
| 469 DCHECK(colon_index < command.size() - 1); | 470 DCHECK(colon_index < command.size() - 1); |
| 470 bool result = base::StringToInt(command.begin() + colon_index + 1, | 471 bool result = base::StringToInt(base::StringPiece(command.begin() + |
| 471 command.end(), | 472 colon_index + 1, |
| 473 command.end()), |
| 472 &element_index); | 474 &element_index); |
| 473 command = command.substr(0, colon_index); | 475 command = command.substr(0, colon_index); |
| 474 DCHECK(result); | 476 DCHECK(result); |
| 475 } | 477 } |
| 476 | 478 |
| 477 if (element_index >= static_cast<int>(unsafe_resources_.size())) { | 479 if (element_index >= static_cast<int>(unsafe_resources_.size())) { |
| 478 NOTREACHED(); | 480 NOTREACHED(); |
| 479 return; | 481 return; |
| 480 } | 482 } |
| 481 | 483 |
| (...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 708 // Client-side phishing detection interstitials never block the main frame | 710 // Client-side phishing detection interstitials never block the main frame |
| 709 // load, since they happen after the page is finished loading. | 711 // load, since they happen after the page is finished loading. |
| 710 if (unsafe_resources[0].threat_type == | 712 if (unsafe_resources[0].threat_type == |
| 711 SafeBrowsingService::CLIENT_SIDE_PHISHING_URL) { | 713 SafeBrowsingService::CLIENT_SIDE_PHISHING_URL) { |
| 712 return false; | 714 return false; |
| 713 } | 715 } |
| 714 | 716 |
| 715 // Otherwise, check the threat type. | 717 // Otherwise, check the threat type. |
| 716 return unsafe_resources.size() == 1 && !unsafe_resources[0].is_subresource; | 718 return unsafe_resources.size() == 1 && !unsafe_resources[0].is_subresource; |
| 717 } | 719 } |
| OLD | NEW |