| 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 #ifndef CHROME_BROWSER_SYSTEM_MONITOR_REMOVABLE_DEVICE_NOTIFICATIONS_WINDOW_WIN_
H_ | 5 #ifndef CHROME_BROWSER_SYSTEM_MONITOR_REMOVABLE_DEVICE_NOTIFICATIONS_WINDOW_WIN_
H_ |
| 6 #define CHROME_BROWSER_SYSTEM_MONITOR_REMOVABLE_DEVICE_NOTIFICATIONS_WINDOW_WIN_
H_ | 6 #define CHROME_BROWSER_SYSTEM_MONITOR_REMOVABLE_DEVICE_NOTIFICATIONS_WINDOW_WIN_
H_ |
| 7 | 7 |
| 8 #include <windows.h> | |
| 9 | |
| 10 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "base/memory/ref_counted.h" |
| 10 #include "base/memory/scoped_ptr.h" |
| 11 #include "base/system_monitor/system_monitor.h" | 11 #include "base/system_monitor/system_monitor.h" |
| 12 #include "chrome/browser/system_monitor/volume_mount_watcher_win.h" | |
| 13 | 12 |
| 14 class FilePath; | 13 class FilePath; |
| 15 | 14 |
| 16 namespace chrome { | 15 namespace chrome { |
| 17 | 16 |
| 17 class PortableDeviceWatcherWin; |
| 18 class VolumeMountWatcherWin; |
| 19 |
| 18 class RemovableDeviceNotificationsWindowWin; | 20 class RemovableDeviceNotificationsWindowWin; |
| 19 typedef RemovableDeviceNotificationsWindowWin RemovableDeviceNotifications; | 21 typedef RemovableDeviceNotificationsWindowWin RemovableDeviceNotifications; |
| 20 | 22 |
| 21 class RemovableDeviceNotificationsWindowWin { | 23 class RemovableDeviceNotificationsWindowWin { |
| 22 public: | 24 public: |
| 23 // Creates an instance of RemovableDeviceNotificationsWindowWin. Should only | 25 // Creates an instance of RemovableDeviceNotificationsWindowWin. Should only |
| 24 // be called by browser start up code. Use GetInstance() instead. | 26 // be called by browser start up code. Use GetInstance() instead. |
| 25 static RemovableDeviceNotificationsWindowWin* Create(); | 27 static RemovableDeviceNotificationsWindowWin* Create(); |
| 26 | 28 |
| 27 virtual ~RemovableDeviceNotificationsWindowWin(); | 29 virtual ~RemovableDeviceNotificationsWindowWin(); |
| 28 | 30 |
| 29 // base::SystemMonitor has a lifetime somewhat shorter than a Singleton and | 31 // base::SystemMonitor has a lifetime somewhat shorter than a Singleton and |
| 30 // |this| is constructed/destroyed just after/before SystemMonitor. | 32 // |this| is constructed/destroyed just after/before SystemMonitor. |
| 31 static RemovableDeviceNotificationsWindowWin* GetInstance(); | 33 static RemovableDeviceNotificationsWindowWin* GetInstance(); |
| 32 | 34 |
| 33 // Must be called after the file thread is created. | 35 // Must be called after the file thread is created. |
| 34 void Init(); | 36 void Init(); |
| 35 | 37 |
| 36 // Finds the device that contains |path| and populates |device_info|. | 38 // Finds the device that contains |path| and populates |device_info|. |
| 37 // Returns false if unable to find the device. | 39 // Returns false if unable to find the device. |
| 38 bool GetDeviceInfoForPath( | 40 bool GetDeviceInfoForPath( |
| 39 const FilePath& path, | 41 const FilePath& path, |
| 40 base::SystemMonitor::RemovableStorageInfo* device_info); | 42 base::SystemMonitor::RemovableStorageInfo* device_info); |
| 41 | 43 |
| 42 private: | 44 private: |
| 43 friend class TestRemovableDeviceNotificationsWindowWin; | 45 friend class TestRemovableDeviceNotificationsWindowWin; |
| 44 | 46 |
| 45 explicit RemovableDeviceNotificationsWindowWin( | 47 RemovableDeviceNotificationsWindowWin( |
| 46 VolumeMountWatcherWin* volume_mount_watcher); | 48 VolumeMountWatcherWin* volume_mount_watcher, |
| 49 PortableDeviceWatcherWin* portable_device_watcher); |
| 47 | 50 |
| 48 // Gets the removable storage information given a |device_path|. On success, | 51 // Gets the removable storage information given a |device_path|. On success, |
| 49 // returns true and fills in |device_location|, |unique_id|, |name| and | 52 // returns true and fills in |device_location|, |unique_id|, |name| and |
| 50 // |removable|. | 53 // |removable|. |
| 51 bool GetDeviceInfo(const FilePath& device_path, | 54 bool GetDeviceInfo(const FilePath& device_path, |
| 52 string16* device_location, | 55 string16* device_location, |
| 53 std::string* unique_id, | 56 std::string* unique_id, |
| 54 string16* name, | 57 string16* name, |
| 55 bool* removable); | 58 bool* removable); |
| 56 | 59 |
| 57 static LRESULT CALLBACK WndProcThunk(HWND hwnd, UINT message, WPARAM wparam, | 60 static LRESULT CALLBACK WndProcThunk(HWND hwnd, UINT message, WPARAM wparam, |
| 58 LPARAM lparam); | 61 LPARAM lparam); |
| 59 | 62 |
| 60 LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wparam, | 63 LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wparam, |
| 61 LPARAM lparam); | 64 LPARAM lparam); |
| 62 | 65 |
| 63 void OnDeviceChange(UINT event_type, LPARAM data); | 66 void OnDeviceChange(UINT event_type, LPARAM data); |
| 64 | 67 |
| 65 // The window class of |window_|. | 68 // The window class of |window_|. |
| 66 ATOM window_class_; | 69 ATOM window_class_; |
| 67 | 70 |
| 68 // The handle of the module that contains the window procedure of |window_|. | 71 // The handle of the module that contains the window procedure of |window_|. |
| 69 HMODULE instance_; | 72 HMODULE instance_; |
| 70 HWND window_; | 73 HWND window_; |
| 71 | 74 |
| 75 // Manages portable device notification handle for |
| 76 // RemovableDeviceNotificationsWindowWin. |
| 77 class PortableDeviceNotifications; |
| 78 scoped_ptr<PortableDeviceNotifications> portable_device_notifications_; |
| 79 |
| 72 // Store the volume mount point watcher to manage the mounted devices. | 80 // Store the volume mount point watcher to manage the mounted devices. |
| 73 scoped_refptr<VolumeMountWatcherWin> volume_mount_watcher_; | 81 scoped_refptr<VolumeMountWatcherWin> volume_mount_watcher_; |
| 74 | 82 |
| 83 // Store the portable device watcher to manage mtp devices. |
| 84 scoped_ptr<PortableDeviceWatcherWin> portable_device_watcher_; |
| 85 |
| 75 DISALLOW_COPY_AND_ASSIGN(RemovableDeviceNotificationsWindowWin); | 86 DISALLOW_COPY_AND_ASSIGN(RemovableDeviceNotificationsWindowWin); |
| 76 }; | 87 }; |
| 77 | 88 |
| 78 } // namespace chrome | 89 } // namespace chrome |
| 79 | 90 |
| 80 #endif // CHROME_BROWSER_SYSTEM_MONITOR_REMOVABLE_DEVICE_NOTIFICATIONS_WINDOW_W
IN_H_ | 91 #endif // CHROME_BROWSER_SYSTEM_MONITOR_REMOVABLE_DEVICE_NOTIFICATIONS_WINDOW_W
IN_H_ |
| OLD | NEW |