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

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

Issue 9274004: Take the Extension Storage API out of experimental. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 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
(Empty)
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
3 // found in the LICENSE file.
4
5 // Custom bindings for the experimental.storage API.
6
7 (function() {
8
9 native function GetChromeHidden();
10
11 var chromeHidden = GetChromeHidden();
12
13 chromeHidden.registerCustomType('StorageNamespace',
14 function(typesAPI) {
15 var sendRequest = typesAPI.sendRequest;
16
17 function extendSchema(schema) {
18 var extendedSchema = schema.slice();
19 extendedSchema.unshift({'type': 'string'});
20 return extendedSchema;
21 }
22
23 function StorageNamespace(namespace, schema) {
24 // Binds an API function for a namespace to its browser-side call, e.g.
25 // experimental.storage.sync.get('foo') -> (binds to) ->
26 // experimental.storage.get('sync', 'foo').
27 //
28 // TODO(kalman): Put as a method on CustomBindingsObject and re-use (or
29 // even generate) for other APIs that need to do this. Same for other
30 // callers of registerCustomType().
31 function bindApiFunction(functionName) {
32 this[functionName] = function() {
33 var schema = this.parameters[functionName];
34 chromeHidden.validate(arguments, schema);
35 return sendRequest(
36 'experimental.storage.' + functionName,
37 [namespace].concat(Array.prototype.slice.call(arguments)),
38 extendSchema(schema));
39 };
40 }
41 ['get', 'set', 'remove', 'clear'].forEach(bindApiFunction.bind(this));
42 }
43
44 return StorageNamespace;
45 });
46
47 })();
OLDNEW
« no previous file with comments | « chrome/renderer/renderer_resources.grd ('k') | chrome/renderer/resources/extensions/storage_custom_bindings.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698