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

Side by Side Diff: chrome/browser/dom_ui/app_launcher_handler.cc

Issue 3332016: Add a confirmation prompt to app uninstallation on the ntp. (Closed) Base URL: git://codf21.jail/chromium.git
Patch Set: fix layout on Windows, remove some old crap Created 10 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) 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
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 }
OLDNEW
« no previous file with comments | « chrome/browser/dom_ui/app_launcher_handler.h ('k') | chrome/browser/extensions/extension_install_ui.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698