Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 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/ui/app_list/extension_uninstaller.h" | 5 #include "chrome/browser/ui/app_list/extension_uninstaller.h" |
| 6 | 6 |
| 7 #include "chrome/browser/extensions/extension_service.h" | 7 #include "chrome/browser/extensions/extension_service.h" |
| 8 #include "chrome/browser/profiles/profile.h" | 8 #include "chrome/browser/profiles/profile.h" |
| 9 #include "chrome/browser/ui/app_list/app_list_controller_delegate.h" | 9 #include "chrome/browser/ui/app_list/app_list_controller_delegate.h" |
| 10 #include "extensions/browser/extension_registry.h" | |
| 10 #include "extensions/browser/extension_system.h" | 11 #include "extensions/browser/extension_system.h" |
| 11 #include "extensions/browser/uninstall_reason.h" | 12 #include "extensions/browser/uninstall_reason.h" |
| 12 #include "extensions/common/extension.h" | 13 #include "extensions/common/extension.h" |
| 13 | 14 |
| 14 ExtensionUninstaller::ExtensionUninstaller( | 15 ExtensionUninstaller::ExtensionUninstaller( |
| 15 Profile* profile, | 16 Profile* profile, |
| 16 const std::string& extension_id, | 17 const std::string& extension_id, |
| 17 AppListControllerDelegate* controller) | 18 AppListControllerDelegate* controller) |
| 18 : profile_(profile), | 19 : profile_(profile), |
| 19 app_id_(extension_id), | 20 app_id_(extension_id), |
| 20 controller_(controller) { | 21 controller_(controller) { |
| 21 } | 22 } |
| 22 | 23 |
| 23 ExtensionUninstaller::~ExtensionUninstaller() { | 24 ExtensionUninstaller::~ExtensionUninstaller() { |
| 24 } | 25 } |
| 25 | 26 |
| 26 void ExtensionUninstaller::Run() { | 27 void ExtensionUninstaller::Run() { |
| 27 const extensions::Extension* extension = | 28 const extensions::Extension* extension = |
| 28 extensions::ExtensionSystem::Get(profile_)->extension_service()-> | 29 extensions::ExtensionRegistry::Get(profile_)->GetExtensionById( |
| 29 GetInstalledExtension(app_id_); | 30 app_id_, |
| 31 extensions::ExtensionRegistry::EVERYTHING); | |
| 30 if (!extension) { | 32 if (!extension) { |
| 31 CleanUp(); | 33 CleanUp(); |
| 32 return; | 34 return; |
| 33 } | 35 } |
| 34 controller_->OnShowChildDialog(); | 36 controller_->OnShowChildDialog(); |
| 35 dialog_.reset(extensions::ExtensionUninstallDialog::Create( | 37 dialog_.reset(extensions::ExtensionUninstallDialog::Create( |
| 36 profile_, controller_->GetAppListWindow(), this)); | 38 profile_, controller_->GetAppListWindow(), this)); |
| 37 dialog_->ConfirmUninstall(extension); | 39 dialog_->ConfirmUninstall(extension); |
| 38 } | 40 } |
| 39 | 41 |
| 40 void ExtensionUninstaller::ExtensionUninstallAccepted() { | 42 void ExtensionUninstaller::ExtensionUninstallAccepted() { |
| 41 ExtensionService* service = | |
| 42 extensions::ExtensionSystem::Get(profile_)->extension_service(); | |
| 43 const extensions::Extension* extension = | 43 const extensions::Extension* extension = |
| 44 service->GetInstalledExtension(app_id_); | 44 extensions::ExtensionRegistry::Get(profile_)->GetExtensionById( |
| 45 app_id_, | |
| 46 extensions::ExtensionRegistry::EVERYTHING); | |
| 45 if (extension) { | 47 if (extension) { |
| 48 ExtensionService* service = | |
| 49 extensions::ExtensionSystem::Get(profile_)->extension_service(); | |
|
stevenjb
2015/05/26 21:26:25
Same comment; we shouldn't have to check Extension
babu
2015/06/04 14:48:11
Code has changed and this change is no longer need
| |
| 46 service->UninstallExtension(app_id_, | 50 service->UninstallExtension(app_id_, |
| 47 extensions::UNINSTALL_REASON_USER_INITIATED, | 51 extensions::UNINSTALL_REASON_USER_INITIATED, |
| 48 base::Bind(&base::DoNothing), | 52 base::Bind(&base::DoNothing), |
| 49 NULL); | 53 NULL); |
| 50 } | 54 } |
| 51 controller_->OnCloseChildDialog(); | 55 controller_->OnCloseChildDialog(); |
| 52 CleanUp(); | 56 CleanUp(); |
| 53 } | 57 } |
| 54 | 58 |
| 55 void ExtensionUninstaller::ExtensionUninstallCanceled() { | 59 void ExtensionUninstaller::ExtensionUninstallCanceled() { |
| 56 controller_->OnCloseChildDialog(); | 60 controller_->OnCloseChildDialog(); |
| 57 CleanUp(); | 61 CleanUp(); |
| 58 } | 62 } |
| 59 | 63 |
| 60 void ExtensionUninstaller::CleanUp() { | 64 void ExtensionUninstaller::CleanUp() { |
| 61 delete this; | 65 delete this; |
| 62 } | 66 } |
| OLD | NEW |