diff options
author | kmadhusu@chromium.org <kmadhusu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-07-31 01:00:38 +0000 |
---|---|---|
committer | kmadhusu@chromium.org <kmadhusu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-07-31 01:00:38 +0000 |
commit | 9c5620d351e6f8f384de2b3c8a3d2ec34101e21e (patch) | |
tree | 7dee7f01aac99b0ee98c8b00e6d5f3a0c238a9c0 /chrome/browser/chromeos/disks | |
parent | 8fbc32e55cd0ce60c3bd536a006e0f88cb563733 (diff) | |
download | chromium_src-9c5620d351e6f8f384de2b3c8a3d2ec34101e21e.zip chromium_src-9c5620d351e6f8f384de2b3c8a3d2ec34101e21e.tar.gz chromium_src-9c5620d351e6f8f384de2b3c8a3d2ec34101e21e.tar.bz2 |
In order to manage device media gallery permissions, use a device id that is unique and persistent across device attachments. Therefore, extract device uuid from DiskInfo::InitializeFromResponse and use that identifier while dispatching media device attached notification event.
BUG=none
TEST=none
Review URL: https://chromiumcodereview.appspot.com/10830003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@149099 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/chromeos/disks')
4 files changed, 57 insertions, 0 deletions
diff --git a/chrome/browser/chromeos/disks/disk_mount_manager.cc b/chrome/browser/chromeos/disks/disk_mount_manager.cc index bcfd490..98e24ac 100644 --- a/chrome/browser/chromeos/disks/disk_mount_manager.cc +++ b/chrome/browser/chromeos/disks/disk_mount_manager.cc @@ -376,6 +376,7 @@ class DiskMountManagerImpl : public DiskMountManager { disk_info.file_path(), disk_info.label(), disk_info.drive_label(), + disk_info.uuid(), FindSystemPathPrefix(disk_info.system_path()), disk_info.device_type(), disk_info.total_size_in_bytes(), @@ -566,6 +567,7 @@ DiskMountManager::Disk::Disk(const std::string& device_path, const std::string& file_path, const std::string& device_label, const std::string& drive_label, + const std::string& fs_uuid, const std::string& system_path_prefix, DeviceType device_type, uint64 total_size_in_bytes, @@ -580,6 +582,7 @@ DiskMountManager::Disk::Disk(const std::string& device_path, file_path_(file_path), device_label_(device_label), drive_label_(drive_label), + fs_uuid_(fs_uuid), system_path_prefix_(system_path_prefix), device_type_(device_type), total_size_in_bytes_(total_size_in_bytes), diff --git a/chrome/browser/chromeos/disks/disk_mount_manager.h b/chrome/browser/chromeos/disks/disk_mount_manager.h index c4e1d6b..df6dd18 100644 --- a/chrome/browser/chromeos/disks/disk_mount_manager.h +++ b/chrome/browser/chromeos/disks/disk_mount_manager.h @@ -52,6 +52,7 @@ class DiskMountManager { const std::string& file_path, const std::string& device_label, const std::string& drive_label, + const std::string& fs_uuid, const std::string& system_path_prefix, DeviceType device_type, uint64 total_size_in_bytes, @@ -85,6 +86,9 @@ class DiskMountManager { // (e.g. "TransMemory") const std::string& drive_label() const { return drive_label_; } + // Returns the file system uuid string. + const std::string& fs_uuid() const { return fs_uuid_; } + // Path of the system device this device's block is a part of. // (e.g. /sys/devices/pci0000:00/.../8:0:0:0/) const std::string& system_path_prefix() const { @@ -125,6 +129,7 @@ class DiskMountManager { std::string file_path_; std::string device_label_; std::string drive_label_; + std::string fs_uuid_; std::string system_path_prefix_; DeviceType device_type_; uint64 total_size_in_bytes_; diff --git a/chrome/browser/chromeos/disks/mock_disk_mount_manager.cc b/chrome/browser/chromeos/disks/mock_disk_mount_manager.cc index 80558e0..4291298 100644 --- a/chrome/browser/chromeos/disks/mock_disk_mount_manager.cc +++ b/chrome/browser/chromeos/disks/mock_disk_mount_manager.cc @@ -5,6 +5,7 @@ #include "chrome/browser/chromeos/disks/mock_disk_mount_manager.h" #include "base/message_loop.h" +#include "base/stl_util.h" #include "base/string_util.h" #include "content/public/browser/browser_thread.h" @@ -26,6 +27,7 @@ const char* kTestMountPath = "/media/foofoo"; const char* kTestFilePath = "/this/file/path"; const char* kTestDeviceLabel = "A label"; const char* kTestDriveLabel = "Another label"; +const char* kTestUuid = "FFFF-FFFF"; } // namespace @@ -50,6 +52,8 @@ MockDiskMountManager::MockDiskMountManager() { } MockDiskMountManager::~MockDiskMountManager() { + STLDeleteContainerPairSecondPointers(disks_.begin(), disks_.end()); + disks_.clear(); } void MockDiskMountManager::NotifyDeviceInsertEvents() { @@ -60,6 +64,7 @@ void MockDiskMountManager::NotifyDeviceInsertEvents() { std::string(kTestFilePath), std::string(), std::string(kTestDriveLabel), + std::string(kTestUuid), std::string(kTestSystemPathPrefix), DEVICE_TYPE_USB, 4294967295U, @@ -90,6 +95,7 @@ void MockDiskMountManager::NotifyDeviceInsertEvents() { std::string(kTestFilePath), std::string(kTestDeviceLabel), std::string(kTestDriveLabel), + std::string(kTestUuid), std::string(kTestSystemPathPrefix), DEVICE_TYPE_MOBILE, 1073741824, @@ -113,6 +119,7 @@ void MockDiskMountManager::NotifyDeviceRemoveEvents() { std::string(kTestFilePath), std::string(kTestDeviceLabel), std::string(kTestDriveLabel), + std::string(kTestUuid), std::string(kTestSystemPathPrefix), DEVICE_TYPE_SD, 1073741824, @@ -148,6 +155,37 @@ void MockDiskMountManager::SetupDefaultReplies() { .Times(AnyNumber()); } +void MockDiskMountManager::CreateDiskEntryForMountDevice( + const DiskMountManager::MountPointInfo& mount_info, + const std::string& device_id) { + Disk* disk = new DiskMountManager::Disk(std::string(mount_info.source_path), + std::string(mount_info.mount_path), + std::string(), // system_path + std::string(), // file_path + std::string(), // device_label + std::string(), // drive_label + device_id, // fs_uuid + std::string(), // system_path_prefix + DEVICE_TYPE_USB, // device_type + 1073741824, // total_size_in_bytes + false, // is_parent + false, // is_read_only + true, // has_media + false, // on_boot_device + false); // is_hidden + disks_.insert(std::pair<std::string, DiskMountManager::Disk*>( + std::string(mount_info.source_path), disk)); +} + +void MockDiskMountManager::RemoveDiskEntryForMountDevice( + const DiskMountManager::MountPointInfo& mount_info) { + DiskMountManager::DiskMap::iterator it = disks_.find(mount_info.source_path); + if (it != disks_.end()) { + delete it->second; + disks_.erase(it); + } +} + void MockDiskMountManager::NotifyDiskChanged(DiskMountManagerEventType event, const DiskMountManager::Disk* disk) { diff --git a/chrome/browser/chromeos/disks/mock_disk_mount_manager.h b/chrome/browser/chromeos/disks/mock_disk_mount_manager.h index 0a3d622..f22e72b 100644 --- a/chrome/browser/chromeos/disks/mock_disk_mount_manager.h +++ b/chrome/browser/chromeos/disks/mock_disk_mount_manager.h @@ -48,6 +48,17 @@ class MockDiskMountManager : public DiskMountManager { // Sets up default results for mock methods. void SetupDefaultReplies(); + // Creates a fake disk entry for the mounted device. This function is + // primarily for MediaDeviceNotificationsTest. + void CreateDiskEntryForMountDevice( + const DiskMountManager::MountPointInfo& mount_info, + const std::string& device_id); + + // Removes the fake disk entry associated with the mounted device. This + // function is primarily for MediaDeviceNotificationsTest. + void RemoveDiskEntryForMountDevice( + const DiskMountManager::MountPointInfo& mount_info); + private: // Is used to implement AddObserver. void AddObserverInternal(DiskMountManager::Observer* observer); |