Chromium Code Reviews| 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 namespace { | |
| 28 bool g_bypass_checks_for_testing = false; | |
| 29 } // namespace | |
| 30 | |
| 31 SigninScreenPolicyProvider::SigninScreenPolicyProvider() {} | |
| 32 | |
| 33 SigninScreenPolicyProvider::~SigninScreenPolicyProvider() {} | |
| 34 | |
| 35 std::string SigninScreenPolicyProvider::GetDebugPolicyProviderName() const { | |
| 36 #if defined(NDEBUG) | |
| 37 NOTREACHED(); | |
| 38 return std::string(); | |
| 39 #else | |
| 40 return "Guard for sign-in screen"; | |
| 41 #endif | |
| 42 } | |
| 43 | |
| 44 bool SigninScreenPolicyProvider::UserMayLoad( | |
| 45 const extensions::Extension* extension, | |
| 46 base::string16* error) const { | |
| 47 if (g_bypass_checks_for_testing) | |
| 48 return true; | |
| 49 const extensions::Feature* feature = | |
| 50 extensions::FeatureProvider::GetBehaviorFeature( | |
| 51 extensions::BehaviorFeature::kSigninScreen); | |
| 52 CHECK(feature); | |
| 53 extensions::Feature::Availability availability = | |
| 54 feature->IsAvailableToExtension(extension); | |
| 55 | |
| 56 if (availability.is_available()) | |
| 57 return true; | |
| 58 | |
| 59 LOG(WARNING) << "Denying load of Extension : " << extension->id() << " / " | |
| 60 << extension->name() << " because of " << availability.message(); | |
| 61 | |
| 62 // Disallow all other extensions. | |
| 63 if (error) { | |
| 64 *error = | |
| 65 l10n_util::GetStringFUTF16(IDS_EXTENSION_CANT_INSTALL_ON_SIGNIN_SCREEN, | |
| 66 base::UTF8ToUTF16(extension->name()), | |
| 67 base::UTF8ToUTF16(extension->id())); | |
| 68 } | |
| 69 return false; | |
| 70 } | |
| 71 | |
| 72 ScopedSigninScreenPolicyProviderDisabler:: | |
| 73 ScopedSigninScreenPolicyProviderDisabler() { | |
| 74 original_flag_ = g_bypass_checks_for_testing; | |
|
emaxx
2016/11/11 16:11:37
nit: Transform into member initializer.
Denis Kuznetsov (DE-MUC)
2016/11/11 21:26:33
Acknowledged.
| |
| 75 g_bypass_checks_for_testing = true; | |
| 76 } | |
| 77 | |
| 78 ScopedSigninScreenPolicyProviderDisabler:: | |
| 79 ~ScopedSigninScreenPolicyProviderDisabler() { | |
| 80 g_bypass_checks_for_testing = original_flag_; | |
| 81 } | |
| 82 | |
| 83 } // namespace chromeos | |
| OLD | NEW |