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 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 const extensions::Feature* whitelist_feature = | |
| 48 extensions::FeatureProvider::GetBehaviorFeature( | |
| 49 extensions::BehaviorFeature::kSigninScreen); | |
|
emaxx
2016/08/30 13:01:41
Shouldn't kSigninScreenWhitelist be used here?
An
Denis Kuznetsov (DE-MUC)
2016/09/01 17:28:57
Ah, yes.
| |
| 50 | |
| 51 if (!feature) { | |
| 52 LOG(ERROR) << "Feature " << extensions::BehaviorFeature::kSigninScreen | |
| 53 << " is not defined"; | |
| 54 return false; | |
|
emaxx
2016/08/30 13:01:41
The error message should be probably also set here
Denis Kuznetsov (DE-MUC)
2016/09/01 17:28:57
Done.
| |
| 55 } | |
| 56 | |
| 57 if (whitelist_feature && | |
| 58 whitelist_feature->IsIdInWhitelist(extension->id())) { | |
| 59 LOG(ERROR) << "Extension whitelisted : " << extension->id(); | |
|
emaxx
2016/08/30 13:01:42
I guess this shouldn't be an ERROR message.
Denis Kuznetsov (DE-MUC)
2016/09/01 17:28:57
Done.
| |
| 60 return true; | |
| 61 } | |
| 62 | |
| 63 extensions::Feature::Availability availability = | |
| 64 feature->IsAvailableToExtension(extension); | |
| 65 | |
| 66 if (availability.is_available()) { | |
| 67 LOG(ERROR) << "Extension allowed : " << extension->id() << " / " | |
|
emaxx
2016/08/30 13:01:41
And this also looks like logging left from the deb
Denis Kuznetsov (DE-MUC)
2016/09/01 17:28:57
Done.
| |
| 68 << extension->name(); | |
| 69 return true; | |
| 70 } | |
| 71 | |
| 72 // Disallow all other extensions. | |
| 73 if (error) { | |
| 74 *error = | |
| 75 l10n_util::GetStringFUTF16(IDS_EXTENSION_CANT_INSTALL_ON_LOGIN_SCREEN, | |
| 76 base::UTF8ToUTF16(extension->name()), | |
| 77 base::UTF8ToUTF16(extension->id())); | |
| 78 } | |
| 79 | |
| 80 LOG(ERROR) << "Extension disabled : " << extension->id() << " / " | |
| 81 << extension->name() << " because of " << availability.message(); | |
| 82 return false; | |
| 83 } | |
| 84 | |
| 85 } // namespace chromeos | |
| OLD | NEW |