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

Side by Side Diff: chrome/renderer/resources/extensions/binding.js

Issue 305643011: Expose enums to extension bindings. Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 6 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | extensions/common/api/runtime.json » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 logActivity = requireNative('activityLogger'); 8 var logActivity = requireNative('activityLogger');
9 var logging = requireNative('logging'); 9 var logging = requireNative('logging');
10 var process = requireNative('process'); 10 var process = requireNative('process');
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 } 236 }
237 237
238 var mod = {}; 238 var mod = {};
239 239
240 var namespaces = $String.split(schema.namespace, '.'); 240 var namespaces = $String.split(schema.namespace, '.');
241 for (var index = 0, name; name = namespaces[index]; index++) { 241 for (var index = 0, name; name = namespaces[index]; index++) {
242 mod[name] = mod[name] || {}; 242 mod[name] = mod[name] || {};
243 mod = mod[name]; 243 mod = mod[name];
244 } 244 }
245 245
246 // Add types to global schemaValidator, the types we depend on from other
247 // namespaces will be added as needed.
248 if (schema.types) { 246 if (schema.types) {
249 $Array.forEach(schema.types, function(t) { 247 $Array.forEach(schema.types, function(t) {
250 if (!isSchemaNodeSupported(t, platform, manifestVersion)) 248 if (!isSchemaNodeSupported(t, platform, manifestVersion))
251 return; 249 return;
250
251 // Add types to global schemaValidator, the types we depend on from
252 // other namespaces will be added as needed.
252 schemaUtils.schemaValidator.addTypes(t); 253 schemaUtils.schemaValidator.addTypes(t);
254
255 // Generate symbols for enums.
256 var enumValues = t['enum'];
257 if (enumValues) {
258 // Type IDs are qualified with the namespace during compilation,
259 // unfortunately, so remove it here.
260 var namespaceAndId = $String.split(t.id, '.');
261 logging.DCHECK(namespaceAndId.length == 2, t.id);
262 logging.DCHECK(namespaceAndId[0] == schema.namespace, t.id);
263 var id = namespaceAndId[1];
264 mod[id] = {};
265 $Array.forEach(enumValues, function(enumValue) {
266 mod[id][enumValue] = enumValue;
267 });
268 }
253 }, this); 269 }, this);
254 } 270 }
255 271
256 // TODO(cduvall): Take out when all APIs have been converted to features. 272 // TODO(cduvall): Take out when all APIs have been converted to features.
257 // Returns whether access to the content of a schema should be denied, 273 // Returns whether access to the content of a schema should be denied,
258 // based on the presence of "unprivileged" and whether this is an 274 // based on the presence of "unprivileged" and whether this is an
259 // extension process (versus e.g. a content script). 275 // extension process (versus e.g. a content script).
260 function isSchemaAccessAllowed(itemSchema) { 276 function isSchemaAccessAllowed(itemSchema) {
261 return (contextType == 'BLESSED_EXTENSION') || 277 return (contextType == 'BLESSED_EXTENSION') ||
262 schema.unprivileged || 278 schema.unprivileged ||
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
425 availability.message); 441 availability.message);
426 return; 442 return;
427 } 443 }
428 444
429 this.runHooks_(mod); 445 this.runHooks_(mod);
430 return mod; 446 return mod;
431 } 447 }
432 }; 448 };
433 449
434 exports.Binding = Binding; 450 exports.Binding = Binding;
OLDNEW
« no previous file with comments | « no previous file | extensions/common/api/runtime.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698