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

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

Issue 11412239: Delay determination of why a synced disabled extension was disabled. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: missing file Created 8 years 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 <set> 8 #include <set>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
(...skipping 1528 matching lines...) Expand 10 before | Expand all | Expand 10 after
1539 1539
1540 // Extension from sync was uninstalled by the user as external extensions. 1540 // Extension from sync was uninstalled by the user as external extensions.
1541 // Honor user choice and skip installation/enabling. 1541 // Honor user choice and skip installation/enabling.
1542 if (IsExternalExtensionUninstalled(id)) { 1542 if (IsExternalExtensionUninstalled(id)) {
1543 LOG(WARNING) << "Extension with id " << id 1543 LOG(WARNING) << "Extension with id " << id
1544 << " from sync was uninstalled as external extension"; 1544 << " from sync was uninstalled as external extension";
1545 return true; 1545 return true;
1546 } 1546 }
1547 1547
1548 // Set user settings. 1548 // Set user settings.
1549 // If the extension has been disabled from sync, it may not have
1550 // been installed yet, so we don't know if the disable reason was a
1551 // permissions increase. That will be updated once InitializePermissions
1552 // is called for it.
1549 if (extension_sync_data.enabled()) 1553 if (extension_sync_data.enabled())
1550 EnableExtension(id); 1554 EnableExtension(id);
1551 else 1555 else
1552 DisableExtension(id, Extension::DISABLE_USER_ACTION); 1556 DisableExtension(id, Extension::DISABLE_UNKNOWN_FROM_SYNC);
1553 1557
1554 // We need to cache some version information here because setting the 1558 // We need to cache some version information here because setting the
1555 // incognito flag invalidates the |extension| pointer (it reloads the 1559 // incognito flag invalidates the |extension| pointer (it reloads the
1556 // extension). 1560 // extension).
1557 bool extension_installed = (extension != NULL); 1561 bool extension_installed = (extension != NULL);
1558 int result = extension ? 1562 int result = extension ?
1559 extension->version()->CompareTo(extension_sync_data.version()) : 0; 1563 extension->version()->CompareTo(extension_sync_data.version()) : 0;
1560 SetIsIncognitoEnabled(id, extension_sync_data.incognito_enabled()); 1564 SetIsIncognitoEnabled(id, extension_sync_data.incognito_enabled());
1561 extension = NULL; // No longer safe to use. 1565 extension = NULL; // No longer safe to use.
1562 1566
(...skipping 526 matching lines...) Expand 10 before | Expand all | Expand 10 after
2089 MaybeWipeout(extension); 2093 MaybeWipeout(extension);
2090 2094
2091 if (extension_prefs_->IsExtensionDisabled(extension->id())) { 2095 if (extension_prefs_->IsExtensionDisabled(extension->id())) {
2092 disabled_extensions_.Insert(extension); 2096 disabled_extensions_.Insert(extension);
2093 SyncExtensionChangeIfNeeded(*extension); 2097 SyncExtensionChangeIfNeeded(*extension);
2094 content::NotificationService::current()->Notify( 2098 content::NotificationService::current()->Notify(
2095 chrome::NOTIFICATION_EXTENSION_UPDATE_DISABLED, 2099 chrome::NOTIFICATION_EXTENSION_UPDATE_DISABLED,
2096 content::Source<Profile>(profile_), 2100 content::Source<Profile>(profile_),
2097 content::Details<const Extension>(extension)); 2101 content::Details<const Extension>(extension));
2098 2102
2099 if (extension_prefs_->GetDisableReasons(extension->id()) & 2103 // Show the extension disabled error if a permissions increase was the
2104 // only reason it was disabled.
2105 if (extension_prefs_->GetDisableReasons(extension->id()) ==
2100 Extension::DISABLE_PERMISSIONS_INCREASE) { 2106 Extension::DISABLE_PERMISSIONS_INCREASE) {
2101 extensions::AddExtensionDisabledError(this, extension); 2107 extensions::AddExtensionDisabledError(this, extension);
2102 } 2108 }
2103 return; 2109 return;
2104 } 2110 }
2105 2111
2106 // All apps that are displayed in the launcher are ordered by their ordinals 2112 // All apps that are displayed in the launcher are ordered by their ordinals
2107 // so we must ensure they have valid ordinals. 2113 // so we must ensure they have valid ordinals.
2108 if (extension->RequiresSortOrdinal()) { 2114 if (extension->RequiresSortOrdinal()) {
2109 extension_prefs_->extension_sorting()->EnsureValidOrdinals( 2115 extension_prefs_->extension_sorting()->EnsureValidOrdinals(
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
2229 // Extensions get upgraded if the privileges are allowed to increase or 2235 // Extensions get upgraded if the privileges are allowed to increase or
2230 // the privileges haven't increased. 2236 // the privileges haven't increased.
2231 if (!is_privilege_increase) { 2237 if (!is_privilege_increase) {
2232 SetBeingUpgraded(old, true); 2238 SetBeingUpgraded(old, true);
2233 SetBeingUpgraded(extension, true); 2239 SetBeingUpgraded(extension, true);
2234 } 2240 }
2235 2241
2236 // If the extension was already disabled, suppress any alerts for becoming 2242 // If the extension was already disabled, suppress any alerts for becoming
2237 // disabled on permissions increase. 2243 // disabled on permissions increase.
2238 previously_disabled = extension_prefs_->IsExtensionDisabled(old->id()); 2244 previously_disabled = extension_prefs_->IsExtensionDisabled(old->id());
2239 if (previously_disabled) { 2245 // Legacy disabled extensions do not have a disable reason. Infer that if
2240 int reasons = extension_prefs_->GetDisableReasons(old->id()); 2246 // there was no permission increase, it was likely disabled by the user.
2241 if (reasons == Extension::DISABLE_NONE) { 2247 if (previously_disabled && disable_reasons == Extension::DISABLE_NONE &&
2242 // Initialize the reason for legacy disabled extensions from whether the 2248 !extension_prefs_->DidExtensionEscalatePermissions(old->id())) {
2243 // extension already exceeded granted permissions. 2249 disable_reasons |= Extension::DISABLE_USER_ACTION;
2244 if (extension_prefs_->DidExtensionEscalatePermissions(old->id()))
2245 disable_reasons = Extension::DISABLE_PERMISSIONS_INCREASE;
2246 else
2247 disable_reasons = Extension::DISABLE_USER_ACTION;
2248 }
2249 } else {
2250 disable_reasons = Extension::DISABLE_PERMISSIONS_INCREASE;
2251 } 2250 }
2251 // Extensions that came to us disabled from sync need a similar inference,
2252 // except based on the new version's permissions.
2253 if (previously_disabled &&
2254 disable_reasons == Extension::DISABLE_UNKNOWN_FROM_SYNC) {
2255 // Remove the DISABLE_UNKNOWN_FROM_SYNC reason.
2256 extension_prefs_->ClearDisableReasons(extension->id());
2257 if (!is_privilege_increase)
2258 disable_reasons |= Extension::DISABLE_USER_ACTION;
2259 }
2260 disable_reasons &= ~Extension::DISABLE_UNKNOWN_FROM_SYNC;
2252 2261
2253 // To upgrade an extension in place, unload the old one and 2262 // To upgrade an extension in place, unload the old one and
2254 // then load the new one. 2263 // then load the new one.
2255 UnloadExtension(old->id(), extension_misc::UNLOAD_REASON_UPDATE); 2264 UnloadExtension(old->id(), extension_misc::UNLOAD_REASON_UPDATE);
2256 old = NULL; 2265 old = NULL;
2257 } 2266 }
2258 2267
2259 // Extension has changed permissions significantly. Disable it. A 2268 // Extension has changed permissions significantly. Disable it. A
2260 // notification should be sent by the caller. 2269 // notification should be sent by the caller.
2261 if (is_privilege_increase) { 2270 if (is_privilege_increase) {
2271 disable_reasons |= Extension::DISABLE_PERMISSIONS_INCREASE;
2262 if (!extension_prefs_->DidExtensionEscalatePermissions(extension->id())) { 2272 if (!extension_prefs_->DidExtensionEscalatePermissions(extension->id())) {
2263 RecordPermissionMessagesHistogram( 2273 RecordPermissionMessagesHistogram(
2264 extension, "Extensions.Permissions_AutoDisable"); 2274 extension, "Extensions.Permissions_AutoDisable");
2265 } 2275 }
2266 extension_prefs_->SetExtensionState(extension->id(), Extension::DISABLED); 2276 extension_prefs_->SetExtensionState(extension->id(), Extension::DISABLED);
2267 extension_prefs_->SetDidExtensionEscalatePermissions(extension, true); 2277 extension_prefs_->SetDidExtensionEscalatePermissions(extension, true);
2268 extension_prefs_->AddDisableReason( 2278 extension_prefs_->AddDisableReason(
2269 extension->id(), 2279 extension->id(),
2270 static_cast<Extension::DisableReason>(disable_reasons)); 2280 static_cast<Extension::DisableReason>(disable_reasons));
2271 } 2281 }
(...skipping 757 matching lines...) Expand 10 before | Expand all | Expand 10 after
3029 extension_id, kOnUpdateAvailableEvent); 3039 extension_id, kOnUpdateAvailableEvent);
3030 } else { 3040 } else {
3031 // Delay installation if the extension is not idle. 3041 // Delay installation if the extension is not idle.
3032 return !IsExtensionIdle(extension_id); 3042 return !IsExtensionIdle(extension_id);
3033 } 3043 }
3034 } 3044 }
3035 3045
3036 void ExtensionService::OnBlacklistUpdated() { 3046 void ExtensionService::OnBlacklistUpdated() {
3037 CheckManagementPolicy(); 3047 CheckManagementPolicy();
3038 } 3048 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_disabled_ui_browsertest.cc ('k') | chrome/common/extensions/extension.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698