| Index: chrome/browser/system_monitor/removable_device_notifications_chromeos.cc
|
| diff --git a/chrome/browser/system_monitor/removable_device_notifications_chromeos.cc b/chrome/browser/system_monitor/removable_device_notifications_chromeos.cc
|
| index 1b17b925cd5ac927a22b4c38c31401bcfae19d69..e0b66d11fa304e280d980dad246287a3726221b2 100644
|
| --- a/chrome/browser/system_monitor/removable_device_notifications_chromeos.cc
|
| +++ b/chrome/browser/system_monitor/removable_device_notifications_chromeos.cc
|
| @@ -20,6 +20,9 @@ namespace chromeos {
|
|
|
| namespace {
|
|
|
| +static RemovableDeviceNotificationsCros*
|
| + g_removable_device_notifications_chromeos = NULL;
|
| +
|
| // Returns true if the requested device is valid, else false. On success, fills
|
| // in |unique_id| and |device_label|
|
| bool GetDeviceInfo(const std::string& source_path, std::string* unique_id,
|
| @@ -46,17 +49,30 @@ using content::BrowserThread;
|
|
|
| RemovableDeviceNotificationsCros::RemovableDeviceNotificationsCros() {
|
| DCHECK(disks::DiskMountManager::GetInstance());
|
| + DCHECK(!g_removable_device_notifications_chromeos);
|
| + g_removable_device_notifications_chromeos = this;
|
| disks::DiskMountManager::GetInstance()->AddObserver(this);
|
| CheckExistingMountPointsOnUIThread();
|
| }
|
|
|
| RemovableDeviceNotificationsCros::~RemovableDeviceNotificationsCros() {
|
| + DCHECK_EQ(this, g_removable_device_notifications_chromeos);
|
| + g_removable_device_notifications_chromeos = NULL;
|
| disks::DiskMountManager* manager = disks::DiskMountManager::GetInstance();
|
| if (manager) {
|
| manager->RemoveObserver(this);
|
| }
|
| }
|
|
|
| +// static
|
| +RemovableDeviceNotificationsCros*
|
| +RemovableDeviceNotificationsCros::GetInstance() {
|
| + return g_removable_device_notifications_chromeos;
|
| +}
|
| +
|
| +RemovableDeviceNotificationsCros::DeviceInfo::DeviceInfo() {
|
| +}
|
| +
|
| void RemovableDeviceNotificationsCros::CheckExistingMountPointsOnUIThread() {
|
| DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
|
| const disks::DiskMountManager::MountPointMap& mount_point_map =
|
| @@ -114,13 +130,38 @@ void RemovableDeviceNotificationsCros::MountCompleted(
|
| MountMap::iterator it = mount_map_.find(mount_info.mount_path);
|
| if (it == mount_map_.end())
|
| return;
|
| - base::SystemMonitor::Get()->ProcessRemovableStorageDetached(it->second);
|
| + base::SystemMonitor::Get()->ProcessRemovableStorageDetached(
|
| + it->second.id);
|
| mount_map_.erase(it);
|
| break;
|
| }
|
| }
|
| }
|
|
|
| +bool RemovableDeviceNotificationsCros::GetDeviceInfoForPath(
|
| + const FilePath& path,
|
| + base::SystemMonitor::RemovableStorageInfo* device_info) const {
|
| + if (!path.IsAbsolute())
|
| + return false;
|
| +
|
| + FilePath current = path;
|
| + while (!ContainsKey(mount_map_, current.value()) &&
|
| + current != current.DirName()) {
|
| + current = current.DirName();
|
| + }
|
| +
|
| + MountMap::const_iterator info_it = mount_map_.find(current.value());
|
| + if (info_it == mount_map_.end())
|
| + return false;
|
| +
|
| + if (device_info) {
|
| + device_info->device_id = info_it->second.id;
|
| + device_info->location = info_it->second.location;
|
| + device_info->name = info_it->second.name;
|
| + }
|
| + return true;
|
| +}
|
| +
|
| void RemovableDeviceNotificationsCros::CheckMountedPathOnFileThread(
|
| const disks::DiskMountManager::MountPointInfo& mount_info) {
|
| DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
|
| @@ -160,7 +201,12 @@ void RemovableDeviceNotificationsCros::AddMountedPathOnUIThread(
|
|
|
| std::string device_id = chrome::MediaStorageUtil::MakeDeviceId(type,
|
| unique_id);
|
| - mount_map_.insert(std::make_pair(mount_info.mount_path, device_id));
|
| + DeviceInfo info;
|
| + info.location = mount_info.mount_path;
|
| + info.id = device_id;
|
| + info.name = device_label;
|
| +
|
| + mount_map_.insert(std::make_pair(mount_info.mount_path, info));
|
| base::SystemMonitor::Get()->ProcessRemovableStorageAttached(
|
| device_id,
|
| device_label,
|
|
|