| 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 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 window_class_ = RegisterClassEx(&window_class); | 81 window_class_ = RegisterClassEx(&window_class); |
| 82 DCHECK(window_class_); | 82 DCHECK(window_class_); |
| 83 | 83 |
| 84 window_ = CreateWindow(MAKEINTATOM(window_class_), 0, 0, 0, 0, 0, 0, 0, 0, | 84 window_ = CreateWindow(MAKEINTATOM(window_class_), 0, 0, 0, 0, 0, 0, 0, 0, |
| 85 instance_, 0); | 85 instance_, 0); |
| 86 SetWindowLongPtr(window_, GWLP_USERDATA, reinterpret_cast<LONG_PTR>(this)); | 86 SetWindowLongPtr(window_, GWLP_USERDATA, reinterpret_cast<LONG_PTR>(this)); |
| 87 volume_mount_watcher_->Init(); | 87 volume_mount_watcher_->Init(); |
| 88 portable_device_watcher_->Init(window_); | 88 portable_device_watcher_->Init(window_); |
| 89 } | 89 } |
| 90 | 90 |
| 91 bool RemovableDeviceNotificationsWindowWin::GetMTPStorageInfoFromDeviceId( |
| 92 const std::string& storage_device_id, |
| 93 string16* device_location, |
| 94 string16* storage_object_id) { |
| 95 MediaStorageUtil::Type type; |
| 96 MediaStorageUtil::CrackDeviceId(storage_device_id, &type, NULL); |
| 97 return ((type == MediaStorageUtil::MTP_OR_PTP) && |
| 98 portable_device_watcher_->GetMTPStorageInfoFromDeviceId( |
| 99 storage_device_id, device_location, storage_object_id)); |
| 100 } |
| 101 |
| 91 bool RemovableDeviceNotificationsWindowWin::GetDeviceInfoForPath( | 102 bool RemovableDeviceNotificationsWindowWin::GetDeviceInfoForPath( |
| 92 const FilePath& path, | 103 const FilePath& path, |
| 93 base::SystemMonitor::RemovableStorageInfo* device_info) { | 104 base::SystemMonitor::RemovableStorageInfo* device_info) { |
| 94 string16 location; | 105 string16 location; |
| 95 std::string unique_id; | 106 std::string unique_id; |
| 96 string16 name; | 107 string16 name; |
| 97 bool removable; | 108 bool removable; |
| 98 if (!GetDeviceInfo(path, &location, &unique_id, &name, &removable)) | 109 if (!GetDeviceInfo(path, &location, &unique_id, &name, &removable)) |
| 99 return false; | 110 return false; |
| 100 | 111 |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 167 unique_id, name, removable); | 178 unique_id, name, removable); |
| 168 } | 179 } |
| 169 | 180 |
| 170 void RemovableDeviceNotificationsWindowWin::OnDeviceChange(UINT event_type, | 181 void RemovableDeviceNotificationsWindowWin::OnDeviceChange(UINT event_type, |
| 171 LPARAM data) { | 182 LPARAM data) { |
| 172 volume_mount_watcher_->OnWindowMessage(event_type, data); | 183 volume_mount_watcher_->OnWindowMessage(event_type, data); |
| 173 portable_device_watcher_->OnWindowMessage(event_type, data); | 184 portable_device_watcher_->OnWindowMessage(event_type, data); |
| 174 } | 185 } |
| 175 | 186 |
| 176 } // namespace chrome | 187 } // namespace chrome |
| OLD | NEW |