| OLD | NEW |
| 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 1104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1115 | 1115 |
| 1116 if (plugins_changed || nacl_modules_changed) | 1116 if (plugins_changed || nacl_modules_changed) |
| 1117 PluginService::GetInstance()->PurgePluginListCache(profile_, false); | 1117 PluginService::GetInstance()->PurgePluginListCache(profile_, false); |
| 1118 } | 1118 } |
| 1119 | 1119 |
| 1120 void ExtensionService::UpdateExtensionBlacklist( | 1120 void ExtensionService::UpdateExtensionBlacklist( |
| 1121 const std::vector<std::string>& blacklist) { | 1121 const std::vector<std::string>& blacklist) { |
| 1122 // Use this set to indicate if an extension in the blacklist has been used. | 1122 // Use this set to indicate if an extension in the blacklist has been used. |
| 1123 std::set<std::string> blacklist_set; | 1123 std::set<std::string> blacklist_set; |
| 1124 for (unsigned int i = 0; i < blacklist.size(); ++i) { | 1124 for (unsigned int i = 0; i < blacklist.size(); ++i) { |
| 1125 if (Extension::IdIsValid(blacklist[i])) { | 1125 if (Extension::IdIsValid(blacklist[i])) |
| 1126 blacklist_set.insert(blacklist[i]); | 1126 blacklist_set.insert(blacklist[i]); |
| 1127 } | |
| 1128 } | 1127 } |
| 1129 extension_prefs_->UpdateBlacklist(blacklist_set); | 1128 extension_prefs_->UpdateBlacklist(blacklist_set); |
| 1130 std::vector<std::string> to_be_removed; | 1129 CheckManagementPolicy(); |
| 1131 // Loop current extensions, unload installed extensions. | |
| 1132 for (ExtensionSet::const_iterator iter = extensions_.begin(); | |
| 1133 iter != extensions_.end(); ++iter) { | |
| 1134 const Extension* extension = (*iter); | |
| 1135 if (blacklist_set.find(extension->id()) != blacklist_set.end()) { | |
| 1136 to_be_removed.push_back(extension->id()); | |
| 1137 } | |
| 1138 } | |
| 1139 | |
| 1140 // UnloadExtension will change the extensions_ list. So, we should | |
| 1141 // call it outside the iterator loop. | |
| 1142 for (unsigned int i = 0; i < to_be_removed.size(); ++i) { | |
| 1143 UnloadExtension(to_be_removed[i], extension_misc::UNLOAD_REASON_DISABLE); | |
| 1144 } | |
| 1145 } | 1130 } |
| 1146 | 1131 |
| 1147 Profile* ExtensionService::profile() { | 1132 Profile* ExtensionService::profile() { |
| 1148 return profile_; | 1133 return profile_; |
| 1149 } | 1134 } |
| 1150 | 1135 |
| 1151 extensions::ExtensionPrefs* ExtensionService::extension_prefs() { | 1136 extensions::ExtensionPrefs* ExtensionService::extension_prefs() { |
| 1152 return extension_prefs_; | 1137 return extension_prefs_; |
| 1153 } | 1138 } |
| 1154 | 1139 |
| 1155 extensions::SettingsFrontend* ExtensionService::settings_frontend() { | 1140 extensions::SettingsFrontend* ExtensionService::settings_frontend() { |
| 1156 return settings_frontend_.get(); | 1141 return settings_frontend_.get(); |
| 1157 } | 1142 } |
| 1158 | 1143 |
| 1159 extensions::ContentSettingsStore* ExtensionService::GetContentSettingsStore() { | 1144 extensions::ContentSettingsStore* ExtensionService::GetContentSettingsStore() { |
| 1160 return extension_prefs()->content_settings_store(); | 1145 return extension_prefs()->content_settings_store(); |
| 1161 } | 1146 } |
| 1162 | 1147 |
| 1163 bool ExtensionService::is_ready() { | 1148 bool ExtensionService::is_ready() { |
| 1164 return ready_; | 1149 return ready_; |
| 1165 } | 1150 } |
| 1166 | 1151 |
| 1167 extensions::ExtensionUpdater* ExtensionService::updater() { | 1152 extensions::ExtensionUpdater* ExtensionService::updater() { |
| 1168 return updater_.get(); | 1153 return updater_.get(); |
| 1169 } | 1154 } |
| 1170 | 1155 |
| 1171 void ExtensionService::CheckAdminBlacklist() { | 1156 void ExtensionService::CheckManagementPolicy() { |
| 1172 std::vector<std::string> to_be_removed; | 1157 std::vector<std::string> to_be_removed; |
| 1173 // Loop through extensions list, unload installed extensions. | 1158 // Loop through extensions list, unload installed extensions. |
| 1174 for (ExtensionSet::const_iterator iter = extensions_.begin(); | 1159 for (ExtensionSet::const_iterator iter = extensions_.begin(); |
| 1175 iter != extensions_.end(); ++iter) { | 1160 iter != extensions_.end(); ++iter) { |
| 1176 const Extension* extension = (*iter); | 1161 const Extension* extension = (*iter); |
| 1177 if (!system_->management_policy()->UserMayLoad(extension, NULL)) { | 1162 if (!system_->management_policy()->UserMayLoad(extension, NULL)) |
| 1178 to_be_removed.push_back(extension->id()); | 1163 to_be_removed.push_back(extension->id()); |
| 1179 } | |
| 1180 } | 1164 } |
| 1181 | 1165 |
| 1182 // UnloadExtension will change the extensions_ list. So, we should | 1166 // UnloadExtension will change the extensions_ list. So, we should |
| 1183 // call it outside the iterator loop. | 1167 // call it outside the iterator loop. |
| 1184 for (unsigned int i = 0; i < to_be_removed.size(); ++i) | 1168 for (unsigned int i = 0; i < to_be_removed.size(); ++i) |
| 1185 UnloadExtension(to_be_removed[i], extension_misc::UNLOAD_REASON_DISABLE); | 1169 UnloadExtension(to_be_removed[i], extension_misc::UNLOAD_REASON_DISABLE); |
| 1186 } | 1170 } |
| 1187 | 1171 |
| 1188 void ExtensionService::CheckForUpdatesSoon() { | 1172 void ExtensionService::CheckForUpdatesSoon() { |
| 1189 if (updater()) { | 1173 if (updater()) { |
| (...skipping 547 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1737 iter != extensions_.end(); ++iter) { | 1721 iter != extensions_.end(); ++iter) { |
| 1738 const Extension* e = *iter; | 1722 const Extension* e = *iter; |
| 1739 if (Extension::IsExternalLocation(e->location())) { | 1723 if (Extension::IsExternalLocation(e->location())) { |
| 1740 if (!e->is_hosted_app()) { | 1724 if (!e->is_hosted_app()) { |
| 1741 if (!extension_prefs_->IsExternalExtensionAcknowledged(e->id())) { | 1725 if (!extension_prefs_->IsExternalExtensionAcknowledged(e->id())) { |
| 1742 extension_error_ui->AddExternalExtension(e->id()); | 1726 extension_error_ui->AddExternalExtension(e->id()); |
| 1743 needs_alert = true; | 1727 needs_alert = true; |
| 1744 } | 1728 } |
| 1745 } | 1729 } |
| 1746 } | 1730 } |
| 1747 if (extension_prefs_->IsExtensionBlacklisted(e->id())) { | 1731 if (!extension_prefs_->UserMayLoad(e, NULL)) { |
| 1748 if (!extension_prefs_->IsBlacklistedExtensionAcknowledged(e->id())) { | 1732 if (!extension_prefs_->IsBlacklistedExtensionAcknowledged(e->id())) { |
| 1749 extension_error_ui->AddBlacklistedExtension(e->id()); | 1733 extension_error_ui->AddBlacklistedExtension(e->id()); |
| 1750 needs_alert = true; | 1734 needs_alert = true; |
| 1751 } | 1735 } |
| 1752 } | 1736 } |
| 1753 if (extension_prefs_->IsExtensionOrphaned(e->id())) { | 1737 if (extension_prefs_->IsExtensionOrphaned(e->id())) { |
| 1754 if (!extension_prefs_->IsOrphanedExtensionAcknowledged(e->id())) { | 1738 if (!extension_prefs_->IsOrphanedExtensionAcknowledged(e->id())) { |
| 1755 extension_error_ui->AddOrphanedExtension(e->id()); | 1739 extension_error_ui->AddOrphanedExtension(e->id()); |
| 1756 needs_alert = true; | 1740 needs_alert = true; |
| 1757 } | 1741 } |
| (...skipping 653 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2411 BrowserThread::IO, FROM_HERE, | 2395 BrowserThread::IO, FROM_HERE, |
| 2412 base::Bind(&ExtensionInfoMap::UnregisterAllExtensionsInProcess, | 2396 base::Bind(&ExtensionInfoMap::UnregisterAllExtensionsInProcess, |
| 2413 system_->info_map(), | 2397 system_->info_map(), |
| 2414 process->GetID())); | 2398 process->GetID())); |
| 2415 break; | 2399 break; |
| 2416 } | 2400 } |
| 2417 case chrome::NOTIFICATION_PREF_CHANGED: { | 2401 case chrome::NOTIFICATION_PREF_CHANGED: { |
| 2418 std::string* pref_name = content::Details<std::string>(details).ptr(); | 2402 std::string* pref_name = content::Details<std::string>(details).ptr(); |
| 2419 if (*pref_name == prefs::kExtensionInstallAllowList || | 2403 if (*pref_name == prefs::kExtensionInstallAllowList || |
| 2420 *pref_name == prefs::kExtensionInstallDenyList) { | 2404 *pref_name == prefs::kExtensionInstallDenyList) { |
| 2421 CheckAdminBlacklist(); | 2405 IdentifyAlertableExtensions(); |
| 2406 CheckManagementPolicy(); |
| 2422 } else { | 2407 } else { |
| 2423 NOTREACHED() << "Unexpected preference name."; | 2408 NOTREACHED() << "Unexpected preference name."; |
| 2424 } | 2409 } |
| 2425 break; | 2410 break; |
| 2426 } | 2411 } |
| 2427 case chrome::NOTIFICATION_IMPORT_FINISHED: { | 2412 case chrome::NOTIFICATION_IMPORT_FINISHED: { |
| 2428 InitAfterImport(); | 2413 InitAfterImport(); |
| 2429 break; | 2414 break; |
| 2430 } | 2415 } |
| 2431 | 2416 |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2552 | 2537 |
| 2553 ExtensionService::NaClModuleInfoList::iterator | 2538 ExtensionService::NaClModuleInfoList::iterator |
| 2554 ExtensionService::FindNaClModule(const GURL& url) { | 2539 ExtensionService::FindNaClModule(const GURL& url) { |
| 2555 for (NaClModuleInfoList::iterator iter = nacl_module_list_.begin(); | 2540 for (NaClModuleInfoList::iterator iter = nacl_module_list_.begin(); |
| 2556 iter != nacl_module_list_.end(); ++iter) { | 2541 iter != nacl_module_list_.end(); ++iter) { |
| 2557 if (iter->url == url) | 2542 if (iter->url == url) |
| 2558 return iter; | 2543 return iter; |
| 2559 } | 2544 } |
| 2560 return nacl_module_list_.end(); | 2545 return nacl_module_list_.end(); |
| 2561 } | 2546 } |
| OLD | NEW |