diff options
author | vandebo@chromium.org <vandebo@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-10-13 03:43:25 +0000 |
---|---|---|
committer | vandebo@chromium.org <vandebo@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-10-13 03:43:25 +0000 |
commit | 35a5774c5e845bb0f2410057b77f7e056718375a (patch) | |
tree | 93dc792c5f74183e9a6189aa3a85797f3534d4c7 | |
parent | fdd8d8e1d49286c5b222f4f6705b8dc96a3aa3cf (diff) | |
download | chromium_src-35a5774c5e845bb0f2410057b77f7e056718375a.zip chromium_src-35a5774c5e845bb0f2410057b77f7e056718375a.tar.gz chromium_src-35a5774c5e845bb0f2410057b77f7e056718375a.tar.bz2 |
Don't access the floppy drive from media galleries.
Also, stop using GetVolumeInformation since it seems to hang some times.
BUG=153763
Review URL: https://chromiumcodereview.appspot.com/11131006
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@161701 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/system_monitor/removable_device_notifications_window_win.cc | 33 |
1 files changed, 19 insertions, 14 deletions
diff --git a/chrome/browser/system_monitor/removable_device_notifications_window_win.cc b/chrome/browser/system_monitor/removable_device_notifications_window_win.cc index 04e2885..2f04fe9 100644 --- a/chrome/browser/system_monitor/removable_device_notifications_window_win.cc +++ b/chrome/browser/system_monitor/removable_device_notifications_window_win.cc @@ -11,6 +11,7 @@ #include "base/file_path.h" #include "base/metrics/histogram.h" #include "base/string_number_conversions.h" +#include "base/string_util.h" #include "base/system_monitor/system_monitor.h" #include "base/utf_string_conversions.h" #include "base/win/wrapped_window_proc.h" @@ -31,6 +32,20 @@ const char16 kWindowClassName[] = L"Chrome_RemovableDeviceNotificationWindow"; static chrome::RemovableDeviceNotificationsWindowWin* g_removable_device_notifications_window_win = NULL; +bool IsRemovable(const char16* mount_point) { + if (GetDriveType(mount_point) != DRIVE_REMOVABLE) + return false; + + // We don't consider floppy disks as removable, so check for that. + string16 device = mount_point; + if (EndsWith(device, L"\\", false)) + device = device.substr(0, device.length() - 1); + char16 device_path[kMaxPathBufLen]; + if (!QueryDosDevice(device.c_str(), device_path, kMaxPathBufLen)) + return true; + return string16(device_path).find(L"Floppy") == string16::npos; +} + // The following msdn blog entry is helpful for understanding disk volumes // and how they are treated in Windows: // http://blogs.msdn.com/b/adioltean/archive/2005/04/16/408947.aspx @@ -54,21 +69,11 @@ bool GetDeviceInfo(const FilePath& device_path, string16* device_location, WideToUTF8(guid, wcslen(guid), unique_id); } - if (name) { - char16 volume_name[kMaxPathBufLen]; - if (!GetVolumeInformation(mount_point, volume_name, kMaxPathBufLen, NULL, - NULL, NULL, NULL, 0)) { - return false; - } - if (wcslen(volume_name) > 0) { - *name = string16(volume_name); - } else { - *name = device_path.LossyDisplayName(); - } - } + if (name) + *name = device_path.LossyDisplayName(); if (removable) - *removable = (GetDriveType(mount_point) == DRIVE_REMOVABLE); + *removable = IsRemovable(mount_point); return true; } @@ -85,7 +90,7 @@ std::vector<FilePath> GetAttachedDevices() { DWORD return_count; if (GetVolumePathNamesForVolumeName(volume_name, volume_path, kMaxPathBufLen, &return_count)) { - if (GetDriveType(volume_path) == DRIVE_REMOVABLE) + if (IsRemovable(volume_path)) result.push_back(FilePath(volume_path)); } else { DPLOG(ERROR); |