OLD | NEW |
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 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
160 | 160 |
161 void ExtensionService::AddProviderForTesting( | 161 void ExtensionService::AddProviderForTesting( |
162 extensions::ExternalProviderInterface* test_provider) { | 162 extensions::ExternalProviderInterface* test_provider) { |
163 CHECK(test_provider); | 163 CHECK(test_provider); |
164 external_extension_providers_.push_back( | 164 external_extension_providers_.push_back( |
165 linked_ptr<extensions::ExternalProviderInterface>(test_provider)); | 165 linked_ptr<extensions::ExternalProviderInterface>(test_provider)); |
166 } | 166 } |
167 | 167 |
168 void ExtensionService::BlacklistExtensionForTest( | 168 void ExtensionService::BlacklistExtensionForTest( |
169 const std::string& extension_id) { | 169 const std::string& extension_id) { |
170 ExtensionIdSet blocked; | 170 ExtensionIdSet blacklisted; |
171 ExtensionIdSet unchanged; | 171 ExtensionIdSet unchanged; |
172 blocked.insert(extension_id); | 172 blacklisted.insert(extension_id); |
173 UpdateBlockedExtensions(blocked, unchanged); | 173 UpdateBlacklistedExtensions(blacklisted, unchanged); |
174 } | 174 } |
175 | 175 |
176 bool ExtensionService::OnExternalExtensionUpdateUrlFound( | 176 bool ExtensionService::OnExternalExtensionUpdateUrlFound( |
177 const std::string& id, | 177 const std::string& id, |
178 const std::string& install_parameter, | 178 const std::string& install_parameter, |
179 const GURL& update_url, | 179 const GURL& update_url, |
180 Manifest::Location location, | 180 Manifest::Location location, |
181 int creation_flags, | 181 int creation_flags, |
182 bool mark_acknowledged) { | 182 bool mark_acknowledged) { |
183 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 183 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
263 pending_extension_manager_(profile), | 263 pending_extension_manager_(profile), |
264 install_directory_(install_directory), | 264 install_directory_(install_directory), |
265 extensions_enabled_(extensions_enabled), | 265 extensions_enabled_(extensions_enabled), |
266 show_extensions_prompts_(true), | 266 show_extensions_prompts_(true), |
267 install_updates_when_idle_(true), | 267 install_updates_when_idle_(true), |
268 ready_(ready), | 268 ready_(ready), |
269 update_once_all_providers_are_ready_(false), | 269 update_once_all_providers_are_ready_(false), |
270 browser_terminating_(false), | 270 browser_terminating_(false), |
271 installs_delayed_for_gc_(false), | 271 installs_delayed_for_gc_(false), |
272 is_first_run_(false), | 272 is_first_run_(false), |
| 273 block_extensions_(false), |
273 shared_module_service_(new extensions::SharedModuleService(profile_)) { | 274 shared_module_service_(new extensions::SharedModuleService(profile_)) { |
274 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 275 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
275 | 276 |
276 // Figure out if extension installation should be enabled. | 277 // Figure out if extension installation should be enabled. |
277 if (extensions::ExtensionsBrowserClient::Get()->AreExtensionsDisabled( | 278 if (extensions::ExtensionsBrowserClient::Get()->AreExtensionsDisabled( |
278 *command_line, profile)) | 279 *command_line, profile)) |
279 extensions_enabled_ = false; | 280 extensions_enabled_ = false; |
280 | 281 |
281 registrar_.Add(this, chrome::NOTIFICATION_APP_TERMINATING, | 282 registrar_.Add(this, chrome::NOTIFICATION_APP_TERMINATING, |
282 content::NotificationService::AllBrowserContextsAndSources()); | 283 content::NotificationService::AllBrowserContextsAndSources()); |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
363 ->GetForBrowserContext(profile()) | 364 ->GetForBrowserContext(profile()) |
364 ->RemoveObserver(this); | 365 ->RemoveObserver(this); |
365 system_->management_policy()->UnregisterProvider( | 366 system_->management_policy()->UnregisterProvider( |
366 shared_module_policy_provider_.get()); | 367 shared_module_policy_provider_.get()); |
367 } | 368 } |
368 | 369 |
369 const Extension* ExtensionService::GetExtensionById( | 370 const Extension* ExtensionService::GetExtensionById( |
370 const std::string& id, bool include_disabled) const { | 371 const std::string& id, bool include_disabled) const { |
371 int include_mask = ExtensionRegistry::ENABLED; | 372 int include_mask = ExtensionRegistry::ENABLED; |
372 if (include_disabled) { | 373 if (include_disabled) { |
373 // Include blacklisted extensions here because there are hundreds of | 374 // Include blacklisted and blocked extensions here because there are |
374 // callers of this function, and many might assume that this includes those | 375 // hundreds of callers of this function, and many might assume that this |
375 // that have been disabled due to blacklisting. | 376 // includes those that have been disabled due to blacklisting or blocking. |
376 include_mask |= ExtensionRegistry::DISABLED | | 377 include_mask |= ExtensionRegistry::DISABLED | |
377 ExtensionRegistry::BLACKLISTED; | 378 ExtensionRegistry::BLACKLISTED | ExtensionRegistry::BLOCKED; |
378 } | 379 } |
379 return registry_->GetExtensionById(id, include_mask); | 380 return registry_->GetExtensionById(id, include_mask); |
380 } | 381 } |
381 | 382 |
382 void ExtensionService::Init() { | 383 void ExtensionService::Init() { |
383 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 384 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
384 | 385 |
385 base::Time begin_time = base::Time::Now(); | 386 base::Time begin_time = base::Time::Now(); |
386 | 387 |
387 DCHECK(!is_ready()); // Can't redo init. | 388 DCHECK(!is_ready()); // Can't redo init. |
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
568 const std::string& transient_extension_id, | 569 const std::string& transient_extension_id, |
569 bool be_noisy) { | 570 bool be_noisy) { |
570 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 571 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
571 | 572 |
572 // If the extension is already reloading, don't reload again. | 573 // If the extension is already reloading, don't reload again. |
573 if (extension_prefs_->GetDisableReasons(transient_extension_id) & | 574 if (extension_prefs_->GetDisableReasons(transient_extension_id) & |
574 Extension::DISABLE_RELOAD) { | 575 Extension::DISABLE_RELOAD) { |
575 return; | 576 return; |
576 } | 577 } |
577 | 578 |
578 // Ignore attempts to reload a blacklisted extension. Sometimes this can | 579 // Ignore attempts to reload a blacklisted or blocked extension. Sometimes |
579 // happen in a convoluted reload sequence triggered by the termination of a | 580 // this can happen in a convoluted reload sequence triggered by the |
580 // blacklisted extension and a naive attempt to reload it. For an example see | 581 // termination of a blacklisted or blocked extension and a naive attempt to |
581 // http://crbug.com/373842. | 582 // reload it. For an example see http://crbug.com/373842. |
582 if (registry_->blacklisted_extensions().Contains(transient_extension_id)) | 583 if (registry_->blacklisted_extensions().Contains(transient_extension_id) || |
| 584 registry_->blocked_extensions().Contains(transient_extension_id)) { |
583 return; | 585 return; |
| 586 } |
584 | 587 |
585 base::FilePath path; | 588 base::FilePath path; |
586 | 589 |
587 std::string extension_id = transient_extension_id; | 590 std::string extension_id = transient_extension_id; |
588 const Extension* transient_current_extension = | 591 const Extension* transient_current_extension = |
589 GetExtensionById(extension_id, false); | 592 GetExtensionById(extension_id, false); |
590 | 593 |
591 // Disable the extension if it's loaded. It might not be loaded if it crashed. | 594 // Disable the extension if it's loaded. It might not be loaded if it crashed. |
592 if (transient_current_extension) { | 595 if (transient_current_extension) { |
593 // If the extension has an inspector open for its background page, detach | 596 // If the extension has an inspector open for its background page, detach |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
778 } | 781 } |
779 | 782 |
780 bool ExtensionService::IsExtensionEnabled( | 783 bool ExtensionService::IsExtensionEnabled( |
781 const std::string& extension_id) const { | 784 const std::string& extension_id) const { |
782 if (registry_->enabled_extensions().Contains(extension_id) || | 785 if (registry_->enabled_extensions().Contains(extension_id) || |
783 registry_->terminated_extensions().Contains(extension_id)) { | 786 registry_->terminated_extensions().Contains(extension_id)) { |
784 return true; | 787 return true; |
785 } | 788 } |
786 | 789 |
787 if (registry_->disabled_extensions().Contains(extension_id) || | 790 if (registry_->disabled_extensions().Contains(extension_id) || |
788 registry_->blacklisted_extensions().Contains(extension_id)) { | 791 registry_->blacklisted_extensions().Contains(extension_id) || |
| 792 registry_->blocked_extensions().Contains(extension_id)) { |
789 return false; | 793 return false; |
790 } | 794 } |
791 | 795 |
| 796 if (block_extensions_ && |
| 797 CanBlockExtension(GetInstalledExtension(extension_id))) |
| 798 return false; |
| 799 |
792 // If the extension hasn't been loaded yet, check the prefs for it. Assume | 800 // If the extension hasn't been loaded yet, check the prefs for it. Assume |
793 // enabled unless otherwise noted. | 801 // enabled unless otherwise noted. |
794 return !extension_prefs_->IsExtensionDisabled(extension_id) && | 802 return !extension_prefs_->IsExtensionDisabled(extension_id) && |
795 !extension_prefs_->IsExtensionBlacklisted(extension_id) && | 803 !extension_prefs_->IsExtensionBlacklisted(extension_id) && |
796 !extension_prefs_->IsExternalExtensionUninstalled(extension_id); | 804 !extension_prefs_->IsExternalExtensionUninstalled(extension_id); |
797 } | 805 } |
798 | 806 |
799 void ExtensionService::EnableExtension(const std::string& extension_id) { | 807 void ExtensionService::EnableExtension(const std::string& extension_id) { |
800 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 808 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
801 | 809 |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
909 if ((*extension)->was_installed_by_default() && | 917 if ((*extension)->was_installed_by_default() && |
910 extension_urls::IsWebstoreUpdateUrl( | 918 extension_urls::IsWebstoreUpdateUrl( |
911 extensions::ManifestURL::GetUpdateURL(extension->get()))) | 919 extensions::ManifestURL::GetUpdateURL(extension->get()))) |
912 continue; | 920 continue; |
913 const std::string& id = (*extension)->id(); | 921 const std::string& id = (*extension)->id(); |
914 if (except_ids.end() == std::find(except_ids.begin(), except_ids.end(), id)) | 922 if (except_ids.end() == std::find(except_ids.begin(), except_ids.end(), id)) |
915 DisableExtension(id, extensions::Extension::DISABLE_USER_ACTION); | 923 DisableExtension(id, extensions::Extension::DISABLE_USER_ACTION); |
916 } | 924 } |
917 } | 925 } |
918 | 926 |
| 927 // Extensions that are not locked, components or forced by policy should be |
| 928 // locked. Extensions are no longer considered enabled or disabled. Blacklisted |
| 929 // extensions are now considered both blacklisted and locked. |
| 930 void ExtensionService::BlockAllExtensions() { |
| 931 if (block_extensions_) |
| 932 return; |
| 933 block_extensions_ = true; |
| 934 |
| 935 // Blacklisted extensions are already unloaded, need not be blocked. |
| 936 scoped_ptr<ExtensionSet> extensions = |
| 937 registry_->GenerateInstalledExtensionsSet(ExtensionRegistry::ENABLED | |
| 938 ExtensionRegistry::DISABLED | |
| 939 ExtensionRegistry::TERMINATED); |
| 940 |
| 941 for (const scoped_refptr<const Extension>& extension : *extensions) { |
| 942 const std::string& id = extension->id(); |
| 943 |
| 944 if (!CanBlockExtension(extension.get())) |
| 945 continue; |
| 946 |
| 947 registry_->RemoveEnabled(id); |
| 948 registry_->RemoveDisabled(id); |
| 949 registry_->RemoveTerminated(id); |
| 950 |
| 951 registry_->AddBlocked(extension.get()); |
| 952 UnloadExtension(id, extensions::UnloadedExtensionInfo::REASON_LOCK_ALL); |
| 953 } |
| 954 } |
| 955 |
| 956 // All locked extensions should revert to being either enabled or disabled |
| 957 // as appropriate. |
| 958 void ExtensionService::UnblockAllExtensions() { |
| 959 block_extensions_ = false; |
| 960 scoped_ptr<ExtensionSet> to_unblock = |
| 961 registry_->GenerateInstalledExtensionsSet(ExtensionRegistry::BLOCKED); |
| 962 |
| 963 for (const scoped_refptr<const Extension>& extension : *to_unblock) { |
| 964 registry_->RemoveBlocked(extension->id()); |
| 965 AddExtension(extension.get()); |
| 966 } |
| 967 } |
| 968 |
919 void ExtensionService::GrantPermissionsAndEnableExtension( | 969 void ExtensionService::GrantPermissionsAndEnableExtension( |
920 const Extension* extension) { | 970 const Extension* extension) { |
921 GrantPermissions(extension); | 971 GrantPermissions(extension); |
922 RecordPermissionMessagesHistogram(extension, | 972 RecordPermissionMessagesHistogram(extension, |
923 "Extensions.Permissions_ReEnable2"); | 973 "Extensions.Permissions_ReEnable2"); |
924 extension_prefs_->SetDidExtensionEscalatePermissions(extension, false); | 974 extension_prefs_->SetDidExtensionEscalatePermissions(extension, false); |
925 EnableExtension(extension->id()); | 975 EnableExtension(extension->id()); |
926 } | 976 } |
927 | 977 |
928 void ExtensionService::GrantPermissions(const Extension* extension) { | 978 void ExtensionService::GrantPermissions(const Extension* extension) { |
(...skipping 435 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1364 // new one. ReloadExtension disables the extension, which is sufficient. | 1414 // new one. ReloadExtension disables the extension, which is sufficient. |
1365 UnloadExtension(extension->id(), UnloadedExtensionInfo::REASON_UPDATE); | 1415 UnloadExtension(extension->id(), UnloadedExtensionInfo::REASON_UPDATE); |
1366 } | 1416 } |
1367 | 1417 |
1368 if (extension_prefs_->IsExtensionBlacklisted(extension->id())) { | 1418 if (extension_prefs_->IsExtensionBlacklisted(extension->id())) { |
1369 // Only prefs is checked for the blacklist. We rely on callers to check the | 1419 // Only prefs is checked for the blacklist. We rely on callers to check the |
1370 // blacklist before calling into here, e.g. CrxInstaller checks before | 1420 // blacklist before calling into here, e.g. CrxInstaller checks before |
1371 // installation then threads through the install and pending install flow | 1421 // installation then threads through the install and pending install flow |
1372 // of this class, and we check when loading installed extensions. | 1422 // of this class, and we check when loading installed extensions. |
1373 registry_->AddBlacklisted(extension); | 1423 registry_->AddBlacklisted(extension); |
| 1424 } else if (block_extensions_ && CanBlockExtension(extension)) { |
| 1425 registry_->AddBlocked(extension); |
1374 } else if (!reloading && | 1426 } else if (!reloading && |
1375 extension_prefs_->IsExtensionDisabled(extension->id())) { | 1427 extension_prefs_->IsExtensionDisabled(extension->id())) { |
1376 registry_->AddDisabled(extension); | 1428 registry_->AddDisabled(extension); |
1377 if (extension_sync_service_) | 1429 if (extension_sync_service_) |
1378 extension_sync_service_->SyncExtensionChangeIfNeeded(*extension); | 1430 extension_sync_service_->SyncExtensionChangeIfNeeded(*extension); |
1379 content::NotificationService::current()->Notify( | 1431 content::NotificationService::current()->Notify( |
1380 extensions::NOTIFICATION_EXTENSION_UPDATE_DISABLED, | 1432 extensions::NOTIFICATION_EXTENSION_UPDATE_DISABLED, |
1381 content::Source<Profile>(profile_), | 1433 content::Source<Profile>(profile_), |
1382 content::Details<const Extension>(extension)); | 1434 content::Details<const Extension>(extension)); |
1383 | 1435 |
(...skipping 803 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2187 if (extension->GetType() != Manifest::TYPE_HOSTED_APP && | 2239 if (extension->GetType() != Manifest::TYPE_HOSTED_APP && |
2188 Manifest::IsExternalLocation(extension->location()) && | 2240 Manifest::IsExternalLocation(extension->location()) && |
2189 !extension_prefs_->IsExternalExtensionAcknowledged(extension->id())) { | 2241 !extension_prefs_->IsExternalExtensionAcknowledged(extension->id())) { |
2190 return Extension::DISABLE_EXTERNAL_EXTENSION; | 2242 return Extension::DISABLE_EXTERNAL_EXTENSION; |
2191 } | 2243 } |
2192 } | 2244 } |
2193 | 2245 |
2194 return Extension::DISABLE_NONE; | 2246 return Extension::DISABLE_NONE; |
2195 } | 2247 } |
2196 | 2248 |
| 2249 // Helper method to determine if an extension can be blocked. |
| 2250 bool ExtensionService::CanBlockExtension(const Extension* extension) const { |
| 2251 return extension->location() != Manifest::COMPONENT && |
| 2252 extension->location() != Manifest::EXTERNAL_COMPONENT && |
| 2253 !system_->management_policy()->MustRemainEnabled(extension, NULL); |
| 2254 } |
| 2255 |
2197 bool ExtensionService::ShouldDelayExtensionUpdate( | 2256 bool ExtensionService::ShouldDelayExtensionUpdate( |
2198 const std::string& extension_id, | 2257 const std::string& extension_id, |
2199 bool install_immediately) const { | 2258 bool install_immediately) const { |
2200 const char kOnUpdateAvailableEvent[] = "runtime.onUpdateAvailable"; | 2259 const char kOnUpdateAvailableEvent[] = "runtime.onUpdateAvailable"; |
2201 | 2260 |
2202 // If delayed updates are globally disabled, or just for this extension, | 2261 // If delayed updates are globally disabled, or just for this extension, |
2203 // don't delay. | 2262 // don't delay. |
2204 if (!install_updates_when_idle_ || install_immediately) | 2263 if (!install_updates_when_idle_ || install_immediately) |
2205 return false; | 2264 return false; |
2206 | 2265 |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2248 void ExtensionService::OnBlacklistUpdated() { | 2307 void ExtensionService::OnBlacklistUpdated() { |
2249 blacklist_->GetBlacklistedIDs( | 2308 blacklist_->GetBlacklistedIDs( |
2250 registry_->GenerateInstalledExtensionsSet()->GetIDs(), | 2309 registry_->GenerateInstalledExtensionsSet()->GetIDs(), |
2251 base::Bind(&ExtensionService::ManageBlacklist, AsWeakPtr())); | 2310 base::Bind(&ExtensionService::ManageBlacklist, AsWeakPtr())); |
2252 } | 2311 } |
2253 | 2312 |
2254 void ExtensionService::ManageBlacklist( | 2313 void ExtensionService::ManageBlacklist( |
2255 const extensions::Blacklist::BlacklistStateMap& state_map) { | 2314 const extensions::Blacklist::BlacklistStateMap& state_map) { |
2256 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 2315 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
2257 | 2316 |
2258 std::set<std::string> blocked; | 2317 std::set<std::string> blacklisted; |
2259 ExtensionIdSet greylist; | 2318 ExtensionIdSet greylist; |
2260 ExtensionIdSet unchanged; | 2319 ExtensionIdSet unchanged; |
2261 for (extensions::Blacklist::BlacklistStateMap::const_iterator it = | 2320 for (extensions::Blacklist::BlacklistStateMap::const_iterator it = |
2262 state_map.begin(); | 2321 state_map.begin(); |
2263 it != state_map.end(); | 2322 it != state_map.end(); |
2264 ++it) { | 2323 ++it) { |
2265 switch (it->second) { | 2324 switch (it->second) { |
2266 case extensions::NOT_BLACKLISTED: | 2325 case extensions::NOT_BLACKLISTED: |
2267 break; | 2326 break; |
2268 | 2327 |
2269 case extensions::BLACKLISTED_MALWARE: | 2328 case extensions::BLACKLISTED_MALWARE: |
2270 blocked.insert(it->first); | 2329 blacklisted.insert(it->first); |
2271 break; | 2330 break; |
2272 | 2331 |
2273 case extensions::BLACKLISTED_SECURITY_VULNERABILITY: | 2332 case extensions::BLACKLISTED_SECURITY_VULNERABILITY: |
2274 case extensions::BLACKLISTED_CWS_POLICY_VIOLATION: | 2333 case extensions::BLACKLISTED_CWS_POLICY_VIOLATION: |
2275 case extensions::BLACKLISTED_POTENTIALLY_UNWANTED: | 2334 case extensions::BLACKLISTED_POTENTIALLY_UNWANTED: |
2276 greylist.insert(it->first); | 2335 greylist.insert(it->first); |
2277 break; | 2336 break; |
2278 | 2337 |
2279 case extensions::BLACKLISTED_UNKNOWN: | 2338 case extensions::BLACKLISTED_UNKNOWN: |
2280 unchanged.insert(it->first); | 2339 unchanged.insert(it->first); |
2281 break; | 2340 break; |
2282 } | 2341 } |
2283 } | 2342 } |
2284 | 2343 |
2285 UpdateBlockedExtensions(blocked, unchanged); | 2344 UpdateBlacklistedExtensions(blacklisted, unchanged); |
2286 UpdateGreylistedExtensions(greylist, unchanged, state_map); | 2345 UpdateGreylistedExtensions(greylist, unchanged, state_map); |
2287 | 2346 |
2288 error_controller_->ShowErrorIfNeeded(); | 2347 error_controller_->ShowErrorIfNeeded(); |
2289 } | 2348 } |
2290 | 2349 |
2291 namespace { | 2350 namespace { |
2292 void Partition(const ExtensionIdSet& before, | 2351 void Partition(const ExtensionIdSet& before, |
2293 const ExtensionIdSet& after, | 2352 const ExtensionIdSet& after, |
2294 const ExtensionIdSet& unchanged, | 2353 const ExtensionIdSet& unchanged, |
2295 ExtensionIdSet* no_longer, | 2354 ExtensionIdSet* no_longer, |
2296 ExtensionIdSet* not_yet) { | 2355 ExtensionIdSet* not_yet) { |
2297 *not_yet = base::STLSetDifference<ExtensionIdSet>(after, before); | 2356 *not_yet = base::STLSetDifference<ExtensionIdSet>(after, before); |
2298 *no_longer = base::STLSetDifference<ExtensionIdSet>(before, after); | 2357 *no_longer = base::STLSetDifference<ExtensionIdSet>(before, after); |
2299 *no_longer = base::STLSetDifference<ExtensionIdSet>(*no_longer, unchanged); | 2358 *no_longer = base::STLSetDifference<ExtensionIdSet>(*no_longer, unchanged); |
2300 } | 2359 } |
2301 } // namespace | 2360 } // namespace |
2302 | 2361 |
2303 void ExtensionService::UpdateBlockedExtensions( | 2362 void ExtensionService::UpdateBlacklistedExtensions( |
2304 const ExtensionIdSet& blocked, | 2363 const ExtensionIdSet& blacklisted, |
2305 const ExtensionIdSet& unchanged) { | 2364 const ExtensionIdSet& unchanged) { |
2306 ExtensionIdSet not_yet_blocked, no_longer_blocked; | 2365 ExtensionIdSet not_yet_blocked, no_longer_blocked; |
2307 Partition(registry_->blacklisted_extensions().GetIDs(), | 2366 Partition(registry_->blacklisted_extensions().GetIDs(), blacklisted, |
2308 blocked, unchanged, | 2367 unchanged, &no_longer_blocked, ¬_yet_blocked); |
2309 &no_longer_blocked, ¬_yet_blocked); | |
2310 | 2368 |
2311 for (ExtensionIdSet::iterator it = no_longer_blocked.begin(); | 2369 for (ExtensionIdSet::iterator it = no_longer_blocked.begin(); |
2312 it != no_longer_blocked.end(); ++it) { | 2370 it != no_longer_blocked.end(); ++it) { |
2313 scoped_refptr<const Extension> extension = | 2371 scoped_refptr<const Extension> extension = |
2314 registry_->blacklisted_extensions().GetByID(*it); | 2372 registry_->blacklisted_extensions().GetByID(*it); |
2315 if (!extension.get()) { | 2373 if (!extension.get()) { |
2316 NOTREACHED() << "Extension " << *it << " no longer blocked, " | 2374 NOTREACHED() << "Extension " << *it << " no longer blacklisted, " |
2317 << "but it was never blocked."; | 2375 << "but it was never blacklisted."; |
2318 continue; | 2376 continue; |
2319 } | 2377 } |
2320 registry_->RemoveBlacklisted(*it); | 2378 registry_->RemoveBlacklisted(*it); |
2321 extension_prefs_->SetExtensionBlacklisted(extension->id(), false); | 2379 extension_prefs_->SetExtensionBlacklisted(extension->id(), false); |
2322 AddExtension(extension.get()); | 2380 AddExtension(extension.get()); |
2323 UMA_HISTOGRAM_ENUMERATION("ExtensionBlacklist.UnblacklistInstalled", | 2381 UMA_HISTOGRAM_ENUMERATION("ExtensionBlacklist.UnblacklistInstalled", |
2324 extension->location(), | 2382 extension->location(), |
2325 Manifest::NUM_LOCATIONS); | 2383 Manifest::NUM_LOCATIONS); |
2326 } | 2384 } |
2327 | 2385 |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2407 } | 2465 } |
2408 | 2466 |
2409 void ExtensionService::OnProfileDestructionStarted() { | 2467 void ExtensionService::OnProfileDestructionStarted() { |
2410 ExtensionIdSet ids_to_unload = registry_->enabled_extensions().GetIDs(); | 2468 ExtensionIdSet ids_to_unload = registry_->enabled_extensions().GetIDs(); |
2411 for (ExtensionIdSet::iterator it = ids_to_unload.begin(); | 2469 for (ExtensionIdSet::iterator it = ids_to_unload.begin(); |
2412 it != ids_to_unload.end(); | 2470 it != ids_to_unload.end(); |
2413 ++it) { | 2471 ++it) { |
2414 UnloadExtension(*it, UnloadedExtensionInfo::REASON_PROFILE_SHUTDOWN); | 2472 UnloadExtension(*it, UnloadedExtensionInfo::REASON_PROFILE_SHUTDOWN); |
2415 } | 2473 } |
2416 } | 2474 } |
OLD | NEW |