| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #include "chrome/browser/system_monitor/removable_device_notifications_window_wi
n.h" | 5 #include "chrome/browser/system_monitor/removable_device_notifications_window_wi
n.h" |
| 6 | 6 |
| 7 #include <windows.h> | 7 #include <windows.h> |
| 8 #include <dbt.h> | 8 #include <dbt.h> |
| 9 #include <fileapi.h> | 9 #include <fileapi.h> |
| 10 | 10 |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 | 76 |
| 77 window_ = CreateWindow(MAKEINTATOM(window_class_), 0, 0, 0, 0, 0, 0, 0, 0, | 77 window_ = CreateWindow(MAKEINTATOM(window_class_), 0, 0, 0, 0, 0, 0, 0, 0, |
| 78 instance_, 0); | 78 instance_, 0); |
| 79 SetWindowLongPtr(window_, GWLP_USERDATA, reinterpret_cast<LONG_PTR>(this)); | 79 SetWindowLongPtr(window_, GWLP_USERDATA, reinterpret_cast<LONG_PTR>(this)); |
| 80 volume_mount_watcher_->Init(); | 80 volume_mount_watcher_->Init(); |
| 81 portable_device_watcher_->Init(window_); | 81 portable_device_watcher_->Init(window_); |
| 82 } | 82 } |
| 83 | 83 |
| 84 bool RemovableDeviceNotificationsWindowWin::GetDeviceInfoForPath( | 84 bool RemovableDeviceNotificationsWindowWin::GetDeviceInfoForPath( |
| 85 const FilePath& path, | 85 const FilePath& path, |
| 86 base::SystemMonitor::RemovableStorageInfo* device_info) const { | 86 RemovableStorageInfo* device_info) const { |
| 87 string16 location; | 87 string16 location; |
| 88 std::string unique_id; | 88 std::string unique_id; |
| 89 string16 name; | 89 string16 name; |
| 90 bool removable; | 90 bool removable; |
| 91 if (!GetDeviceInfo(path, &location, &unique_id, &name, &removable)) | 91 if (!GetDeviceInfo(path, &location, &unique_id, &name, &removable)) |
| 92 return false; | 92 return false; |
| 93 | 93 |
| 94 // To compute the device id, the device type is needed. For removable | 94 // To compute the device id, the device type is needed. For removable |
| 95 // devices, that requires knowing if there's a DCIM directory, which would | 95 // devices, that requires knowing if there's a DCIM directory, which would |
| 96 // require bouncing over to the file thread. Instead, just iterate the | 96 // require bouncing over to the file thread. Instead, just iterate the |
| 97 // devices in base::SystemMonitor. | 97 // devices. |
| 98 std::string device_id; | 98 std::string device_id; |
| 99 if (removable) { | 99 if (removable) { |
| 100 std::vector<base::SystemMonitor::RemovableStorageInfo> attached_devices = | 100 std::vector<RemovableStorageInfo> attached_devices = |
| 101 base::SystemMonitor::Get()->GetAttachedRemovableStorage(); | 101 GetAttachedRemovableStorage(); |
| 102 bool found = false; | 102 bool found = false; |
| 103 for (size_t i = 0; i < attached_devices.size(); i++) { | 103 for (size_t i = 0; i < attached_devices.size(); i++) { |
| 104 MediaStorageUtil::Type type; | 104 MediaStorageUtil::Type type; |
| 105 std::string id; | 105 std::string id; |
| 106 MediaStorageUtil::CrackDeviceId(attached_devices[i].device_id, &type, | 106 MediaStorageUtil::CrackDeviceId(attached_devices[i].device_id, &type, |
| 107 &id); | 107 &id); |
| 108 if (id == unique_id) { | 108 if (id == unique_id) { |
| 109 found = true; | 109 found = true; |
| 110 device_id = attached_devices[i].device_id; | 110 device_id = attached_devices[i].device_id; |
| 111 break; | 111 break; |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 172 portable_device_watcher_->OnWindowMessage(event_type, data); | 172 portable_device_watcher_->OnWindowMessage(event_type, data); |
| 173 } | 173 } |
| 174 | 174 |
| 175 // static | 175 // static |
| 176 RemovableStorageNotifications* RemovableStorageNotifications::GetInstance() { | 176 RemovableStorageNotifications* RemovableStorageNotifications::GetInstance() { |
| 177 DCHECK(g_removable_device_notifications_window_win); | 177 DCHECK(g_removable_device_notifications_window_win); |
| 178 return g_removable_device_notifications_window_win; | 178 return g_removable_device_notifications_window_win; |
| 179 } | 179 } |
| 180 | 180 |
| 181 } // namespace chrome | 181 } // namespace chrome |
| OLD | NEW |