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

Side by Side 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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/extensions_service.h" 5 #include "chrome/browser/extensions/extensions_service.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/file_util.h" 8 #include "base/file_util.h"
9 #include "base/string_util.h" 9 #include "base/string_util.h"
10 #include "base/values.h" 10 #include "base/values.h"
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 UnloadExtension(extension_id); 213 UnloadExtension(extension_id);
214 } 214 }
215 215
216 void ExtensionsService::EnableExtension(const std::string& extension_id) { 216 void ExtensionsService::EnableExtension(const std::string& extension_id) {
217 Extension* extension = GetExtensionByIdInternal(extension_id, false, true); 217 Extension* extension = GetExtensionByIdInternal(extension_id, false, true);
218 if (!extension) { 218 if (!extension) {
219 NOTREACHED() << "Trying to enable an extension that isn't disabled."; 219 NOTREACHED() << "Trying to enable an extension that isn't disabled.";
220 return; 220 return;
221 } 221 }
222 222
223 // Remember that we enabled it, unless it's temporary.
224 if (extension->location() != Extension::LOAD)
225 extension_prefs_->SetExtensionState(extension, Extension::ENABLED);
226
223 // Move it over to the enabled list. 227 // Move it over to the enabled list.
224 extension_prefs_->SetExtensionState(extension, Extension::ENABLED);
225 extensions_.push_back(extension); 228 extensions_.push_back(extension);
226 ExtensionList::iterator iter = std::find(disabled_extensions_.begin(), 229 ExtensionList::iterator iter = std::find(disabled_extensions_.begin(),
227 disabled_extensions_.end(), 230 disabled_extensions_.end(),
228 extension); 231 extension);
229 disabled_extensions_.erase(iter); 232 disabled_extensions_.erase(iter);
230 233
231 ExtensionDOMUI::RegisterChromeURLOverrides(profile_, 234 ExtensionDOMUI::RegisterChromeURLOverrides(profile_,
232 extension->GetChromeURLOverrides()); 235 extension->GetChromeURLOverrides());
233 236
234 NotificationService::current()->Notify( 237 NotificationService::current()->Notify(
235 NotificationType::EXTENSION_LOADED, 238 NotificationType::EXTENSION_LOADED,
236 Source<ExtensionsService>(this), 239 Source<ExtensionsService>(this),
237 Details<Extension>(extension)); 240 Details<Extension>(extension));
238 } 241 }
239 242
243 void ExtensionsService::DisableExtension(const std::string& extension_id) {
244 Extension* extension = GetExtensionByIdInternal(extension_id, true, false);
245 if (!extension) {
246 NOTREACHED() << "Trying to disable an extension that isn't enabled.";
247 return;
248 }
249
250 // Remember that we disabled it, unless it's temporary.
251 if (extension->location() != Extension::LOAD)
252 extension_prefs_->SetExtensionState(extension, Extension::DISABLED);
253
254 // Move it over to the disabled list.
255 disabled_extensions_.push_back(extension);
256 ExtensionList::iterator iter = std::find(extensions_.begin(),
257 extensions_.end(),
258 extension);
259 extensions_.erase(iter);
260
261 ExtensionDOMUI::UnregisterChromeURLOverrides(profile_,
262 extension->GetChromeURLOverrides());
263
264 NotificationService::current()->Notify(
265 NotificationType::EXTENSION_UNLOADED,
266 Source<ExtensionsService>(this),
267 Details<Extension>(extension));
268 }
269
240 void ExtensionsService::LoadExtension(const FilePath& extension_path) { 270 void ExtensionsService::LoadExtension(const FilePath& extension_path) {
241 backend_loop_->PostTask(FROM_HERE, NewRunnableMethod(backend_.get(), 271 backend_loop_->PostTask(FROM_HERE, NewRunnableMethod(backend_.get(),
242 &ExtensionsServiceBackend::LoadSingleExtension, 272 &ExtensionsServiceBackend::LoadSingleExtension,
243 extension_path, scoped_refptr<ExtensionsService>(this))); 273 extension_path, scoped_refptr<ExtensionsService>(this)));
244 } 274 }
245 275
246 void ExtensionsService::LoadAllExtensions() { 276 void ExtensionsService::LoadAllExtensions() {
247 // Load the previously installed extensions. 277 // Load the previously installed extensions.
248 scoped_ptr<InstalledExtensions> installed( 278 scoped_ptr<InstalledExtensions> installed(
249 new InstalledExtensions(extension_prefs_.get())); 279 new InstalledExtensions(extension_prefs_.get()));
(...skipping 456 matching lines...) Expand 10 before | Expand all | Expand 10 after
706 linked_ptr<ExternalExtensionProvider>(test_provider); 736 linked_ptr<ExternalExtensionProvider>(test_provider);
707 } 737 }
708 738
709 void ExtensionsServiceBackend::OnExternalExtensionFound( 739 void ExtensionsServiceBackend::OnExternalExtensionFound(
710 const std::string& id, const Version* version, const FilePath& path, 740 const std::string& id, const Version* version, const FilePath& path,
711 Extension::Location location) { 741 Extension::Location location) {
712 frontend_loop_->PostTask(FROM_HERE, NewRunnableMethod(frontend_, 742 frontend_loop_->PostTask(FROM_HERE, NewRunnableMethod(frontend_,
713 &ExtensionsService::OnExternalExtensionFound, id, version->GetString(), 743 &ExtensionsService::OnExternalExtensionFound, id, version->GetString(),
714 path, location)); 744 path, location));
715 } 745 }
OLDNEW
« 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