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

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

Issue 93513006: Allow re-enabling of DISABLE_NOT_VERIFIED extensions if appropriate (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: updated to auto-recheck on settings page load when appropriate Created 7 years 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 550 matching lines...) Expand 10 before | Expand all | Expand 10 after
561 extension_prefs_->GetAllDelayedInstallInfo()); 561 extension_prefs_->GetAllDelayedInstallInfo());
562 UMA_HISTOGRAM_COUNTS_100("Extensions.UpdateOnLoad", 562 UMA_HISTOGRAM_COUNTS_100("Extensions.UpdateOnLoad",
563 delayed_info2->size() - delayed_info->size()); 563 delayed_info2->size() - delayed_info->size());
564 564
565 SetReadyAndNotifyListeners(); 565 SetReadyAndNotifyListeners();
566 566
567 // TODO(erikkay) this should probably be deferred to a future point 567 // TODO(erikkay) this should probably be deferred to a future point
568 // rather than running immediately at startup. 568 // rather than running immediately at startup.
569 CheckForExternalUpdates(); 569 CheckForExternalUpdates();
570 570
571 InstallVerifier* verifier =
572 extensions::ExtensionSystem::Get(profile_)->install_verifier();
573 if (verifier->NeedsBootstrap())
574 VerifyAllExtensions();
575
571 base::MessageLoop::current()->PostDelayedTask( 576 base::MessageLoop::current()->PostDelayedTask(
572 FROM_HERE, 577 FROM_HERE,
573 base::Bind(&ExtensionService::GarbageCollectExtensions, AsWeakPtr()), 578 base::Bind(&ExtensionService::GarbageCollectExtensions, AsWeakPtr()),
574 base::TimeDelta::FromSeconds(kGarbageCollectStartupDelay)); 579 base::TimeDelta::FromSeconds(kGarbageCollectStartupDelay));
575 580
576 if (extension_prefs_->NeedsStorageGarbageCollection()) { 581 if (extension_prefs_->NeedsStorageGarbageCollection()) {
577 GarbageCollectIsolatedStorage(); 582 GarbageCollectIsolatedStorage();
578 extension_prefs_->SetNeedsStorageGarbageCollection(false); 583 extension_prefs_->SetNeedsStorageGarbageCollection(false);
579 } 584 }
580 system_->management_policy()->RegisterProvider( 585 system_->management_policy()->RegisterProvider(
581 shared_module_policy_provider_.get()); 586 shared_module_policy_provider_.get());
582 } 587 }
583 588
584 UMA_HISTOGRAM_TIMES("Extensions.ExtensionServiceInitTime", 589 UMA_HISTOGRAM_TIMES("Extensions.ExtensionServiceInitTime",
585 base::Time::Now() - begin_time); 590 base::Time::Now() - begin_time);
586 } 591 }
587 592
593 void ExtensionService::VerifyAllExtensions() {
594 ExtensionIdSet to_add;
595 scoped_ptr<ExtensionSet> all_extensions = GenerateInstalledExtensionsSet();
596
597 for (ExtensionSet::const_iterator i = all_extensions->begin();
598 i != all_extensions->end(); ++i) {
599 const Extension& extension = **i;
600
601 if (extensions::ManifestURL::UpdatesFromGallery(&extension) &&
602 extension.is_extension())
603 to_add.insert(extension.id());
604 }
605 extensions::ExtensionSystem::Get(profile_)->install_verifier()->AddMany(
606 to_add, base::Bind(&ExtensionService::FinishVerifyAllExtensions,
607 AsWeakPtr()));
608 }
609
610 void ExtensionService::FinishVerifyAllExtensions(bool success) {
611 if (success) {
612 // Check to see if any currently unverified extensions became verified.
613 InstallVerifier* verifier =
614 extensions::ExtensionSystem::Get(profile_)->install_verifier();
615 for (ExtensionSet::const_iterator i = disabled_extensions_.begin();
616 i != disabled_extensions_.end(); ++i) {
617 const Extension& extension = **i;
618 int disable_reasons = extension_prefs_->GetDisableReasons(extension.id());
619 if (disable_reasons & Extension::DISABLE_NOT_VERIFIED &&
620 !verifier->MustRemainDisabled(&extension, NULL, NULL)) {
621 extension_prefs_->RemoveDisableReason(extension.id(),
622 Extension::DISABLE_NOT_VERIFIED);
623 // Notify interested observers (eg the extensions settings page) by
624 // sending an UNLOADED notification.
625 //
626 // TODO(asargent) - this is a slight hack because it's already
627 // disabled; the right solution might be to add a separate listener
628 // interface for DisableReason's changing.
Finnur 2013/12/16 14:21:51 Log a bug for this?
asargent_no_longer_on_chrome 2013/12/16 18:47:10 Done.
629 UnloadedExtensionInfo details(&extension,
630 UnloadedExtensionInfo::REASON_DISABLE);
631 content::NotificationService::current()->Notify(
632 chrome::NOTIFICATION_EXTENSION_UNLOADED,
633 content::Source<Profile>(profile_),
634 content::Details<UnloadedExtensionInfo>(&details));
635 }
636 }
637 // Might disable some extensions.
638 CheckManagementPolicy();
639 }
640 }
641
588 bool ExtensionService::UpdateExtension(const std::string& id, 642 bool ExtensionService::UpdateExtension(const std::string& id,
589 const base::FilePath& extension_path, 643 const base::FilePath& extension_path,
590 const GURL& download_url, 644 const GURL& download_url,
591 CrxInstaller** out_crx_installer) { 645 CrxInstaller** out_crx_installer) {
592 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 646 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
593 if (browser_terminating_) { 647 if (browser_terminating_) {
594 LOG(WARNING) << "Skipping UpdateExtension due to browser shutdown"; 648 LOG(WARNING) << "Skipping UpdateExtension due to browser shutdown";
595 // Leak the temp file at extension_path. We don't want to add to the disk 649 // Leak the temp file at extension_path. We don't want to add to the disk
596 // I/O burden at shutdown, we can't rely on the I/O completing anyway, and 650 // I/O burden at shutdown, we can't rely on the I/O completing anyway, and
597 // the file is in the OS temp directory which should be cleaned up for us. 651 // the file is in the OS temp directory which should be cleaned up for us.
(...skipping 2191 matching lines...) Expand 10 before | Expand all | Expand 10 after
2789 } 2843 }
2790 2844
2791 void ExtensionService::AddUpdateObserver(extensions::UpdateObserver* observer) { 2845 void ExtensionService::AddUpdateObserver(extensions::UpdateObserver* observer) {
2792 update_observers_.AddObserver(observer); 2846 update_observers_.AddObserver(observer);
2793 } 2847 }
2794 2848
2795 void ExtensionService::RemoveUpdateObserver( 2849 void ExtensionService::RemoveUpdateObserver(
2796 extensions::UpdateObserver* observer) { 2850 extensions::UpdateObserver* observer) {
2797 update_observers_.RemoveObserver(observer); 2851 update_observers_.RemoveObserver(observer);
2798 } 2852 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698