OLD | NEW |
| (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 Media Gallery API. | |
6 | |
7 var mediaGalleriesNatives = requireNative('experimental_mediaGalleries'); | |
8 var CreateMediaGalleryObject = mediaGalleriesNatives.CreateMediaGalleryObject; | |
9 | |
10 var chromeHidden = requireNative('chrome_hidden').GetChromeHidden(); | |
11 | |
12 chromeHidden.registerCustomHook('experimental.mediaGalleries', | |
13 function(bindingsAPI, extensionId) { | |
14 var apiFunctions = bindingsAPI.apiFunctions; | |
15 | |
16 apiFunctions.setCustomCallback('getMediaGalleries', | |
17 function(name, request, response) { | |
18 var result = []; | |
19 var resp = response ? chromeHidden.JSON.parse(response) : []; | |
20 for (var i = 0; i < resp.length; i++) { | |
21 result.push(CreateMediaGalleryObject(resp[i].id, resp[i].name, | |
22 resp[i].flags)); | |
23 | |
24 } | |
25 if (request.callback) | |
26 request.callback(result); | |
27 request.callback = null; | |
28 }); | |
29 }); | |
OLD | NEW |