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

Unified Diff: chrome/browser/extensions/api/management/management_api.cc

Issue 137793011: Require user confirmation for chrome.management.uninstall except when uninstalling self. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix ExtensionManagementApiBrowserTest.LaunchApp Created 6 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/browser/extensions/api/management/management_api_browsertest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/extensions/api/management/management_api.cc
diff --git a/chrome/browser/extensions/api/management/management_api.cc b/chrome/browser/extensions/api/management/management_api.cc
index 6c3489ad6b46fa35fa2ce9048b30207ff25ce41a..3ba118dec395a462c9c9fb32f8721f0201924d60 100644
--- a/chrome/browser/extensions/api/management/management_api.cc
+++ b/chrome/browser/extensions/api/management/management_api.cc
@@ -604,12 +604,21 @@ ManagementUninstallFunction::~ManagementUninstallFunction() {
bool ManagementUninstallFunction::RunImpl() {
scoped_ptr<management::Uninstall::Params> params(
management::Uninstall::Params::Create(*args_));
+ EXTENSION_FUNCTION_VALIDATE(extension_);
EXTENSION_FUNCTION_VALIDATE(params.get());
- bool show_confirm_dialog = false;
- if (params->options.get() && params->options->show_confirm_dialog.get())
- show_confirm_dialog = *params->options->show_confirm_dialog;
-
+ bool show_confirm_dialog = true;
+ // By default confirmation dialog isn't shown when uninstalling self, but this
+ // can be overridden with showConfirmDialog.
+ if (params->id == extension_->id()) {
+ show_confirm_dialog = params->options.get() &&
+ params->options->show_confirm_dialog.get() &&
+ *params->options->show_confirm_dialog;
+ }
+ if (show_confirm_dialog && !user_gesture()) {
+ error_ = keys::kGestureNeededForUninstallError;
+ return false;
+ }
return Uninstall(params->id, show_confirm_dialog);
}
« no previous file with comments | « no previous file | chrome/browser/extensions/api/management/management_api_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698