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

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

Issue 10854009: Extension white and force lists (set by policy) should have priority over auto-updated Google black… (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Rebased and merged Created 8 years, 4 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 <set> 8 #include <set>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
(...skipping 1107 matching lines...) Expand 10 before | Expand all | Expand 10 after
1118 1118
1119 if (plugins_changed || nacl_modules_changed) 1119 if (plugins_changed || nacl_modules_changed)
1120 PluginService::GetInstance()->PurgePluginListCache(profile_, false); 1120 PluginService::GetInstance()->PurgePluginListCache(profile_, false);
1121 } 1121 }
1122 1122
1123 void ExtensionService::UpdateExtensionBlacklist( 1123 void ExtensionService::UpdateExtensionBlacklist(
1124 const std::vector<std::string>& blacklist) { 1124 const std::vector<std::string>& blacklist) {
1125 // Use this set to indicate if an extension in the blacklist has been used. 1125 // Use this set to indicate if an extension in the blacklist has been used.
1126 std::set<std::string> blacklist_set; 1126 std::set<std::string> blacklist_set;
1127 for (unsigned int i = 0; i < blacklist.size(); ++i) { 1127 for (unsigned int i = 0; i < blacklist.size(); ++i) {
1128 if (Extension::IdIsValid(blacklist[i])) { 1128 if (Extension::IdIsValid(blacklist[i]))
1129 blacklist_set.insert(blacklist[i]); 1129 blacklist_set.insert(blacklist[i]);
1130 }
1131 } 1130 }
1132 extension_prefs_->UpdateBlacklist(blacklist_set); 1131 extension_prefs_->UpdateBlacklist(blacklist_set);
1133 std::vector<std::string> to_be_removed; 1132 CheckManagementPolicy();
1134 // Loop current extensions, unload installed extensions.
1135 for (ExtensionSet::const_iterator iter = extensions_.begin();
1136 iter != extensions_.end(); ++iter) {
1137 const Extension* extension = (*iter);
1138 if (blacklist_set.find(extension->id()) != blacklist_set.end()) {
1139 to_be_removed.push_back(extension->id());
1140 }
1141 }
1142
1143 // UnloadExtension will change the extensions_ list. So, we should
1144 // call it outside the iterator loop.
1145 for (unsigned int i = 0; i < to_be_removed.size(); ++i) {
1146 UnloadExtension(to_be_removed[i], extension_misc::UNLOAD_REASON_DISABLE);
1147 }
1148 } 1133 }
1149 1134
1150 Profile* ExtensionService::profile() { 1135 Profile* ExtensionService::profile() {
1151 return profile_; 1136 return profile_;
1152 } 1137 }
1153 1138
1154 extensions::ExtensionPrefs* ExtensionService::extension_prefs() { 1139 extensions::ExtensionPrefs* ExtensionService::extension_prefs() {
1155 return extension_prefs_; 1140 return extension_prefs_;
1156 } 1141 }
1157 1142
1158 extensions::SettingsFrontend* ExtensionService::settings_frontend() { 1143 extensions::SettingsFrontend* ExtensionService::settings_frontend() {
1159 return settings_frontend_.get(); 1144 return settings_frontend_.get();
1160 } 1145 }
1161 1146
1162 extensions::ContentSettingsStore* ExtensionService::GetContentSettingsStore() { 1147 extensions::ContentSettingsStore* ExtensionService::GetContentSettingsStore() {
1163 return extension_prefs()->content_settings_store(); 1148 return extension_prefs()->content_settings_store();
1164 } 1149 }
1165 1150
1166 bool ExtensionService::is_ready() { 1151 bool ExtensionService::is_ready() {
1167 return ready_; 1152 return ready_;
1168 } 1153 }
1169 1154
1170 extensions::ExtensionUpdater* ExtensionService::updater() { 1155 extensions::ExtensionUpdater* ExtensionService::updater() {
1171 return updater_.get(); 1156 return updater_.get();
1172 } 1157 }
1173 1158
1174 void ExtensionService::CheckAdminBlacklist() { 1159 void ExtensionService::CheckManagementPolicy() {
1175 std::vector<std::string> to_be_removed; 1160 std::vector<std::string> to_be_removed;
1176 // Loop through extensions list, unload installed extensions. 1161 // Loop through extensions list, unload installed extensions.
1177 for (ExtensionSet::const_iterator iter = extensions_.begin(); 1162 for (ExtensionSet::const_iterator iter = extensions_.begin();
1178 iter != extensions_.end(); ++iter) { 1163 iter != extensions_.end(); ++iter) {
1179 const Extension* extension = (*iter); 1164 const Extension* extension = (*iter);
1180 if (!system_->management_policy()->UserMayLoad(extension, NULL)) { 1165 if (!system_->management_policy()->UserMayLoad(extension, NULL))
1181 to_be_removed.push_back(extension->id()); 1166 to_be_removed.push_back(extension->id());
1182 }
1183 } 1167 }
1184 1168
1185 // UnloadExtension will change the extensions_ list. So, we should 1169 // UnloadExtension will change the extensions_ list. So, we should
1186 // call it outside the iterator loop. 1170 // call it outside the iterator loop.
1187 for (unsigned int i = 0; i < to_be_removed.size(); ++i) 1171 for (unsigned int i = 0; i < to_be_removed.size(); ++i)
1188 UnloadExtension(to_be_removed[i], extension_misc::UNLOAD_REASON_DISABLE); 1172 UnloadExtension(to_be_removed[i], extension_misc::UNLOAD_REASON_DISABLE);
1189 } 1173 }
1190 1174
1191 void ExtensionService::CheckForUpdatesSoon() { 1175 void ExtensionService::CheckForUpdatesSoon() {
1192 if (updater()) { 1176 if (updater()) {
(...skipping 547 matching lines...) Expand 10 before | Expand all | Expand 10 after
1740 iter != extensions_.end(); ++iter) { 1724 iter != extensions_.end(); ++iter) {
1741 const Extension* e = *iter; 1725 const Extension* e = *iter;
1742 if (Extension::IsExternalLocation(e->location())) { 1726 if (Extension::IsExternalLocation(e->location())) {
1743 if (!e->is_hosted_app()) { 1727 if (!e->is_hosted_app()) {
1744 if (!extension_prefs_->IsExternalExtensionAcknowledged(e->id())) { 1728 if (!extension_prefs_->IsExternalExtensionAcknowledged(e->id())) {
1745 extension_error_ui->AddExternalExtension(e->id()); 1729 extension_error_ui->AddExternalExtension(e->id());
1746 needs_alert = true; 1730 needs_alert = true;
1747 } 1731 }
1748 } 1732 }
1749 } 1733 }
1750 if (extension_prefs_->IsExtensionBlacklisted(e->id())) { 1734 if (!extension_prefs_->UserMayLoad(e, NULL)) {
1751 if (!extension_prefs_->IsBlacklistedExtensionAcknowledged(e->id())) { 1735 if (!extension_prefs_->IsBlacklistedExtensionAcknowledged(e->id())) {
1752 extension_error_ui->AddBlacklistedExtension(e->id()); 1736 extension_error_ui->AddBlacklistedExtension(e->id());
1753 needs_alert = true; 1737 needs_alert = true;
1754 } 1738 }
1755 } 1739 }
1756 if (extension_prefs_->IsExtensionOrphaned(e->id())) { 1740 if (extension_prefs_->IsExtensionOrphaned(e->id())) {
1757 if (!extension_prefs_->IsOrphanedExtensionAcknowledged(e->id())) { 1741 if (!extension_prefs_->IsOrphanedExtensionAcknowledged(e->id())) {
1758 extension_error_ui->AddOrphanedExtension(e->id()); 1742 extension_error_ui->AddOrphanedExtension(e->id());
1759 needs_alert = true; 1743 needs_alert = true;
1760 } 1744 }
(...skipping 661 matching lines...) Expand 10 before | Expand all | Expand 10 after
2422 BrowserThread::IO, FROM_HERE, 2406 BrowserThread::IO, FROM_HERE,
2423 base::Bind(&ExtensionInfoMap::UnregisterAllExtensionsInProcess, 2407 base::Bind(&ExtensionInfoMap::UnregisterAllExtensionsInProcess,
2424 system_->info_map(), 2408 system_->info_map(),
2425 process->GetID())); 2409 process->GetID()));
2426 break; 2410 break;
2427 } 2411 }
2428 case chrome::NOTIFICATION_PREF_CHANGED: { 2412 case chrome::NOTIFICATION_PREF_CHANGED: {
2429 std::string* pref_name = content::Details<std::string>(details).ptr(); 2413 std::string* pref_name = content::Details<std::string>(details).ptr();
2430 if (*pref_name == prefs::kExtensionInstallAllowList || 2414 if (*pref_name == prefs::kExtensionInstallAllowList ||
2431 *pref_name == prefs::kExtensionInstallDenyList) { 2415 *pref_name == prefs::kExtensionInstallDenyList) {
2432 CheckAdminBlacklist(); 2416 IdentifyAlertableExtensions();
2417 CheckManagementPolicy();
2433 } else { 2418 } else {
2434 NOTREACHED() << "Unexpected preference name."; 2419 NOTREACHED() << "Unexpected preference name.";
2435 } 2420 }
2436 break; 2421 break;
2437 } 2422 }
2438 case chrome::NOTIFICATION_IMPORT_FINISHED: { 2423 case chrome::NOTIFICATION_IMPORT_FINISHED: {
2439 InitAfterImport(); 2424 InitAfterImport();
2440 break; 2425 break;
2441 } 2426 }
2442 2427
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
2573 2558
2574 ExtensionService::NaClModuleInfoList::iterator 2559 ExtensionService::NaClModuleInfoList::iterator
2575 ExtensionService::FindNaClModule(const GURL& url) { 2560 ExtensionService::FindNaClModule(const GURL& url) {
2576 for (NaClModuleInfoList::iterator iter = nacl_module_list_.begin(); 2561 for (NaClModuleInfoList::iterator iter = nacl_module_list_.begin();
2577 iter != nacl_module_list_.end(); ++iter) { 2562 iter != nacl_module_list_.end(); ++iter) {
2578 if (iter->url == url) 2563 if (iter->url == url)
2579 return iter; 2564 return iter;
2580 } 2565 }
2581 return nacl_module_list_.end(); 2566 return nacl_module_list_.end();
2582 } 2567 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_service.h ('k') | chrome/browser/extensions/extension_service_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698