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

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

Issue 145463002: Extensions: Send the tab id to platform apps. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 6 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 binding for the Media Gallery API. 5 // Custom binding for the Media Gallery API.
6 6
7 var binding = require('binding').Binding.create('mediaGalleries'); 7 var binding = require('binding').Binding.create('mediaGalleries');
8 8 var blobNatives = requireNative('blob_natives');
9 var mediaGalleriesNatives = requireNative('mediaGalleries'); 9 var mediaGalleriesNatives = requireNative('mediaGalleries');
10 var blobNatives = requireNative('blob_natives'); 10 var messaging = require('messaging');
11 var sendRequest = require('sendRequest').sendRequest;
11 12
12 var mediaGalleriesMetadata = {}; 13 var mediaGalleriesMetadata = {};
13 14
14 function createFileSystemObjectsAndUpdateMetadata(response) { 15 function createFileSystemObjectsAndUpdateMetadata(response) {
15 var result = null; 16 var result = null;
16 mediaGalleriesMetadata = {}; // Clear any previous metadata. 17 mediaGalleriesMetadata = {}; // Clear any previous metadata.
17 if (response) { 18 if (response) {
18 result = []; 19 result = [];
19 for (var i = 0; i < response.length; i++) { 20 for (var i = 0; i < response.length; i++) {
20 var filesystem = mediaGalleriesNatives.GetMediaFileSystemObject( 21 var filesystem = mediaGalleriesNatives.GetMediaFileSystemObject(
(...skipping 13 matching lines...) Expand all
34 // getMediaFileSystems uses a custom callback so that it can instantiate and 35 // getMediaFileSystems uses a custom callback so that it can instantiate and
35 // return an array of file system objects. 36 // return an array of file system objects.
36 apiFunctions.setCustomCallback('getMediaFileSystems', 37 apiFunctions.setCustomCallback('getMediaFileSystems',
37 function(name, request, response) { 38 function(name, request, response) {
38 var result = createFileSystemObjectsAndUpdateMetadata(response); 39 var result = createFileSystemObjectsAndUpdateMetadata(response);
39 if (request.callback) 40 if (request.callback)
40 request.callback(result); 41 request.callback(result);
41 request.callback = null; 42 request.callback = null;
42 }); 43 });
43 44
45 apiFunctions.setHandleRequest('addUserSelectedFolder',
46 function() {
47 var optArgs = {customCallback: this.customCallback};
48 var senderTabId = messaging.currentTabId();
49 if (senderTabId)
50 optArgs['senderTabId'] = senderTabId;
51 sendRequest(this.name, arguments, this.definition.parameters, optArgs);
52 });
53
44 // addUserSelectedFolder uses a custom callback so that it can instantiate 54 // addUserSelectedFolder uses a custom callback so that it can instantiate
45 // and return an array of file system objects. 55 // and return an array of file system objects.
46 apiFunctions.setCustomCallback('addUserSelectedFolder', 56 apiFunctions.setCustomCallback('addUserSelectedFolder',
47 function(name, request, response) { 57 function(name, request, response) {
48 var fileSystems = []; 58 var fileSystems = [];
49 var selectedFileSystemName = ""; 59 var selectedFileSystemName = "";
50 if (response && 'mediaFileSystems' in response && 60 if (response && 'mediaFileSystems' in response &&
51 'selectedFileSystemIndex' in response) { 61 'selectedFileSystemIndex' in response) {
52 fileSystems = createFileSystemObjectsAndUpdateMetadata( 62 fileSystems = createFileSystemObjectsAndUpdateMetadata(
53 response['mediaFileSystems']); 63 response['mediaFileSystems']);
(...skipping 17 matching lines...) Expand all
71 }); 81 });
72 82
73 apiFunctions.setUpdateArgumentsPostValidate('getMetadata', 83 apiFunctions.setUpdateArgumentsPostValidate('getMetadata',
74 function(mediaFile, options, callback) { 84 function(mediaFile, options, callback) {
75 var blobUuid = blobNatives.GetBlobUuid(mediaFile) 85 var blobUuid = blobNatives.GetBlobUuid(mediaFile)
76 return [blobUuid, options, callback]; 86 return [blobUuid, options, callback];
77 }); 87 });
78 }); 88 });
79 89
80 exports.binding = binding.generate(); 90 exports.binding = binding.generate();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698