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/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
(...skipping 982 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
993 DCHECK(will_check_soon_); | 993 DCHECK(will_check_soon_); |
994 CheckNow(); | 994 CheckNow(); |
995 will_check_soon_ = false; | 995 will_check_soon_ = false; |
996 } | 996 } |
997 | 997 |
998 void ExtensionUpdater::CheckNow() { | 998 void ExtensionUpdater::CheckNow() { |
999 DCHECK(alive_); | 999 DCHECK(alive_); |
1000 NotifyStarted(); | 1000 NotifyStarted(); |
1001 ManifestFetchesBuilder fetches_builder(service_, extension_prefs_); | 1001 ManifestFetchesBuilder fetches_builder(service_, extension_prefs_); |
1002 | 1002 |
1003 const ExtensionList* extensions = service_->extensions(); | |
1004 for (ExtensionList::const_iterator iter = extensions->begin(); | |
1005 iter != extensions->end(); ++iter) { | |
1006 fetches_builder.AddExtension(**iter); | |
1007 } | |
1008 | |
1009 const PendingExtensionManager* pending_extension_manager = | 1003 const PendingExtensionManager* pending_extension_manager = |
1010 service_->pending_extension_manager(); | 1004 service_->pending_extension_manager(); |
| 1005 std::set<std::string> pending_ids; |
1011 | 1006 |
1012 PendingExtensionManager::const_iterator iter; | 1007 PendingExtensionManager::const_iterator iter; |
1013 for (iter = pending_extension_manager->begin(); | 1008 for (iter = pending_extension_manager->begin(); |
1014 iter != pending_extension_manager->end(); iter++) { | 1009 iter != pending_extension_manager->end(); iter++) { |
1015 // TODO(skerner): Move the determination of what gets fetched into | 1010 // TODO(skerner): Move the determination of what gets fetched into |
1016 // class PendingExtensionManager. | 1011 // class PendingExtensionManager. |
1017 Extension::Location location = iter->second.install_source(); | 1012 Extension::Location location = iter->second.install_source(); |
1018 if (location != Extension::EXTERNAL_PREF && | 1013 if (location != Extension::EXTERNAL_PREF && |
1019 location != Extension::EXTERNAL_REGISTRY) | 1014 location != Extension::EXTERNAL_REGISTRY) { |
1020 fetches_builder.AddPendingExtension(iter->first, iter->second); | 1015 fetches_builder.AddPendingExtension(iter->first, iter->second); |
| 1016 pending_ids.insert(iter->first); |
| 1017 } |
| 1018 } |
| 1019 |
| 1020 const ExtensionList* extensions = service_->extensions(); |
| 1021 for (ExtensionList::const_iterator iter = extensions->begin(); |
| 1022 iter != extensions->end(); ++iter) { |
| 1023 // An extension might be overwritten by policy, and have its update url |
| 1024 // changed. Make sure existing extensions aren't fetched again, if a |
| 1025 // pending fetch for an extension with the same id already exists. |
| 1026 if (!ContainsKey(pending_ids, (*iter)->id())) { |
| 1027 fetches_builder.AddExtension(**iter); |
| 1028 } |
1021 } | 1029 } |
1022 | 1030 |
1023 fetches_builder.ReportStats(); | 1031 fetches_builder.ReportStats(); |
1024 | 1032 |
1025 std::vector<ManifestFetchData*> fetches(fetches_builder.GetFetches()); | 1033 std::vector<ManifestFetchData*> fetches(fetches_builder.GetFetches()); |
1026 | 1034 |
1027 // Start a fetch of the blacklist if needed. | 1035 // Start a fetch of the blacklist if needed. |
1028 if (blacklist_checks_enabled_) { | 1036 if (blacklist_checks_enabled_) { |
1029 // Note: it is very important that we use the https version of the update | 1037 // Note: it is very important that we use the https version of the update |
1030 // url here to avoid DNS hijacking of the blacklist, which is not validated | 1038 // url here to avoid DNS hijacking of the blacklist, which is not validated |
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1234 std::set<std::string>::const_iterator i; | 1242 std::set<std::string>::const_iterator i; |
1235 for (i = ids.begin(); i != ids.end(); ++i) | 1243 for (i = ids.begin(); i != ids.end(); ++i) |
1236 in_progress_ids_.insert(*i); | 1244 in_progress_ids_.insert(*i); |
1237 } | 1245 } |
1238 | 1246 |
1239 void ExtensionUpdater::RemoveFromInProgress(const std::set<std::string>& ids) { | 1247 void ExtensionUpdater::RemoveFromInProgress(const std::set<std::string>& ids) { |
1240 std::set<std::string>::const_iterator i; | 1248 std::set<std::string>::const_iterator i; |
1241 for (i = ids.begin(); i != ids.end(); ++i) | 1249 for (i = ids.begin(); i != ids.end(); ++i) |
1242 in_progress_ids_.erase(*i); | 1250 in_progress_ids_.erase(*i); |
1243 } | 1251 } |
OLD | NEW |