| OLD | NEW |
| (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/strings/string_util.h" |
| 14 #include "base/strings/utf_string_conversions.h" |
| 15 #include "base/values.h" |
| 16 #include "chrome/grit/generated_resources.h" |
| 17 #include "extensions/common/extension.h" |
| 18 #include "extensions/common/features/behavior_feature.h" |
| 19 #include "extensions/common/features/feature.h" |
| 20 #include "extensions/common/features/feature_provider.h" |
| 21 #include "extensions/common/manifest.h" |
| 22 #include "extensions/common/manifest_constants.h" |
| 23 #include "ui/base/l10n/l10n_util.h" |
| 24 |
| 25 namespace chromeos { |
| 26 |
| 27 SigninScreenPolicyProvider::SigninScreenPolicyProvider() {} |
| 28 |
| 29 SigninScreenPolicyProvider::~SigninScreenPolicyProvider() {} |
| 30 |
| 31 std::string SigninScreenPolicyProvider::GetDebugPolicyProviderName() const { |
| 32 #if defined(NDEBUG) |
| 33 NOTREACHED(); |
| 34 return std::string(); |
| 35 #else |
| 36 return "Guard for sign-in screen"; |
| 37 #endif |
| 38 } |
| 39 |
| 40 bool SigninScreenPolicyProvider::UserMayLoad( |
| 41 const extensions::Extension* extension, |
| 42 base::string16* error) const { |
| 43 const extensions::Feature* feature = |
| 44 extensions::FeatureProvider::GetBehaviorFeature( |
| 45 extensions::BehaviorFeature::kSigninScreen); |
| 46 |
| 47 if (feature) { |
| 48 extensions::Feature::Availability availability = |
| 49 feature->IsAvailableToExtension(extension); |
| 50 |
| 51 if (availability.is_available()) { |
| 52 VLOG(0) << "Extension allowed : " << extension->id() << " / " |
| 53 << extension->name(); |
| 54 return true; |
| 55 } |
| 56 VLOG(0) << "Extension disabled : " << extension->id() << " / " |
| 57 << extension->name() << " because of " << availability.message(); |
| 58 } else { |
| 59 VLOG(0) << "Feature " << extensions::BehaviorFeature::kSigninScreen |
| 60 << " is not defined"; |
| 61 } |
| 62 |
| 63 // Disallow all other extensions. |
| 64 if (error) { |
| 65 *error = |
| 66 l10n_util::GetStringFUTF16(IDS_EXTENSION_CANT_INSTALL_ON_LOGIN_SCREEN, |
| 67 base::UTF8ToUTF16(extension->name()), |
| 68 base::UTF8ToUTF16(extension->id())); |
| 69 } |
| 70 return false; |
| 71 } |
| 72 |
| 73 } // namespace chromeos |
| OLD | NEW |