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

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: mpcomplete 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 2017 matching lines...) Expand 10 before | Expand all | Expand 10 after
2028 2028
2029 void ExtensionService::SyncExtensionChangeIfNeeded(const Extension& extension) { 2029 void ExtensionService::SyncExtensionChangeIfNeeded(const Extension& extension) {
2030 if (app_sync_bundle_.HandlesApp(extension)) { 2030 if (app_sync_bundle_.HandlesApp(extension)) {
2031 app_sync_bundle_.SyncChangeIfNeeded(extension); 2031 app_sync_bundle_.SyncChangeIfNeeded(extension);
2032 } else if (extension_sync_bundle_.HandlesExtension(extension)) { 2032 } else if (extension_sync_bundle_.HandlesExtension(extension)) {
2033 extension_sync_bundle_.SyncChangeIfNeeded(extension); 2033 extension_sync_bundle_.SyncChangeIfNeeded(extension);
2034 } 2034 }
2035 } 2035 }
2036 2036
2037 void ExtensionService::OnLoadedInstalledExtensions() { 2037 void ExtensionService::OnLoadedInstalledExtensions() {
2038 DCHECK(!ready_);
2039
2038 if (updater_.get()) 2040 if (updater_.get())
2039 updater_->Start(); 2041 updater_->Start();
2040 2042
2043 OnBlacklistUpdated();
2044
2041 ready_ = true; 2045 ready_ = true;
2046
2042 content::NotificationService::current()->Notify( 2047 content::NotificationService::current()->Notify(
2043 chrome::NOTIFICATION_EXTENSIONS_READY, 2048 chrome::NOTIFICATION_EXTENSIONS_READY,
2044 content::Source<Profile>(profile_), 2049 content::Source<Profile>(profile_),
2045 content::NotificationService::NoDetails()); 2050 content::NotificationService::NoDetails());
2046 } 2051 }
2047 2052
2048 void ExtensionService::AddExtension(const Extension* extension) { 2053 void ExtensionService::AddExtension(const Extension* extension) {
2049 // TODO(jstritar): We may be able to get rid of this branch by overriding the 2054 // TODO(jstritar): We may be able to get rid of this branch by overriding the
2050 // default extension state to DISABLED when the --disable-extensions flag 2055 // default extension state to DISABLED when the --disable-extensions flag
2051 // is set (http://crbug.com/29067). 2056 // is set (http://crbug.com/29067).
(...skipping 17 matching lines...) Expand all
2069 EnableExtension(extension->id()); 2074 EnableExtension(extension->id());
2070 2075
2071 // Check if the extension's privileges have changed and disable the 2076 // Check if the extension's privileges have changed and disable the
2072 // extension if necessary. 2077 // extension if necessary.
2073 InitializePermissions(extension); 2078 InitializePermissions(extension);
2074 2079
2075 // If this extension is a sideloaded extension and we've not performed a 2080 // If this extension is a sideloaded extension and we've not performed a
2076 // wipeout before, we might disable this extension here. 2081 // wipeout before, we might disable this extension here.
2077 MaybeWipeout(extension); 2082 MaybeWipeout(extension);
2078 2083
2079 // Communicated to the Blacklist.
2080 std::set<std::string> already_in_blacklist;
2081
2082 if (extension_prefs_->IsExtensionBlacklisted(extension->id())) { 2084 if (extension_prefs_->IsExtensionBlacklisted(extension->id())) {
2083 // Don't check the Blacklist yet because it's asynchronous (we do it at 2085 // 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 2086 // 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 2087 // blacklisted state of *installed* extensions in prefs, and it's important
2086 // not to re-enable blacklisted extensions. 2088 // not to re-enable blacklisted extensions.
2087 blacklisted_extensions_.Insert(extension); 2089 blacklisted_extensions_.Insert(extension);
2088 already_in_blacklist.insert(extension->id());
2089 } else if (extension_prefs_->IsExtensionDisabled(extension->id())) { 2090 } else if (extension_prefs_->IsExtensionDisabled(extension->id())) {
2090 disabled_extensions_.Insert(extension); 2091 disabled_extensions_.Insert(extension);
2091 SyncExtensionChangeIfNeeded(*extension); 2092 SyncExtensionChangeIfNeeded(*extension);
2092 content::NotificationService::current()->Notify( 2093 content::NotificationService::current()->Notify(
2093 chrome::NOTIFICATION_EXTENSION_UPDATE_DISABLED, 2094 chrome::NOTIFICATION_EXTENSION_UPDATE_DISABLED,
2094 content::Source<Profile>(profile_), 2095 content::Source<Profile>(profile_),
2095 content::Details<const Extension>(extension)); 2096 content::Details<const Extension>(extension));
2096 2097
2097 // Show the extension disabled error if a permissions increase was the 2098 // Show the extension disabled error if a permissions increase was the
2098 // only reason it was disabled. 2099 // only reason it was disabled.
2099 if (extension_prefs_->GetDisableReasons(extension->id()) == 2100 if (extension_prefs_->GetDisableReasons(extension->id()) ==
2100 Extension::DISABLE_PERMISSIONS_INCREASE) { 2101 Extension::DISABLE_PERMISSIONS_INCREASE) {
2101 extensions::AddExtensionDisabledError(this, extension); 2102 extensions::AddExtensionDisabledError(this, extension);
2102 } 2103 }
2103 } else { 2104 } else {
2104 // All apps that are displayed in the launcher are ordered by their ordinals 2105 // All apps that are displayed in the launcher are ordered by their ordinals
2105 // so we must ensure they have valid ordinals. 2106 // so we must ensure they have valid ordinals.
2106 if (extension->RequiresSortOrdinal()) { 2107 if (extension->RequiresSortOrdinal()) {
2107 extension_prefs_->extension_sorting()->EnsureValidOrdinals( 2108 extension_prefs_->extension_sorting()->EnsureValidOrdinals(
2108 extension->id(), syncer::StringOrdinal()); 2109 extension->id(), syncer::StringOrdinal());
2109 } 2110 }
2110 2111
2111 extensions_.Insert(extension); 2112 extensions_.Insert(extension);
2112 SyncExtensionChangeIfNeeded(*extension); 2113 SyncExtensionChangeIfNeeded(*extension);
2113 NotifyExtensionLoaded(extension); 2114 NotifyExtensionLoaded(extension);
2114 DoPostLoadTasks(extension); 2115 DoPostLoadTasks(extension);
2115 } 2116 }
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(
2122 id_set,
2123 base::Bind(&ExtensionService::ManageBlacklist,
2124 AsWeakPtr(),
2125 already_in_blacklist));
2126 } 2117 }
2127 2118
2128 void ExtensionService::AddComponentExtension(const Extension* extension) { 2119 void ExtensionService::AddComponentExtension(const Extension* extension) {
2129 const std::string old_version_string( 2120 const std::string old_version_string(
2130 extension_prefs_->GetVersionString(extension->id())); 2121 extension_prefs_->GetVersionString(extension->id()));
2131 const Version old_version(old_version_string); 2122 const Version old_version(old_version_string);
2132 2123
2133 if (!old_version.IsValid() || !old_version.Equals(*extension->version())) { 2124 if (!old_version.IsValid() || !old_version.Equals(*extension->version())) {
2134 VLOG(1) << "Component extension " << extension->name() << " (" 2125 VLOG(1) << "Component extension " << extension->name() << " ("
2135 << extension->id() << ") installing/upgrading from '" 2126 << extension->id() << ") installing/upgrading from '"
(...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after
2474 // Unpacked extensions default to allowing file access, but if that has been 2465 // Unpacked extensions default to allowing file access, but if that has been
2475 // overridden, don't reset the value. 2466 // overridden, don't reset the value.
2476 if (Manifest::ShouldAlwaysAllowFileAccess(extension->location()) && 2467 if (Manifest::ShouldAlwaysAllowFileAccess(extension->location()) &&
2477 !extension_prefs_->HasAllowFileAccessSetting(extension->id())) { 2468 !extension_prefs_->HasAllowFileAccessSetting(extension->id())) {
2478 extension_prefs_->SetAllowFileAccess(extension->id(), true); 2469 extension_prefs_->SetAllowFileAccess(extension->id(), true);
2479 } 2470 }
2480 2471
2481 AddExtension(extension); 2472 AddExtension(extension);
2482 2473
2483 #if defined(ENABLE_THEMES) 2474 #if defined(ENABLE_THEMES)
2484 // We do this here since AddExtension() is always called on browser 2475 // We do this here since AddExtension() is always called on browser startup,
2485 // startup, and we only really care about the last theme installed. 2476 // and we only really care about the last theme installed.
2486 // If that ever changes and we have to move this code somewhere 2477 // If that ever changes and we have to move this code somewhere
2487 // else, it should be somewhere that's not in the startup path. 2478 // else, it should be somewhere that's not in the startup path.
2488 if (extension->is_theme() && extensions_.GetByID(extension->id())) { 2479 if (extension->is_theme() && extensions_.GetByID(extension->id())) {
2489 DCHECK_EQ(extensions_.GetByID(extension->id()), extension); 2480 DCHECK_EQ(extensions_.GetByID(extension->id()), extension);
2490 // Now that the theme extension is visible from outside the 2481 // Now that the theme extension is visible from outside the
2491 // ExtensionService, notify the ThemeService about the 2482 // ExtensionService, notify the ThemeService about the
2492 // newly-installed theme. 2483 // newly-installed theme.
2493 ThemeServiceFactory::GetForProfile(profile_)->SetTheme(extension); 2484 ThemeServiceFactory::GetForProfile(profile_)->SetTheme(extension);
2494 } 2485 }
2495 #endif 2486 #endif
(...skipping 619 matching lines...) Expand 10 before | Expand all | Expand 10 after
3115 scoped_refptr<const Extension> extension = GetInstalledExtension(*it); 3106 scoped_refptr<const Extension> extension = GetInstalledExtension(*it);
3116 DCHECK(extension); 3107 DCHECK(extension);
3117 if (!extension) 3108 if (!extension)
3118 continue; 3109 continue;
3119 blacklisted_extensions_.Insert(extension); 3110 blacklisted_extensions_.Insert(extension);
3120 UnloadExtension(*it, extension_misc::UNLOAD_REASON_BLACKLIST); 3111 UnloadExtension(*it, extension_misc::UNLOAD_REASON_BLACKLIST);
3121 } 3112 }
3122 3113
3123 IdentifyAlertableExtensions(); 3114 IdentifyAlertableExtensions();
3124 } 3115 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698