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

Unified Diff: chrome/browser/extensions/extensions_service.cc

Issue 199018: Add a disable button to the Extension management UI. (Closed)
Patch Set: comments Created 11 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/extensions/extensions_service.h ('k') | chrome/browser/extensions/extensions_ui.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/extensions/extensions_service.cc
diff --git a/chrome/browser/extensions/extensions_service.cc b/chrome/browser/extensions/extensions_service.cc
index 46bce982bd6955c5ecc8a32017d690e2806ba1f6..d7cb20647a6d32c70c3f7946fde674901e583a03 100644
--- a/chrome/browser/extensions/extensions_service.cc
+++ b/chrome/browser/extensions/extensions_service.cc
@@ -220,8 +220,11 @@ void ExtensionsService::EnableExtension(const std::string& extension_id) {
return;
}
+ // Remember that we enabled it, unless it's temporary.
+ if (extension->location() != Extension::LOAD)
+ extension_prefs_->SetExtensionState(extension, Extension::ENABLED);
+
// Move it over to the enabled list.
- extension_prefs_->SetExtensionState(extension, Extension::ENABLED);
extensions_.push_back(extension);
ExtensionList::iterator iter = std::find(disabled_extensions_.begin(),
disabled_extensions_.end(),
@@ -237,6 +240,33 @@ void ExtensionsService::EnableExtension(const std::string& extension_id) {
Details<Extension>(extension));
}
+void ExtensionsService::DisableExtension(const std::string& extension_id) {
+ Extension* extension = GetExtensionByIdInternal(extension_id, true, false);
+ if (!extension) {
+ NOTREACHED() << "Trying to disable an extension that isn't enabled.";
+ return;
+ }
+
+ // Remember that we disabled it, unless it's temporary.
+ if (extension->location() != Extension::LOAD)
+ extension_prefs_->SetExtensionState(extension, Extension::DISABLED);
+
+ // Move it over to the disabled list.
+ disabled_extensions_.push_back(extension);
+ ExtensionList::iterator iter = std::find(extensions_.begin(),
+ extensions_.end(),
+ extension);
+ extensions_.erase(iter);
+
+ ExtensionDOMUI::UnregisterChromeURLOverrides(profile_,
+ extension->GetChromeURLOverrides());
+
+ NotificationService::current()->Notify(
+ NotificationType::EXTENSION_UNLOADED,
+ Source<ExtensionsService>(this),
+ Details<Extension>(extension));
+}
+
void ExtensionsService::LoadExtension(const FilePath& extension_path) {
backend_loop_->PostTask(FROM_HERE, NewRunnableMethod(backend_.get(),
&ExtensionsServiceBackend::LoadSingleExtension,
« no previous file with comments | « chrome/browser/extensions/extensions_service.h ('k') | chrome/browser/extensions/extensions_ui.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698