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

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

Issue 695133005: Temporarily disable extensions and sync while a profile is locked - Profiles Approach (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Compiling is awesome Created 6 years, 1 month 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) 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
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
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 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
367 ->GetForBrowserContext(profile()) 368 ->GetForBrowserContext(profile())
368 ->RemoveObserver(this); 369 ->RemoveObserver(this);
369 system_->management_policy()->UnregisterProvider( 370 system_->management_policy()->UnregisterProvider(
370 shared_module_policy_provider_.get()); 371 shared_module_policy_provider_.get());
371 } 372 }
372 373
373 const Extension* ExtensionService::GetExtensionById( 374 const Extension* ExtensionService::GetExtensionById(
374 const std::string& id, bool include_disabled) const { 375 const std::string& id, bool include_disabled) const {
375 int include_mask = ExtensionRegistry::ENABLED; 376 int include_mask = ExtensionRegistry::ENABLED;
376 if (include_disabled) { 377 if (include_disabled) {
377 // Include blacklisted extensions here because there are hundreds of 378 // Include blacklisted and blocked extensions here because there are
378 // callers of this function, and many might assume that this includes those 379 // hundreds of callers of this function, and many might assume that this
379 // that have been disabled due to blacklisting. 380 // includes those that have been disabled due to blacklisting or blocking.
380 include_mask |= ExtensionRegistry::DISABLED | 381 include_mask |= ExtensionRegistry::DISABLED |
381 ExtensionRegistry::BLACKLISTED; 382 ExtensionRegistry::BLACKLISTED | ExtensionRegistry::BLOCKED;
382 } 383 }
383 return registry_->GetExtensionById(id, include_mask); 384 return registry_->GetExtensionById(id, include_mask);
384 } 385 }
385 386
386 void ExtensionService::Init() { 387 void ExtensionService::Init() {
387 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 388 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
388 389
389 base::Time begin_time = base::Time::Now(); 390 base::Time begin_time = base::Time::Now();
390 391
391 DCHECK(!is_ready()); // Can't redo init. 392 DCHECK(!is_ready()); // Can't redo init.
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
572 const std::string& transient_extension_id, 573 const std::string& transient_extension_id,
573 bool be_noisy) { 574 bool be_noisy) {
574 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 575 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
575 576
576 // If the extension is already reloading, don't reload again. 577 // If the extension is already reloading, don't reload again.
577 if (extension_prefs_->GetDisableReasons(transient_extension_id) & 578 if (extension_prefs_->GetDisableReasons(transient_extension_id) &
578 Extension::DISABLE_RELOAD) { 579 Extension::DISABLE_RELOAD) {
579 return; 580 return;
580 } 581 }
581 582
582 // Ignore attempts to reload a blacklisted extension. Sometimes this can 583 // Ignore attempts to reload a blacklisted or blocked extension. Sometimes
583 // happen in a convoluted reload sequence triggered by the termination of a 584 // this can happen in a convoluted reload sequence triggered by the
584 // blacklisted extension and a naive attempt to reload it. For an example see 585 // termination of a blacklisted or blocked extension and a naive attempt to
585 // http://crbug.com/373842. 586 // reload it. For an example see http://crbug.com/373842.
586 if (registry_->blacklisted_extensions().Contains(transient_extension_id)) 587 if (registry_->blacklisted_extensions().Contains(transient_extension_id) ||
588 registry_->blocked_extensions().Contains(transient_extension_id)) {
587 return; 589 return;
590 }
588 591
589 base::FilePath path; 592 base::FilePath path;
590 593
591 std::string extension_id = transient_extension_id; 594 std::string extension_id = transient_extension_id;
592 const Extension* transient_current_extension = 595 const Extension* transient_current_extension =
593 GetExtensionById(extension_id, false); 596 GetExtensionById(extension_id, false);
594 597
595 // Disable the extension if it's loaded. It might not be loaded if it crashed. 598 // Disable the extension if it's loaded. It might not be loaded if it crashed.
596 if (transient_current_extension) { 599 if (transient_current_extension) {
597 // If the extension has an inspector open for its background page, detach 600 // If the extension has an inspector open for its background page, detach
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
782 } 785 }
783 786
784 bool ExtensionService::IsExtensionEnabled( 787 bool ExtensionService::IsExtensionEnabled(
785 const std::string& extension_id) const { 788 const std::string& extension_id) const {
786 if (registry_->enabled_extensions().Contains(extension_id) || 789 if (registry_->enabled_extensions().Contains(extension_id) ||
787 registry_->terminated_extensions().Contains(extension_id)) { 790 registry_->terminated_extensions().Contains(extension_id)) {
788 return true; 791 return true;
789 } 792 }
790 793
791 if (registry_->disabled_extensions().Contains(extension_id) || 794 if (registry_->disabled_extensions().Contains(extension_id) ||
792 registry_->blacklisted_extensions().Contains(extension_id)) { 795 registry_->blacklisted_extensions().Contains(extension_id) ||
796 registry_->blocked_extensions().Contains(extension_id)) {
793 return false; 797 return false;
794 } 798 }
795 799
796 // 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
797 // enabled unless otherwise noted. 801 // enabled unless otherwise noted.
798 return !extension_prefs_->IsExtensionDisabled(extension_id) && 802 return !extension_prefs_->IsExtensionDisabled(extension_id) &&
799 !extension_prefs_->IsExtensionBlacklisted(extension_id) && 803 !extension_prefs_->IsExtensionBlacklisted(extension_id) &&
804 !extension_prefs_->IsExtensionBlocked(extension_id) &&
800 !extension_prefs_->IsExternalExtensionUninstalled(extension_id); 805 !extension_prefs_->IsExternalExtensionUninstalled(extension_id);
801 } 806 }
802 807
803 void ExtensionService::EnableExtension(const std::string& extension_id) { 808 void ExtensionService::EnableExtension(const std::string& extension_id) {
804 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 809 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
805 810
806 if (IsExtensionEnabled(extension_id)) 811 if (IsExtensionEnabled(extension_id))
807 return; 812 return;
808 const Extension* extension = 813 const Extension* extension =
809 registry_->disabled_extensions().GetByID(extension_id); 814 registry_->disabled_extensions().GetByID(extension_id);
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
913 if ((*extension)->was_installed_by_default() && 918 if ((*extension)->was_installed_by_default() &&
914 extension_urls::IsWebstoreUpdateUrl( 919 extension_urls::IsWebstoreUpdateUrl(
915 extensions::ManifestURL::GetUpdateURL(extension->get()))) 920 extensions::ManifestURL::GetUpdateURL(extension->get())))
916 continue; 921 continue;
917 const std::string& id = (*extension)->id(); 922 const std::string& id = (*extension)->id();
918 if (except_ids.end() == std::find(except_ids.begin(), except_ids.end(), id)) 923 if (except_ids.end() == std::find(except_ids.begin(), except_ids.end(), id))
919 DisableExtension(id, extensions::Extension::DISABLE_USER_ACTION); 924 DisableExtension(id, extensions::Extension::DISABLE_USER_ACTION);
920 } 925 }
921 } 926 }
922 927
928 // Extensions that are not locked, components or forced by policy should be
Andrew T Wilson (Slow) 2014/11/17 16:09:25 So, if I have a force-installed extension that is
not at google - send to devlin 2014/11/17 17:04:20 Yeah, good point. You could argue it either way, b
929 // locked. Extensions are no longer considered enabled or disabled. Blacklisted
930 // extensions are now considered both blacklisted and locked.
931 void ExtensionService::BlockAllExtensions() {
932 block_extensions_ = true;
not at google - send to devlin 2014/11/17 17:04:20 Can you early-return from this function if it's al
Mike Lerman 2014/11/19 14:54:34 Done.
933 // Blacklisted extensions are already unloaded, need not be blocked.
934 scoped_ptr<ExtensionSet> extensions =
935 registry_->GenerateInstalledExtensionsSet(ExtensionRegistry::ENABLED |
936 ExtensionRegistry::DISABLED |
937 ExtensionRegistry::TERMINATED);
938
939 for (const scoped_refptr<const Extension> extension : *extensions.get()) {
not at google - send to devlin 2014/11/17 17:04:20 1. Make it a const scoped_refptr<const Extension>&
Mike Lerman 2014/11/19 14:54:34 Done.
940 const std::string& id = extension->id();
941
942 if (!CanBlockExtension(extension.get()))
943 continue;
944
945 registry_->RemoveEnabled(id);
946 registry_->RemoveDisabled(id);
947 registry_->RemoveTerminated(id);
948
949 registry_->AddBlocked(extension.get());
950 UnloadExtension(id, extensions::UnloadedExtensionInfo::REASON_LOCK_ALL);
951 }
952 }
953
954 // All locked extensions should revert to being either enabled or disabled
955 // as appropriate.
956 void ExtensionService::UnblockAllExtensions() {
957 block_extensions_ = false;
958 scoped_ptr<ExtensionSet> to_unblock =
959 registry_->GenerateInstalledExtensionsSet(ExtensionRegistry::BLOCKED);
960
961 for (const scoped_refptr<const Extension> extension : *to_unblock.get()) {
not at google - send to devlin 2014/11/17 17:04:20 Also use a reference, no .get().
Mike Lerman 2014/11/19 14:54:34 Done.
962 registry_->RemoveBlocked(extension->id());
963 AddExtension(extension.get());
964 }
965 }
966
923 void ExtensionService::GrantPermissionsAndEnableExtension( 967 void ExtensionService::GrantPermissionsAndEnableExtension(
924 const Extension* extension) { 968 const Extension* extension) {
925 GrantPermissions(extension); 969 GrantPermissions(extension);
926 RecordPermissionMessagesHistogram(extension, 970 RecordPermissionMessagesHistogram(extension,
927 "Extensions.Permissions_ReEnable2"); 971 "Extensions.Permissions_ReEnable2");
928 extension_prefs_->SetDidExtensionEscalatePermissions(extension, false); 972 extension_prefs_->SetDidExtensionEscalatePermissions(extension, false);
929 EnableExtension(extension->id()); 973 EnableExtension(extension->id());
930 } 974 }
931 975
932 void ExtensionService::GrantPermissions(const Extension* extension) { 976 void ExtensionService::GrantPermissions(const Extension* extension) {
(...skipping 433 matching lines...) Expand 10 before | Expand all | Expand 10 after
1366 // new one. ReloadExtension disables the extension, which is sufficient. 1410 // new one. ReloadExtension disables the extension, which is sufficient.
1367 UnloadExtension(extension->id(), UnloadedExtensionInfo::REASON_UPDATE); 1411 UnloadExtension(extension->id(), UnloadedExtensionInfo::REASON_UPDATE);
1368 } 1412 }
1369 1413
1370 if (extension_prefs_->IsExtensionBlacklisted(extension->id())) { 1414 if (extension_prefs_->IsExtensionBlacklisted(extension->id())) {
1371 // Only prefs is checked for the blacklist. We rely on callers to check the 1415 // Only prefs is checked for the blacklist. We rely on callers to check the
1372 // blacklist before calling into here, e.g. CrxInstaller checks before 1416 // blacklist before calling into here, e.g. CrxInstaller checks before
1373 // installation then threads through the install and pending install flow 1417 // installation then threads through the install and pending install flow
1374 // of this class, and we check when loading installed extensions. 1418 // of this class, and we check when loading installed extensions.
1375 registry_->AddBlacklisted(extension); 1419 registry_->AddBlacklisted(extension);
1420 } else if (extension_prefs_->IsExtensionBlocked(extension->id()) ||
1421 (block_extensions_ && CanBlockExtension(extension))) {
1422 registry_->AddBlocked(extension);
1376 } else if (!reloading && 1423 } else if (!reloading &&
1377 extension_prefs_->IsExtensionDisabled(extension->id())) { 1424 extension_prefs_->IsExtensionDisabled(extension->id())) {
1378 registry_->AddDisabled(extension); 1425 registry_->AddDisabled(extension);
1379 if (extension_sync_service_) 1426 if (extension_sync_service_)
1380 extension_sync_service_->SyncExtensionChangeIfNeeded(*extension); 1427 extension_sync_service_->SyncExtensionChangeIfNeeded(*extension);
1381 content::NotificationService::current()->Notify( 1428 content::NotificationService::current()->Notify(
1382 extensions::NOTIFICATION_EXTENSION_UPDATE_DISABLED, 1429 extensions::NOTIFICATION_EXTENSION_UPDATE_DISABLED,
1383 content::Source<Profile>(profile_), 1430 content::Source<Profile>(profile_),
1384 content::Details<const Extension>(extension)); 1431 content::Details<const Extension>(extension));
1385 1432
(...skipping 782 matching lines...) Expand 10 before | Expand all | Expand 10 after
2168 if (extension->GetType() != Manifest::TYPE_HOSTED_APP && 2215 if (extension->GetType() != Manifest::TYPE_HOSTED_APP &&
2169 Manifest::IsExternalLocation(extension->location()) && 2216 Manifest::IsExternalLocation(extension->location()) &&
2170 !extension_prefs_->IsExternalExtensionAcknowledged(extension->id())) { 2217 !extension_prefs_->IsExternalExtensionAcknowledged(extension->id())) {
2171 return false; 2218 return false;
2172 } 2219 }
2173 } 2220 }
2174 2221
2175 return true; 2222 return true;
2176 } 2223 }
2177 2224
2225 // Helper method to determine if an extension can be blocked.
2226 bool ExtensionService::CanBlockExtension(const Extension* extension) {
2227 return extension->location() != Manifest::COMPONENT &&
2228 extension->location() != Manifest::EXTERNAL_COMPONENT &&
2229 !system_->management_policy()->MustRemainEnabled(extension, NULL);
2230 }
2231
2178 bool ExtensionService::ShouldDelayExtensionUpdate( 2232 bool ExtensionService::ShouldDelayExtensionUpdate(
2179 const std::string& extension_id, 2233 const std::string& extension_id,
2180 bool install_immediately) const { 2234 bool install_immediately) const {
2181 const char kOnUpdateAvailableEvent[] = "runtime.onUpdateAvailable"; 2235 const char kOnUpdateAvailableEvent[] = "runtime.onUpdateAvailable";
2182 2236
2183 // If delayed updates are globally disabled, or just for this extension, 2237 // If delayed updates are globally disabled, or just for this extension,
2184 // don't delay. 2238 // don't delay.
2185 if (!install_updates_when_idle_ || install_immediately) 2239 if (!install_updates_when_idle_ || install_immediately)
2186 return false; 2240 return false;
2187 2241
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
2229 void ExtensionService::OnBlacklistUpdated() { 2283 void ExtensionService::OnBlacklistUpdated() {
2230 blacklist_->GetBlacklistedIDs( 2284 blacklist_->GetBlacklistedIDs(
2231 registry_->GenerateInstalledExtensionsSet()->GetIDs(), 2285 registry_->GenerateInstalledExtensionsSet()->GetIDs(),
2232 base::Bind(&ExtensionService::ManageBlacklist, AsWeakPtr())); 2286 base::Bind(&ExtensionService::ManageBlacklist, AsWeakPtr()));
2233 } 2287 }
2234 2288
2235 void ExtensionService::ManageBlacklist( 2289 void ExtensionService::ManageBlacklist(
2236 const extensions::Blacklist::BlacklistStateMap& state_map) { 2290 const extensions::Blacklist::BlacklistStateMap& state_map) {
2237 DCHECK_CURRENTLY_ON(BrowserThread::UI); 2291 DCHECK_CURRENTLY_ON(BrowserThread::UI);
2238 2292
2239 std::set<std::string> blocked; 2293 std::set<std::string> blacklisted;
2240 ExtensionIdSet greylist; 2294 ExtensionIdSet greylist;
2241 ExtensionIdSet unchanged; 2295 ExtensionIdSet unchanged;
2242 for (extensions::Blacklist::BlacklistStateMap::const_iterator it = 2296 for (extensions::Blacklist::BlacklistStateMap::const_iterator it =
2243 state_map.begin(); 2297 state_map.begin();
2244 it != state_map.end(); 2298 it != state_map.end();
2245 ++it) { 2299 ++it) {
2246 switch (it->second) { 2300 switch (it->second) {
2247 case extensions::NOT_BLACKLISTED: 2301 case extensions::NOT_BLACKLISTED:
2248 break; 2302 break;
2249 2303
2250 case extensions::BLACKLISTED_MALWARE: 2304 case extensions::BLACKLISTED_MALWARE:
2251 blocked.insert(it->first); 2305 blacklisted.insert(it->first);
2252 break; 2306 break;
2253 2307
2254 case extensions::BLACKLISTED_SECURITY_VULNERABILITY: 2308 case extensions::BLACKLISTED_SECURITY_VULNERABILITY:
2255 case extensions::BLACKLISTED_CWS_POLICY_VIOLATION: 2309 case extensions::BLACKLISTED_CWS_POLICY_VIOLATION:
2256 case extensions::BLACKLISTED_POTENTIALLY_UNWANTED: 2310 case extensions::BLACKLISTED_POTENTIALLY_UNWANTED:
2257 greylist.insert(it->first); 2311 greylist.insert(it->first);
2258 break; 2312 break;
2259 2313
2260 case extensions::BLACKLISTED_UNKNOWN: 2314 case extensions::BLACKLISTED_UNKNOWN:
2261 unchanged.insert(it->first); 2315 unchanged.insert(it->first);
2262 break; 2316 break;
2263 } 2317 }
2264 } 2318 }
2265 2319
2266 UpdateBlockedExtensions(blocked, unchanged); 2320 UpdateBlacklistedExtensions(blacklisted, unchanged);
2267 UpdateGreylistedExtensions(greylist, unchanged, state_map); 2321 UpdateGreylistedExtensions(greylist, unchanged, state_map);
2268 2322
2269 error_controller_->ShowErrorIfNeeded(); 2323 error_controller_->ShowErrorIfNeeded();
2270 } 2324 }
2271 2325
2272 namespace { 2326 namespace {
2273 void Partition(const ExtensionIdSet& before, 2327 void Partition(const ExtensionIdSet& before,
2274 const ExtensionIdSet& after, 2328 const ExtensionIdSet& after,
2275 const ExtensionIdSet& unchanged, 2329 const ExtensionIdSet& unchanged,
2276 ExtensionIdSet* no_longer, 2330 ExtensionIdSet* no_longer,
2277 ExtensionIdSet* not_yet) { 2331 ExtensionIdSet* not_yet) {
2278 *not_yet = base::STLSetDifference<ExtensionIdSet>(after, before); 2332 *not_yet = base::STLSetDifference<ExtensionIdSet>(after, before);
2279 *no_longer = base::STLSetDifference<ExtensionIdSet>(before, after); 2333 *no_longer = base::STLSetDifference<ExtensionIdSet>(before, after);
2280 *no_longer = base::STLSetDifference<ExtensionIdSet>(*no_longer, unchanged); 2334 *no_longer = base::STLSetDifference<ExtensionIdSet>(*no_longer, unchanged);
2281 } 2335 }
2282 } // namespace 2336 } // namespace
2283 2337
2284 void ExtensionService::UpdateBlockedExtensions( 2338 void ExtensionService::UpdateBlacklistedExtensions(
2285 const ExtensionIdSet& blocked, 2339 const ExtensionIdSet& blacklisted,
2286 const ExtensionIdSet& unchanged) { 2340 const ExtensionIdSet& unchanged) {
2287 ExtensionIdSet not_yet_blocked, no_longer_blocked; 2341 ExtensionIdSet not_yet_blocked, no_longer_blocked;
2288 Partition(registry_->blacklisted_extensions().GetIDs(), 2342 Partition(registry_->blacklisted_extensions().GetIDs(), blacklisted,
2289 blocked, unchanged, 2343 unchanged, &no_longer_blocked, &not_yet_blocked);
2290 &no_longer_blocked, &not_yet_blocked);
2291 2344
2292 for (ExtensionIdSet::iterator it = no_longer_blocked.begin(); 2345 for (ExtensionIdSet::iterator it = no_longer_blocked.begin();
2293 it != no_longer_blocked.end(); ++it) { 2346 it != no_longer_blocked.end(); ++it) {
2294 scoped_refptr<const Extension> extension = 2347 scoped_refptr<const Extension> extension =
2295 registry_->blacklisted_extensions().GetByID(*it); 2348 registry_->blacklisted_extensions().GetByID(*it);
2296 if (!extension.get()) { 2349 if (!extension.get()) {
2297 NOTREACHED() << "Extension " << *it << " no longer blocked, " 2350 NOTREACHED() << "Extension " << *it << " no longer blacklisted, "
2298 << "but it was never blocked."; 2351 << "but it was never blacklisted.";
2299 continue; 2352 continue;
2300 } 2353 }
2301 registry_->RemoveBlacklisted(*it); 2354 registry_->RemoveBlacklisted(*it);
2302 extension_prefs_->SetExtensionBlacklisted(extension->id(), false); 2355 extension_prefs_->SetExtensionBlacklisted(extension->id(), false);
2303 AddExtension(extension.get()); 2356 AddExtension(extension.get());
2304 UMA_HISTOGRAM_ENUMERATION("ExtensionBlacklist.UnblacklistInstalled", 2357 UMA_HISTOGRAM_ENUMERATION("ExtensionBlacklist.UnblacklistInstalled",
2305 extension->location(), 2358 extension->location(),
2306 Manifest::NUM_LOCATIONS); 2359 Manifest::NUM_LOCATIONS);
2307 } 2360 }
2308 2361
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
2388 } 2441 }
2389 2442
2390 void ExtensionService::OnProfileDestructionStarted() { 2443 void ExtensionService::OnProfileDestructionStarted() {
2391 ExtensionIdSet ids_to_unload = registry_->enabled_extensions().GetIDs(); 2444 ExtensionIdSet ids_to_unload = registry_->enabled_extensions().GetIDs();
2392 for (ExtensionIdSet::iterator it = ids_to_unload.begin(); 2445 for (ExtensionIdSet::iterator it = ids_to_unload.begin();
2393 it != ids_to_unload.end(); 2446 it != ids_to_unload.end();
2394 ++it) { 2447 ++it) {
2395 UnloadExtension(*it, UnloadedExtensionInfo::REASON_PROFILE_SHUTDOWN); 2448 UnloadExtension(*it, UnloadedExtensionInfo::REASON_PROFILE_SHUTDOWN);
2396 } 2449 }
2397 } 2450 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698