| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 developerPrivate API. | 5 // Custom binding for the developerPrivate API. |
| 6 | 6 |
| 7 var binding = require('binding').Binding.create('developerPrivate'); | 7 var binding = require('binding').Binding.create('developerPrivate'); |
| 8 | 8 |
| 9 binding.registerCustomHook(function(bindingsAPI) { | 9 binding.registerCustomHook(function(bindingsAPI) { |
| 10 var apiFunctions = bindingsAPI.apiFunctions; | 10 var apiFunctions = bindingsAPI.apiFunctions; |
| 11 | 11 |
| 12 // Converts the argument of |functionName| from DirectoryEntry to URL. | 12 // Converts the argument of |functionName| from DirectoryEntry to URL. |
| 13 function bindFileSystemFunction(functionName) { | 13 function bindFileSystemFunction(functionName) { |
| 14 apiFunctions.setUpdateArgumentsPostValidate( | 14 apiFunctions.setUpdateArgumentsPostValidate( |
| 15 functionName, function(directoryEntry, callback) { | 15 functionName, function(directoryEntry, callback) { |
| 16 var fileSystemName = directoryEntry.filesystem.name; | 16 var fileSystemName = directoryEntry.filesystem.name; |
| 17 var relativePath = $String.slice(directoryEntry.fullPath, 1); | 17 var relativePath = $String.slice(directoryEntry.fullPath, 1); |
| 18 var url = directoryEntry.toURL(); | 18 var url = directoryEntry.toURL(); |
| 19 return [fileSystemName, relativePath, url, callback]; | 19 return [fileSystemName, relativePath, url, callback]; |
| 20 }); | 20 }); |
| 21 } | 21 } |
| 22 | 22 |
| 23 bindFileSystemFunction('loadDirectory'); | 23 bindFileSystemFunction('loadDirectory'); |
| 24 | 24 |
| 25 // developerPrivate.enable is the same as chrome.management.setEnabled. | 25 // developerPrivate.enable is the same as chrome.management.setEnabled. |
| 26 // TODO(devlin): Migrate callers off developerPrivate.enable. | 26 // TODO(devlin): Migrate callers off developerPrivate.enable. |
| 27 bindingsAPI.compiledApi.enable = chrome.management.setEnabled; | 27 bindingsAPI.compiledApi.enable = chrome.management.setEnabled; |
| 28 |
| 29 bindingsAPI.compiledApi.allowFileAccess = function(id, allow, callback) { |
| 30 chrome.developerPrivate.setExtensionPermission({ |
| 31 extensionId: id, |
| 32 permission: chrome.developerPrivate.PermissionType.FILE_ACCESS, |
| 33 isActive: allow}, |
| 34 callback); |
| 35 }; |
| 36 |
| 37 bindingsAPI.compiledApi.allowIncognito = function(id, allow, callback) { |
| 38 chrome.developerPrivate.setExtensionPermission({ |
| 39 extensionId: id, |
| 40 permission: chrome.developerPrivate.PermissionType.INCOGNITO_ACCESS, |
| 41 isActive: allow}, |
| 42 callback); |
| 43 }; |
| 28 }); | 44 }); |
| 29 | 45 |
| 30 exports.binding = binding.generate(); | 46 exports.binding = binding.generate(); |
| OLD | NEW |