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 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 return extensions::ManifestFetchData::kNeverPinged; | 80 return extensions::ManifestFetchData::kNeverPinged; |
81 return SanitizeDays((Time::Now() - last_active_ping_day).InDays()); | 81 return SanitizeDays((Time::Now() - last_active_ping_day).InDays()); |
82 } | 82 } |
83 | 83 |
84 } // namespace | 84 } // namespace |
85 | 85 |
86 namespace extensions { | 86 namespace extensions { |
87 | 87 |
88 ExtensionUpdater::FetchedCRXFile::FetchedCRXFile(const std::string& i, | 88 ExtensionUpdater::FetchedCRXFile::FetchedCRXFile(const std::string& i, |
89 const FilePath& p, | 89 const FilePath& p, |
90 const GURL& u) | 90 const GURL& u, |
| 91 bool is_sync) |
91 : id(i), | 92 : id(i), |
92 path(p), | 93 path(p), |
93 download_url(u) {} | 94 download_url(u), |
| 95 is_sync(is_sync) {} |
94 | 96 |
95 ExtensionUpdater::FetchedCRXFile::FetchedCRXFile() | 97 ExtensionUpdater::FetchedCRXFile::FetchedCRXFile() |
96 : id(""), | 98 : id(""), |
97 path(), | 99 path(), |
98 download_url() {} | 100 download_url(), |
| 101 is_sync(false) {} |
99 | 102 |
100 ExtensionUpdater::FetchedCRXFile::~FetchedCRXFile() {} | 103 ExtensionUpdater::FetchedCRXFile::~FetchedCRXFile() {} |
101 | 104 |
102 ExtensionUpdater::ExtensionUpdater(ExtensionServiceInterface* service, | 105 ExtensionUpdater::ExtensionUpdater(ExtensionServiceInterface* service, |
103 ExtensionPrefs* extension_prefs, | 106 ExtensionPrefs* extension_prefs, |
104 PrefService* prefs, | 107 PrefService* prefs, |
105 Profile* profile, | 108 Profile* profile, |
106 int frequency_seconds) | 109 int frequency_seconds) |
107 : alive_(false), | 110 : alive_(false), |
108 weak_ptr_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)), | 111 weak_ptr_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)), |
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
303 pending_extension_manager->GetPendingIdsForUpdateCheck(&pending_ids); | 306 pending_extension_manager->GetPendingIdsForUpdateCheck(&pending_ids); |
304 | 307 |
305 std::list<std::string>::const_iterator iter; | 308 std::list<std::string>::const_iterator iter; |
306 for (iter = pending_ids.begin(); iter != pending_ids.end(); ++iter) { | 309 for (iter = pending_ids.begin(); iter != pending_ids.end(); ++iter) { |
307 const PendingExtensionInfo* info = pending_extension_manager->GetById( | 310 const PendingExtensionInfo* info = pending_extension_manager->GetById( |
308 *iter); | 311 *iter); |
309 if (!Extension::IsAutoUpdateableLocation(info->install_source())) { | 312 if (!Extension::IsAutoUpdateableLocation(info->install_source())) { |
310 VLOG(2) << "Extension " << *iter << " is not auto updateable"; | 313 VLOG(2) << "Extension " << *iter << " is not auto updateable"; |
311 continue; | 314 continue; |
312 } | 315 } |
313 if (downloader_->AddPendingExtension(*iter, info->update_url())) | 316 if (downloader_->AddPendingExtension(*iter, info->update_url(), |
| 317 info->is_from_sync())) |
314 in_progress_ids_.push_back(*iter); | 318 in_progress_ids_.push_back(*iter); |
315 } | 319 } |
316 | 320 |
317 AddToDownloader(service_->extensions(), pending_ids); | 321 AddToDownloader(service_->extensions(), pending_ids); |
318 AddToDownloader(service_->disabled_extensions(), pending_ids); | 322 AddToDownloader(service_->disabled_extensions(), pending_ids); |
319 | 323 |
320 // Start a fetch of the blacklist if needed. | 324 // Start a fetch of the blacklist if needed. |
321 if (blacklist_checks_enabled_) { | 325 if (blacklist_checks_enabled_) { |
322 ManifestFetchData::PingData ping_data; | 326 ManifestFetchData::PingData ping_data; |
323 ping_data.rollcall_days = | 327 ping_data.rollcall_days = |
(...skipping 15 matching lines...) Expand all Loading... |
339 DCHECK(alive_); | 343 DCHECK(alive_); |
340 UpdatePingData(id, ping); | 344 UpdatePingData(id, ping); |
341 in_progress_ids_.remove(id); | 345 in_progress_ids_.remove(id); |
342 NotifyIfFinished(); | 346 NotifyIfFinished(); |
343 } | 347 } |
344 | 348 |
345 void ExtensionUpdater::OnExtensionDownloadFinished(const std::string& id, | 349 void ExtensionUpdater::OnExtensionDownloadFinished(const std::string& id, |
346 const FilePath& path, | 350 const FilePath& path, |
347 const GURL& download_url, | 351 const GURL& download_url, |
348 const std::string& version, | 352 const std::string& version, |
349 const PingResult& ping) { | 353 const PingResult& ping, |
| 354 const bool is_sync) { |
350 DCHECK(alive_); | 355 DCHECK(alive_); |
351 UpdatePingData(id, ping); | 356 UpdatePingData(id, ping); |
352 | 357 |
353 VLOG(2) << download_url << " written to " << path.value(); | 358 VLOG(2) << download_url << " written to " << path.value(); |
354 | 359 |
355 FetchedCRXFile fetched(id, path, download_url); | 360 FetchedCRXFile fetched(id, path, download_url, is_sync); |
356 fetched_crx_files_.push(fetched); | 361 fetched_crx_files_.push(fetched); |
357 | 362 |
358 // MaybeInstallCRXFile() removes extensions from |in_progress_ids_| after | 363 // MaybeInstallCRXFile() removes extensions from |in_progress_ids_| after |
359 // starting the crx installer. | 364 // starting the crx installer. |
360 MaybeInstallCRXFile(); | 365 MaybeInstallCRXFile(); |
361 } | 366 } |
362 | 367 |
363 void ExtensionUpdater::OnBlacklistDownloadFinished( | 368 void ExtensionUpdater::OnBlacklistDownloadFinished( |
364 const std::string& data, | 369 const std::string& data, |
365 const std::string& package_hash, | 370 const std::string& package_hash, |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
499 if (in_progress_ids_.empty()) { | 504 if (in_progress_ids_.empty()) { |
500 VLOG(1) << "Sending EXTENSION_UPDATING_FINISHED"; | 505 VLOG(1) << "Sending EXTENSION_UPDATING_FINISHED"; |
501 content::NotificationService::current()->Notify( | 506 content::NotificationService::current()->Notify( |
502 chrome::NOTIFICATION_EXTENSION_UPDATING_FINISHED, | 507 chrome::NOTIFICATION_EXTENSION_UPDATING_FINISHED, |
503 content::Source<Profile>(profile_), | 508 content::Source<Profile>(profile_), |
504 content::NotificationService::NoDetails()); | 509 content::NotificationService::NoDetails()); |
505 } | 510 } |
506 } | 511 } |
507 | 512 |
508 } // namespace extensions | 513 } // namespace extensions |
OLD | NEW |