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

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

Issue 11189094: Implement sideload wipeout for Extensions. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 2 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 <set> 8 #include <set>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 131
132 using content::BrowserContext; 132 using content::BrowserContext;
133 using content::BrowserThread; 133 using content::BrowserThread;
134 using content::DevToolsAgentHost; 134 using content::DevToolsAgentHost;
135 using content::DevToolsAgentHostRegistry; 135 using content::DevToolsAgentHostRegistry;
136 using content::PluginService; 136 using content::PluginService;
137 using extensions::CrxInstaller; 137 using extensions::CrxInstaller;
138 using extensions::Extension; 138 using extensions::Extension;
139 using extensions::ExtensionIdSet; 139 using extensions::ExtensionIdSet;
140 using extensions::ExtensionInfo; 140 using extensions::ExtensionInfo;
141 using extensions::FeatureSwitch;
141 using extensions::UnloadedExtensionInfo; 142 using extensions::UnloadedExtensionInfo;
142 using extensions::PermissionMessage; 143 using extensions::PermissionMessage;
143 using extensions::PermissionMessages; 144 using extensions::PermissionMessages;
144 using extensions::PermissionSet; 145 using extensions::PermissionSet;
145 146
146 namespace errors = extension_manifest_errors; 147 namespace errors = extension_manifest_errors;
147 148
148 namespace { 149 namespace {
149 150
150 #if defined(OS_LINUX) 151 #if defined(OS_LINUX)
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after
434 } 435 }
435 436
436 const ExtensionSet* ExtensionService::GenerateInstalledExtensionsSet() const { 437 const ExtensionSet* ExtensionService::GenerateInstalledExtensionsSet() const {
437 ExtensionSet* installed_extensions = new ExtensionSet(); 438 ExtensionSet* installed_extensions = new ExtensionSet();
438 installed_extensions->InsertAll(extensions_); 439 installed_extensions->InsertAll(extensions_);
439 installed_extensions->InsertAll(disabled_extensions_); 440 installed_extensions->InsertAll(disabled_extensions_);
440 installed_extensions->InsertAll(terminated_extensions_); 441 installed_extensions->InsertAll(terminated_extensions_);
441 return installed_extensions; 442 return installed_extensions;
442 } 443 }
443 444
445 const ExtensionSet* ExtensionService::GetWipedOutExtensions() const {
446 ExtensionSet* extension_set = new ExtensionSet();
447 for (ExtensionSet::const_iterator iter = disabled_extensions_.begin();
448 iter != disabled_extensions_.end(); ++iter) {
449 int disabled_reason = extension_prefs_->GetDisableReasons((*iter)->id());
450 if ((disabled_reason & Extension::DISABLE_SIDELOAD_WIPEOUT) != 0)
451 extension_set->Insert(*iter);
452 }
453 return extension_set;
454 }
455
444 extensions::PendingExtensionManager* 456 extensions::PendingExtensionManager*
445 ExtensionService::pending_extension_manager() { 457 ExtensionService::pending_extension_manager() {
446 return &pending_extension_manager_; 458 return &pending_extension_manager_;
447 } 459 }
448 460
449 ExtensionService::~ExtensionService() { 461 ExtensionService::~ExtensionService() {
450 // No need to unload extensions here because they are profile-scoped, and the 462 // No need to unload extensions here because they are profile-scoped, and the
451 // profile is in the process of being deleted. 463 // profile is in the process of being deleted.
452 464
453 extensions::ProviderCollection::const_iterator i; 465 extensions::ProviderCollection::const_iterator i;
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
555 567
556 void ExtensionService::Init() { 568 void ExtensionService::Init() {
557 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 569 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
558 570
559 DCHECK(!ready_); // Can't redo init. 571 DCHECK(!ready_); // Can't redo init.
560 DCHECK_EQ(extensions_.size(), 0u); 572 DCHECK_EQ(extensions_.size(), 0u);
561 573
562 component_loader_->LoadAll(); 574 component_loader_->LoadAll();
563 extensions::InstalledLoader(this).LoadAllExtensions(); 575 extensions::InstalledLoader(this).LoadAllExtensions();
564 576
577 // The Sideload Wipeout effort takes place during load (see above), so once
578 // that is done the flag can be set so that we don't have to check again.
579 if (FeatureSwitch::sideload_wipeout()->IsEnabled())
580 extension_prefs_->SetSideloadWipeoutDone();
581
565 // If we are running in the import process, don't bother initializing the 582 // If we are running in the import process, don't bother initializing the
566 // extension service since this can interfere with the main browser process 583 // extension service since this can interfere with the main browser process
567 // that is already running an extension service for this profile. 584 // that is already running an extension service for this profile.
568 // TODO(aa): can we start up even less of ExtensionService? 585 // TODO(aa): can we start up even less of ExtensionService?
569 // http://crbug.com/107636 586 // http://crbug.com/107636
570 if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kImport) && 587 if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kImport) &&
571 !CommandLine::ForCurrentProcess()->HasSwitch(switches::kImportFromFile)) { 588 !CommandLine::ForCurrentProcess()->HasSwitch(switches::kImportFromFile)) {
572 if (g_browser_process->profile_manager() && 589 if (g_browser_process->profile_manager() &&
573 g_browser_process->profile_manager()->will_import()) { 590 g_browser_process->profile_manager()->will_import()) {
574 RegisterForImportFinished(); 591 RegisterForImportFinished();
(...skipping 1417 matching lines...) Expand 10 before | Expand all | Expand 10 after
1992 UntrackTerminatedExtension(extension->id()); 2009 UntrackTerminatedExtension(extension->id());
1993 2010
1994 // If the extension was disabled for a reload, then enable it. 2011 // If the extension was disabled for a reload, then enable it.
1995 if (disabled_extension_paths_.erase(extension->id()) > 0) 2012 if (disabled_extension_paths_.erase(extension->id()) > 0)
1996 EnableExtension(extension->id()); 2013 EnableExtension(extension->id());
1997 2014
1998 // Check if the extension's privileges have changed and disable the 2015 // Check if the extension's privileges have changed and disable the
1999 // extension if necessary. 2016 // extension if necessary.
2000 InitializePermissions(extension); 2017 InitializePermissions(extension);
2001 2018
2019 // If this extension is a sideloaded extension and we've not performed a
2020 // wipeout before, we might disable this extension here.
2021 MaybeWipeout(extension);
2022
2002 if (extension_prefs_->IsExtensionDisabled(extension->id())) { 2023 if (extension_prefs_->IsExtensionDisabled(extension->id())) {
2003 disabled_extensions_.Insert(scoped_extension); 2024 disabled_extensions_.Insert(scoped_extension);
2004 SyncExtensionChangeIfNeeded(*extension); 2025 SyncExtensionChangeIfNeeded(*extension);
2005 content::NotificationService::current()->Notify( 2026 content::NotificationService::current()->Notify(
2006 chrome::NOTIFICATION_EXTENSION_UPDATE_DISABLED, 2027 chrome::NOTIFICATION_EXTENSION_UPDATE_DISABLED,
2007 content::Source<Profile>(profile_), 2028 content::Source<Profile>(profile_),
2008 content::Details<const Extension>(extension)); 2029 content::Details<const Extension>(extension));
2009 2030
2010 if (extension_prefs_->GetDisableReasons(extension->id()) & 2031 if (extension_prefs_->GetDisableReasons(extension->id()) &
2011 Extension::DISABLE_PERMISSIONS_INCREASE) { 2032 Extension::DISABLE_PERMISSIONS_INCREASE) {
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
2156 extension, "Extensions.Permissions_AutoDisable"); 2177 extension, "Extensions.Permissions_AutoDisable");
2157 } 2178 }
2158 extension_prefs_->SetExtensionState(extension->id(), Extension::DISABLED); 2179 extension_prefs_->SetExtensionState(extension->id(), Extension::DISABLED);
2159 extension_prefs_->SetDidExtensionEscalatePermissions(extension, true); 2180 extension_prefs_->SetDidExtensionEscalatePermissions(extension, true);
2160 extension_prefs_->AddDisableReason( 2181 extension_prefs_->AddDisableReason(
2161 extension->id(), 2182 extension->id(),
2162 static_cast<Extension::DisableReason>(disable_reasons)); 2183 static_cast<Extension::DisableReason>(disable_reasons));
2163 } 2184 }
2164 } 2185 }
2165 2186
2187 void ExtensionService::MaybeWipeout(
2188 const extensions::Extension* extension) {
2189 if (!FeatureSwitch::sideload_wipeout()->IsEnabled())
2190 return;
2191
2192 bool done = extension_prefs_->GetSideloadWipeoutDone();
2193 if (done)
2194 return;
2195
2196 int disable_reasons = extension_prefs_->GetDisableReasons(extension->id());
2197 if (disable_reasons == Extension::DISABLE_NONE) {
2198 Extension::Location location = extension->location();
2199 if (location == Extension::EXTERNAL_REGISTRY ||
2200 (location == Extension::INTERNAL && !extension->from_webstore())) {
2201 extension_prefs_->SetExtensionState(extension->id(), Extension::DISABLED);
2202 extension_prefs_->AddDisableReason(
2203 extension->id(),
2204 static_cast<Extension::DisableReason>(
2205 Extension::DISABLE_SIDELOAD_WIPEOUT));
2206 }
2207 }
2208 }
2209
2166 void ExtensionService::UpdateActiveExtensionsInCrashReporter() { 2210 void ExtensionService::UpdateActiveExtensionsInCrashReporter() {
2167 std::set<std::string> extension_ids; 2211 std::set<std::string> extension_ids;
2168 for (ExtensionSet::const_iterator iter = extensions_.begin(); 2212 for (ExtensionSet::const_iterator iter = extensions_.begin();
2169 iter != extensions_.end(); ++iter) { 2213 iter != extensions_.end(); ++iter) {
2170 const Extension* extension = *iter; 2214 const Extension* extension = *iter;
2171 if (!extension->is_theme() && extension->location() != Extension::COMPONENT) 2215 if (!extension->is_theme() && extension->location() != Extension::COMPONENT)
2172 extension_ids.insert(extension->id()); 2216 extension_ids.insert(extension->id());
2173 } 2217 }
2174 2218
2175 child_process_logging::SetActiveExtensions(extension_ids); 2219 child_process_logging::SetActiveExtensions(extension_ids);
(...skipping 567 matching lines...) Expand 10 before | Expand all | Expand 10 after
2743 // enabling them. 2787 // enabling them.
2744 if (Extension::IsExternalLocation(extension->location()) && 2788 if (Extension::IsExternalLocation(extension->location()) &&
2745 !extension_prefs_->IsExternalExtensionAcknowledged(extension->id())) { 2789 !extension_prefs_->IsExternalExtensionAcknowledged(extension->id())) {
2746 return false; 2790 return false;
2747 } 2791 }
2748 } 2792 }
2749 #endif 2793 #endif
2750 2794
2751 return true; 2795 return true;
2752 } 2796 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_service.h ('k') | chrome/browser/resources/extensions/extension_list.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698