Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1378)

Unified Diff: extensions/common/extension_api.cc

Issue 2266113002: [Extensions] Prefix extension apis in the generation step (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: lazyboys Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « extensions/common/extension_api.h ('k') | tools/json_schema_compiler/cpp_bundle_generator.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: extensions/common/extension_api.cc
diff --git a/extensions/common/extension_api.cc b/extensions/common/extension_api.cc
index c5453ea25b03299c8f32a17fc359a7e2bbd55ab0..a8d51723306ae7c0524317b7401505bbd8e93cda 100644
--- a/extensions/common/extension_api.cc
+++ b/extensions/common/extension_api.cc
@@ -112,66 +112,6 @@ base::LazyInstance<Static> g_lazy_instance = LAZY_INSTANCE_INITIALIZER;
// May override |g_lazy_instance| for a test.
ExtensionAPI* g_shared_instance_for_test = NULL;
-// If it exists and does not already specify a namespace, then the value stored
-// with key |key| in |schema| will be updated to |schema_namespace| + "." +
-// |schema[key]|.
-void MaybePrefixFieldWithNamespace(const std::string& schema_namespace,
- base::DictionaryValue* schema,
- const std::string& key) {
- if (!schema->HasKey(key))
- return;
-
- std::string old_id;
- CHECK(schema->GetString(key, &old_id));
- if (old_id.find(".") == std::string::npos)
- schema->SetString(key, schema_namespace + "." + old_id);
-}
-
-// Modify all "$ref" keys anywhere in |schema| to be prefxied by
-// |schema_namespace| if they do not already specify a namespace.
-void PrefixRefsWithNamespace(const std::string& schema_namespace,
- base::Value* value) {
- base::ListValue* list = NULL;
- base::DictionaryValue* dict = NULL;
- if (value->GetAsList(&list)) {
- for (const auto& i : *list) {
- PrefixRefsWithNamespace(schema_namespace, i.get());
- }
- } else if (value->GetAsDictionary(&dict)) {
- MaybePrefixFieldWithNamespace(schema_namespace, dict, "$ref");
- for (base::DictionaryValue::Iterator i(*dict); !i.IsAtEnd(); i.Advance()) {
- base::Value* value = NULL;
- CHECK(dict->GetWithoutPathExpansion(i.key(), &value));
- PrefixRefsWithNamespace(schema_namespace, value);
- }
- }
-}
-
-// Modify all objects in the "types" section of the schema to be prefixed by
-// |schema_namespace| if they do not already specify a namespace.
-void PrefixTypesWithNamespace(const std::string& schema_namespace,
- base::DictionaryValue* schema) {
- if (!schema->HasKey("types"))
- return;
-
- // Add the namespace to all of the types defined in this schema
- base::ListValue *types = NULL;
- CHECK(schema->GetList("types", &types));
- for (size_t i = 0; i < types->GetSize(); ++i) {
- base::DictionaryValue *type = NULL;
- CHECK(types->GetDictionary(i, &type));
- MaybePrefixFieldWithNamespace(schema_namespace, type, "id");
- MaybePrefixFieldWithNamespace(schema_namespace, type, "customBindings");
- }
-}
-
-// Modify the schema so that all types are fully qualified.
-void PrefixWithNamespace(const std::string& schema_namespace,
- base::DictionaryValue* schema) {
- PrefixTypesWithNamespace(schema_namespace, schema);
- PrefixRefsWithNamespace(schema_namespace, schema);
-}
-
} // namespace
// static
@@ -232,7 +172,6 @@ void ExtensionAPI::LoadSchema(const std::string& name,
CHECK(schema);
}
CHECK(schema->GetString("namespace", &schema_namespace));
- PrefixWithNamespace(schema_namespace, schema.get());
schemas_[schema_namespace] = std::move(schema);
}
}
« no previous file with comments | « extensions/common/extension_api.h ('k') | tools/json_schema_compiler/cpp_bundle_generator.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698