Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(849)

Side by Side Diff: chrome/browser/extensions/updater/extension_updater.cc

Issue 9718028: Allow autoupdate to update disabled extensions. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Synced Created 8 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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
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 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
411 return service_->pending_extension_manager()->IsIdPending(id); 414 return service_->pending_extension_manager()->IsIdPending(id);
412 } 415 }
413 416
414 bool ExtensionUpdater::GetExtensionExistingVersion(const std::string& id, 417 bool ExtensionUpdater::GetExtensionExistingVersion(const std::string& id,
415 std::string* version) { 418 std::string* version) {
416 DCHECK(alive_); 419 DCHECK(alive_);
417 if (id == ExtensionDownloader::kBlacklistAppID) { 420 if (id == ExtensionDownloader::kBlacklistAppID) {
418 *version = prefs_->GetString(kExtensionBlacklistUpdateVersion); 421 *version = prefs_->GetString(kExtensionBlacklistUpdateVersion);
419 return true; 422 return true;
420 } 423 }
421 const Extension* extension = service_->GetExtensionById(id, false); 424 const Extension* extension = service_->GetExtensionById(id, true);
422 if (!extension) 425 if (!extension)
423 return false; 426 return false;
424 *version = extension->version()->GetString(); 427 *version = extension->version()->GetString();
425 return true; 428 return true;
426 } 429 }
427 430
428 void ExtensionUpdater::UpdatePingData(const std::string& id, 431 void ExtensionUpdater::UpdatePingData(const std::string& id,
429 const PingResult& ping_result) { 432 const PingResult& ping_result) {
430 DCHECK(alive_); 433 DCHECK(alive_);
431 if (ping_result.did_ping) { 434 if (ping_result.did_ping) {
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
497 if (in_progress_ids_.empty()) { 500 if (in_progress_ids_.empty()) {
498 VLOG(1) << "Sending EXTENSION_UPDATING_FINISHED"; 501 VLOG(1) << "Sending EXTENSION_UPDATING_FINISHED";
499 content::NotificationService::current()->Notify( 502 content::NotificationService::current()->Notify(
500 chrome::NOTIFICATION_EXTENSION_UPDATING_FINISHED, 503 chrome::NOTIFICATION_EXTENSION_UPDATING_FINISHED,
501 content::Source<Profile>(profile_), 504 content::Source<Profile>(profile_),
502 content::NotificationService::NoDetails()); 505 content::NotificationService::NoDetails());
503 } 506 }
504 } 507 }
505 508
506 } // namespace extensions 509 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/extensions/updater/extension_updater.h ('k') | chrome/browser/extensions/updater/extension_updater_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698