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

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

Issue 11571014: Lazy load chrome.* APIs (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: comments/TODOs Created 7 years, 11 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
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 // Custom bindings for the storage API. 5 // Custom bindings for the storage API.
6 6
7 var chromeHidden = requireNative('chrome_hidden').GetChromeHidden(); 7 var bindings = new (require('schema_binding_generator').Bindings)('storage');
8
8 var normalizeArgumentsAndValidate = 9 var normalizeArgumentsAndValidate =
9 require('schemaUtils').normalizeArgumentsAndValidate 10 require('schemaUtils').normalizeArgumentsAndValidate
10 var sendRequest = require('sendRequest').sendRequest; 11 var sendRequest = require('sendRequest').sendRequest;
11 12
12 chromeHidden.registerCustomType('storage.StorageArea', function() { 13 bindings.registerCustomType('storage.StorageArea', function() {
13 function extendSchema(schema) { 14 function extendSchema(schema) {
14 var extendedSchema = schema.slice(); 15 var extendedSchema = schema.slice();
15 extendedSchema.unshift({'type': 'string'}); 16 extendedSchema.unshift({'type': 'string'});
16 return extendedSchema; 17 return extendedSchema;
17 } 18 }
18 19
19 function StorageArea(namespace, schema) { 20 function StorageArea(namespace, schema) {
20 // Binds an API function for a namespace to its browser-side call, e.g. 21 // Binds an API function for a namespace to its browser-side call, e.g.
21 // storage.sync.get('foo') -> (binds to) -> 22 // storage.sync.get('foo') -> (binds to) ->
22 // storage.get('sync', 'foo'). 23 // storage.get('sync', 'foo').
(...skipping 13 matching lines...) Expand all
36 extendSchema(funSchema.definition.parameters), 37 extendSchema(funSchema.definition.parameters),
37 {preserveNullInObjects: true}); 38 {preserveNullInObjects: true});
38 }; 39 };
39 } 40 }
40 var apiFunctions = ['get', 'set', 'remove', 'clear', 'getBytesInUse']; 41 var apiFunctions = ['get', 'set', 'remove', 'clear', 'getBytesInUse'];
41 apiFunctions.forEach(bindApiFunction); 42 apiFunctions.forEach(bindApiFunction);
42 } 43 }
43 44
44 return StorageArea; 45 return StorageArea;
45 }); 46 });
47
48 exports.bindings = bindings.generate();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698