| Index: chrome/browser/extensions/requirements_provider_impl.cc
|
| diff --git a/chrome/browser/extensions/requirements_provider_impl.cc b/chrome/browser/extensions/requirements_provider_impl.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..869c059f96e5e74a2d53ed66fce39c6b90c21d4b
|
| --- /dev/null
|
| +++ b/chrome/browser/extensions/requirements_provider_impl.cc
|
| @@ -0,0 +1,63 @@
|
| +// Copyright (c) 2012 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 "chrome/browser/extensions/requirements_provider_impl.h"
|
| +
|
| +#include "base/string16.h"
|
| +#include "base/utf_string_conversions.h"
|
| +#include "chrome/common/extensions/extension_manifest_constants.h"
|
| +#include "chrome/common/extensions/manifest.h"
|
| +
|
| +namespace keys = extension_manifest_keys;
|
| +
|
| +namespace extensions {
|
| +
|
| +// static
|
| +RequirementsProvider* RequirementsProvider::Create() {
|
| + return new RequirementsProviderImpl();
|
| +}
|
| +
|
| +RequirementsProviderImpl::RequirementsProviderImpl() {
|
| +}
|
| +
|
| +bool RequirementsProviderImpl::Supports(const Manifest& manifest,
|
| + string16* error) {
|
| + DictionaryValue* requirements_value = NULL;
|
| + manifest.GetDictionary(keys::kRequirements, &requirements_value);
|
| + if (!requirements_value)
|
| + return true;
|
| +
|
| + for (DictionaryValue::key_iterator it = requirements_value->begin_keys();
|
| + it != requirements_value->end_keys(); ++it) {
|
| + DictionaryValue* requirement_value;
|
| + requirements_value->GetDictionaryWithoutPathExpansion(
|
| + *it, &requirement_value);
|
| + if (!requirement_value)
|
| + continue;
|
| +
|
| + if (*it == "plugins") {
|
| +#if defined(OS_CHROMEOS)
|
| + // TODO(eriq): i18n
|
| + *error = ASCIIToUTF16("Plugins are not supported on CHROMEOS");
|
| + return false;
|
| +#endif
|
| + } else if (*it == "foo") {
|
| + ListValue* features;
|
| + requirement_value->GetListWithoutPathExpansion("features", &features);
|
| + if (!features)
|
| + continue;
|
| + std::string feature;
|
| + features->GetString(0, &feature);
|
| + if (feature != "bar") {
|
| + *error = ASCIIToUTF16(
|
| + "Requirement 'foo' only supports the feature 'bar'");
|
| + return false;
|
| + }
|
| + }
|
| + }
|
| +
|
| + return true;
|
| +}
|
| +
|
| +} // namespace extensions
|
|
|