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

Side by Side Diff: chrome/browser/chromeos/extensions/signin_screen_policy_provider.cc

Issue 2159103006: Add policy provider that would filter extensions/apps allowed on the (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix typo Created 4 years, 1 month 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
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "chrome/browser/chromeos/extensions/signin_screen_policy_provider.h"
6
7 #include <stddef.h>
8
9 #include <cstddef>
10 #include <string>
11
12 #include "base/logging.h"
13 #include "base/memory/ptr_util.h"
14 #include "base/strings/string_util.h"
15 #include "base/strings/utf_string_conversions.h"
16 #include "base/values.h"
17 #include "chrome/grit/generated_resources.h"
18 #include "extensions/common/extension.h"
19 #include "extensions/common/features/behavior_feature.h"
20 #include "extensions/common/features/feature.h"
21 #include "extensions/common/features/feature_provider.h"
22 #include "extensions/common/manifest.h"
23 #include "extensions/common/manifest_constants.h"
24 #include "ui/base/l10n/l10n_util.h"
25
26 namespace chromeos {
27
28 namespace {
29 bool g_bypass_checks_for_testing = false;
30 } // namespace
31
32 SigninScreenPolicyProvider::SigninScreenPolicyProvider() {}
33
34 SigninScreenPolicyProvider::~SigninScreenPolicyProvider() {}
35
36 std::string SigninScreenPolicyProvider::GetDebugPolicyProviderName() const {
37 #if defined(NDEBUG)
38 NOTREACHED();
39 return std::string();
40 #else
41 return "Guard for sign-in screen";
42 #endif
43 }
44
45 bool SigninScreenPolicyProvider::UserMayLoad(
46 const extensions::Extension* extension,
47 base::string16* error) const {
48 if (g_bypass_checks_for_testing)
49 return true;
50 const extensions::Feature* feature =
51 extensions::FeatureProvider::GetBehaviorFeature(
52 extensions::BehaviorFeature::kSigninScreen);
53 CHECK(feature);
54 extensions::Feature::Availability availability =
55 feature->IsAvailableToExtension(extension);
56
57 if (availability.is_available())
58 return true;
59
60 LOG(WARNING) << "Denying load of Extension : " << extension->id() << " / "
61 << extension->name() << " because of " << availability.message();
62
63 // Disallow all other extensions.
64 if (error) {
65 *error =
66 l10n_util::GetStringFUTF16(IDS_EXTENSION_CANT_INSTALL_ON_SIGNIN_SCREEN,
67 base::UTF8ToUTF16(extension->name()),
68 base::UTF8ToUTF16(extension->id()));
69 }
70 return false;
71 }
72
73 std::unique_ptr<base::AutoReset<bool>>
74 GetScopedSigninScreenPolicyProviderDisablerForTesting() {
75 return base::MakeUnique<base::AutoReset<bool>>(&g_bypass_checks_for_testing,
76 true);
77 }
78
79 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698