OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/dom_ui/app_launcher_handler.h" | 5 #include "chrome/browser/dom_ui/app_launcher_handler.h" |
6 | 6 |
7 #include "app/animation.h" | 7 #include "app/animation.h" |
8 #include "base/string_number_conversions.h" | 8 #include "base/string_number_conversions.h" |
| 9 #include "base/string_util.h" |
9 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
10 #include "base/values.h" | 11 #include "base/values.h" |
11 #include "chrome/browser/app_launched_animation.h" | 12 #include "chrome/browser/app_launched_animation.h" |
12 #include "chrome/browser/browser.h" | 13 #include "chrome/browser/browser.h" |
13 #include "chrome/browser/browser_list.h" | 14 #include "chrome/browser/browser_list.h" |
14 #include "chrome/browser/extensions/extensions_service.h" | 15 #include "chrome/browser/extensions/extensions_service.h" |
15 #include "chrome/browser/platform_util.h" | 16 #include "chrome/browser/platform_util.h" |
16 #include "chrome/browser/tab_contents/tab_contents.h" | 17 #include "chrome/browser/tab_contents/tab_contents.h" |
17 #include "chrome/common/chrome_switches.h" | 18 #include "chrome/common/chrome_switches.h" |
18 #include "chrome/common/extensions/extension.h" | 19 #include "chrome/common/extensions/extension.h" |
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
190 #if defined(OS_WIN) | 191 #if defined(OS_WIN) |
191 AppLaunchedAnimation::Show(extension, rect); | 192 AppLaunchedAnimation::Show(extension, rect); |
192 #else | 193 #else |
193 NOTIMPLEMENTED(); | 194 NOTIMPLEMENTED(); |
194 #endif | 195 #endif |
195 } | 196 } |
196 } | 197 } |
197 | 198 |
198 void AppLauncherHandler::HandleUninstallApp(const ListValue* args) { | 199 void AppLauncherHandler::HandleUninstallApp(const ListValue* args) { |
199 std::string extension_id = WideToUTF8(ExtractStringValue(args)); | 200 std::string extension_id = WideToUTF8(ExtractStringValue(args)); |
| 201 Extension* extension = extensions_service_->GetExtensionById( |
| 202 extension_id, false); |
| 203 if (!extension) |
| 204 return; |
200 | 205 |
201 // Make sure that the extension exists. | 206 if (!extension_id_prompting_.empty()) |
| 207 return; // Only one prompt at a time. |
| 208 |
| 209 extension_id_prompting_ = extension_id; |
| 210 GetExtensionInstallUI()->ConfirmUninstall(this, extension); |
| 211 } |
| 212 |
| 213 ExtensionInstallUI* AppLauncherHandler::GetExtensionInstallUI() { |
| 214 if (!install_ui_.get()) |
| 215 install_ui_.reset(new ExtensionInstallUI(dom_ui_->GetProfile())); |
| 216 return install_ui_.get(); |
| 217 } |
| 218 |
| 219 void AppLauncherHandler::InstallUIProceed(bool create_app_shortcut) { |
| 220 // We only ever use ExtensionInstallUI for uninstalling, which should never |
| 221 // result in it telling us to create a shortcut. |
| 222 DCHECK(!create_app_shortcut); |
| 223 DCHECK(!extension_id_prompting_.empty()); |
| 224 |
| 225 // The extension can be uninstalled in another window while the UI was |
| 226 // showing. Do nothing in that case. |
202 Extension* extension = | 227 Extension* extension = |
203 extensions_service_->GetExtensionById(extension_id, false); | 228 extensions_service_->GetExtensionById(extension_id_prompting_, true); |
204 DCHECK(extension); | 229 if (!extension) |
| 230 return; |
205 | 231 |
206 extensions_service_->UninstallExtension(extension_id, false); | 232 extensions_service_->UninstallExtension(extension_id_prompting_, |
| 233 false /* external_uninstall */); |
| 234 extension_id_prompting_ = ""; |
207 } | 235 } |
| 236 |
| 237 void AppLauncherHandler::InstallUIAbort() { |
| 238 extension_id_prompting_ = ""; |
| 239 } |
OLD | NEW |