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 3 // found in the LICENSE file. 4 #ifndef CHROME_BROWSER_EXTENSIONS_API_IMAGE_WRITER_PRIVATE_REMOVABLE_STORAGE_PROVIDER_H_ 5 #define CHROME_BROWSER_EXTENSIONS_API_IMAGE_WRITER_PRIVATE_REMOVABLE_STORAGE_PROVIDER_H_ 6 7 #include "base/callback.h" 8 #include "chrome/common/extensions/api/image_writer_private.h" 9 #include "chrome/common/ref_counted_util.h" 10 11 namespace extensions { 12 13 // TODO(haven): Clean up this class to remove refcounting. http://crbug/370590 14 15 typedef RefCountedVector<linked_ptr 16 <api::image_writer_private::RemovableStorageDevice> > StorageDeviceList; 17 18 // Abstraction for platform specific implementations of listing removable 19 // storage devices 20 class RemovableStorageProvider { 21 public: 22 typedef base::Callback<void(scoped_refptr<StorageDeviceList>, bool)> 23 DeviceListReadyCallback; 24 25 // Gets the list of all available devices and returns it via callback. 26 static void GetAllDevices(DeviceListReadyCallback callback); 27 28 // Sets the list of devices that will be returned by GetAllDevices during 29 // testing. All calls to |GetAllDevices| will return this list until 30 // |ClearDeviceListForTesting| is called. 31 static void SetDeviceListForTesting( 32 scoped_refptr<StorageDeviceList> device_list); 33 // Clears the list of devices that is used during testing. 34 static void ClearDeviceListForTesting(); 35 36 private: 37 // Fills the provided empty device list with the available devices. 38 static bool PopulateDeviceList(scoped_refptr<StorageDeviceList> device_list); 39 }; 40 41 } // namespace extensions 42 43 #endif // CHROME_BROWSER_EXTENSIONS_API_IMAGE_WRITER_PRIVATE_REMOVABLE_STORAGE_PROVIDER_H_ 44