| 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 'use strict'; | 5 'use strict'; |
| 6 | 6 |
| 7 /** | 7 /** |
| 8 * @param {Object.<string, string>} stringData String data. | 8 * @param {Object.<string, string>} stringData String data. |
| 9 * @param {VolumeManager} volumeManager Volume manager. | 9 * @param {VolumeManager} volumeManager Volume manager. |
| 10 */ | 10 */ |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 */ | 55 */ |
| 56 var backgroundComponentsPromise = BackgroundComponents.load(); | 56 var backgroundComponentsPromise = BackgroundComponents.load(); |
| 57 | 57 |
| 58 /** | 58 /** |
| 59 * Resolves file system names and obtains entries. | 59 * Resolves file system names and obtains entries. |
| 60 * @param {Array.<FileEntry>} entries Names of isolated file system. | 60 * @param {Array.<FileEntry>} entries Names of isolated file system. |
| 61 * @return {Promise} Promise to be fulfilled with an entry array. | 61 * @return {Promise} Promise to be fulfilled with an entry array. |
| 62 */ | 62 */ |
| 63 function resolveEntries(entries) { | 63 function resolveEntries(entries) { |
| 64 return new Promise(function(fulfill, reject) { | 64 return new Promise(function(fulfill, reject) { |
| 65 chrome.fileManagerPrivate.resolveIsolatedEntries(entries, | 65 chrome.fileManagerPrivate.resolveIsolatedEntries( |
| 66 function(externalEntries) { | 66 entries, function(externalEntries) { |
| 67 if (!chrome.runtime.lastError) | 67 if (!chrome.runtime.lastError) |
| 68 fulfill(externalEntries); | 68 fulfill(externalEntries); |
| 69 else | 69 else |
| 70 reject(chrome.runtime.lastError); | 70 reject(chrome.runtime.lastError); |
| 71 }); | 71 }); |
| 72 }); | 72 }); |
| 73 } | 73 } |
| 74 | 74 |
| 75 /** | 75 /** |
| 76 * Obtains child entries. | 76 * Obtains child entries. |
| 77 * @param {DirectoryEntry} entry Directory entry. | 77 * @param {DirectoryEntry} entry Directory entry. |
| 78 * @return {Promise} Promise to be fulfilled with child entries. | 78 * @return {Promise} Promise to be fulfilled with child entries. |
| 79 */ | 79 */ |
| 80 function getChildren(entry) { | 80 function getChildren(entry) { |
| 81 var reader = entry.createReader(); | 81 var reader = entry.createReader(); |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 196 }); | 196 }); |
| 197 | 197 |
| 198 launch(selectedEntriesPromise).catch(function(error) { | 198 launch(selectedEntriesPromise).catch(function(error) { |
| 199 console.error(error.stack || error); | 199 console.error(error.stack || error); |
| 200 }); | 200 }); |
| 201 }); | 201 }); |
| 202 | 202 |
| 203 // If is is run in the browser test, wait for the test resources are installed | 203 // If is is run in the browser test, wait for the test resources are installed |
| 204 // as a component extension, and then load the test resources. | 204 // as a component extension, and then load the test resources. |
| 205 if (chrome.test) { | 205 if (chrome.test) { |
| 206 /** @type {string} */ |
| 206 window.testExtensionId = 'ejhcmmdhhpdhhgmifplfmjobgegbibkn'; | 207 window.testExtensionId = 'ejhcmmdhhpdhhgmifplfmjobgegbibkn'; |
| 207 chrome.runtime.onMessageExternal.addListener(function(message) { | 208 chrome.runtime.onMessageExternal.addListener(function(message) { |
| 208 if (message.name !== 'testResourceLoaded') | 209 if (message.name !== 'testResourceLoaded') |
| 209 return; | 210 return; |
| 210 var script = document.createElement('script'); | 211 var script = document.createElement('script'); |
| 211 script.src = | 212 script.src = |
| 212 'chrome-extension://' + window.testExtensionId + | 213 'chrome-extension://' + window.testExtensionId + |
| 213 '/common/test_loader.js'; | 214 '/common/test_loader.js'; |
| 214 document.documentElement.appendChild(script); | 215 document.documentElement.appendChild(script); |
| 215 }); | 216 }); |
| 216 } | 217 } |
| OLD | NEW |