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

Side by Side Diff: chrome/browser/extensions/extension_service.cc

Issue 160313002: Don't disable extensions immediately if verification is out of date (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fixes suggested by review Created 6 years, 10 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 | Annotate | Revision Log
OLDNEW
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
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
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 if (verifier->NeedsVerification(extension) &&
628 extension_prefs_->GetInstallTime(extension.id()) >= timestamp) {
629 do_bootstrap = true;
630 break;
631 }
632 }
633 }
634 if (do_bootstrap)
635 VerifyAllExtensions(true); // bootstrap=true.
636 }
637
614 void ExtensionService::VerifyAllExtensions(bool bootstrap) { 638 void ExtensionService::VerifyAllExtensions(bool bootstrap) {
615 ExtensionIdSet to_add; 639 ExtensionIdSet to_add;
616 scoped_ptr<ExtensionSet> all_extensions = GenerateInstalledExtensionsSet(); 640 scoped_ptr<ExtensionSet> all_extensions = GenerateInstalledExtensionsSet();
617 641
618 for (ExtensionSet::const_iterator i = all_extensions->begin(); 642 for (ExtensionSet::const_iterator i = all_extensions->begin();
619 i != all_extensions->end(); ++i) { 643 i != all_extensions->end(); ++i) {
620 const Extension& extension = **i; 644 const Extension& extension = **i;
621 645
622 if (InstallVerifier::NeedsVerification(extension)) 646 if (InstallVerifier::NeedsVerification(extension))
623 to_add.insert(extension.id()); 647 to_add.insert(extension.id());
(...skipping 2248 matching lines...) Expand 10 before | Expand all | Expand 10 after
2872 void ExtensionService::UnloadAllExtensionsInternal() { 2896 void ExtensionService::UnloadAllExtensionsInternal() {
2873 profile_->GetExtensionSpecialStoragePolicy()->RevokeRightsForAllExtensions(); 2897 profile_->GetExtensionSpecialStoragePolicy()->RevokeRightsForAllExtensions();
2874 2898
2875 registry_->ClearAll(); 2899 registry_->ClearAll();
2876 system_->runtime_data()->ClearAll(); 2900 system_->runtime_data()->ClearAll();
2877 2901
2878 // TODO(erikkay) should there be a notification for this? We can't use 2902 // 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 2903 // EXTENSION_UNLOADED since that implies that the extension has been disabled
2880 // or uninstalled. 2904 // or uninstalled.
2881 } 2905 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698