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

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

Issue 1854983002: [Extensions] Add more bindings access checks (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: comment Created 4 years, 8 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
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 fileManagerPrivate API. 5 // Custom binding for the fileManagerPrivate API.
6 6
7 // Bindings 7 // Bindings
8 var binding = require('binding').Binding.create('fileManagerPrivate'); 8 var binding = require('binding').Binding.create('fileManagerPrivate');
9 var eventBindings = require('event_bindings'); 9 var eventBindings = require('event_bindings');
10 10
11 // Natives 11 // Natives
12 var fileManagerPrivateNatives = requireNative('file_manager_private'); 12 var fileManagerPrivateNatives = requireNative('file_manager_private');
13 var fileBrowserHandlerNatives = requireNative('file_browser_handler');
14 13
15 // Internals 14 // Internals
16 var fileManagerPrivateInternal = 15 var fileManagerPrivateInternal =
17 require('binding').Binding.create('fileManagerPrivateInternal').generate(); 16 require('binding').Binding.create('fileManagerPrivateInternal').generate();
18 17
19 // Shorthands 18 // Shorthands
20 var GetFileSystem = fileManagerPrivateNatives.GetFileSystem; 19 var GetFileSystem = fileManagerPrivateNatives.GetFileSystem;
21 var GetExternalFileEntry = fileBrowserHandlerNatives.GetExternalFileEntry; 20 var GetExternalFileEntry = fileManagerPrivateNatives.GetExternalFileEntry;
22 21
23 binding.registerCustomHook(function(bindingsAPI) { 22 binding.registerCustomHook(function(bindingsAPI) {
24 var apiFunctions = bindingsAPI.apiFunctions; 23 var apiFunctions = bindingsAPI.apiFunctions;
25 24
26 apiFunctions.setCustomCallback('searchDrive', 25 apiFunctions.setCustomCallback('searchDrive',
27 function(name, request, callback, response) { 26 function(name, request, callback, response) {
28 if (response && !response.error && response.entries) { 27 if (response && !response.error && response.entries) {
29 response.entries = response.entries.map(function(entry) { 28 response.entries = response.entries.map(function(entry) {
30 return GetExternalFileEntry(entry); 29 return GetExternalFileEntry(entry);
31 }); 30 });
(...skipping 20 matching lines...) Expand all
52 if (!response) 51 if (!response)
53 response = {}; 52 response = {};
54 53
55 if (callback) 54 if (callback)
56 callback(response); 55 callback(response);
57 }); 56 });
58 57
59 apiFunctions.setHandleRequest('resolveIsolatedEntries', 58 apiFunctions.setHandleRequest('resolveIsolatedEntries',
60 function(entries, callback) { 59 function(entries, callback) {
61 var urls = entries.map(function(entry) { 60 var urls = entries.map(function(entry) {
62 return fileBrowserHandlerNatives.GetEntryURL(entry); 61 return fileManagerPrivateNatives.GetEntryURL(entry);
63 }); 62 });
64 fileManagerPrivateInternal.resolveIsolatedEntries(urls, function( 63 fileManagerPrivateInternal.resolveIsolatedEntries(urls, function(
65 entryDescriptions) { 64 entryDescriptions) {
66 callback(entryDescriptions.map(function(description) { 65 callback(entryDescriptions.map(function(description) {
67 return GetExternalFileEntry(description); 66 return GetExternalFileEntry(description);
68 })); 67 }));
69 }); 68 });
70 }); 69 });
71 70
72 apiFunctions.setHandleRequest('getEntryProperties', 71 apiFunctions.setHandleRequest('getEntryProperties',
73 function(entries, names, callback) { 72 function(entries, names, callback) {
74 var urls = entries.map(function(entry) { 73 var urls = entries.map(function(entry) {
75 return fileBrowserHandlerNatives.GetEntryURL(entry); 74 return fileManagerPrivateNatives.GetEntryURL(entry);
76 }); 75 });
77 fileManagerPrivateInternal.getEntryProperties(urls, names, callback); 76 fileManagerPrivateInternal.getEntryProperties(urls, names, callback);
78 }); 77 });
79 78
80 apiFunctions.setHandleRequest('addFileWatch', function(entry, callback) { 79 apiFunctions.setHandleRequest('addFileWatch', function(entry, callback) {
81 var url = fileBrowserHandlerNatives.GetEntryURL(entry); 80 var url = fileManagerPrivateNatives.GetEntryURL(entry);
82 fileManagerPrivateInternal.addFileWatch(url, callback); 81 fileManagerPrivateInternal.addFileWatch(url, callback);
83 }); 82 });
84 83
85 apiFunctions.setHandleRequest('removeFileWatch', function(entry, callback) { 84 apiFunctions.setHandleRequest('removeFileWatch', function(entry, callback) {
86 var url = fileBrowserHandlerNatives.GetEntryURL(entry); 85 var url = fileManagerPrivateNatives.GetEntryURL(entry);
87 fileManagerPrivateInternal.removeFileWatch(url, callback); 86 fileManagerPrivateInternal.removeFileWatch(url, callback);
88 }); 87 });
89 88
90 apiFunctions.setHandleRequest('getCustomActions', function( 89 apiFunctions.setHandleRequest('getCustomActions', function(
91 entries, callback) { 90 entries, callback) {
92 var urls = entries.map(function(entry) { 91 var urls = entries.map(function(entry) {
93 return fileBrowserHandlerNatives.GetEntryURL(entry); 92 return fileManagerPrivateNatives.GetEntryURL(entry);
94 }); 93 });
95 fileManagerPrivateInternal.getCustomActions(urls, callback); 94 fileManagerPrivateInternal.getCustomActions(urls, callback);
96 }); 95 });
97 96
98 apiFunctions.setHandleRequest('executeCustomAction', function( 97 apiFunctions.setHandleRequest('executeCustomAction', function(
99 entries, actionId, callback) { 98 entries, actionId, callback) {
100 var urls = entries.map(function(entry) { 99 var urls = entries.map(function(entry) {
101 return fileBrowserHandlerNatives.GetEntryURL(entry); 100 return fileManagerPrivateNatives.GetEntryURL(entry);
102 }); 101 });
103 fileManagerPrivateInternal.executeCustomAction(urls, actionId, callback); 102 fileManagerPrivateInternal.executeCustomAction(urls, actionId, callback);
104 }); 103 });
105 104
106 apiFunctions.setHandleRequest('computeChecksum', function(entry, callback) { 105 apiFunctions.setHandleRequest('computeChecksum', function(entry, callback) {
107 var url = fileBrowserHandlerNatives.GetEntryURL(entry); 106 var url = fileManagerPrivateNatives.GetEntryURL(entry);
108 fileManagerPrivateInternal.computeChecksum(url, callback); 107 fileManagerPrivateInternal.computeChecksum(url, callback);
109 }); 108 });
110 109
111 apiFunctions.setHandleRequest('getMimeType', function(entry, callback) { 110 apiFunctions.setHandleRequest('getMimeType', function(entry, callback) {
112 var url = fileBrowserHandlerNatives.GetEntryURL(entry); 111 var url = fileManagerPrivateNatives.GetEntryURL(entry);
113 fileManagerPrivateInternal.getMimeType(url, callback); 112 fileManagerPrivateInternal.getMimeType(url, callback);
114 }); 113 });
115 114
116 apiFunctions.setHandleRequest('pinDriveFile', function(entry, pin, callback) { 115 apiFunctions.setHandleRequest('pinDriveFile', function(entry, pin, callback) {
117 var url = fileBrowserHandlerNatives.GetEntryURL(entry); 116 var url = fileManagerPrivateNatives.GetEntryURL(entry);
118 fileManagerPrivateInternal.pinDriveFile(url, pin, callback); 117 fileManagerPrivateInternal.pinDriveFile(url, pin, callback);
119 }); 118 });
120 119
121 apiFunctions.setHandleRequest('executeTask', 120 apiFunctions.setHandleRequest('executeTask',
122 function(taskId, entries, callback) { 121 function(taskId, entries, callback) {
123 var urls = entries.map(function(entry) { 122 var urls = entries.map(function(entry) {
124 return fileBrowserHandlerNatives.GetEntryURL(entry); 123 return fileManagerPrivateNatives.GetEntryURL(entry);
125 }); 124 });
126 fileManagerPrivateInternal.executeTask(taskId, urls, callback); 125 fileManagerPrivateInternal.executeTask(taskId, urls, callback);
127 }); 126 });
128 127
129 apiFunctions.setHandleRequest('setDefaultTask', 128 apiFunctions.setHandleRequest('setDefaultTask',
130 function(taskId, entries, mimeTypes, callback) { 129 function(taskId, entries, mimeTypes, callback) {
131 var urls = entries.map(function(entry) { 130 var urls = entries.map(function(entry) {
132 return fileBrowserHandlerNatives.GetEntryURL(entry); 131 return fileManagerPrivateNatives.GetEntryURL(entry);
133 }); 132 });
134 fileManagerPrivateInternal.setDefaultTask( 133 fileManagerPrivateInternal.setDefaultTask(
135 taskId, urls, mimeTypes, callback); 134 taskId, urls, mimeTypes, callback);
136 }); 135 });
137 136
138 apiFunctions.setHandleRequest('getFileTasks', function(entries, callback) { 137 apiFunctions.setHandleRequest('getFileTasks', function(entries, callback) {
139 var urls = entries.map(function(entry) { 138 var urls = entries.map(function(entry) {
140 return fileBrowserHandlerNatives.GetEntryURL(entry); 139 return fileManagerPrivateNatives.GetEntryURL(entry);
141 }); 140 });
142 fileManagerPrivateInternal.getFileTasks(urls, callback); 141 fileManagerPrivateInternal.getFileTasks(urls, callback);
143 }); 142 });
144 143
145 apiFunctions.setHandleRequest('getShareUrl', function(entry, callback) { 144 apiFunctions.setHandleRequest('getShareUrl', function(entry, callback) {
146 var url = fileBrowserHandlerNatives.GetEntryURL(entry); 145 var url = fileManagerPrivateNatives.GetEntryURL(entry);
147 fileManagerPrivateInternal.getShareUrl(url, callback); 146 fileManagerPrivateInternal.getShareUrl(url, callback);
148 }); 147 });
149 148
150 apiFunctions.setHandleRequest('getDownloadUrl', function(entry, callback) { 149 apiFunctions.setHandleRequest('getDownloadUrl', function(entry, callback) {
151 var url = fileBrowserHandlerNatives.GetEntryURL(entry); 150 var url = fileManagerPrivateNatives.GetEntryURL(entry);
152 fileManagerPrivateInternal.getDownloadUrl(url, callback); 151 fileManagerPrivateInternal.getDownloadUrl(url, callback);
153 }); 152 });
154 153
155 apiFunctions.setHandleRequest('requestDriveShare', function( 154 apiFunctions.setHandleRequest('requestDriveShare', function(
156 entry, shareType, callback) { 155 entry, shareType, callback) {
157 var url = fileBrowserHandlerNatives.GetEntryURL(entry); 156 var url = fileManagerPrivateNatives.GetEntryURL(entry);
158 fileManagerPrivateInternal.requestDriveShare(url, shareType, callback); 157 fileManagerPrivateInternal.requestDriveShare(url, shareType, callback);
159 }); 158 });
160 159
161 apiFunctions.setHandleRequest('setEntryTag', function( 160 apiFunctions.setHandleRequest('setEntryTag', function(
162 entry, visibility, key, value, callback) { 161 entry, visibility, key, value, callback) {
163 var url = fileBrowserHandlerNatives.GetEntryURL(entry); 162 var url = fileManagerPrivateNatives.GetEntryURL(entry);
164 fileManagerPrivateInternal.setEntryTag( 163 fileManagerPrivateInternal.setEntryTag(
165 url, visibility, key, value, callback); 164 url, visibility, key, value, callback);
166 }); 165 });
167 166
168 apiFunctions.setHandleRequest('cancelFileTransfers', function( 167 apiFunctions.setHandleRequest('cancelFileTransfers', function(
169 entries, callback) { 168 entries, callback) {
170 var urls = entries.map(function(entry) { 169 var urls = entries.map(function(entry) {
171 return fileBrowserHandlerNatives.GetEntryURL(entry); 170 return fileManagerPrivateNatives.GetEntryURL(entry);
172 }); 171 });
173 fileManagerPrivateInternal.cancelFileTransfers(urls, callback); 172 fileManagerPrivateInternal.cancelFileTransfers(urls, callback);
174 }); 173 });
175 174
176 apiFunctions.setHandleRequest('startCopy', function( 175 apiFunctions.setHandleRequest('startCopy', function(
177 entry, parentEntry, newName, callback) { 176 entry, parentEntry, newName, callback) {
178 var url = fileBrowserHandlerNatives.GetEntryURL(entry); 177 var url = fileManagerPrivateNatives.GetEntryURL(entry);
179 var parentUrl = fileBrowserHandlerNatives.GetEntryURL(parentEntry); 178 var parentUrl = fileManagerPrivateNatives.GetEntryURL(parentEntry);
180 fileManagerPrivateInternal.startCopy( 179 fileManagerPrivateInternal.startCopy(
181 url, parentUrl, newName, callback); 180 url, parentUrl, newName, callback);
182 }); 181 });
183 182
184 apiFunctions.setHandleRequest('zipSelection', function( 183 apiFunctions.setHandleRequest('zipSelection', function(
185 parentEntry, entries, destName, callback) { 184 parentEntry, entries, destName, callback) {
186 var parentUrl = fileBrowserHandlerNatives.GetEntryURL(parentEntry); 185 var parentUrl = fileManagerPrivateNatives.GetEntryURL(parentEntry);
187 var urls = entries.map(function(entry) { 186 var urls = entries.map(function(entry) {
188 return fileBrowserHandlerNatives.GetEntryURL(entry); 187 return fileManagerPrivateNatives.GetEntryURL(entry);
189 }); 188 });
190 fileManagerPrivateInternal.zipSelection( 189 fileManagerPrivateInternal.zipSelection(
191 parentUrl, urls, destName, callback); 190 parentUrl, urls, destName, callback);
192 }); 191 });
193 192
194 apiFunctions.setHandleRequest('validatePathNameLength', function( 193 apiFunctions.setHandleRequest('validatePathNameLength', function(
195 entry, name, callback) { 194 entry, name, callback) {
196 var url = fileBrowserHandlerNatives.GetEntryURL(entry); 195 var url = fileManagerPrivateNatives.GetEntryURL(entry);
197 fileManagerPrivateInternal.validatePathNameLength(url, name, callback); 196 fileManagerPrivateInternal.validatePathNameLength(url, name, callback);
198 }); 197 });
199 }); 198 });
200 199
201 eventBindings.registerArgumentMassager( 200 eventBindings.registerArgumentMassager(
202 'fileManagerPrivate.onDirectoryChanged', function(args, dispatch) { 201 'fileManagerPrivate.onDirectoryChanged', function(args, dispatch) {
203 // Convert the entry arguments into a real Entry object. 202 // Convert the entry arguments into a real Entry object.
204 args[0].entry = GetExternalFileEntry(args[0].entry); 203 args[0].entry = GetExternalFileEntry(args[0].entry);
205 dispatch(args); 204 dispatch(args);
206 }); 205 });
207 206
208 exports.$set('binding', binding.generate()); 207 exports.$set('binding', binding.generate());
OLDNEW
« no previous file with comments | « chrome/renderer/extensions/page_capture_custom_bindings.cc ('k') | extensions/renderer/object_backed_native_handler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698