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

Unified Diff: chrome/browser/extensions/api/developer_private/developer_private_api.cc

Issue 2801583003: developerPrivate.repair: Skip not-corrupted and policy extensions (Closed)
Patch Set: sync + comments Created 3 years, 8 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
Index: chrome/browser/extensions/api/developer_private/developer_private_api.cc
diff --git a/chrome/browser/extensions/api/developer_private/developer_private_api.cc b/chrome/browser/extensions/api/developer_private/developer_private_api.cc
index f2b455a41118817bc33a49a150372e93107a9182..c7d41cad7f821c6e7de0fbb2db961ff22c8809f5 100644
--- a/chrome/browser/extensions/api/developer_private/developer_private_api.cc
+++ b/chrome/browser/extensions/api/developer_private/developer_private_api.cc
@@ -75,6 +75,7 @@
#include "extensions/common/install_warning.h"
#include "extensions/common/manifest.h"
#include "extensions/common/manifest_handlers/options_page_info.h"
+#include "extensions/common/manifest_url_handlers.h"
#include "extensions/common/permissions/permissions_data.h"
#include "extensions/grit/extensions_browser_resources.h"
#include "storage/browser/fileapi/external_mount_points.h"
@@ -109,6 +110,8 @@ const char kCannotUpdateSupervisedProfileSettingsError[] =
"Cannot change settings for a supervised profile.";
const char kNoOptionsPageForExtensionError[] =
"Extension does not have an options page.";
+const char kCannotRepairNotCorruptedExtension[] =
+ "Cannot repair a not corrupted extension.";
const char kUnpackedAppsFolder[] = "apps_target";
const char kManifestFile[] = "manifest.json";
@@ -1461,6 +1464,19 @@ DeveloperPrivateRepairExtensionFunction::Run() {
if (!extension)
return RespondNow(Error(kNoSuchExtensionError));
+ ExtensionSystem* extension_system = ExtensionSystem::Get(browser_context());
+ if (extension_system->management_policy()->MustRemainEnabled(extension,
+ nullptr)) {
+ int disable_reason = ExtensionPrefs::Get(browser_context())
+ ->GetDisableReasons(extension->id());
+ // Do not let a policy extension that is not corrupted to be
+ // reinstalled/repaired. If we let |reinstaller| continue with the repair,
+ // this would have uninstalled the extension but then we would have failed
+ // to reinstall it for policy check.
+ if ((disable_reason & Extension::DISABLE_CORRUPTED) == 0)
Devlin 2017/04/06 15:12:31 To elaborate on a previous comment, I don't think
lazyboy 2017/04/06 18:06:05 Done.
+ return RespondNow(Error(kCannotRepairNotCorruptedExtension));
+ }
+
content::WebContents* web_contents = GetSenderWebContents();
if (!web_contents)
return RespondNow(Error(kCouldNotFindWebContentsError));

Powered by Google App Engine
This is Rietveld 408576698