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

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

Issue 12211029: Sanity tweaks to the extension blacklist: check all extensions at once on (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: ready for review Created 7 years, 10 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 | Annotate | Revision Log
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 <iterator> 8 #include <iterator>
9 #include <set> 9 #include <set>
10 10
(...skipping 29 matching lines...) Expand all
40 #include "chrome/browser/extensions/app_sync_data.h" 40 #include "chrome/browser/extensions/app_sync_data.h"
41 #include "chrome/browser/extensions/browser_event_router.h" 41 #include "chrome/browser/extensions/browser_event_router.h"
42 #include "chrome/browser/extensions/component_loader.h" 42 #include "chrome/browser/extensions/component_loader.h"
43 #include "chrome/browser/extensions/crx_installer.h" 43 #include "chrome/browser/extensions/crx_installer.h"
44 #include "chrome/browser/extensions/data_deleter.h" 44 #include "chrome/browser/extensions/data_deleter.h"
45 #include "chrome/browser/extensions/extension_disabled_ui.h" 45 #include "chrome/browser/extensions/extension_disabled_ui.h"
46 #include "chrome/browser/extensions/extension_error_reporter.h" 46 #include "chrome/browser/extensions/extension_error_reporter.h"
47 #include "chrome/browser/extensions/extension_error_ui.h" 47 #include "chrome/browser/extensions/extension_error_ui.h"
48 #include "chrome/browser/extensions/extension_host.h" 48 #include "chrome/browser/extensions/extension_host.h"
49 #include "chrome/browser/extensions/extension_install_ui.h" 49 #include "chrome/browser/extensions/extension_install_ui.h"
50 #include "chrome/browser/extensions/extension_install_ui_default.h"
50 #include "chrome/browser/extensions/extension_process_manager.h" 51 #include "chrome/browser/extensions/extension_process_manager.h"
51 #include "chrome/browser/extensions/extension_sorting.h" 52 #include "chrome/browser/extensions/extension_sorting.h"
52 #include "chrome/browser/extensions/extension_special_storage_policy.h" 53 #include "chrome/browser/extensions/extension_special_storage_policy.h"
53 #include "chrome/browser/extensions/extension_sync_data.h" 54 #include "chrome/browser/extensions/extension_sync_data.h"
54 #include "chrome/browser/extensions/extension_system.h" 55 #include "chrome/browser/extensions/extension_system.h"
55 #include "chrome/browser/extensions/external_install_ui.h" 56 #include "chrome/browser/extensions/external_install_ui.h"
56 #include "chrome/browser/extensions/external_provider_impl.h" 57 #include "chrome/browser/extensions/external_provider_impl.h"
57 #include "chrome/browser/extensions/external_provider_interface.h" 58 #include "chrome/browser/extensions/external_provider_interface.h"
58 #include "chrome/browser/extensions/installed_loader.h" 59 #include "chrome/browser/extensions/installed_loader.h"
59 #include "chrome/browser/extensions/lazy_background_task_queue.h" 60 #include "chrome/browser/extensions/lazy_background_task_queue.h"
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 #include "content/public/browser/site_instance.h" 101 #include "content/public/browser/site_instance.h"
101 #include "content/public/browser/storage_partition.h" 102 #include "content/public/browser/storage_partition.h"
102 #include "content/public/browser/url_data_source.h" 103 #include "content/public/browser/url_data_source.h"
103 #include "content/public/common/pepper_plugin_info.h" 104 #include "content/public/common/pepper_plugin_info.h"
104 #include "extensions/common/error_utils.h" 105 #include "extensions/common/error_utils.h"
105 #include "googleurl/src/gurl.h" 106 #include "googleurl/src/gurl.h"
106 #include "grit/generated_resources.h" 107 #include "grit/generated_resources.h"
107 #include "net/base/registry_controlled_domains/registry_controlled_domain.h" 108 #include "net/base/registry_controlled_domains/registry_controlled_domain.h"
108 #include "sync/api/sync_change.h" 109 #include "sync/api/sync_change.h"
109 #include "sync/api/sync_error_factory.h" 110 #include "sync/api/sync_error_factory.h"
111 #include "ui/base/l10n/l10n_util.h"
110 #include "webkit/database/database_tracker.h" 112 #include "webkit/database/database_tracker.h"
111 #include "webkit/database/database_util.h" 113 #include "webkit/database/database_util.h"
112 114
113 #if defined(OS_CHROMEOS) 115 #if defined(OS_CHROMEOS)
114 #include "chrome/browser/chromeos/extensions/install_limiter.h" 116 #include "chrome/browser/chromeos/extensions/install_limiter.h"
115 #include "webkit/fileapi/file_system_context.h" 117 #include "webkit/fileapi/file_system_context.h"
116 #include "webkit/fileapi/file_system_mount_point_provider.h" 118 #include "webkit/fileapi/file_system_mount_point_provider.h"
117 #endif 119 #endif
118 120
119 using content::BrowserContext; 121 using content::BrowserContext;
120 using content::BrowserThread; 122 using content::BrowserThread;
121 using content::DevToolsAgentHost; 123 using content::DevToolsAgentHost;
122 using content::PluginService; 124 using content::PluginService;
123 using extensions::CrxInstaller; 125 using extensions::CrxInstaller;
124 using extensions::Extension; 126 using extensions::Extension;
125 using extensions::ExtensionIdSet; 127 using extensions::ExtensionIdSet;
126 using extensions::ExtensionInfo; 128 using extensions::ExtensionInfo;
129 using extensions::ExtensionList;
127 using extensions::FeatureSwitch; 130 using extensions::FeatureSwitch;
128 using extensions::Manifest; 131 using extensions::Manifest;
129 using extensions::PermissionMessage; 132 using extensions::PermissionMessage;
130 using extensions::PermissionMessages; 133 using extensions::PermissionMessages;
131 using extensions::PermissionSet; 134 using extensions::PermissionSet;
132 using extensions::UnloadedExtensionInfo; 135 using extensions::UnloadedExtensionInfo;
133 136
134 namespace errors = extension_manifest_errors; 137 namespace errors = extension_manifest_errors;
135 138
136 namespace { 139 namespace {
(...skipping 615 matching lines...) Expand 10 before | Expand all | Expand 10 after
752 component_loader_->Reload(extension_id); 755 component_loader_->Reload(extension_id);
753 return; 756 return;
754 } 757 }
755 758
756 // Check the installed extensions to see if what we're reloading was already 759 // Check the installed extensions to see if what we're reloading was already
757 // installed. 760 // installed.
758 scoped_ptr<ExtensionInfo> installed_extension( 761 scoped_ptr<ExtensionInfo> installed_extension(
759 extension_prefs_->GetInstalledExtensionInfo(extension_id)); 762 extension_prefs_->GetInstalledExtensionInfo(extension_id));
760 if (installed_extension.get() && 763 if (installed_extension.get() &&
761 installed_extension->extension_manifest.get()) { 764 installed_extension->extension_manifest.get()) {
762 extensions::InstalledLoader(this).Load(*installed_extension, false); 765 // The extension is being reloaded so it couldn't have been blacklisted, so
766 // it probably isn't blacklisted now either...
767 AddNonBlacklistedExtension(
768 extensions::InstalledLoader(this).Load(*installed_extension, false));
763 } else { 769 } else {
764 // Otherwise, the extension is unpacked (location LOAD). 770 // Otherwise, the extension is unpacked (location LOAD).
765 // We should always be able to remember the extension's path. If it's not in 771 // We should always be able to remember the extension's path. If it's not in
766 // the map, someone failed to update |unloaded_extension_paths_|. 772 // the map, someone failed to update |unloaded_extension_paths_|.
767 CHECK(!path.empty()); 773 CHECK(!path.empty());
768 extensions::UnpackedInstaller::Create(this)->Load(path); 774 extensions::UnpackedInstaller::Create(this)->Load(path);
769 } 775 }
770 } 776 }
771 777
772 bool ExtensionService::UninstallExtension( 778 bool ExtensionService::UninstallExtension(
(...skipping 1265 matching lines...) Expand 10 before | Expand all | Expand 10 after
2038 if (updater_.get()) 2044 if (updater_.get())
2039 updater_->Start(); 2045 updater_->Start();
2040 2046
2041 ready_ = true; 2047 ready_ = true;
2042 content::NotificationService::current()->Notify( 2048 content::NotificationService::current()->Notify(
2043 chrome::NOTIFICATION_EXTENSIONS_READY, 2049 chrome::NOTIFICATION_EXTENSIONS_READY,
2044 content::Source<Profile>(profile_), 2050 content::Source<Profile>(profile_),
2045 content::NotificationService::NoDetails()); 2051 content::NotificationService::NoDetails());
2046 } 2052 }
2047 2053
2048 void ExtensionService::AddExtension(const Extension* extension) { 2054 void ExtensionService::AddExtensions(const ExtensionList& extensions) {
Matt Perry 2013/02/07 01:05:35 Rather than adding a new API, couldn't you instead
not at google - send to devlin 2013/02/07 02:11:37 Done.
2049 // TODO(jstritar): We may be able to get rid of this branch by overriding the 2055 if (extensions.empty())
2050 // default extension state to DISABLED when the --disable-extensions flag
2051 // is set (http://crbug.com/29067).
2052 if (!extensions_enabled() &&
2053 !extension->is_theme() &&
2054 extension->location() != Manifest::COMPONENT &&
2055 !Manifest::IsExternalLocation(extension->location())) {
2056 return; 2056 return;
2057
2058 std::set<std::string> all_ids;
2059 std::set<std::string> already_in_blacklist;
2060
2061 for (ExtensionList::const_iterator it = extensions.begin();
2062 it != extensions.end(); ++it) {
2063 const std::string& id = (*it)->id();
2064 // Well... this is a lie, it might actually be blacklisted, but we check
2065 // that below asynchronously.
2066 if (!AddNonBlacklistedExtension(*it))
2067 already_in_blacklist.insert(id);
2068 all_ids.insert(id);
2057 } 2069 }
2058 2070
2059 SetBeingUpgraded(extension, false);
2060
2061 // The extension is now loaded, remove its data from unloaded extension map.
2062 unloaded_extension_paths_.erase(extension->id());
2063
2064 // If a terminated extension is loaded, remove it from the terminated list.
2065 UntrackTerminatedExtension(extension->id());
2066
2067 // If the extension was disabled for a reload, then enable it.
2068 if (disabled_extension_paths_.erase(extension->id()) > 0)
2069 EnableExtension(extension->id());
2070
2071 // Check if the extension's privileges have changed and disable the
2072 // extension if necessary.
2073 InitializePermissions(extension);
2074
2075 // If this extension is a sideloaded extension and we've not performed a
2076 // wipeout before, we might disable this extension here.
2077 MaybeWipeout(extension);
2078
2079 // Communicated to the Blacklist.
2080 std::set<std::string> already_in_blacklist;
2081
2082 if (extension_prefs_->IsExtensionBlacklisted(extension->id())) {
2083 // Don't check the Blacklist yet because it's asynchronous (we do it at
2084 // the end). This pre-emptive check is because we will always store the
2085 // blacklisted state of *installed* extensions in prefs, and it's important
2086 // not to re-enable blacklisted extensions.
2087 blacklisted_extensions_.Insert(extension);
2088 already_in_blacklist.insert(extension->id());
2089 } else if (extension_prefs_->IsExtensionDisabled(extension->id())) {
2090 disabled_extensions_.Insert(extension);
2091 SyncExtensionChangeIfNeeded(*extension);
2092 content::NotificationService::current()->Notify(
2093 chrome::NOTIFICATION_EXTENSION_UPDATE_DISABLED,
2094 content::Source<Profile>(profile_),
2095 content::Details<const Extension>(extension));
2096
2097 // Show the extension disabled error if a permissions increase was the
2098 // only reason it was disabled.
2099 if (extension_prefs_->GetDisableReasons(extension->id()) ==
2100 Extension::DISABLE_PERMISSIONS_INCREASE) {
2101 extensions::AddExtensionDisabledError(this, extension);
2102 }
2103 } else {
2104 // All apps that are displayed in the launcher are ordered by their ordinals
2105 // so we must ensure they have valid ordinals.
2106 if (extension->RequiresSortOrdinal()) {
2107 extension_prefs_->extension_sorting()->EnsureValidOrdinals(
2108 extension->id(), syncer::StringOrdinal());
2109 }
2110
2111 extensions_.Insert(extension);
2112 SyncExtensionChangeIfNeeded(*extension);
2113 NotifyExtensionLoaded(extension);
2114 DoPostLoadTasks(extension);
2115 }
2116
2117 // Lastly, begin the process for checking the blacklist status of extensions.
2118 // This may need to go to other threads so is asynchronous.
2119 std::set<std::string> id_set;
2120 id_set.insert(extension->id());
2121 blacklist_->GetBlacklistedIDs( 2071 blacklist_->GetBlacklistedIDs(
2122 id_set, 2072 all_ids,
2123 base::Bind(&ExtensionService::ManageBlacklist, 2073 base::Bind(&ExtensionService::ManageBlacklist,
2124 AsWeakPtr(), 2074 AsWeakPtr(),
2125 already_in_blacklist)); 2075 already_in_blacklist));
2126 } 2076 }
2127 2077
2078 void ExtensionService::AddExtension(const Extension* extension) {
2079 AddExtensions(ExtensionList(1, make_scoped_refptr(extension)));
2080 }
2081
2128 void ExtensionService::AddComponentExtension(const Extension* extension) { 2082 void ExtensionService::AddComponentExtension(const Extension* extension) {
2129 const std::string old_version_string( 2083 const std::string old_version_string(
2130 extension_prefs_->GetVersionString(extension->id())); 2084 extension_prefs_->GetVersionString(extension->id()));
2131 const Version old_version(old_version_string); 2085 const Version old_version(old_version_string);
2132 2086
2133 if (!old_version.IsValid() || !old_version.Equals(*extension->version())) { 2087 if (!old_version.IsValid() || !old_version.Equals(*extension->version())) {
2134 VLOG(1) << "Component extension " << extension->name() << " (" 2088 VLOG(1) << "Component extension " << extension->name() << " ("
2135 << extension->id() << ") installing/upgrading from '" 2089 << extension->id() << ") installing/upgrading from '"
2136 << old_version_string << "' to " << extension->version()->GetString(); 2090 << old_version_string << "' to " << extension->version()->GetString();
2137 2091
2138 AddNewOrUpdatedExtension(extension, 2092 AddNewOrUpdatedExtension(extension,
2139 Extension::ENABLED_COMPONENT, 2093 Extension::ENABLED_COMPONENT,
2140 syncer::StringOrdinal()); 2094 syncer::StringOrdinal());
2141 return; 2095 return;
2142 } 2096 }
2143 2097
2144 AddExtension(extension); 2098 AddNonBlacklistedExtension(extension);
2145 } 2099 }
2146 2100
2147 void ExtensionService::InitializePermissions(const Extension* extension) { 2101 void ExtensionService::InitializePermissions(const Extension* extension) {
2148 // If the extension has used the optional permissions API, it will have a 2102 // If the extension has used the optional permissions API, it will have a
2149 // custom set of active permissions defined in the extension prefs. Here, 2103 // custom set of active permissions defined in the extension prefs. Here,
2150 // we update the extension's active permissions based on the prefs. 2104 // we update the extension's active permissions based on the prefs.
2151 scoped_refptr<PermissionSet> active_permissions = 2105 scoped_refptr<PermissionSet> active_permissions =
2152 extension_prefs()->GetActivePermissions(extension->id()); 2106 extension_prefs()->GetActivePermissions(extension->id());
2153 2107
2154 if (active_permissions.get()) { 2108 if (active_permissions.get()) {
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
2315 for (ExtensionSet::const_iterator iter = extensions_.begin(); 2269 for (ExtensionSet::const_iterator iter = extensions_.begin();
2316 iter != extensions_.end(); ++iter) { 2270 iter != extensions_.end(); ++iter) {
2317 const Extension* extension = *iter; 2271 const Extension* extension = *iter;
2318 if (!extension->is_theme() && extension->location() != Manifest::COMPONENT) 2272 if (!extension->is_theme() && extension->location() != Manifest::COMPONENT)
2319 extension_ids.insert(extension->id()); 2273 extension_ids.insert(extension->id());
2320 } 2274 }
2321 2275
2322 child_process_logging::SetActiveExtensions(extension_ids); 2276 child_process_logging::SetActiveExtensions(extension_ids);
2323 } 2277 }
2324 2278
2325 void ExtensionService::OnExtensionInstalled( 2279 namespace {
2280
2281 // Runs |closure| if |extension| isn't blacklisted, and runs |on_done| either
2282 // way.
2283 void RunIfNotBlacklisted(Profile* profile,
2284 const scoped_refptr<const Extension>& extension,
2285 const base::Closure& closure,
2286 const base::Callback<void(bool)>& on_done,
2287 const std::set<std::string>& blacklist) {
2288 if (blacklist.count(extension->id())) {
2289 ExtensionInstallUIDefault(profile).OnInstallFailure(
2290 extensions::CrxInstallerError(
2291 l10n_util::GetStringFUTF16(IDS_EXTENSION_IS_BLACKLISTED,
2292 UTF8ToUTF16(extension->name()))));
2293 on_done.Run(false);
2294 return;
2295 }
2296
2297 closure.Run();
2298 on_done.Run(true);
2299 }
2300
2301 } // namespace
2302
2303 void ExtensionService::InstallExtensionAsync(
2326 const Extension* extension, 2304 const Extension* extension,
2327 const syncer::StringOrdinal& page_ordinal, 2305 const syncer::StringOrdinal& page_ordinal,
2328 bool has_requirement_errors, 2306 bool has_requirement_errors,
2307 bool wait_for_idle,
2308 const base::Callback<void(bool)>& on_done) {
2309 std::set<std::string> id;
2310 id.insert(extension->id());
2311 blacklist_->GetBlacklistedIDs(
2312 id,
2313 base::Bind(&RunIfNotBlacklisted,
2314 profile_,
2315 // Note: binding extension here to a scoped_ptr keeps it in
2316 // scope all the way to InstallExtensionNow.
2317 make_scoped_refptr(extension),
2318 base::Bind(&ExtensionService::InstallExtensionNow,
2319 AsWeakPtr(),
2320 extension,
2321 page_ordinal,
2322 has_requirement_errors,
2323 wait_for_idle),
2324 on_done));
2325 }
2326
2327 void ExtensionService::InstallExtensionNow(
2328 const Extension* extension,
2329 const syncer::StringOrdinal& page_ordinal,
2330 bool has_requirement_errors,
2329 bool wait_for_idle) { 2331 bool wait_for_idle) {
2330 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 2332 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
2331 2333
2332 const std::string& id = extension->id(); 2334 const std::string& id = extension->id();
2333 bool initial_enable = ShouldEnableOnInstall(extension); 2335 bool initial_enable = ShouldEnableOnInstall(extension);
2334 const extensions::PendingExtensionInfo* pending_extension_info = NULL; 2336 const extensions::PendingExtensionInfo* pending_extension_info = NULL;
2335 if ((pending_extension_info = pending_extension_manager()->GetById(id))) { 2337 if ((pending_extension_info = pending_extension_manager()->GetById(id))) {
2336 if (!pending_extension_info->ShouldAllowInstall(*extension)) { 2338 if (!pending_extension_info->ShouldAllowInstall(*extension)) {
2337 pending_extension_manager()->Remove(id); 2339 pending_extension_manager()->Remove(id);
2338 2340
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
2474 // Unpacked extensions default to allowing file access, but if that has been 2476 // Unpacked extensions default to allowing file access, but if that has been
2475 // overridden, don't reset the value. 2477 // overridden, don't reset the value.
2476 if (Manifest::ShouldAlwaysAllowFileAccess(extension->location()) && 2478 if (Manifest::ShouldAlwaysAllowFileAccess(extension->location()) &&
2477 !extension_prefs_->HasAllowFileAccessSetting(extension->id())) { 2479 !extension_prefs_->HasAllowFileAccessSetting(extension->id())) {
2478 extension_prefs_->SetAllowFileAccess(extension->id(), true); 2480 extension_prefs_->SetAllowFileAccess(extension->id(), true);
2479 } 2481 }
2480 2482
2481 AddExtension(extension); 2483 AddExtension(extension);
2482 2484
2483 #if defined(ENABLE_THEMES) 2485 #if defined(ENABLE_THEMES)
2484 // We do this here since AddExtension() is always called on browser 2486 // We do this here since AddExtensions() is always called on browser startup,
2485 // startup, and we only really care about the last theme installed. 2487 // and we only really care about the last theme installed. If that ever
2486 // If that ever changes and we have to move this code somewhere 2488 // changes and we have to move this code somewhere else, it should be
2487 // else, it should be somewhere that's not in the startup path. 2489 // somewhere that's not in the startup path.
2488 if (extension->is_theme() && extensions_.GetByID(extension->id())) { 2490 if (extension->is_theme() && extensions_.GetByID(extension->id())) {
2489 DCHECK_EQ(extensions_.GetByID(extension->id()), extension); 2491 DCHECK_EQ(extensions_.GetByID(extension->id()), extension);
2490 // Now that the theme extension is visible from outside the 2492 // Now that the theme extension is visible from outside the
2491 // ExtensionService, notify the ThemeService about the 2493 // ExtensionService, notify the ThemeService about the
2492 // newly-installed theme. 2494 // newly-installed theme.
2493 ThemeServiceFactory::GetForProfile(profile_)->SetTheme(extension); 2495 ThemeServiceFactory::GetForProfile(profile_)->SetTheme(extension);
2494 } 2496 }
2495 #endif 2497 #endif
2496 2498
2497 // If this is a new external extension that was disabled, alert the user 2499 // If this is a new external extension that was disabled, alert the user
(...skipping 17 matching lines...) Expand all
2515 terminated_extensions_.Insert(make_scoped_refptr(extension)); 2517 terminated_extensions_.Insert(make_scoped_refptr(extension));
2516 2518
2517 UnloadExtension(extension->id(), extension_misc::UNLOAD_REASON_TERMINATE); 2519 UnloadExtension(extension->id(), extension_misc::UNLOAD_REASON_TERMINATE);
2518 } 2520 }
2519 2521
2520 void ExtensionService::UntrackTerminatedExtension(const std::string& id) { 2522 void ExtensionService::UntrackTerminatedExtension(const std::string& id) {
2521 std::string lowercase_id = StringToLowerASCII(id); 2523 std::string lowercase_id = StringToLowerASCII(id);
2522 terminated_extensions_.Remove(lowercase_id); 2524 terminated_extensions_.Remove(lowercase_id);
2523 } 2525 }
2524 2526
2527 bool ExtensionService::AddNonBlacklistedExtension(const Extension* extension) {
2528 // TODO(jstritar): We may be able to get rid of this branch by overriding the
2529 // default extension state to DISABLED when the --disable-extensions flag
2530 // is set (http://crbug.com/29067).
2531 if (!extensions_enabled() &&
2532 !extension->is_theme() &&
2533 extension->location() != Manifest::COMPONENT &&
2534 !Manifest::IsExternalLocation(extension->location())) {
2535 return true;
2536 }
2537
2538 SetBeingUpgraded(extension, false);
2539
2540 // The extension is now loaded, remove its data from unloaded extension map.
2541 unloaded_extension_paths_.erase(extension->id());
2542
2543 // If a terminated extension is loaded, remove it from the terminated list.
2544 UntrackTerminatedExtension(extension->id());
2545
2546 // If the extension was disabled for a reload, then enable it.
2547 if (disabled_extension_paths_.erase(extension->id()) > 0)
2548 EnableExtension(extension->id());
2549
2550 // Check if the extension's privileges have changed and disable the
2551 // extension if necessary.
2552 InitializePermissions(extension);
2553
2554 // If this extension is a sideloaded extension and we've not performed a
2555 // wipeout before, we might disable this extension here.
2556 MaybeWipeout(extension);
2557
2558 // Communicated to the Blacklist.
2559 bool was_prefs_blacklisted = false;
2560
2561 if (extension_prefs_->IsExtensionBlacklisted(extension->id())) {
2562 // We always store the blacklisted state of *installed* extensions in
2563 // prefs, and it's important not to re-enable them.
2564 blacklisted_extensions_.Insert(extension);
2565 was_prefs_blacklisted = true;
2566 } else if (extension_prefs_->IsExtensionDisabled(extension->id())) {
2567 disabled_extensions_.Insert(extension);
2568 SyncExtensionChangeIfNeeded(*extension);
2569 content::NotificationService::current()->Notify(
2570 chrome::NOTIFICATION_EXTENSION_UPDATE_DISABLED,
2571 content::Source<Profile>(profile_),
2572 content::Details<const Extension>(extension));
2573
2574 // Show the extension disabled error if a permissions increase was the
2575 // only reason it was disabled.
2576 if (extension_prefs_->GetDisableReasons(extension->id()) ==
2577 Extension::DISABLE_PERMISSIONS_INCREASE) {
2578 extensions::AddExtensionDisabledError(this, extension);
2579 }
2580 } else {
2581 // All apps that are displayed in the launcher are ordered by their ordinals
2582 // so we must ensure they have valid ordinals.
2583 if (extension->RequiresSortOrdinal()) {
2584 extension_prefs_->extension_sorting()->EnsureValidOrdinals(
2585 extension->id(), syncer::StringOrdinal());
2586 }
2587
2588 extensions_.Insert(extension);
2589 SyncExtensionChangeIfNeeded(*extension);
2590 NotifyExtensionLoaded(extension);
2591 DoPostLoadTasks(extension);
2592 }
2593
2594 return !was_prefs_blacklisted;
2595 }
2596
2525 const Extension* ExtensionService::GetTerminatedExtension( 2597 const Extension* ExtensionService::GetTerminatedExtension(
2526 const std::string& id) const { 2598 const std::string& id) const {
2527 return GetExtensionById(id, INCLUDE_TERMINATED); 2599 return GetExtensionById(id, INCLUDE_TERMINATED);
2528 } 2600 }
2529 2601
2530 const Extension* ExtensionService::GetInstalledExtension( 2602 const Extension* ExtensionService::GetInstalledExtension(
2531 const std::string& id) const { 2603 const std::string& id) const {
2532 int include_mask = INCLUDE_ENABLED | 2604 int include_mask = INCLUDE_ENABLED |
2533 INCLUDE_DISABLED | 2605 INCLUDE_DISABLED |
2534 INCLUDE_TERMINATED | 2606 INCLUDE_TERMINATED |
(...skipping 565 matching lines...) Expand 10 before | Expand all | Expand 10 after
3100 not_yet_blacklisted.begin())); 3172 not_yet_blacklisted.begin()));
3101 3173
3102 for (std::set<std::string>::iterator it = no_longer_blacklisted.begin(); 3174 for (std::set<std::string>::iterator it = no_longer_blacklisted.begin();
3103 it != no_longer_blacklisted.end(); ++it) { 3175 it != no_longer_blacklisted.end(); ++it) {
3104 scoped_refptr<const Extension> extension = 3176 scoped_refptr<const Extension> extension =
3105 blacklisted_extensions_.GetByID(*it); 3177 blacklisted_extensions_.GetByID(*it);
3106 DCHECK(extension); 3178 DCHECK(extension);
3107 if (!extension) 3179 if (!extension)
3108 continue; 3180 continue;
3109 blacklisted_extensions_.Remove(*it); 3181 blacklisted_extensions_.Remove(*it);
3110 AddExtension(extension); 3182 AddNonBlacklistedExtension(extension);
3111 } 3183 }
3112 3184
3113 for (std::set<std::string>::iterator it = not_yet_blacklisted.begin(); 3185 for (std::set<std::string>::iterator it = not_yet_blacklisted.begin();
3114 it != not_yet_blacklisted.end(); ++it) { 3186 it != not_yet_blacklisted.end(); ++it) {
3115 scoped_refptr<const Extension> extension = GetInstalledExtension(*it); 3187 scoped_refptr<const Extension> extension = GetInstalledExtension(*it);
3116 DCHECK(extension); 3188 DCHECK(extension);
3117 if (!extension) 3189 if (!extension)
3118 continue; 3190 continue;
3119 blacklisted_extensions_.Insert(extension); 3191 blacklisted_extensions_.Insert(extension);
3120 UnloadExtension(*it, extension_misc::UNLOAD_REASON_BLACKLIST); 3192 UnloadExtension(*it, extension_misc::UNLOAD_REASON_BLACKLIST);
3121 } 3193 }
3122 3194
3123 IdentifyAlertableExtensions(); 3195 IdentifyAlertableExtensions();
3124 } 3196 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698