| 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/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/bind.h" | 10 #include "base/bind.h" |
| (...skipping 1017 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1028 DCHECK(alive_); | 1028 DCHECK(alive_); |
| 1029 NotifyStarted(); | 1029 NotifyStarted(); |
| 1030 ManifestFetchesBuilder fetches_builder(service_, extension_prefs_); | 1030 ManifestFetchesBuilder fetches_builder(service_, extension_prefs_); |
| 1031 | 1031 |
| 1032 // Add fetch records for extensions that should be fetched by an update URL. | 1032 // Add fetch records for extensions that should be fetched by an update URL. |
| 1033 // These extensions are not yet installed. They come from group policy | 1033 // These extensions are not yet installed. They come from group policy |
| 1034 // and external install sources. | 1034 // and external install sources. |
| 1035 const PendingExtensionManager* pending_extension_manager = | 1035 const PendingExtensionManager* pending_extension_manager = |
| 1036 service_->pending_extension_manager(); | 1036 service_->pending_extension_manager(); |
| 1037 | 1037 |
| 1038 std::set<std::string> pending_ids; | 1038 std::list<std::string> pending_ids; |
| 1039 pending_extension_manager->GetPendingIdsForUpdateCheck(&pending_ids); | 1039 pending_extension_manager->GetPendingIdsForUpdateCheck(&pending_ids); |
| 1040 | 1040 |
| 1041 std::set<std::string>::const_iterator iter; | 1041 std::list<std::string>::const_iterator iter; |
| 1042 for (iter = pending_ids.begin(); iter != pending_ids.end(); ++iter) { | 1042 for (iter = pending_ids.begin(); iter != pending_ids.end(); ++iter) { |
| 1043 PendingExtensionInfo info; | 1043 PendingExtensionInfo info; |
| 1044 bool found_id = pending_extension_manager->GetById(*iter, &info); | 1044 bool found_id = pending_extension_manager->GetById(*iter, &info); |
| 1045 DCHECK(found_id); | 1045 DCHECK(found_id); |
| 1046 if (!found_id) | 1046 if (!found_id) |
| 1047 continue; | 1047 continue; |
| 1048 | 1048 |
| 1049 fetches_builder.AddPendingExtension( | 1049 fetches_builder.AddPendingExtension( |
| 1050 *iter, | 1050 *iter, |
| 1051 info.install_source(), | 1051 info.install_source(), |
| 1052 info.update_url()); | 1052 info.update_url()); |
| 1053 } | 1053 } |
| 1054 | 1054 |
| 1055 // Add fetch records for extensions that are installed and have an | 1055 // Add fetch records for extensions that are installed and have an |
| 1056 // update URL. | 1056 // update URL. |
| 1057 const ExtensionSet* extensions = service_->extensions(); | 1057 const ExtensionSet* extensions = service_->extensions(); |
| 1058 for (ExtensionSet::const_iterator iter = extensions->begin(); | 1058 for (ExtensionSet::const_iterator iter = extensions->begin(); |
| 1059 iter != extensions->end(); ++iter) { | 1059 iter != extensions->end(); ++iter) { |
| 1060 // An extension might be overwritten by policy, and have its update url | 1060 // An extension might be overwritten by policy, and have its update url |
| 1061 // changed. Make sure existing extensions aren't fetched again, if a | 1061 // changed. Make sure existing extensions aren't fetched again, if a |
| 1062 // pending fetch for an extension with the same id already exists. | 1062 // pending fetch for an extension with the same id already exists. |
| 1063 if (!ContainsKey(pending_ids, (*iter)->id())) { | 1063 if (!pending_extension_manager->IsIdPending((*iter)->id())) { |
| 1064 fetches_builder.AddExtension(**iter); | 1064 fetches_builder.AddExtension(**iter); |
| 1065 } | 1065 } |
| 1066 } | 1066 } |
| 1067 | 1067 |
| 1068 fetches_builder.ReportStats(); | 1068 fetches_builder.ReportStats(); |
| 1069 | 1069 |
| 1070 std::vector<ManifestFetchData*> fetches(fetches_builder.GetFetches()); | 1070 std::vector<ManifestFetchData*> fetches(fetches_builder.GetFetches()); |
| 1071 | 1071 |
| 1072 // Start a fetch of the blacklist if needed. | 1072 // Start a fetch of the blacklist if needed. |
| 1073 if (blacklist_checks_enabled_) { | 1073 if (blacklist_checks_enabled_) { |
| (...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1299 std::set<std::string>::const_iterator i; | 1299 std::set<std::string>::const_iterator i; |
| 1300 for (i = ids.begin(); i != ids.end(); ++i) | 1300 for (i = ids.begin(); i != ids.end(); ++i) |
| 1301 in_progress_ids_.insert(*i); | 1301 in_progress_ids_.insert(*i); |
| 1302 } | 1302 } |
| 1303 | 1303 |
| 1304 void ExtensionUpdater::RemoveFromInProgress(const std::set<std::string>& ids) { | 1304 void ExtensionUpdater::RemoveFromInProgress(const std::set<std::string>& ids) { |
| 1305 std::set<std::string>::const_iterator i; | 1305 std::set<std::string>::const_iterator i; |
| 1306 for (i = ids.begin(); i != ids.end(); ++i) | 1306 for (i = ids.begin(); i != ids.end(); ++i) |
| 1307 in_progress_ids_.erase(*i); | 1307 in_progress_ids_.erase(*i); |
| 1308 } | 1308 } |
| OLD | NEW |