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

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: ready for review 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 870 matching lines...) Expand 10 before | Expand all | Expand 10 after
881 } 881 }
882 882
883 void ExtensionService::EnableExtension(const std::string& extension_id) { 883 void ExtensionService::EnableExtension(const std::string& extension_id) {
884 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 884 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
885 885
886 if (IsExtensionEnabled(extension_id)) 886 if (IsExtensionEnabled(extension_id))
887 return; 887 return;
888 const Extension* extension = disabled_extensions_.GetByID(extension_id); 888 const Extension* extension = disabled_extensions_.GetByID(extension_id);
889 889
890 ManagementPolicy* policy = system_->management_policy(); 890 ManagementPolicy* policy = system_->management_policy();
891 if (extension && policy->MustRemainDisabled(extension, NULL, NULL)) { 891 Extension::DisableReason reason;
892 if (extension && policy->MustRemainDisabled(extension, &reason, NULL)) {
892 UMA_HISTOGRAM_COUNTS_100("Extensions.EnableDeniedByPolicy", 1); 893 UMA_HISTOGRAM_COUNTS_100("Extensions.EnableDeniedByPolicy", 1);
894 if (reason == Extension::DISABLE_NOT_VERIFIED) {
895 // Try adding this id to the verified list, and if it succeeds we may
896 // be able to enable it.
897 extensions::ExtensionSystem::Get(profile_)->install_verifier()->Add(
898 extension->id(), base::Bind(&ExtensionService::EnableOnVerifySuccess,
899 base::Unretained(this),
900 extension_id));
Finnur 2013/12/11 17:28:20 I'm worried this will slam the webstore with lots
asargent_no_longer_on_chrome 2013/12/11 21:26:05 I think this should only happen as a result of the
Finnur 2013/12/11 21:46:31 Does the only codepath through this function invol
901 }
893 return; 902 return;
894 } 903 }
895 904
896 extension_prefs_->SetExtensionState(extension_id, Extension::ENABLED); 905 extension_prefs_->SetExtensionState(extension_id, Extension::ENABLED);
897 extension_prefs_->ClearDisableReasons(extension_id); 906 extension_prefs_->ClearDisableReasons(extension_id);
898 907
899 // This can happen if sync enables an extension that is not 908 // This can happen if sync enables an extension that is not
900 // installed yet. 909 // installed yet.
901 if (!extension) 910 if (!extension)
902 return; 911 return;
(...skipping 1878 matching lines...) Expand 10 before | Expand all | Expand 10 after
2781 blacklisted_extensions_.Insert(extension); 2790 blacklisted_extensions_.Insert(extension);
2782 extension_prefs_->SetExtensionBlacklisted(extension->id(), true); 2791 extension_prefs_->SetExtensionBlacklisted(extension->id(), true);
2783 UnloadExtension(*it, UnloadedExtensionInfo::REASON_BLACKLIST); 2792 UnloadExtension(*it, UnloadedExtensionInfo::REASON_BLACKLIST);
2784 UMA_HISTOGRAM_ENUMERATION("ExtensionBlacklist.BlacklistInstalled", 2793 UMA_HISTOGRAM_ENUMERATION("ExtensionBlacklist.BlacklistInstalled",
2785 extension->location(), Manifest::NUM_LOCATIONS); 2794 extension->location(), Manifest::NUM_LOCATIONS);
2786 } 2795 }
2787 2796
2788 IdentifyAlertableExtensions(); 2797 IdentifyAlertableExtensions();
2789 } 2798 }
2790 2799
2800 void ExtensionService::EnableOnVerifySuccess(std::string extension_id,
2801 bool verify_success) {
2802 ManagementPolicy* policy = system_->management_policy();
2803 const Extension* extension = GetExtensionById(extension_id, true);
2804 if (verify_success && !IsExtensionEnabled(extension_id) &&
2805 !policy->MustRemainDisabled(extension, NULL, NULL)) {
Finnur 2013/12/11 17:28:20 We're guaranteed to have this check in other locat
asargent_no_longer_on_chrome 2013/12/11 21:26:05 Yeah, I agree this is a little awkward. The proble
Finnur 2013/12/11 21:46:31 As discussed in person I had a concern that we hav
2806 EnableExtension(extension_id);
2807 }
Finnur 2013/12/11 17:28:20 nit: Single line if body, no braces.
asargent_no_longer_on_chrome 2013/12/11 21:26:05 Done.
2808 }
2809
2810
2791 void ExtensionService::AddUpdateObserver(extensions::UpdateObserver* observer) { 2811 void ExtensionService::AddUpdateObserver(extensions::UpdateObserver* observer) {
2792 update_observers_.AddObserver(observer); 2812 update_observers_.AddObserver(observer);
2793 } 2813 }
2794 2814
2795 void ExtensionService::RemoveUpdateObserver( 2815 void ExtensionService::RemoveUpdateObserver(
2796 extensions::UpdateObserver* observer) { 2816 extensions::UpdateObserver* observer) {
2797 update_observers_.RemoveObserver(observer); 2817 update_observers_.RemoveObserver(observer);
2798 } 2818 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698