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

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 optArgs['senderTabId'] = mediaGalleriesNatives.GetSenderTabId();
49 sendRequest(this.name, arguments, this.definition.parameters, optArgs);
50 });
51
44 // addUserSelectedFolder uses a custom callback so that it can instantiate 52 // addUserSelectedFolder uses a custom callback so that it can instantiate
45 // and return an array of file system objects. 53 // and return an array of file system objects.
46 apiFunctions.setCustomCallback('addUserSelectedFolder', 54 apiFunctions.setCustomCallback('addUserSelectedFolder',
47 function(name, request, response) { 55 function(name, request, response) {
48 var fileSystems = []; 56 var fileSystems = [];
49 var selectedFileSystemName = ""; 57 var selectedFileSystemName = "";
50 if (response && 'mediaFileSystems' in response && 58 if (response && 'mediaFileSystems' in response &&
51 'selectedFileSystemIndex' in response) { 59 'selectedFileSystemIndex' in response) {
52 fileSystems = createFileSystemObjectsAndUpdateMetadata( 60 fileSystems = createFileSystemObjectsAndUpdateMetadata(
53 response['mediaFileSystems']); 61 response['mediaFileSystems']);
(...skipping 17 matching lines...) Expand all
71 }); 79 });
72 80
73 apiFunctions.setUpdateArgumentsPostValidate('getMetadata', 81 apiFunctions.setUpdateArgumentsPostValidate('getMetadata',
74 function(mediaFile, options, callback) { 82 function(mediaFile, options, callback) {
75 var blobUuid = blobNatives.GetBlobUuid(mediaFile) 83 var blobUuid = blobNatives.GetBlobUuid(mediaFile)
76 return [blobUuid, options, callback]; 84 return [blobUuid, options, callback];
77 }); 85 });
78 }); 86 });
79 87
80 exports.binding = binding.generate(); 88 exports.binding = binding.generate();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698