OLD | NEW |
---|---|
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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_service.h" | 5 #include "chrome/browser/extensions/extension_service.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <iterator> | 8 #include <iterator> |
9 #include <set> | 9 #include <set> |
10 | 10 |
(...skipping 556 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
567 extension_prefs_->GetAllDelayedInstallInfo()); | 567 extension_prefs_->GetAllDelayedInstallInfo()); |
568 UMA_HISTOGRAM_COUNTS_100("Extensions.UpdateOnLoad", | 568 UMA_HISTOGRAM_COUNTS_100("Extensions.UpdateOnLoad", |
569 delayed_info2->size() - delayed_info->size()); | 569 delayed_info2->size() - delayed_info->size()); |
570 | 570 |
571 SetReadyAndNotifyListeners(); | 571 SetReadyAndNotifyListeners(); |
572 | 572 |
573 // TODO(erikkay) this should probably be deferred to a future point | 573 // TODO(erikkay) this should probably be deferred to a future point |
574 // rather than running immediately at startup. | 574 // rather than running immediately at startup. |
575 CheckForExternalUpdates(); | 575 CheckForExternalUpdates(); |
576 | 576 |
577 InstallVerifier* verifier = | 577 MaybeBootstrapVerifier(); |
578 extensions::ExtensionSystem::Get(profile_)->install_verifier(); | |
579 if (verifier->NeedsBootstrap()) | |
580 VerifyAllExtensions(true); // bootstrap=true. | |
581 base::MessageLoop::current()->PostDelayedTask( | 578 base::MessageLoop::current()->PostDelayedTask( |
582 FROM_HERE, | 579 FROM_HERE, |
583 base::Bind(&ExtensionService::GarbageCollectExtensions, AsWeakPtr()), | 580 base::Bind(&ExtensionService::GarbageCollectExtensions, AsWeakPtr()), |
584 base::TimeDelta::FromSeconds(kGarbageCollectStartupDelay)); | 581 base::TimeDelta::FromSeconds(kGarbageCollectStartupDelay)); |
585 | 582 |
586 if (extension_prefs_->NeedsStorageGarbageCollection()) { | 583 if (extension_prefs_->NeedsStorageGarbageCollection()) { |
587 GarbageCollectIsolatedStorage(); | 584 GarbageCollectIsolatedStorage(); |
588 extension_prefs_->SetNeedsStorageGarbageCollection(false); | 585 extension_prefs_->SetNeedsStorageGarbageCollection(false); |
589 } | 586 } |
590 system_->management_policy()->RegisterProvider( | 587 system_->management_policy()->RegisterProvider( |
(...skipping 13 matching lines...) Expand all Loading... | |
604 it != all_extensions->end(); ++it) { | 601 it != all_extensions->end(); ++it) { |
605 extensions::BlacklistState state = | 602 extensions::BlacklistState state = |
606 extension_prefs_->GetExtensionBlacklistState((*it)->id()); | 603 extension_prefs_->GetExtensionBlacklistState((*it)->id()); |
607 if (state == extensions::BLACKLISTED_SECURITY_VULNERABILITY || | 604 if (state == extensions::BLACKLISTED_SECURITY_VULNERABILITY || |
608 state == extensions::BLACKLISTED_POTENTIALLY_UNWANTED || | 605 state == extensions::BLACKLISTED_POTENTIALLY_UNWANTED || |
609 state == extensions::BLACKLISTED_CWS_POLICY_VIOLATION) | 606 state == extensions::BLACKLISTED_CWS_POLICY_VIOLATION) |
610 greylist_.Insert(*it); | 607 greylist_.Insert(*it); |
611 } | 608 } |
612 } | 609 } |
613 | 610 |
611 void ExtensionService::MaybeBootstrapVerifier() { | |
612 InstallVerifier* verifier = | |
613 extensions::ExtensionSystem::Get(profile_)->install_verifier(); | |
614 bool do_bootstrap = false; | |
615 | |
616 if (verifier->NeedsBootstrap()) { | |
617 do_bootstrap = true; | |
618 } else { | |
619 // If any of the installed extensions have an install time newer than the | |
620 // signature's timestamp, we need to bootstrap because our signature may | |
621 // be missing valid extensions. | |
622 base::Time timestamp = verifier->SignatureTimestamp(); | |
623 for (extensions::ExtensionSet::const_iterator i = extensions()->begin(); | |
624 i != extensions()->end(); | |
625 ++i) { | |
626 const Extension& extension = **i; | |
627 base::Time install_time = | |
628 extension_prefs_->GetInstallTime(extension.id()); | |
629 if (verifier->NeedsVerification(extension) && | |
630 install_time < base::Time::Now() && install_time >= timestamp) { | |
asargent_no_longer_on_chrome
2014/02/12 18:32:26
Note: I added the same "ignore times in the future
| |
631 do_bootstrap = true; | |
632 break; | |
633 } | |
634 } | |
635 } | |
636 if (do_bootstrap) | |
637 VerifyAllExtensions(true); // bootstrap=true. | |
638 } | |
639 | |
614 void ExtensionService::VerifyAllExtensions(bool bootstrap) { | 640 void ExtensionService::VerifyAllExtensions(bool bootstrap) { |
615 ExtensionIdSet to_add; | 641 ExtensionIdSet to_add; |
616 scoped_ptr<ExtensionSet> all_extensions = GenerateInstalledExtensionsSet(); | 642 scoped_ptr<ExtensionSet> all_extensions = GenerateInstalledExtensionsSet(); |
617 | 643 |
618 for (ExtensionSet::const_iterator i = all_extensions->begin(); | 644 for (ExtensionSet::const_iterator i = all_extensions->begin(); |
619 i != all_extensions->end(); ++i) { | 645 i != all_extensions->end(); ++i) { |
620 const Extension& extension = **i; | 646 const Extension& extension = **i; |
621 | 647 |
622 if (InstallVerifier::NeedsVerification(extension)) | 648 if (InstallVerifier::NeedsVerification(extension)) |
623 to_add.insert(extension.id()); | 649 to_add.insert(extension.id()); |
(...skipping 2248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2872 void ExtensionService::UnloadAllExtensionsInternal() { | 2898 void ExtensionService::UnloadAllExtensionsInternal() { |
2873 profile_->GetExtensionSpecialStoragePolicy()->RevokeRightsForAllExtensions(); | 2899 profile_->GetExtensionSpecialStoragePolicy()->RevokeRightsForAllExtensions(); |
2874 | 2900 |
2875 registry_->ClearAll(); | 2901 registry_->ClearAll(); |
2876 system_->runtime_data()->ClearAll(); | 2902 system_->runtime_data()->ClearAll(); |
2877 | 2903 |
2878 // TODO(erikkay) should there be a notification for this? We can't use | 2904 // TODO(erikkay) should there be a notification for this? We can't use |
2879 // EXTENSION_UNLOADED since that implies that the extension has been disabled | 2905 // EXTENSION_UNLOADED since that implies that the extension has been disabled |
2880 // or uninstalled. | 2906 // or uninstalled. |
2881 } | 2907 } |
OLD | NEW |