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..5255684f1757ccd7c4d1cf250875980d0d2a2494 |
--- /dev/null |
+++ b/extensions/browser/policy_check.cc |
@@ -0,0 +1,36 @@ |
+// 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, |
+ 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); |
+} |
+ |
+bool PolicyCheck::GetErrorMessage(base::string16* error) const { |
+ if (!error || !error_.size()) |
Devlin
2017/03/08 03:01:45
Why do we want to handle null string16 pointers?
michaelpg
2017/03/09 01:53:30
you're right, that seems pointless, and it's uncle
|
+ return false; |
+ *error = error_; |
+ return true; |
+} |
+ |
+} // namespace extensions |