Chromium Code Reviews| Index: chrome/renderer/resources/extensions/declarative_content_custom_bindings.js |
| diff --git a/chrome/renderer/resources/extensions/declarative_content_custom_bindings.js b/chrome/renderer/resources/extensions/declarative_content_custom_bindings.js |
| index beb5409e7baab66667f49f3452b5615f13bb8f99..7e06fc66606ef947e47fdeb2d3cf6aaf39126d3d 100644 |
| --- a/chrome/renderer/resources/extensions/declarative_content_custom_bindings.js |
| +++ b/chrome/renderer/resources/extensions/declarative_content_custom_bindings.js |
| @@ -8,6 +8,8 @@ var binding = require('binding').Binding.create('declarativeContent'); |
| var utils = require('utils'); |
| var validate = require('schemaUtils').validate; |
| +var canonicalizeCompoundSelector = |
| + requireNative('schema_utils').CanonicalizeCompoundSelector; |
| binding.registerCustomHook( function(api) { |
| var declarativeContent = api.compiledApi; |
| @@ -35,9 +37,25 @@ binding.registerCustomHook( function(api) { |
| validate([instance], [schema]); |
| } |
| + function canonicalizeCssSelectors(selectors) { |
|
not at google - send to devlin
2013/08/29 15:20:25
you may also want to validate that selectors is an
Jeffrey Yasskin
2013/08/29 21:46:43
The schema validator gets that. I've added a test.
|
| + for (var i = 0; i < selectors.length; i++) { |
| + var canonicalizedSelector = canonicalizeCompoundSelector(selectors[i]); |
| + if (canonicalizedSelector == '') { |
| + throw new Error( |
| + 'Element of \'css\' array must be a ' + |
| + 'list of valid compound selectors: ' + |
| + selectors[i]); |
| + } |
| + selectors[i] = canonicalizedSelector; |
| + } |
| + } |
| + |
| // Setup all data types for the declarative content API. |
| declarativeContent.PageStateMatcher = function(parameters) { |
| setupInstance(this, parameters, 'PageStateMatcher'); |
| + if ($Object.hasOwnProperty(this, 'css')) { |
| + canonicalizeCssSelectors(this.css); |
| + } |
| }; |
| declarativeContent.ShowPageAction = function(parameters) { |
| setupInstance(this, parameters, 'ShowPageAction'); |