| 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 |
| 11 #include "base/bind.h" | 11 #include "base/bind.h" |
| 12 #include "base/logging.h" | 12 #include "base/logging.h" |
| 13 #include "base/metrics/histogram.h" | 13 #include "base/metrics/histogram.h" |
| 14 #include "base/rand_util.h" | 14 #include "base/rand_util.h" |
| 15 #include "base/stl_util.h" | 15 #include "base/stl_util.h" |
| 16 #include "base/string_number_conversions.h" | 16 #include "base/string_number_conversions.h" |
| 17 #include "base/string_split.h" | 17 #include "base/string_split.h" |
| 18 #include "chrome/browser/extensions/blacklist.h" | 18 #include "chrome/browser/extensions/blacklist.h" |
| 19 #include "chrome/browser/extensions/crx_installer.h" | 19 #include "chrome/browser/extensions/crx_installer.h" |
| 20 #include "chrome/browser/extensions/extension_service.h" | 20 #include "chrome/browser/extensions/extension_service.h" |
| 21 #include "chrome/browser/extensions/pending_extension_manager.h" | 21 #include "chrome/browser/extensions/pending_extension_manager.h" |
| 22 #include "chrome/browser/extensions/updater/extension_downloader.h" | 22 #include "chrome/browser/extensions/updater/extension_downloader.h" |
| 23 #include "chrome/browser/prefs/pref_service.h" | 23 #include "chrome/browser/prefs/pref_service.h" |
| 24 #include "chrome/browser/profiles/profile.h" | 24 #include "chrome/browser/profiles/profile.h" |
| 25 #include "chrome/common/chrome_notification_types.h" | 25 #include "chrome/common/chrome_notification_types.h" |
| 26 #include "chrome/common/extensions/extension.h" | 26 #include "chrome/common/extensions/extension.h" |
| 27 #include "chrome/common/extensions/extension_set.h" | 27 #include "chrome/common/extensions/extension_set.h" |
| 28 #include "chrome/common/extensions/manifest.h" |
| 28 #include "chrome/common/pref_names.h" | 29 #include "chrome/common/pref_names.h" |
| 29 #include "content/public/browser/browser_thread.h" | 30 #include "content/public/browser/browser_thread.h" |
| 30 #include "content/public/browser/notification_details.h" | 31 #include "content/public/browser/notification_details.h" |
| 31 #include "content/public/browser/notification_service.h" | 32 #include "content/public/browser/notification_service.h" |
| 32 #include "content/public/browser/notification_source.h" | 33 #include "content/public/browser/notification_source.h" |
| 33 #include "crypto/sha2.h" | 34 #include "crypto/sha2.h" |
| 34 | 35 |
| 35 using base::RandDouble; | 36 using base::RandDouble; |
| 36 using base::RandInt; | 37 using base::RandInt; |
| 37 using base::Time; | 38 using base::Time; |
| (...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 297 } | 298 } |
| 298 | 299 |
| 299 void ExtensionUpdater::AddToDownloader( | 300 void ExtensionUpdater::AddToDownloader( |
| 300 const ExtensionSet* extensions, | 301 const ExtensionSet* extensions, |
| 301 const std::list<std::string>& pending_ids, | 302 const std::list<std::string>& pending_ids, |
| 302 int request_id) { | 303 int request_id) { |
| 303 InProgressCheck& request = requests_in_progress_[request_id]; | 304 InProgressCheck& request = requests_in_progress_[request_id]; |
| 304 for (ExtensionSet::const_iterator extension_iter = extensions->begin(); | 305 for (ExtensionSet::const_iterator extension_iter = extensions->begin(); |
| 305 extension_iter != extensions->end(); ++extension_iter) { | 306 extension_iter != extensions->end(); ++extension_iter) { |
| 306 const Extension& extension = **extension_iter; | 307 const Extension& extension = **extension_iter; |
| 307 if (!Extension::IsAutoUpdateableLocation(extension.location())) { | 308 if (!Manifest::IsAutoUpdateableLocation(extension.location())) { |
| 308 VLOG(2) << "Extension " << extension.id() << " is not auto updateable"; | 309 VLOG(2) << "Extension " << extension.id() << " is not auto updateable"; |
| 309 continue; | 310 continue; |
| 310 } | 311 } |
| 311 // An extension might be overwritten by policy, and have its update url | 312 // An extension might be overwritten by policy, and have its update url |
| 312 // changed. Make sure existing extensions aren't fetched again, if a | 313 // changed. Make sure existing extensions aren't fetched again, if a |
| 313 // pending fetch for an extension with the same id already exists. | 314 // pending fetch for an extension with the same id already exists. |
| 314 std::list<std::string>::const_iterator pending_id_iter = std::find( | 315 std::list<std::string>::const_iterator pending_id_iter = std::find( |
| 315 pending_ids.begin(), pending_ids.end(), extension.id()); | 316 pending_ids.begin(), pending_ids.end(), extension.id()); |
| 316 if (pending_id_iter == pending_ids.end()) { | 317 if (pending_id_iter == pending_ids.end()) { |
| 317 if (downloader_->AddExtension(extension, request_id)) | 318 if (downloader_->AddExtension(extension, request_id)) |
| (...skipping 29 matching lines...) Expand all Loading... |
| 347 std::list<std::string> pending_ids; | 348 std::list<std::string> pending_ids; |
| 348 | 349 |
| 349 if (params.ids.empty()) { | 350 if (params.ids.empty()) { |
| 350 // If no extension ids are specified, check for updates for all extensions. | 351 // If no extension ids are specified, check for updates for all extensions. |
| 351 pending_extension_manager->GetPendingIdsForUpdateCheck(&pending_ids); | 352 pending_extension_manager->GetPendingIdsForUpdateCheck(&pending_ids); |
| 352 | 353 |
| 353 std::list<std::string>::const_iterator iter; | 354 std::list<std::string>::const_iterator iter; |
| 354 for (iter = pending_ids.begin(); iter != pending_ids.end(); ++iter) { | 355 for (iter = pending_ids.begin(); iter != pending_ids.end(); ++iter) { |
| 355 const PendingExtensionInfo* info = pending_extension_manager->GetById( | 356 const PendingExtensionInfo* info = pending_extension_manager->GetById( |
| 356 *iter); | 357 *iter); |
| 357 if (!Extension::IsAutoUpdateableLocation(info->install_source())) { | 358 if (!Manifest::IsAutoUpdateableLocation(info->install_source())) { |
| 358 VLOG(2) << "Extension " << *iter << " is not auto updateable"; | 359 VLOG(2) << "Extension " << *iter << " is not auto updateable"; |
| 359 continue; | 360 continue; |
| 360 } | 361 } |
| 361 if (downloader_->AddPendingExtension(*iter, info->update_url(), | 362 if (downloader_->AddPendingExtension(*iter, info->update_url(), |
| 362 request_id)) | 363 request_id)) |
| 363 request.in_progress_ids_.push_back(*iter); | 364 request.in_progress_ids_.push_back(*iter); |
| 364 } | 365 } |
| 365 | 366 |
| 366 AddToDownloader(service_->extensions(), pending_ids, request_id); | 367 AddToDownloader(service_->extensions(), pending_ids, request_id); |
| 367 AddToDownloader(service_->disabled_extensions(), pending_ids, request_id); | 368 AddToDownloader(service_->disabled_extensions(), pending_ids, request_id); |
| (...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 689 const InProgressCheck& request = requests_in_progress_[request_id]; | 690 const InProgressCheck& request = requests_in_progress_[request_id]; |
| 690 if (request.in_progress_ids_.empty()) { | 691 if (request.in_progress_ids_.empty()) { |
| 691 VLOG(2) << "Finished update check " << request_id; | 692 VLOG(2) << "Finished update check " << request_id; |
| 692 if (!request.callback.is_null()) | 693 if (!request.callback.is_null()) |
| 693 request.callback.Run(); | 694 request.callback.Run(); |
| 694 requests_in_progress_.erase(request_id); | 695 requests_in_progress_.erase(request_id); |
| 695 } | 696 } |
| 696 } | 697 } |
| 697 | 698 |
| 698 } // namespace extensions | 699 } // namespace extensions |
| OLD | NEW |