Disable view source for Developer Tools.
[chromium-blink-merge.git] / chrome / browser / ui / app_list / extension_uninstaller.cc
blobb8b8b667ad8e0f6e5e2c4ebfe5fa84bfc4466e3f
1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "chrome/browser/ui/app_list/extension_uninstaller.h"
7 #include "chrome/browser/extensions/extension_service.h"
8 #include "chrome/browser/extensions/extension_system.h"
9 #include "chrome/browser/profiles/profile.h"
10 #include "chrome/browser/ui/app_list/app_list_controller_delegate.h"
11 #include "extensions/common/extension.h"
13 ExtensionUninstaller::ExtensionUninstaller(
14 Profile* profile,
15 const std::string& extension_id,
16 AppListControllerDelegate* controller)
17 : profile_(profile),
18 app_id_(extension_id),
19 controller_(controller) {
22 ExtensionUninstaller::~ExtensionUninstaller() {
25 void ExtensionUninstaller::Run() {
26 const extensions::Extension* extension =
27 extensions::ExtensionSystem::Get(profile_)->extension_service()->
28 GetInstalledExtension(app_id_);
29 if (!extension) {
30 CleanUp();
31 return;
33 controller_->OnShowExtensionPrompt();
34 dialog_.reset(ExtensionUninstallDialog::Create(profile_, NULL, this));
35 dialog_->ConfirmUninstall(extension);
38 void ExtensionUninstaller::ExtensionUninstallAccepted() {
39 ExtensionService* service =
40 extensions::ExtensionSystem::Get(profile_)->extension_service();
41 const extensions::Extension* extension =
42 service->GetInstalledExtension(app_id_);
43 if (extension) {
44 service->UninstallExtension(app_id_,
45 false, /* external_uninstall*/
46 NULL);
48 controller_->OnCloseExtensionPrompt();
49 CleanUp();
52 void ExtensionUninstaller::ExtensionUninstallCanceled() {
53 controller_->OnCloseExtensionPrompt();
54 CleanUp();
57 void ExtensionUninstaller::CleanUp() {
58 delete this;