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/updater/extension_updater.h" | 5 #include "chrome/browser/extensions/updater/extension_updater.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <set> | 8 #include <set> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
255 bool ExtensionUpdater::WillCheckSoon() const { | 255 bool ExtensionUpdater::WillCheckSoon() const { |
256 return will_check_soon_; | 256 return will_check_soon_; |
257 } | 257 } |
258 | 258 |
259 void ExtensionUpdater::DoCheckSoon() { | 259 void ExtensionUpdater::DoCheckSoon() { |
260 DCHECK(will_check_soon_); | 260 DCHECK(will_check_soon_); |
261 CheckNow(); | 261 CheckNow(); |
262 will_check_soon_ = false; | 262 will_check_soon_ = false; |
263 } | 263 } |
264 | 264 |
| 265 void ExtensionUpdater::AddToDownloader(const ExtensionSet* extensions, |
| 266 const std::set<std::string>& pending_ids) { |
| 267 for (ExtensionSet::const_iterator iter = extensions->begin(); |
| 268 iter != extensions->end(); ++iter) { |
| 269 const Extension& extension = **iter; |
| 270 if (!Extension::IsAutoUpdateableLocation(extension.location())) { |
| 271 VLOG(2) << "Extension " << extension.id() << " is not auto updateable"; |
| 272 continue; |
| 273 } |
| 274 // An extension might be overwritten by policy, and have its update url |
| 275 // changed. Make sure existing extensions aren't fetched again, if a |
| 276 // pending fetch for an extension with the same id already exists. |
| 277 if (!ContainsKey(pending_ids, extension.id())) { |
| 278 if (downloader_->AddExtension(extension)) |
| 279 in_progress_ids_.insert(extension.id()); |
| 280 } |
| 281 } |
| 282 } |
| 283 |
265 void ExtensionUpdater::CheckNow() { | 284 void ExtensionUpdater::CheckNow() { |
266 VLOG(2) << "Starting update check"; | 285 VLOG(2) << "Starting update check"; |
267 DCHECK(alive_); | 286 DCHECK(alive_); |
268 NotifyStarted(); | 287 NotifyStarted(); |
269 | 288 |
270 if (!downloader_.get()) { | 289 if (!downloader_.get()) { |
271 downloader_.reset( | 290 downloader_.reset( |
272 new ExtensionDownloader(this, profile_->GetRequestContext())); | 291 new ExtensionDownloader(this, profile_->GetRequestContext())); |
273 } | 292 } |
274 | 293 |
(...skipping 14 matching lines...) Expand all Loading... |
289 if (!found_id) | 308 if (!found_id) |
290 continue; | 309 continue; |
291 if (!Extension::IsAutoUpdateableLocation(info.install_source())) { | 310 if (!Extension::IsAutoUpdateableLocation(info.install_source())) { |
292 VLOG(2) << "Extension " << *iter << " is not auto updateable"; | 311 VLOG(2) << "Extension " << *iter << " is not auto updateable"; |
293 continue; | 312 continue; |
294 } | 313 } |
295 if (downloader_->AddPendingExtension(*iter, info.update_url())) | 314 if (downloader_->AddPendingExtension(*iter, info.update_url())) |
296 in_progress_ids_.insert(*iter); | 315 in_progress_ids_.insert(*iter); |
297 } | 316 } |
298 | 317 |
299 // Add fetch records for extensions that are installed and have an | 318 AddToDownloader(service_->extensions(), pending_ids); |
300 // update URL. | 319 AddToDownloader(service_->disabled_extensions(), pending_ids); |
301 const ExtensionSet* extensions = service_->extensions(); | |
302 for (ExtensionSet::const_iterator iter = extensions->begin(); | |
303 iter != extensions->end(); ++iter) { | |
304 const Extension& extension = **iter; | |
305 if (!Extension::IsAutoUpdateableLocation(extension.location())) { | |
306 VLOG(2) << "Extension " << extension.id() << " is not auto updateable"; | |
307 continue; | |
308 } | |
309 // An extension might be overwritten by policy, and have its update url | |
310 // changed. Make sure existing extensions aren't fetched again, if a | |
311 // pending fetch for an extension with the same id already exists. | |
312 if (!ContainsKey(pending_ids, extension.id())) { | |
313 if (downloader_->AddExtension(extension)) | |
314 in_progress_ids_.insert(extension.id()); | |
315 } | |
316 } | |
317 | 320 |
318 // Start a fetch of the blacklist if needed. | 321 // Start a fetch of the blacklist if needed. |
319 if (blacklist_checks_enabled_) { | 322 if (blacklist_checks_enabled_) { |
320 ManifestFetchData::PingData ping_data; | 323 ManifestFetchData::PingData ping_data; |
321 ping_data.rollcall_days = | 324 ping_data.rollcall_days = |
322 CalculatePingDays(extension_prefs_->BlacklistLastPingDay()); | 325 CalculatePingDays(extension_prefs_->BlacklistLastPingDay()); |
323 downloader_->StartBlacklistUpdate( | 326 downloader_->StartBlacklistUpdate( |
324 prefs_->GetString(kExtensionBlacklistUpdateVersion), ping_data); | 327 prefs_->GetString(kExtensionBlacklistUpdateVersion), ping_data); |
325 } | 328 } |
326 | 329 |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
410 return service_->pending_extension_manager()->IsIdPending(id); | 413 return service_->pending_extension_manager()->IsIdPending(id); |
411 } | 414 } |
412 | 415 |
413 bool ExtensionUpdater::GetExtensionExistingVersion(const std::string& id, | 416 bool ExtensionUpdater::GetExtensionExistingVersion(const std::string& id, |
414 std::string* version) { | 417 std::string* version) { |
415 DCHECK(alive_); | 418 DCHECK(alive_); |
416 if (id == ExtensionDownloader::kBlacklistAppID) { | 419 if (id == ExtensionDownloader::kBlacklistAppID) { |
417 *version = prefs_->GetString(kExtensionBlacklistUpdateVersion); | 420 *version = prefs_->GetString(kExtensionBlacklistUpdateVersion); |
418 return true; | 421 return true; |
419 } | 422 } |
420 const Extension* extension = service_->GetExtensionById(id, false); | 423 const Extension* extension = service_->GetExtensionById(id, true); |
421 if (!extension) | 424 if (!extension) |
422 return false; | 425 return false; |
423 *version = extension->version()->GetString(); | 426 *version = extension->version()->GetString(); |
424 return true; | 427 return true; |
425 } | 428 } |
426 | 429 |
427 void ExtensionUpdater::UpdatePingData(const std::string& id, | 430 void ExtensionUpdater::UpdatePingData(const std::string& id, |
428 const PingResult& ping_result) { | 431 const PingResult& ping_result) { |
429 DCHECK(alive_); | 432 DCHECK(alive_); |
430 if (ping_result.did_ping) { | 433 if (ping_result.did_ping) { |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
496 if (in_progress_ids_.empty()) { | 499 if (in_progress_ids_.empty()) { |
497 VLOG(1) << "Sending EXTENSION_UPDATING_FINISHED"; | 500 VLOG(1) << "Sending EXTENSION_UPDATING_FINISHED"; |
498 content::NotificationService::current()->Notify( | 501 content::NotificationService::current()->Notify( |
499 chrome::NOTIFICATION_EXTENSION_UPDATING_FINISHED, | 502 chrome::NOTIFICATION_EXTENSION_UPDATING_FINISHED, |
500 content::Source<Profile>(profile_), | 503 content::Source<Profile>(profile_), |
501 content::NotificationService::NoDetails()); | 504 content::NotificationService::NoDetails()); |
502 } | 505 } |
503 } | 506 } |
504 | 507 |
505 } // namespace extensions | 508 } // namespace extensions |
OLD | NEW |