| 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/extensions/extension_updater.h" | 5 #include "chrome/browser/extensions/extension_updater.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <set> | 8 #include <set> |
| 9 | 9 |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| 11 #include "base/file_util.h" | 11 #include "base/file_util.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/sha2.h" | |
| 15 #include "base/stl_util-inl.h" | 14 #include "base/stl_util-inl.h" |
| 16 #include "base/string_number_conversions.h" | 15 #include "base/string_number_conversions.h" |
| 17 #include "base/string_split.h" | 16 #include "base/string_split.h" |
| 18 #include "base/string_util.h" | 17 #include "base/string_util.h" |
| 19 #include "base/time.h" | 18 #include "base/time.h" |
| 20 #include "base/threading/thread.h" | 19 #include "base/threading/thread.h" |
| 21 #include "base/version.h" | 20 #include "base/version.h" |
| 21 #include "crypto/sha2.h" |
| 22 #include "content/common/notification_service.h" | 22 #include "content/common/notification_service.h" |
| 23 #include "chrome/browser/browser_process.h" | 23 #include "chrome/browser/browser_process.h" |
| 24 #include "chrome/browser/extensions/extension_error_reporter.h" | 24 #include "chrome/browser/extensions/extension_error_reporter.h" |
| 25 #include "chrome/browser/extensions/extension_service.h" | 25 #include "chrome/browser/extensions/extension_service.h" |
| 26 #include "chrome/browser/prefs/pref_service.h" | 26 #include "chrome/browser/prefs/pref_service.h" |
| 27 #include "chrome/browser/profiles/profile.h" | 27 #include "chrome/browser/profiles/profile.h" |
| 28 #include "chrome/browser/utility_process_host.h" | 28 #include "chrome/browser/utility_process_host.h" |
| 29 #include "chrome/common/chrome_switches.h" | 29 #include "chrome/common/chrome_switches.h" |
| 30 #include "chrome/common/chrome_version_info.h" | 30 #include "chrome/common/chrome_version_info.h" |
| 31 #include "chrome/common/extensions/extension.h" | 31 #include "chrome/common/extensions/extension.h" |
| (...skipping 679 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 711 extension_prefs_->SetLastActivePingDay(*i, daystart); | 711 extension_prefs_->SetLastActivePingDay(*i, daystart); |
| 712 } | 712 } |
| 713 } | 713 } |
| 714 } | 714 } |
| 715 NotifyIfFinished(); | 715 NotifyIfFinished(); |
| 716 } | 716 } |
| 717 | 717 |
| 718 void ExtensionUpdater::ProcessBlacklist(const std::string& data) { | 718 void ExtensionUpdater::ProcessBlacklist(const std::string& data) { |
| 719 DCHECK(alive_); | 719 DCHECK(alive_); |
| 720 // Verify sha256 hash value. | 720 // Verify sha256 hash value. |
| 721 char sha256_hash_value[base::SHA256_LENGTH]; | 721 char sha256_hash_value[crypto::SHA256_LENGTH]; |
| 722 base::SHA256HashString(data, sha256_hash_value, base::SHA256_LENGTH); | 722 crypto::SHA256HashString(data, sha256_hash_value, crypto::SHA256_LENGTH); |
| 723 std::string hash_in_hex = base::HexEncode(sha256_hash_value, | 723 std::string hash_in_hex = base::HexEncode(sha256_hash_value, |
| 724 base::SHA256_LENGTH); | 724 crypto::SHA256_LENGTH); |
| 725 | 725 |
| 726 if (current_extension_fetch_.package_hash != hash_in_hex) { | 726 if (current_extension_fetch_.package_hash != hash_in_hex) { |
| 727 NOTREACHED() << "Fetched blacklist checksum is not as expected. " | 727 NOTREACHED() << "Fetched blacklist checksum is not as expected. " |
| 728 << "Expected: " << current_extension_fetch_.package_hash | 728 << "Expected: " << current_extension_fetch_.package_hash |
| 729 << " Actual: " << hash_in_hex; | 729 << " Actual: " << hash_in_hex; |
| 730 return; | 730 return; |
| 731 } | 731 } |
| 732 std::vector<std::string> blacklist; | 732 std::vector<std::string> blacklist; |
| 733 base::SplitString(data, '\n', &blacklist); | 733 base::SplitString(data, '\n', &blacklist); |
| 734 | 734 |
| (...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1076 std::set<std::string>::const_iterator i; | 1076 std::set<std::string>::const_iterator i; |
| 1077 for (i = ids.begin(); i != ids.end(); ++i) | 1077 for (i = ids.begin(); i != ids.end(); ++i) |
| 1078 in_progress_ids_.insert(*i); | 1078 in_progress_ids_.insert(*i); |
| 1079 } | 1079 } |
| 1080 | 1080 |
| 1081 void ExtensionUpdater::RemoveFromInProgress(const std::set<std::string>& ids) { | 1081 void ExtensionUpdater::RemoveFromInProgress(const std::set<std::string>& ids) { |
| 1082 std::set<std::string>::const_iterator i; | 1082 std::set<std::string>::const_iterator i; |
| 1083 for (i = ids.begin(); i != ids.end(); ++i) | 1083 for (i = ids.begin(); i != ids.end(); ++i) |
| 1084 in_progress_ids_.erase(*i); | 1084 in_progress_ids_.erase(*i); |
| 1085 } | 1085 } |
| OLD | NEW |