summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/DEPS1
-rw-r--r--chrome/browser/extensions/api/storage/managed_value_store_cache.cc2
-rw-r--r--chrome/browser/policy/DEPS26
-rw-r--r--chrome/browser/policy/cloud/DEPS1
-rw-r--r--chrome/browser/policy/cloud/component_cloud_policy_service_unittest.cc2
-rw-r--r--chrome/browser/policy/policy_domain_descriptor.cc2
-rw-r--r--chrome/browser/policy/policy_domain_descriptor_unittest.cc2
-rw-r--r--chrome/browser/policy/policy_loader_mac.cc2
-rw-r--r--chrome/browser/policy/policy_service_impl_unittest.cc2
-rw-r--r--chrome/browser/ui/webui/policy_ui.cc2
-rw-r--r--chrome/chrome_common.gypi3
-rw-r--r--chrome/chrome_tests_unit.gypi1
-rw-r--r--chrome/common/DEPS1
-rw-r--r--chrome/common/extensions/api/storage/storage_schema_manifest_handler.cc2
-rw-r--r--chrome/common/policy/OWNERS7
-rw-r--r--chrome/common/policy/policy_schema.cc244
-rw-r--r--chrome/common/policy/policy_schema.h69
-rw-r--r--chrome/common/policy/policy_schema_unittest.cc194
18 files changed, 11 insertions, 552 deletions
diff --git a/chrome/browser/DEPS b/chrome/browser/DEPS
index 09f2cd0..6b18145 100644
--- a/chrome/browser/DEPS
+++ b/chrome/browser/DEPS
@@ -12,6 +12,7 @@ include_rules = [
"+components/browser_context_keyed_service",
"+components/nacl/common",
"+components/navigation_interception",
+ "+components/policy",
"+components/user_prefs",
"+components/visitedlink/browser",
"+components/webdata",
diff --git a/chrome/browser/extensions/api/storage/managed_value_store_cache.cc b/chrome/browser/extensions/api/storage/managed_value_store_cache.cc
index 6184cfc..3b3b15b 100644
--- a/chrome/browser/extensions/api/storage/managed_value_store_cache.cc
+++ b/chrome/browser/extensions/api/storage/managed_value_store_cache.cc
@@ -29,7 +29,7 @@
#include "chrome/common/extensions/extension_set.h"
#include "chrome/common/extensions/manifest.h"
#include "chrome/common/extensions/permissions/api_permission.h"
-#include "chrome/common/policy/policy_schema.h"
+#include "components/policy/core/common/policy_schema.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/notification_observer.h"
#include "content/public/browser/notification_registrar.h"
diff --git a/chrome/browser/policy/DEPS b/chrome/browser/policy/DEPS
index 37874c3..b3df281 100644
--- a/chrome/browser/policy/DEPS
+++ b/chrome/browser/policy/DEPS
@@ -74,25 +74,8 @@ specific_include_rules = {
"+chrome/common/pref_names.h",
],
- r"policy_domain_descriptor\.cc": [
- "+chrome/common/policy/policy_schema.h",
- ],
-
- r"policy_domain_descriptor_unittest\.cc": [
- "+chrome/common/policy/policy_schema.h",
- ],
-
- r"policy_loader_mac\.cc": [
- "+chrome/common/policy/policy_schema.h",
- ],
-
- r"policy_loader_win\.cc": [
- "+chrome/common/json_schema/json_schema_constants.h",
- ],
-
r"policy_loader_win_unittest\.cc": [
"+chrome/common/chrome_paths.h",
- "+chrome/common/json_schema/json_schema_constants.h",
],
r"policy_path_parser_win\.cc": [
@@ -100,7 +83,6 @@ specific_include_rules = {
],
r"policy_service_impl_unittest\.cc": [
- "+chrome/common/policy/policy_schema.h",
"+content/public/browser/browser_thread.h",
"+content/public/test/test_browser_thread_bundle.h",
],
@@ -118,14 +100,6 @@ specific_include_rules = {
"+chrome/common/chrome_paths.h",
],
- r"registry_dict_win\.cc": [
- "+chrome/common/json_schema/json_schema_constants.h",
- ],
-
- r"registry_dict_win_unittest\.cc": [
- "+chrome/common/json_schema/json_schema_constants.h",
- ],
-
r"test/local_policy_test_server\.cc": [
"+chrome/common/chrome_paths.h",
],
diff --git a/chrome/browser/policy/cloud/DEPS b/chrome/browser/policy/cloud/DEPS
index 0f3934a..fdfd970 100644
--- a/chrome/browser/policy/cloud/DEPS
+++ b/chrome/browser/policy/cloud/DEPS
@@ -91,7 +91,6 @@ specific_include_rules = {
],
r"component_cloud_policy_service_unittest\.cc": [
- "+chrome/common/policy/policy_schema.h",
"+content/public/browser/browser_thread.h",
"+content/public/test/test_browser_thread.h",
],
diff --git a/chrome/browser/policy/cloud/component_cloud_policy_service_unittest.cc b/chrome/browser/policy/cloud/component_cloud_policy_service_unittest.cc
index 5fb06e3..0d95a7c 100644
--- a/chrome/browser/policy/cloud/component_cloud_policy_service_unittest.cc
+++ b/chrome/browser/policy/cloud/component_cloud_policy_service_unittest.cc
@@ -24,7 +24,7 @@
#include "chrome/browser/policy/policy_types.h"
#include "chrome/browser/policy/proto/cloud/chrome_extension_policy.pb.h"
#include "chrome/browser/policy/proto/cloud/device_management_backend.pb.h"
-#include "chrome/common/policy/policy_schema.h"
+#include "components/policy/core/common/policy_schema.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/test/test_browser_thread.h"
#include "net/url_request/test_url_fetcher_factory.h"
diff --git a/chrome/browser/policy/policy_domain_descriptor.cc b/chrome/browser/policy/policy_domain_descriptor.cc
index 0999062..c841a55 100644
--- a/chrome/browser/policy/policy_domain_descriptor.cc
+++ b/chrome/browser/policy/policy_domain_descriptor.cc
@@ -9,7 +9,7 @@
#include "base/values.h"
#include "chrome/browser/policy/policy_bundle.h"
#include "chrome/browser/policy/policy_map.h"
-#include "chrome/common/policy/policy_schema.h"
+#include "components/policy/core/common/policy_schema.h"
namespace policy {
diff --git a/chrome/browser/policy/policy_domain_descriptor_unittest.cc b/chrome/browser/policy/policy_domain_descriptor_unittest.cc
index 06e103d..9a03f8e 100644
--- a/chrome/browser/policy/policy_domain_descriptor_unittest.cc
+++ b/chrome/browser/policy/policy_domain_descriptor_unittest.cc
@@ -13,7 +13,7 @@
#include "chrome/browser/policy/external_data_manager.h"
#include "chrome/browser/policy/policy_bundle.h"
#include "chrome/browser/policy/policy_map.h"
-#include "chrome/common/policy/policy_schema.h"
+#include "components/policy/core/common/policy_schema.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace policy {
diff --git a/chrome/browser/policy/policy_loader_mac.cc b/chrome/browser/policy/policy_loader_mac.cc
index 407ac99..29774f0 100644
--- a/chrome/browser/policy/policy_loader_mac.cc
+++ b/chrome/browser/policy/policy_loader_mac.cc
@@ -21,7 +21,7 @@
#include "chrome/browser/policy/policy_load_status.h"
#include "chrome/browser/policy/policy_map.h"
#include "chrome/browser/policy/preferences_mac.h"
-#include "chrome/common/policy/policy_schema.h"
+#include "components/policy/core/common/policy_schema.h"
#include "policy/policy_constants.h"
using base::mac::CFCast;
diff --git a/chrome/browser/policy/policy_service_impl_unittest.cc b/chrome/browser/policy/policy_service_impl_unittest.cc
index 364e3c4..dc38412 100644
--- a/chrome/browser/policy/policy_service_impl_unittest.cc
+++ b/chrome/browser/policy/policy_service_impl_unittest.cc
@@ -15,7 +15,7 @@
#include "chrome/browser/policy/mock_configuration_policy_provider.h"
#include "chrome/browser/policy/mock_policy_service.h"
#include "chrome/browser/policy/policy_domain_descriptor.h"
-#include "chrome/common/policy/policy_schema.h"
+#include "components/policy/core/common/policy_schema.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/test/test_browser_thread_bundle.h"
#include "testing/gmock/include/gmock/gmock.h"
diff --git a/chrome/browser/ui/webui/policy_ui.cc b/chrome/browser/ui/webui/policy_ui.cc
index c514db3..83958bf 100644
--- a/chrome/browser/ui/webui/policy_ui.cc
+++ b/chrome/browser/ui/webui/policy_ui.cc
@@ -66,7 +66,7 @@
#include "chrome/common/extensions/extension_manifest_constants.h"
#include "chrome/common/extensions/extension_set.h"
#include "chrome/common/extensions/manifest.h"
-#include "chrome/common/policy/policy_schema.h"
+#include "components/policy/core/common/policy_schema.h"
#endif
namespace em = enterprise_management;
diff --git a/chrome/chrome_common.gypi b/chrome/chrome_common.gypi
index 7062139..bb2ec2f 100644
--- a/chrome/chrome_common.gypi
+++ b/chrome/chrome_common.gypi
@@ -38,6 +38,7 @@
'<(DEPTH)/chrome/chrome_resources.gyp:theme_resources',
'<(DEPTH)/chrome/common_constants.gyp:common_constants',
'<(DEPTH)/components/components.gyp:json_schema',
+ '<(DEPTH)/components/components.gyp:policy_component',
'<(DEPTH)/components/components.gyp:visitedlink_common',
'<(DEPTH)/content/content.gyp:content_common',
'<(DEPTH)/net/net.gyp:net',
@@ -423,8 +424,6 @@
'common/pepper_flash.h',
'common/pepper_permission_util.cc',
'common/pepper_permission_util.h',
- 'common/policy/policy_schema.cc',
- 'common/policy/policy_schema.h',
'common/pref_names_util.cc',
'common/pref_names_util.h',
'common/print_messages.cc',
diff --git a/chrome/chrome_tests_unit.gypi b/chrome/chrome_tests_unit.gypi
index 576fa0c..1cc82a0 100644
--- a/chrome/chrome_tests_unit.gypi
+++ b/chrome/chrome_tests_unit.gypi
@@ -1774,7 +1774,6 @@
'common/net/url_fixer_upper_unittest.cc',
'common/net/x509_certificate_model_unittest.cc',
'common/partial_circular_buffer_unittest.cc',
- 'common/policy/policy_schema_unittest.cc',
'common/pref_names_util_unittest.cc',
'common/service_process_util_unittest.cc',
'common/switch_utils_unittest.cc',
diff --git a/chrome/common/DEPS b/chrome/common/DEPS
index 7101165..18b6bce 100644
--- a/chrome/common/DEPS
+++ b/chrome/common/DEPS
@@ -4,6 +4,7 @@ include_rules = [
"+chromeos", # For chromeos_switches.h
"+components/autofill/core/common",
"+components/nacl/common",
+ "+components/policy/core/common",
"+device/bluetooth", # For BluetoothPermission
"+device/media_transfer_protocol", # For MediaTransferProtocolManager
"+device/usb", # For UsbDevicePermission
diff --git a/chrome/common/extensions/api/storage/storage_schema_manifest_handler.cc b/chrome/common/extensions/api/storage/storage_schema_manifest_handler.cc
index 103b19b..23966d3 100644
--- a/chrome/common/extensions/api/storage/storage_schema_manifest_handler.cc
+++ b/chrome/common/extensions/api/storage/storage_schema_manifest_handler.cc
@@ -17,7 +17,7 @@
#include "chrome/common/extensions/extension_manifest_constants.h"
#include "chrome/common/extensions/manifest.h"
#include "chrome/common/extensions/permissions/api_permission.h"
-#include "chrome/common/policy/policy_schema.h"
+#include "components/policy/core/common/policy_schema.h"
#include "extensions/common/install_warning.h"
using extension_manifest_keys::kStorageManagedSchema;
diff --git a/chrome/common/policy/OWNERS b/chrome/common/policy/OWNERS
deleted file mode 100644
index 317a807..0000000
--- a/chrome/common/policy/OWNERS
+++ /dev/null
@@ -1,7 +0,0 @@
-# This should match chrome/browser/policy/OWNERS
-mnissler@chromium.org
-pastarmovj@chromium.org
-joaodasilva@chromium.org
-bartfab@chromium.org
-atwilson@chromium.org
-pneubeck@chromium.org
diff --git a/chrome/common/policy/policy_schema.cc b/chrome/common/policy/policy_schema.cc
deleted file mode 100644
index a3e2e7e..0000000
--- a/chrome/common/policy/policy_schema.cc
+++ /dev/null
@@ -1,244 +0,0 @@
-// Copyright 2013 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/common/policy/policy_schema.h"
-
-#include "base/compiler_specific.h"
-#include "base/logging.h"
-#include "base/stl_util.h"
-#include "components/json_schema/json_schema_constants.h"
-#include "components/json_schema/json_schema_validator.h"
-
-namespace policy {
-
-namespace {
-
-const char kJSONSchemaVersion[] = "http://json-schema.org/draft-03/schema#";
-
-// Describes the properties of a TYPE_DICTIONARY policy schema.
-class DictionaryPolicySchema : public PolicySchema {
- public:
- static scoped_ptr<PolicySchema> Parse(const base::DictionaryValue& schema,
- std::string* error);
-
- virtual ~DictionaryPolicySchema();
-
- virtual const PolicySchemaMap* GetProperties() const OVERRIDE;
- virtual const PolicySchema* GetSchemaForAdditionalProperties() const OVERRIDE;
-
- private:
- DictionaryPolicySchema();
-
- PolicySchemaMap properties_;
- scoped_ptr<PolicySchema> additional_properties_;
-
- DISALLOW_COPY_AND_ASSIGN(DictionaryPolicySchema);
-};
-
-// Describes the items of a TYPE_LIST policy schema.
-class ListPolicySchema : public PolicySchema {
- public:
- static scoped_ptr<PolicySchema> Parse(const base::DictionaryValue& schema,
- std::string* error);
-
- virtual ~ListPolicySchema();
-
- virtual const PolicySchema* GetSchemaForItems() const OVERRIDE;
-
- private:
- ListPolicySchema();
-
- scoped_ptr<PolicySchema> items_schema_;
-
- DISALLOW_COPY_AND_ASSIGN(ListPolicySchema);
-};
-
-bool SchemaTypeToValueType(const std::string& type_string,
- base::Value::Type* type) {
- // Note: "any" is not an accepted type.
- static const struct {
- const char* schema_type;
- base::Value::Type value_type;
- } kSchemaToValueTypeMap[] = {
- { json_schema_constants::kArray, base::Value::TYPE_LIST },
- { json_schema_constants::kBoolean, base::Value::TYPE_BOOLEAN },
- { json_schema_constants::kInteger, base::Value::TYPE_INTEGER },
- { json_schema_constants::kNull, base::Value::TYPE_NULL },
- { json_schema_constants::kNumber, base::Value::TYPE_DOUBLE },
- { json_schema_constants::kObject, base::Value::TYPE_DICTIONARY },
- { json_schema_constants::kString, base::Value::TYPE_STRING },
- };
- for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kSchemaToValueTypeMap); ++i) {
- if (kSchemaToValueTypeMap[i].schema_type == type_string) {
- *type = kSchemaToValueTypeMap[i].value_type;
- return true;
- }
- }
- return false;
-}
-
-scoped_ptr<PolicySchema> ParseSchema(const base::DictionaryValue& schema,
- std::string* error) {
- std::string type_string;
- if (!schema.GetString(json_schema_constants::kType, &type_string)) {
- *error = "The schema type must be declared.";
- return scoped_ptr<PolicySchema>();
- }
-
- base::Value::Type type = base::Value::TYPE_NULL;
- if (!SchemaTypeToValueType(type_string, &type)) {
- *error = "The \"any\" type can't be used.";
- return scoped_ptr<PolicySchema>();
- }
-
- switch (type) {
- case base::Value::TYPE_DICTIONARY:
- return DictionaryPolicySchema::Parse(schema, error);
- case base::Value::TYPE_LIST:
- return ListPolicySchema::Parse(schema, error);
- default:
- return make_scoped_ptr(new PolicySchema(type));
- }
-}
-
-DictionaryPolicySchema::DictionaryPolicySchema()
- : PolicySchema(base::Value::TYPE_DICTIONARY) {}
-
-DictionaryPolicySchema::~DictionaryPolicySchema() {
- STLDeleteValues(&properties_);
-}
-
-const PolicySchemaMap* DictionaryPolicySchema::GetProperties() const {
- return &properties_;
-}
-
-const PolicySchema*
- DictionaryPolicySchema::GetSchemaForAdditionalProperties() const {
- return additional_properties_.get();
-}
-
-// static
-scoped_ptr<PolicySchema> DictionaryPolicySchema::Parse(
- const base::DictionaryValue& schema,
- std::string* error) {
- scoped_ptr<DictionaryPolicySchema> dict_schema(new DictionaryPolicySchema());
-
- const base::DictionaryValue* dict = NULL;
- const base::DictionaryValue* properties = NULL;
- if (schema.GetDictionary(json_schema_constants::kProperties, &properties)) {
- for (base::DictionaryValue::Iterator it(*properties);
- !it.IsAtEnd(); it.Advance()) {
- // This should have been verified by the JSONSchemaValidator.
- CHECK(it.value().GetAsDictionary(&dict));
- scoped_ptr<PolicySchema> sub_schema = ParseSchema(*dict, error);
- if (!sub_schema)
- return scoped_ptr<PolicySchema>();
- dict_schema->properties_[it.key()] = sub_schema.release();
- }
- }
-
- if (schema.GetDictionary(json_schema_constants::kAdditionalProperties,
- &dict)) {
- scoped_ptr<PolicySchema> sub_schema = ParseSchema(*dict, error);
- if (!sub_schema)
- return scoped_ptr<PolicySchema>();
- dict_schema->additional_properties_ = sub_schema.Pass();
- }
-
- return dict_schema.PassAs<PolicySchema>();
-}
-
-ListPolicySchema::ListPolicySchema()
- : PolicySchema(base::Value::TYPE_LIST) {}
-
-ListPolicySchema::~ListPolicySchema() {}
-
-const PolicySchema* ListPolicySchema::GetSchemaForItems() const {
- return items_schema_.get();
-}
-
-scoped_ptr<PolicySchema> ListPolicySchema::Parse(
- const base::DictionaryValue& schema,
- std::string* error) {
- const base::DictionaryValue* dict = NULL;
- if (!schema.GetDictionary(json_schema_constants::kItems, &dict)) {
- *error = "Arrays must declare a single schema for their items.";
- return scoped_ptr<PolicySchema>();
- }
- scoped_ptr<PolicySchema> items_schema = ParseSchema(*dict, error);
- if (!items_schema)
- return scoped_ptr<PolicySchema>();
-
- scoped_ptr<ListPolicySchema> list_schema(new ListPolicySchema());
- list_schema->items_schema_ = items_schema.Pass();
- return list_schema.PassAs<PolicySchema>();
-}
-
-} // namespace
-
-PolicySchema::PolicySchema(base::Value::Type type)
- : type_(type) {}
-
-PolicySchema::~PolicySchema() {}
-
-const PolicySchemaMap* PolicySchema::GetProperties() const {
- NOTREACHED();
- return NULL;
-}
-
-const PolicySchema* PolicySchema::GetSchemaForAdditionalProperties() const {
- NOTREACHED();
- return NULL;
-}
-
-const PolicySchema* PolicySchema::GetSchemaForProperty(
- const std::string& key) const {
- const PolicySchemaMap* properties = GetProperties();
- PolicySchemaMap::const_iterator it = properties->find(key);
- return it == properties->end() ? GetSchemaForAdditionalProperties()
- : it->second;
-}
-
-const PolicySchema* PolicySchema::GetSchemaForItems() const {
- NOTREACHED();
- return NULL;
-}
-
-// static
-scoped_ptr<PolicySchema> PolicySchema::Parse(const std::string& content,
- std::string* error) {
- // Validate as a generic JSON schema.
- scoped_ptr<base::DictionaryValue> dict =
- JSONSchemaValidator::IsValidSchema(content, error);
- if (!dict)
- return scoped_ptr<PolicySchema>();
-
- // Validate the schema version.
- std::string string_value;
- if (!dict->GetString(json_schema_constants::kSchema, &string_value) ||
- string_value != kJSONSchemaVersion) {
- *error = "Must declare JSON Schema v3 version in \"$schema\".";
- return scoped_ptr<PolicySchema>();
- }
-
- // Validate the main type.
- if (!dict->GetString(json_schema_constants::kType, &string_value) ||
- string_value != json_schema_constants::kObject) {
- *error =
- "The main schema must have a type attribute with \"object\" value.";
- return scoped_ptr<PolicySchema>();
- }
-
- // Checks for invalid attributes at the top-level.
- if (dict->HasKey(json_schema_constants::kAdditionalProperties) ||
- dict->HasKey(json_schema_constants::kPatternProperties)) {
- *error = "\"additionalProperties\" and \"patternProperties\" are not "
- "supported at the main schema.";
- return scoped_ptr<PolicySchema>();
- }
-
- return ParseSchema(*dict, error);
-}
-
-} // namespace policy
diff --git a/chrome/common/policy/policy_schema.h b/chrome/common/policy/policy_schema.h
deleted file mode 100644
index 75db591..0000000
--- a/chrome/common/policy/policy_schema.h
+++ /dev/null
@@ -1,69 +0,0 @@
-// Copyright 2013 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.
-
-#ifndef CHROME_COMMON_POLICY_POLICY_SCHEMA_H_
-#define CHROME_COMMON_POLICY_POLICY_SCHEMA_H_
-
-#include <map>
-#include <string>
-
-#include "base/basictypes.h"
-#include "base/memory/scoped_ptr.h"
-#include "base/values.h"
-
-namespace policy {
-
-class PolicySchema;
-typedef std::map<std::string, PolicySchema*> PolicySchemaMap;
-
-// Maps known policy keys to their expected types, and recursively describes
-// the known keys within dictionary or list types.
-class PolicySchema {
- public:
-
- // Parses |schema| as a JSON v3 schema, and additionally verifies that:
- // - the version is JSON schema v3;
- // - the top-level entry is of type "object";
- // - the top-level object doesn't contain "additionalProperties" nor
- // "patternProperties";
- // - each "property" maps to a schema with one "type";
- // - the type "any" is not used.
- // If all the checks pass then the parsed PolicySchema is returned; otherwise
- // returns NULL.
- static scoped_ptr<PolicySchema> Parse(const std::string& schema,
- std::string* error);
-
- explicit PolicySchema(base::Value::Type type);
- virtual ~PolicySchema();
-
- // Returns the expected type for this policy. At the top-level PolicySchema
- // this is always TYPE_DICTIONARY.
- base::Value::Type type() const { return type_; }
-
- // It is invalid to call these methods when type() is not TYPE_DICTIONARY.
- //
- // GetProperties() returns a map of the known property names to their schemas;
- // the map is never NULL.
- // GetSchemaForAdditionalProperties() returns the schema that should be used
- // for keys not found in the map, and may be NULL.
- // GetSchemaForProperty() is a utility method that combines both, returning
- // the mapped schema if found in GetProperties(), otherwise returning
- // GetSchemaForAdditionalProperties().
- virtual const PolicySchemaMap* GetProperties() const;
- virtual const PolicySchema* GetSchemaForAdditionalProperties() const;
- const PolicySchema* GetSchemaForProperty(const std::string& key) const;
-
- // It is invalid to call this method when type() is not TYPE_LIST.
- // Returns the type of the entries of this "array", which is never NULL.
- virtual const PolicySchema* GetSchemaForItems() const;
-
- private:
- const base::Value::Type type_;
-
- DISALLOW_COPY_AND_ASSIGN(PolicySchema);
-};
-
-} // namespace policy
-
-#endif // CHROME_COMMON_POLICY_POLICY_SCHEMA_H_
diff --git a/chrome/common/policy/policy_schema_unittest.cc b/chrome/common/policy/policy_schema_unittest.cc
deleted file mode 100644
index 9f515a2..0000000
--- a/chrome/common/policy/policy_schema_unittest.cc
+++ /dev/null
@@ -1,194 +0,0 @@
-// Copyright 2013 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/common/policy/policy_schema.h"
-
-#include "testing/gtest/include/gtest/gtest.h"
-
-namespace policy {
-
-namespace {
-
-#define SCHEMA_VERSION "\"$schema\":\"http://json-schema.org/draft-03/schema#\""
-#define OBJECT_TYPE "\"type\":\"object\""
-
-bool ParseFails(const std::string& content) {
- std::string error;
- scoped_ptr<PolicySchema> schema = PolicySchema::Parse(content, &error);
- EXPECT_TRUE(schema || !error.empty());
- return !schema;
-}
-
-} // namespace
-
-TEST(PolicySchemaTest, MinimalSchema) {
- EXPECT_FALSE(ParseFails(
- "{"
- SCHEMA_VERSION ","
- OBJECT_TYPE
- "}"));
-}
-
-TEST(PolicySchemaTest, InvalidSchemas) {
- EXPECT_TRUE(ParseFails(""));
- EXPECT_TRUE(ParseFails("omg"));
- EXPECT_TRUE(ParseFails("\"omg\""));
- EXPECT_TRUE(ParseFails("123"));
- EXPECT_TRUE(ParseFails("[]"));
- EXPECT_TRUE(ParseFails("null"));
- EXPECT_TRUE(ParseFails("{}"));
- EXPECT_TRUE(ParseFails("{" SCHEMA_VERSION "}"));
- EXPECT_TRUE(ParseFails("{" OBJECT_TYPE "}"));
-
- EXPECT_TRUE(ParseFails(
- "{"
- SCHEMA_VERSION ","
- OBJECT_TYPE ","
- "\"additionalProperties\": { \"type\":\"object\" }"
- "}"));
-
- EXPECT_TRUE(ParseFails(
- "{"
- SCHEMA_VERSION ","
- OBJECT_TYPE ","
- "\"patternProperties\": { \"a+b*\": { \"type\": \"object\" } }"
- "}"));
-
- EXPECT_TRUE(ParseFails(
- "{"
- SCHEMA_VERSION ","
- OBJECT_TYPE ","
- "\"properties\": { \"Policy\": { \"type\": \"bogus\" } }"
- "}"));
-
- EXPECT_TRUE(ParseFails(
- "{"
- SCHEMA_VERSION ","
- OBJECT_TYPE ","
- "\"properties\": { \"Policy\": { \"type\": [\"string\", \"number\"] } }"
- "}"));
-
- EXPECT_TRUE(ParseFails(
- "{"
- SCHEMA_VERSION ","
- OBJECT_TYPE ","
- "\"properties\": { \"Policy\": { \"type\": \"any\" } }"
- "}"));
-}
-
-TEST(PolicySchemaTest, ValidSchema) {
- std::string error;
- scoped_ptr<PolicySchema> schema = PolicySchema::Parse(
- "{"
- SCHEMA_VERSION ","
- OBJECT_TYPE ","
- "\"properties\": {"
- " \"Boolean\": { \"type\": \"boolean\" },"
- " \"Integer\": { \"type\": \"integer\" },"
- " \"Null\": { \"type\": \"null\" },"
- " \"Number\": { \"type\": \"number\" },"
- " \"String\": { \"type\": \"string\" },"
- " \"Array\": {"
- " \"type\": \"array\","
- " \"items\": { \"type\": \"string\" }"
- " },"
- " \"ArrayOfObjects\": {"
- " \"type\": \"array\","
- " \"items\": {"
- " \"type\": \"object\","
- " \"properties\": {"
- " \"one\": { \"type\": \"string\" },"
- " \"two\": { \"type\": \"integer\" }"
- " }"
- " }"
- " },"
- " \"ArrayOfArray\": {"
- " \"type\": \"array\","
- " \"items\": {"
- " \"type\": \"array\","
- " \"items\": { \"type\": \"string\" }"
- " }"
- " },"
- " \"Object\": {"
- " \"type\": \"object\","
- " \"properties\": {"
- " \"one\": { \"type\": \"boolean\" },"
- " \"two\": { \"type\": \"integer\" }"
- " },"
- " \"additionalProperties\": { \"type\": \"string\" }"
- " }"
- "}"
- "}", &error);
- ASSERT_TRUE(schema) << error;
-
- ASSERT_EQ(base::Value::TYPE_DICTIONARY, schema->type());
- EXPECT_FALSE(schema->GetSchemaForProperty("invalid"));
-
- const PolicySchema* sub = schema->GetSchemaForProperty("Boolean");
- ASSERT_TRUE(sub);
- EXPECT_EQ(base::Value::TYPE_BOOLEAN, sub->type());
-
- sub = schema->GetSchemaForProperty("Integer");
- ASSERT_TRUE(sub);
- EXPECT_EQ(base::Value::TYPE_INTEGER, sub->type());
-
- sub = schema->GetSchemaForProperty("Null");
- ASSERT_TRUE(sub);
- EXPECT_EQ(base::Value::TYPE_NULL, sub->type());
-
- sub = schema->GetSchemaForProperty("Number");
- ASSERT_TRUE(sub);
- EXPECT_EQ(base::Value::TYPE_DOUBLE, sub->type());
- sub = schema->GetSchemaForProperty("String");
- ASSERT_TRUE(sub);
- EXPECT_EQ(base::Value::TYPE_STRING, sub->type());
-
- sub = schema->GetSchemaForProperty("Array");
- ASSERT_TRUE(sub);
- ASSERT_EQ(base::Value::TYPE_LIST, sub->type());
- sub = sub->GetSchemaForItems();
- ASSERT_TRUE(sub);
- EXPECT_EQ(base::Value::TYPE_STRING, sub->type());
-
- sub = schema->GetSchemaForProperty("ArrayOfObjects");
- ASSERT_TRUE(sub);
- ASSERT_EQ(base::Value::TYPE_LIST, sub->type());
- sub = sub->GetSchemaForItems();
- ASSERT_TRUE(sub);
- EXPECT_EQ(base::Value::TYPE_DICTIONARY, sub->type());
- const PolicySchema* subsub = sub->GetSchemaForProperty("one");
- ASSERT_TRUE(subsub);
- EXPECT_EQ(base::Value::TYPE_STRING, subsub->type());
- subsub = sub->GetSchemaForProperty("two");
- ASSERT_TRUE(subsub);
- EXPECT_EQ(base::Value::TYPE_INTEGER, subsub->type());
- subsub = sub->GetSchemaForProperty("invalid");
- EXPECT_FALSE(subsub);
-
- sub = schema->GetSchemaForProperty("ArrayOfArray");
- ASSERT_TRUE(sub);
- ASSERT_EQ(base::Value::TYPE_LIST, sub->type());
- sub = sub->GetSchemaForItems();
- ASSERT_TRUE(sub);
- ASSERT_EQ(base::Value::TYPE_LIST, sub->type());
- sub = sub->GetSchemaForItems();
- ASSERT_TRUE(sub);
- EXPECT_EQ(base::Value::TYPE_STRING, sub->type());
-
- sub = schema->GetSchemaForProperty("Object");
- ASSERT_TRUE(sub);
- ASSERT_EQ(base::Value::TYPE_DICTIONARY, sub->type());
- subsub = sub->GetSchemaForProperty("one");
- ASSERT_TRUE(subsub);
- EXPECT_EQ(base::Value::TYPE_BOOLEAN, subsub->type());
- subsub = sub->GetSchemaForProperty("two");
- ASSERT_TRUE(subsub);
- EXPECT_EQ(base::Value::TYPE_INTEGER, subsub->type());
- subsub = sub->GetSchemaForProperty("undeclared");
- ASSERT_TRUE(subsub);
- EXPECT_EQ(base::Value::TYPE_STRING, subsub->type());
-}
-
-} // namespace policy
-