summaryrefslogtreecommitdiffstats
path: root/tools/json_schema_compiler
diff options
context:
space:
mode:
authormitchellwrosen@chromium.org <mitchellwrosen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-07-28 03:59:50 +0000
committermitchellwrosen@chromium.org <mitchellwrosen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-07-28 03:59:50 +0000
commit08c876aaeba4fdecad77e25307f048638a0557da (patch)
tree939cc15cf0b93829fb891c984cb2ba1dfd006e2b /tools/json_schema_compiler
parent0d0c9cc55efb89986cfcb3d9421b71c55b9d4a6c (diff)
downloadchromium_src-08c876aaeba4fdecad77e25307f048638a0557da.zip
chromium_src-08c876aaeba4fdecad77e25307f048638a0557da.tar.gz
chromium_src-08c876aaeba4fdecad77e25307f048638a0557da.tar.bz2
Added ToJson to JSON schema compiler.
Also re-factored the recently landed Debugger api (I believe it's the only API to have compiled events, so far) BUG=138767 Review URL: https://chromiumcodereview.appspot.com/10796114 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@148878 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'tools/json_schema_compiler')
-rw-r--r--tools/json_schema_compiler/cc_generator.py23
-rw-r--r--tools/json_schema_compiler/cpp_type_generator.py2
-rwxr-xr-xtools/json_schema_compiler/cpp_type_generator_test.py183
-rw-r--r--tools/json_schema_compiler/cpp_util.py2
-rw-r--r--tools/json_schema_compiler/h_generator.py7
-rw-r--r--tools/json_schema_compiler/test/content_settings.json221
-rw-r--r--tools/json_schema_compiler/test/objects_unittest.cc6
7 files changed, 350 insertions, 94 deletions
diff --git a/tools/json_schema_compiler/cc_generator.py b/tools/json_schema_compiler/cc_generator.py
index e9318dc..c7465651 100644
--- a/tools/json_schema_compiler/cc_generator.py
+++ b/tools/json_schema_compiler/cc_generator.py
@@ -88,7 +88,7 @@ class CCGenerator(object):
)
for event in self._namespace.events.values():
(c.Concat(self._GenerateCreateCallbackArguments(
- cpp_util.Classname(event.name), event))
+ cpp_util.Classname(event.name), event, generate_to_json=True))
.Append()
)
(c.Concat(self._cpp_type_generator.GetNamespaceEnd())
@@ -689,7 +689,10 @@ class CCGenerator(object):
)
return c
- def _GenerateCreateCallbackArguments(self, function_scope, callback):
+ def _GenerateCreateCallbackArguments(self,
+ function_scope,
+ callback,
+ generate_to_json=False):
"""Generate all functions to create Value parameters for a callback.
E.g for function "Bar", generate Bar::Results::Create
@@ -698,6 +701,7 @@ class CCGenerator(object):
function_scope: the function scope path, e.g. Foo::Bar for the function
Foo::Bar::Baz().
callback: the Function object we are creating callback arguments for.
+ generate_to_json: Generate a ToJson method.
"""
c = Code()
params = callback.params
@@ -724,9 +728,22 @@ class CCGenerator(object):
c.Append('return create_results.Pass();')
c.Eblock('}')
+ if generate_to_json:
+ c.Append()
+ (c.Sblock('std::string %(function_scope)s::'
+ 'ToJson(%(declaration_list)s) {')
+ .Append('scoped_ptr<base::ListValue> create_results = '
+ '%(function_scope)s::Create(%(param_list)s);')
+ .Append('std::string json;')
+ .Append('base::JSONWriter::Write(create_results.get(), &json);')
+ .Append('return json;')
+ )
+ c.Eblock('}')
+
c.Substitute({
'function_scope': function_scope,
- 'declaration_list': ', '.join(declaration_list)
+ 'declaration_list': ', '.join(declaration_list),
+ 'param_list': ', '.join(param.unix_name for param in param_list)
})
return c
diff --git a/tools/json_schema_compiler/cpp_type_generator.py b/tools/json_schema_compiler/cpp_type_generator.py
index 0ccda1a..a305b75 100644
--- a/tools/json_schema_compiler/cpp_type_generator.py
+++ b/tools/json_schema_compiler/cpp_type_generator.py
@@ -222,6 +222,8 @@ class CppTypeGenerator(object):
self._cpp_namespaces[dependency])
for dependency in self._NamespaceTypeDependencies().keys()]):
c.Append('#include "%s"' % header)
+ if self._namespace.events:
+ c.Append('#include "base/json/json_writer.h"')
return c
def _ResolveTypeNamespace(self, ref_type):
diff --git a/tools/json_schema_compiler/cpp_type_generator_test.py b/tools/json_schema_compiler/cpp_type_generator_test.py
index a9408fa..17b501e 100755
--- a/tools/json_schema_compiler/cpp_type_generator_test.py
+++ b/tools/json_schema_compiler/cpp_type_generator_test.py
@@ -13,52 +13,61 @@ class CppTypeGeneratorTest(unittest.TestCase):
self.model = model.Model()
self.forbidden_json = CachedLoad('test/forbidden.json')
self.model.AddNamespace(self.forbidden_json[0],
- 'path/to/forbidden.json')
+ 'path/to/forbidden.json')
self.forbidden = self.model.namespaces.get('forbidden')
self.permissions_json = CachedLoad('test/permissions.json')
self.model.AddNamespace(self.permissions_json[0],
- 'path/to/permissions.json')
+ 'path/to/permissions.json')
self.permissions = self.model.namespaces.get('permissions')
self.windows_json = CachedLoad('test/windows.json')
self.model.AddNamespace(self.windows_json[0],
- 'path/to/window.json')
+ 'path/to/window.json')
self.windows = self.model.namespaces.get('windows')
self.tabs_json = CachedLoad('test/tabs.json')
self.model.AddNamespace(self.tabs_json[0],
- 'path/to/tabs.json')
+ 'path/to/tabs.json')
self.tabs = self.model.namespaces.get('tabs')
self.browser_action_json = CachedLoad('test/browser_action.json')
self.model.AddNamespace(self.browser_action_json[0],
- 'path/to/browser_action.json')
+ 'path/to/browser_action.json')
self.browser_action = self.model.namespaces.get('browserAction')
self.font_settings_json = CachedLoad('test/font_settings.json')
self.model.AddNamespace(self.font_settings_json[0],
- 'path/to/font_settings.json')
+ 'path/to/font_settings.json')
self.font_settings = self.model.namespaces.get('fontSettings')
self.dependency_tester_json = CachedLoad('test/dependency_tester.json')
self.model.AddNamespace(self.dependency_tester_json[0],
- 'path/to/dependency_tester.json')
+ 'path/to/dependency_tester.json')
self.dependency_tester = self.model.namespaces.get('dependencyTester')
+ self.content_settings_json = CachedLoad('test/content_settings.json')
+ self.model.AddNamespace(self.content_settings_json[0],
+ 'path/to/content_settings.json')
+ self.content_settings = self.model.namespaces.get('contentSettings')
def testGenerateIncludesAndForwardDeclarations(self):
manager = CppTypeGenerator('', self.windows, self.windows.unix_name)
manager.AddNamespace(self.tabs, self.tabs.unix_name)
- self.assertEquals('#include "path/to/tabs.h"',
- manager.GenerateIncludes().Render())
- self.assertEquals(
- 'namespace tabs {\n'
- 'struct Tab;\n'
- '}\n'
- 'namespace windows {\n'
- 'struct Window;\n'
- '} // windows',
- manager.GenerateForwardDeclarations().Render())
+ self.assertEquals('#include "path/to/tabs.h"\n'
+ '#include "base/json/json_writer.h"',
+ manager.GenerateIncludes().Render())
+ self.assertEquals('namespace tabs {\n'
+ 'struct Tab;\n'
+ '}\n'
+ 'namespace windows {\n'
+ 'struct Window;\n'
+ '} // windows',
+ manager.GenerateForwardDeclarations().Render())
manager = CppTypeGenerator('', self.permissions, self.permissions.unix_name)
- self.assertEquals('', manager.GenerateIncludes().Render())
+ self.assertEquals('#include "base/json/json_writer.h"',
+ manager.GenerateIncludes().Render())
self.assertEquals('namespace permissions {\n'
'struct Permissions;\n'
'} // permissions',
manager.GenerateForwardDeclarations().Render())
+ manager = CppTypeGenerator('', self.content_settings,
+ self.content_settings.unix_name)
+ self.assertEquals('', manager.GenerateIncludes().Render())
+
def testGenerateIncludesAndForwardDeclarationsMultipleTypes(self):
m = model.Model()
@@ -68,108 +77,109 @@ class CppTypeGeneratorTest(unittest.TestCase):
# Insert 'windows' before 'tabs' in order to test that they are sorted
# properly.
windows = m.AddNamespace(self.windows_json[0],
- 'path/to/windows.json')
+ 'path/to/windows.json')
tabs_namespace = m.AddNamespace(self.tabs_json[0],
- 'path/to/tabs.json')
+ 'path/to/tabs.json')
manager = CppTypeGenerator('', windows, self.windows.unix_name)
manager.AddNamespace(tabs_namespace, self.tabs.unix_name)
- self.assertEquals('#include "path/to/tabs.h"',
- manager.GenerateIncludes().Render())
- self.assertEquals(
- 'namespace tabs {\n'
- 'struct Permissions;\n'
- 'struct Tab;\n'
- '}\n'
- 'namespace windows {\n'
- 'struct Window;\n'
- '} // windows',
- manager.GenerateForwardDeclarations().Render())
+ self.assertEquals('#include "path/to/tabs.h"\n'
+ '#include "base/json/json_writer.h"',
+ manager.GenerateIncludes().Render())
+ self.assertEquals('namespace tabs {\n'
+ 'struct Permissions;\n'
+ 'struct Tab;\n'
+ '}\n'
+ 'namespace windows {\n'
+ 'struct Window;\n'
+ '} // windows',
+ manager.GenerateForwardDeclarations().Render())
def testGenerateIncludesAndForwardDeclarationsDependencies(self):
m = model.Model()
# Insert 'font_settings' before 'browser_action' in order to test that
# CppTypeGenerator sorts them properly.
font_settings_namespace = m.AddNamespace(self.font_settings_json[0],
- 'path/to/font_settings.json')
+ 'path/to/font_settings.json')
browser_action_namespace = m.AddNamespace(self.browser_action_json[0],
- 'path/to/browser_action.json')
+ 'path/to/browser_action.json')
manager = CppTypeGenerator('', self.dependency_tester,
- self.dependency_tester.unix_name)
+ self.dependency_tester.unix_name)
manager.AddNamespace(font_settings_namespace,
- self.font_settings.unix_name)
+ self.font_settings.unix_name)
manager.AddNamespace(browser_action_namespace,
- self.browser_action.unix_name)
+ self.browser_action.unix_name)
self.assertEquals('#include "path/to/browser_action.h"\n'
'#include "path/to/font_settings.h"',
manager.GenerateIncludes().Render())
- self.assertEquals(
- 'namespace browserAction {\n'
- 'typedef std::vector<int> ColorArray;\n'
- '}\n'
- 'namespace fontSettings {\n'
- 'typedef std::string ScriptCode;\n'
- '}\n'
- 'namespace dependency_tester {\n'
- '} // dependency_tester',
- manager.GenerateForwardDeclarations().Render())
+ self.assertEquals('namespace browserAction {\n'
+ 'typedef std::vector<int> ColorArray;\n'
+ '}\n'
+ 'namespace fontSettings {\n'
+ 'typedef std::string ScriptCode;\n'
+ '}\n'
+ 'namespace dependency_tester {\n'
+ '} // dependency_tester',
+ manager.GenerateForwardDeclarations().Render())
def testChoicesEnum(self):
manager = CppTypeGenerator('', self.tabs, self.tabs.unix_name)
prop = self.tabs.functions['move'].params[0]
self.assertEquals('TAB_IDS_ARRAY',
- manager.GetEnumValue(prop, model.PropertyType.ARRAY.name))
- self.assertEquals('TAB_IDS_INTEGER',
+ manager.GetEnumValue(prop, model.PropertyType.ARRAY.name))
+ self.assertEquals(
+ 'TAB_IDS_INTEGER',
manager.GetEnumValue(prop, model.PropertyType.INTEGER.name))
self.assertEquals('TabIdsType',
- manager.GetChoicesEnumType(prop))
+ manager.GetChoicesEnumType(prop))
def testGetTypeSimple(self):
manager = CppTypeGenerator('', self.tabs, self.tabs.unix_name)
- self.assertEquals('int',
- manager.GetType(
- self.tabs.types['tabs.Tab'].properties['id']))
- self.assertEquals('std::string',
- manager.GetType(
- self.tabs.types['tabs.Tab'].properties['status']))
- self.assertEquals('bool',
- manager.GetType(
- self.tabs.types['tabs.Tab'].properties['selected']))
+ self.assertEquals(
+ 'int',
+ manager.GetType(self.tabs.types['tabs.Tab'].properties['id']))
+ self.assertEquals(
+ 'std::string',
+ manager.GetType(self.tabs.types['tabs.Tab'].properties['status']))
+ self.assertEquals(
+ 'bool',
+ manager.GetType(self.tabs.types['tabs.Tab'].properties['selected']))
def testStringAsType(self):
manager = CppTypeGenerator('', self.font_settings,
self.font_settings.unix_name)
- self.assertEquals('std::string',
- manager.GetType(
- self.font_settings.types['fontSettings.ScriptCode']))
+ self.assertEquals(
+ 'std::string',
+ manager.GetType(self.font_settings.types['fontSettings.ScriptCode']))
def testArrayAsType(self):
manager = CppTypeGenerator('', self.browser_action,
self.browser_action.unix_name)
- self.assertEquals('std::vector<int>',
- manager.GetType(
- self.browser_action.types['browserAction.ColorArray']))
+ self.assertEquals(
+ 'std::vector<int>',
+ manager.GetType(self.browser_action.types['browserAction.ColorArray']))
def testGetTypeArray(self):
manager = CppTypeGenerator('', self.windows, self.windows.unix_name)
- self.assertEquals('std::vector<linked_ptr<Window> >',
- manager.GetType(
- self.windows.functions['getAll'].callback.params[0]))
+ self.assertEquals(
+ 'std::vector<linked_ptr<Window> >',
+ manager.GetType(self.windows.functions['getAll'].callback.params[0]))
manager = CppTypeGenerator('', self.permissions, self.permissions.unix_name)
self.assertEquals('std::vector<std::string>', manager.GetType(
self.permissions.types['permissions.Permissions'].properties['origins']))
def testGetTypeLocalRef(self):
manager = CppTypeGenerator('', self.tabs, self.tabs.unix_name)
- self.assertEquals('Tab',
- manager.GetType(
- self.tabs.functions['get'].callback.params[0]))
+ self.assertEquals(
+ 'Tab',
+ manager.GetType(self.tabs.functions['get'].callback.params[0]))
def testGetTypeIncludedRef(self):
manager = CppTypeGenerator('', self.windows, self.windows.unix_name)
manager.AddNamespace(self.tabs, self.tabs.unix_name)
- self.assertEquals('std::vector<linked_ptr<tabs::Tab> >',
+ self.assertEquals(
+ 'std::vector<linked_ptr<tabs::Tab> >',
manager.GetType(
- self.windows.types['windows.Window'].properties['tabs']))
+ self.windows.types['windows.Window'].properties['tabs']))
def testGetTypeNotfound(self):
prop = self.windows.types['windows.Window'].properties['tabs'].item_type
@@ -191,32 +201,29 @@ class CppTypeGeneratorTest(unittest.TestCase):
pad_for_generics=True))
self.assertEquals('bool',
manager.GetType(
- self.permissions.functions['contains'].callback.params[0],
+ self.permissions.functions['contains'].callback.params[0],
pad_for_generics=True))
def testNamespaceDeclaration(self):
manager = CppTypeGenerator('extensions', self.permissions,
self.permissions.unix_name)
- self.assertEquals(
- 'namespace extensions {',
- manager.GetRootNamespaceStart().Render())
+ self.assertEquals('namespace extensions {',
+ manager.GetRootNamespaceStart().Render())
manager = CppTypeGenerator('extensions::gen::api', self.permissions,
self.permissions.unix_name)
self.assertEquals('namespace permissions {',
- manager.GetNamespaceStart().Render())
+ manager.GetNamespaceStart().Render())
self.assertEquals('} // permissions',
- manager.GetNamespaceEnd().Render())
- self.assertEquals(
- 'namespace extensions {\n'
- 'namespace gen {\n'
- 'namespace api {',
- manager.GetRootNamespaceStart().Render())
- self.assertEquals(
- '} // api\n'
- '} // gen\n'
- '} // extensions',
- manager.GetRootNamespaceEnd().Render())
+ manager.GetNamespaceEnd().Render())
+ self.assertEquals('namespace extensions {\n'
+ 'namespace gen {\n'
+ 'namespace api {',
+ manager.GetRootNamespaceStart().Render())
+ self.assertEquals('} // api\n'
+ '} // gen\n'
+ '} // extensions',
+ manager.GetRootNamespaceEnd().Render())
def testExpandParams(self):
manager = CppTypeGenerator('extensions', self.tabs,
diff --git a/tools/json_schema_compiler/cpp_util.py b/tools/json_schema_compiler/cpp_util.py
index fd13235..1229fb8 100644
--- a/tools/json_schema_compiler/cpp_util.py
+++ b/tools/json_schema_compiler/cpp_util.py
@@ -65,7 +65,7 @@ def GetParameterDeclaration(param, type_):
type.
"""
if param.type_ in (PropertyType.REF, PropertyType.OBJECT, PropertyType.ARRAY,
- PropertyType.STRING):
+ PropertyType.STRING, PropertyType.ANY):
arg = '%(type)s& %(name)s'
else:
arg = '%(type)s %(name)s'
diff --git a/tools/json_schema_compiler/h_generator.py b/tools/json_schema_compiler/h_generator.py
index 4cc0e6f..03879ca 100644
--- a/tools/json_schema_compiler/h_generator.py
+++ b/tools/json_schema_compiler/h_generator.py
@@ -230,7 +230,8 @@ class HGenerator(object):
"""
c = Code()
(c.Sblock('namespace %s {' % cpp_util.Classname(event.name))
- .Concat(self._GenerateCreateCallbackArguments(event))
+ .Concat(self._GenerateCreateCallbackArguments(event,
+ generate_to_json=True))
.Eblock('};')
)
return c
@@ -324,7 +325,7 @@ class HGenerator(object):
cpp_util.Classname(prop.name)))
return c
- def _GenerateCreateCallbackArguments(self, function):
+ def _GenerateCreateCallbackArguments(self, function, generate_to_json=False):
"""Generates functions for passing paramaters to a callback.
"""
c = Code()
@@ -341,6 +342,8 @@ class HGenerator(object):
param, self._cpp_type_generator.GetType(param)))
c.Append('scoped_ptr<base::ListValue> Create(%s);' %
', '.join(declaration_list))
+ if generate_to_json:
+ c.Append('std::string ToJson(%s);' % ', '.join(declaration_list))
return c
def _GenerateFunctionResults(self, callback):
diff --git a/tools/json_schema_compiler/test/content_settings.json b/tools/json_schema_compiler/test/content_settings.json
new file mode 100644
index 0000000..2d6e803
--- /dev/null
+++ b/tools/json_schema_compiler/test/content_settings.json
@@ -0,0 +1,221 @@
+// 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.
+
+[
+ {
+ "namespace": "contentSettings",
+ "types": [
+ {
+ "id": "ResourceIdentifier",
+ "type": "object",
+ "properties": {
+ "id": {
+ "type": "string",
+ "description": "The resource identifier for the given content type."
+ },
+ "description": {
+ "type": "string",
+ "optional": true,
+ "description": "A human readable description of the resource."
+ }
+ },
+ "description": "The only content type using resource identifiers is <a href=\"contentSettings.html#property-plugins\"><var>plugins</var></a>. For more information, see <a href=\"contentSettings.html#resource-identifiers\">Resource Identifiers</a>."
+ },
+ {
+ "id": "ContentSetting",
+ "type": "object",
+ "functions": [
+ {
+ "name": "clear",
+ "type": "function",
+ "description": "Clear all content setting rules set by this extension.",
+ "parameters": [
+ {
+ "name": "details",
+ "type": "object",
+ "properties": {
+ "scope": {
+ "type": "string",
+ "enum": ["regular", "incognito_session_only"],
+ "optional": true,
+ "description": "Where to set the setting (default: regular). One of<br><var>regular</var>: setting for regular profile (which is inherited by the incognito profile if not overridden elsewhere),<br><var>incognito_session_only</var>: setting for incognito profile that can only be set during an incognito session and is deleted when the incognito session ends (overrides regular settings)."
+ }
+ }
+ },
+ {
+ "type": "function",
+ "name": "callback",
+ "optional": true,
+ "parameters": []
+ }
+ ]
+ },
+ {
+ "name": "get",
+ "type": "function",
+ "description": "Gets the current content setting for a given pair of URLs.",
+ "parameters": [
+ {
+ "name": "details",
+ "type": "object",
+ "properties": {
+ "primaryUrl": {
+ "type": "string",
+ "description": "The primary URL for which the content setting should be retrieved. Note that the meaning of a primary URL depends on the content type."
+ },
+ "secondaryUrl": {
+ "type": "string",
+ "description": "The secondary URL for which the content setting should be retrieved. Defaults to the primary URL. Note that the meaning of a secondary URL depends on the content type, and not all content types use secondary URLs.",
+ "optional": true
+ },
+ "resourceIdentifier": {
+ "$ref": "ResourceIdentifier",
+ "optional": true,
+ "description": "A more specific identifier of the type of content for which the settings should be retrieved."
+ },
+ "incognito": {
+ "type": "boolean",
+ "optional": true,
+ "description": "Whether to check the content settings for an incognito session. (default false)"
+ }
+ }
+ },
+ {
+ "type": "function",
+ "name": "callback",
+ "parameters": [
+ {
+ "name": "details",
+ "type": "object",
+ "properties": {
+ "setting": {
+ "type": "any",
+ "description": "The content setting. See the description of the individual ContentSetting objects for the possible values."
+ }
+ }
+ }
+ ]
+ }
+ ]
+ },
+ {
+ "name": "set",
+ "type": "function",
+ "description": "Applies a new content setting rule.",
+ "parameters": [
+ {
+ "name": "details",
+ "type": "object",
+ "properties": {
+ "primaryPattern": {
+ "type": "string",
+ "description": "The pattern for the primary URL. For details on the format of a pattern, see <a href='contentSettings.html#patterns'>Content Setting Patterns</a>."
+ },
+ "secondaryPattern": {
+ "type": "string",
+ "description": "The pattern for the secondary URL. Defaults to matching all URLs. For details on the format of a pattern, see <a href='contentSettings.html#patterns'>Content Setting Patterns</a>.",
+ "optional": true
+ },
+ "resourceIdentifier": {
+ "$ref": "ResourceIdentifier",
+ "optional": true,
+ "description": "The resource identifier for the content type."
+ },
+ "setting": {
+ "type": "any",
+ "description": "The setting applied by this rule. See the description of the individual ContentSetting objects for the possible values."
+ },
+ "scope": {
+ "type": "string",
+ "enum": ["regular", "incognito_session_only"],
+ "optional": true,
+ "description": "Where to clear the setting (default: regular). One of<br><var>regular</var>: setting for regular profile (which is inherited by the incognito profile if not overridden elsewhere),<br><var>incognito_session_only</var>: setting for incognito profile that can only be set during an incognito session and is deleted when the incognito session ends (overrides regular settings)."
+ }
+ }
+ },
+ {
+ "type": "function",
+ "name": "callback",
+ "optional": true,
+ "parameters": []
+ }
+ ]
+ },
+ {
+ "name": "getResourceIdentifiers",
+ "type": "function",
+ "description": "",
+ "parameters": [
+ {
+ "name": "callback",
+ "type": "function",
+ "parameters": [
+ {
+ "name": "resourceIdentifiers",
+ "type": "array",
+ "description": "A list of resource identifiers for this content type, or <var>undefined</var> if this content type does not use resource identifiers.",
+ "optional": true,
+ "items": {
+ "$ref": "ResourceIdentifier"
+ }
+ }
+ ]
+ }
+ ]
+ }
+ ]
+ }
+ ],
+ "properties": {
+ "cookies": {
+ "$ref": "ContentSetting",
+ "description": "Whether to allow cookies and other local data to be set by websites. One of<br><var>allow</var>: Accept cookies,<br><var>block</var>: Block cookies,<br><var>session_only</var>: Accept cookies only for the current session. <br>Default is <var>allow</var>.<br>The primary URL is the URL representing the cookie origin. The secondary URL is the URL of the top-level frame.",
+ "value": [
+ "cookies",
+ {"type":"string", "enum": ["allow", "block", "session_only"]}
+ ]
+ },
+ "images": {
+ "$ref": "ContentSetting",
+ "description": "Whether to show images. One of<br><var>allow</var>: Show images,<br><var>block</var>: Don't show images. <br>Default is <var>allow</var>.<br>The primary URL is the main-frame URL. The secondary URL is the URL of the image.",
+ "value": [
+ "images",
+ {"type":"string", "enum": ["allow", "block"]}
+ ]
+ },
+ "javascript": {
+ "$ref": "ContentSetting",
+ "description": "Whether to run JavaScript. One of<br><var>allow</var>: Run JavaScript,<br><var>block</var>: Don't run JavaScript. <br>Default is <var>allow</var>.<br>The primary URL is the main-frame URL. The secondary URL is not used.",
+ "value": [
+ "javascript",
+ {"type":"string", "enum": ["allow", "block"]}
+ ]
+ },
+ "plugins": {
+ "$ref": "ContentSetting",
+ "description": "Whether to run plug-ins. One of<br><var>allow</var>: Run plug-ins automatically,<br><var>block</var>: Don't run plug-ins automatically. <br>Default is <var>allow</var>.<br>The primary URL is the main-frame URL. The secondary URL is not used.",
+ "value": [
+ "plugins",
+ {"type":"string", "enum": ["allow", "block"]}
+ ]
+ },
+ "popups": {
+ "$ref": "ContentSetting",
+ "description": "Whether to allow sites to show pop-ups. One of<br><var>allow</var>: Allow sites to show pop-ups,<br><var>block</var>: Don't allow sites to show pop-ups. <br>Default is <var>block</var>.<br>The primary URL is the main-frame URL. The secondary URL is not used.",
+ "value": [
+ "popups",
+ {"type":"string", "enum": ["allow", "block"]}
+ ]
+ },
+ "notifications": {
+ "$ref": "ContentSetting",
+ "description": "Whether to allow sites to show desktop notifications. One of<br><var>allow</var>: Allow sites to show desktop notifications,<br><var>block</var>: Don't allow sites to show desktop notifications,<br><var>ask</var>: Ask when a site wants to show desktop notifications. <br>Default is <var>ask</var>.<br>The primary URL is the main-frame URL. The secondary URL is not used.",
+ "value": [
+ "notifications",
+ {"type":"string", "enum": ["allow", "block", "ask"]}
+ ]
+ }
+ }
+ }
+]
diff --git a/tools/json_schema_compiler/test/objects_unittest.cc b/tools/json_schema_compiler/test/objects_unittest.cc
index 95c3f0d..3582f4f 100644
--- a/tools/json_schema_compiler/test/objects_unittest.cc
+++ b/tools/json_schema_compiler/test/objects_unittest.cc
@@ -4,6 +4,7 @@
#include "tools/json_schema_compiler/test/objects.h"
+#include "base/json/json_writer.h"
#include "testing/gtest/include/gtest/gtest.h"
using namespace test::api::objects;
@@ -67,4 +68,9 @@ TEST(JsonSchemaCompilerObjectsTest, OnObjectFiredCreate) {
DictionaryValue* result = NULL;
ASSERT_TRUE(results->GetDictionary(0, &result));
ASSERT_TRUE(result->Equals(&expected));
+
+ std::string json1 = OnObjectFired::ToJson(object);
+ std::string json2;
+ base::JSONWriter::Write(results.get(), &json2);
+ ASSERT_EQ(json1, json2);
}