| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 var attachedDeviceId; | 5 var attachedDeviceId; |
| 6 | 6 |
| 7 systemInfo = chrome.experimental.systemInfo; | |
| 8 | |
| 9 function testAttach(details) { | 7 function testAttach(details) { |
| 10 attachedDeviceId = details.id; | 8 attachedDeviceId = details.id; |
| 11 chrome.test.sendMessage('attach_test_ok,' + details.name); | 9 chrome.test.sendMessage('attach_test_ok,' + details.name); |
| 12 }; | 10 }; |
| 13 | 11 |
| 14 function ejectCallback(result) { | 12 function ejectCallback(result) { |
| 15 if (result == "success") { | 13 if (result == "success") { |
| 16 chrome.test.sendMessage("eject_ok"); | 14 chrome.test.sendMessage("eject_ok"); |
| 17 } else if (result == "in_use") { | 15 } else if (result == "in_use") { |
| 18 chrome.test.sendMessage("eject_in_use"); | 16 chrome.test.sendMessage("eject_in_use"); |
| 19 } else if (result == "no_such_device") { | 17 } else if (result == "no_such_device") { |
| 20 chrome.test.sendMessage("eject_no_such_device"); | 18 chrome.test.sendMessage("eject_no_such_device"); |
| 21 } else { | 19 } else { |
| 22 chrome.test.sendMessage("eject_failure"); | 20 chrome.test.sendMessage("eject_failure"); |
| 23 } | 21 } |
| 24 }; | 22 }; |
| 25 | 23 |
| 26 function ejectTest() { | 24 function ejectTest() { |
| 27 systemInfo.storage.ejectDevice(attachedDeviceId, ejectCallback); | 25 chrome.system.storage.ejectDevice(attachedDeviceId, ejectCallback); |
| 28 }; | 26 }; |
| 29 | 27 |
| 30 function addAttachListener() { | 28 function addAttachListener() { |
| 31 systemInfo.storage.onAttached.addListener(testAttach); | 29 chrome.system.storage.onAttached.addListener(testAttach); |
| 32 chrome.test.sendMessage('add_attach_ok'); | 30 chrome.test.sendMessage('add_attach_ok'); |
| 33 }; | 31 }; |
| 34 | 32 |
| 35 function removeAttachListener() { | 33 function removeAttachListener() { |
| 36 systemInfo.storage.onAttached.removeListener(testAttach); | 34 chrome.system.storage.onAttached.removeListener(testAttach); |
| 37 chrome.test.sendMessage('remove_attach_ok'); | 35 chrome.test.sendMessage('remove_attach_ok'); |
| 38 }; | 36 }; |
| 39 | 37 |
| 40 function ejectFailTest() { | 38 function ejectFailTest() { |
| 41 systemInfo.storage.ejectDevice('-1', ejectCallback); | 39 chrome.system.storage.ejectDevice('-1', ejectCallback); |
| 42 }; | 40 }; |
| OLD | NEW |