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

Unified Diff: extensions/browser/policy_check.cc

Issue 2693373003: PreloadCheck class for extension pre-install checks (Closed)
Patch Set: don't break enable_extensions=false Created 3 years, 9 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 | « extensions/browser/policy_check.h ('k') | extensions/browser/policy_check_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: extensions/browser/policy_check.cc
diff --git a/extensions/browser/policy_check.cc b/extensions/browser/policy_check.cc
new file mode 100644
index 0000000000000000000000000000000000000000..f4e427f030a0e8f94dcbebd2250a5a121c833725
--- /dev/null
+++ b/extensions/browser/policy_check.cc
@@ -0,0 +1,33 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "extensions/browser/policy_check.h"
+
+#include "content/public/browser/browser_context.h"
+#include "extensions/browser/extension_system.h"
+#include "extensions/browser/management_policy.h"
+
+namespace extensions {
+
+PolicyCheck::PolicyCheck(content::BrowserContext* context,
+ scoped_refptr<const Extension> extension)
+ : PreloadCheck(extension), context_(context) {}
+
+PolicyCheck::~PolicyCheck() {}
+
+void PolicyCheck::Start(ResultCallback callback) {
+ Errors errors;
+ if (!ExtensionSystem::Get(context_)->management_policy()->UserMayLoad(
+ extension(), &error_)) {
+ DCHECK(!error_.empty());
+ errors.insert(DISALLOWED_BY_POLICY);
+ }
+ std::move(callback).Run(errors);
+}
+
+base::string16 PolicyCheck::GetErrorMessage() const {
+ return error_;
+}
+
+} // namespace extensions
« no previous file with comments | « extensions/browser/policy_check.h ('k') | extensions/browser/policy_check_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698