OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 var Event = require('event_bindings').Event; | 5 var Event = require('event_bindings').Event; |
6 var forEach = require('utils').forEach; | 6 var forEach = require('utils').forEach; |
7 var GetAvailability = requireNative('v8_context').GetAvailability; | 7 var GetAvailability = requireNative('v8_context').GetAvailability; |
8 var exceptionHandler = require('uncaught_exception_handler'); | 8 var exceptionHandler = require('uncaught_exception_handler'); |
9 var lastError = require('lastError'); | 9 var lastError = require('lastError'); |
10 var logActivity = requireNative('activityLogger'); | 10 var logActivity = requireNative('activityLogger'); |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
157 | 157 |
158 function isSchemaNodeSupported(schemaNode, platform, manifestVersion) { | 158 function isSchemaNodeSupported(schemaNode, platform, manifestVersion) { |
159 return isPlatformSupported(schemaNode, platform) && | 159 return isPlatformSupported(schemaNode, platform) && |
160 isManifestVersionSupported(schemaNode, manifestVersion); | 160 isManifestVersionSupported(schemaNode, manifestVersion); |
161 } | 161 } |
162 | 162 |
163 function createCustomType(type) { | 163 function createCustomType(type) { |
164 var jsModuleName = type.js_module; | 164 var jsModuleName = type.js_module; |
165 logging.CHECK(jsModuleName, 'Custom type ' + type.id + | 165 logging.CHECK(jsModuleName, 'Custom type ' + type.id + |
166 ' has no "js_module" property.'); | 166 ' has no "js_module" property.'); |
| 167 // This list contains all types that has a js_module property. It is ugly to |
| 168 // hard-code them here, but the number of APIs that use js_module has not |
| 169 // changed since the introduction of js_modules in crbug.com/222156. |
| 170 // This whitelist serves as an extra line of defence to avoid exposing |
| 171 // arbitrary extension modules when the |type| definition is poisoned. |
| 172 var whitelistedModules = [ |
| 173 'ChromeDirectSetting', |
| 174 'ChromeSetting', |
| 175 'ContentSetting', |
| 176 'StorageArea', |
| 177 ]; |
| 178 logging.CHECK($Array.indexOf(whitelistedModules, jsModuleName) !== -1, |
| 179 'Module ' + jsModuleName + ' does not define a custom type.'); |
167 var jsModule = require(jsModuleName); | 180 var jsModule = require(jsModuleName); |
168 logging.CHECK(jsModule, 'No module ' + jsModuleName + ' found for ' + | 181 logging.CHECK(jsModule, 'No module ' + jsModuleName + ' found for ' + |
169 type.id + '.'); | 182 type.id + '.'); |
170 var customType = jsModule[jsModuleName]; | 183 var customType = jsModule[jsModuleName]; |
171 logging.CHECK(customType, jsModuleName + ' must export itself.'); | 184 logging.CHECK(customType, jsModuleName + ' must export itself.'); |
172 customType.prototype = new CustomBindingsObject(); | 185 customType.prototype = new CustomBindingsObject(); |
173 customType.prototype.setSchema(type); | 186 customType.prototype.setSchema(type); |
174 return customType; | 187 return customType; |
175 } | 188 } |
176 | 189 |
(...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
532 availability.message); | 545 availability.message); |
533 return; | 546 return; |
534 } | 547 } |
535 | 548 |
536 this.runHooks_(mod); | 549 this.runHooks_(mod); |
537 return mod; | 550 return mod; |
538 } | 551 } |
539 }; | 552 }; |
540 | 553 |
541 exports.$set('Binding', Binding); | 554 exports.$set('Binding', Binding); |
OLD | NEW |