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

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: 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->signature_timestamp();
623 extensions::ExtensionSet::const_iterator i;
Finnur 2014/02/12 13:54:57 nit: Like you, I have a tendency to move large dec
asargent_no_longer_on_chrome 2014/02/12 16:27:56 Ah, that's actually a good argument - fixed it.
624 for (i = extensions()->begin(); i != extensions()->end(); ++i) {
625 const Extension& extension = **i;
626 if (verifier->NeedsVerification(extension) &&
627 extension_prefs_->GetInstallTime(extension.id()) >= timestamp) {
Finnur 2014/02/12 13:54:57 You seem to have thought about this problem elsewh
asargent_no_longer_on_chrome 2014/02/12 16:27:56 We have code elsewhere that forces a request for a
628 do_bootstrap = true;
629 break;
630 }
631 }
632 }
633 if (do_bootstrap)
634 VerifyAllExtensions(true); // bootstrap=true.
Finnur 2014/02/12 13:54:57 Refresh my memory... Bootstrap means: Fetch the si
asargent_no_longer_on_chrome 2014/02/12 16:27:56 Right - inside the callback function FinishVerify
Finnur 2014/02/12 16:56:26 Good. I was worried that someone could force Chrom
635 }
636
614 void ExtensionService::VerifyAllExtensions(bool bootstrap) { 637 void ExtensionService::VerifyAllExtensions(bool bootstrap) {
615 ExtensionIdSet to_add; 638 ExtensionIdSet to_add;
616 scoped_ptr<ExtensionSet> all_extensions = GenerateInstalledExtensionsSet(); 639 scoped_ptr<ExtensionSet> all_extensions = GenerateInstalledExtensionsSet();
617 640
618 for (ExtensionSet::const_iterator i = all_extensions->begin(); 641 for (ExtensionSet::const_iterator i = all_extensions->begin();
619 i != all_extensions->end(); ++i) { 642 i != all_extensions->end(); ++i) {
620 const Extension& extension = **i; 643 const Extension& extension = **i;
621 644
622 if (InstallVerifier::NeedsVerification(extension)) 645 if (InstallVerifier::NeedsVerification(extension))
623 to_add.insert(extension.id()); 646 to_add.insert(extension.id());
(...skipping 2248 matching lines...) Expand 10 before | Expand all | Expand 10 after
2872 void ExtensionService::UnloadAllExtensionsInternal() { 2895 void ExtensionService::UnloadAllExtensionsInternal() {
2873 profile_->GetExtensionSpecialStoragePolicy()->RevokeRightsForAllExtensions(); 2896 profile_->GetExtensionSpecialStoragePolicy()->RevokeRightsForAllExtensions();
2874 2897
2875 registry_->ClearAll(); 2898 registry_->ClearAll();
2876 system_->runtime_data()->ClearAll(); 2899 system_->runtime_data()->ClearAll();
2877 2900
2878 // TODO(erikkay) should there be a notification for this? We can't use 2901 // 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 2902 // EXTENSION_UNLOADED since that implies that the extension has been disabled
2880 // or uninstalled. 2903 // or uninstalled.
2881 } 2904 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698