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: |
45 class PortableDeviceNotifications; | |
43 friend class TestRemovableDeviceNotificationsWindowWin; | 46 friend class TestRemovableDeviceNotificationsWindowWin; |
44 | 47 |
45 explicit RemovableDeviceNotificationsWindowWin( | 48 RemovableDeviceNotificationsWindowWin( |
Peter Kasting
2012/10/29 21:57:19
Nit: Add comments about why we take these objects
kmadhusu
2012/10/30 01:29:24
Done.
| |
46 VolumeMountWatcherWin* volume_mount_watcher); | 49 VolumeMountWatcherWin* volume_mount_watcher, |
50 PortableDeviceWatcherWin* portable_device_watcher); | |
47 | 51 |
48 // Gets the removable storage information given a |device_path|. On success, | 52 // Gets the removable storage information given a |device_path|. On success, |
49 // returns true and fills in |device_location|, |unique_id|, |name| and | 53 // returns true and fills in |device_location|, |unique_id|, |name| and |
50 // |removable|. | 54 // |removable|. |
51 bool GetDeviceInfo(const FilePath& device_path, | 55 bool GetDeviceInfo(const FilePath& device_path, |
52 string16* device_location, | 56 string16* device_location, |
53 std::string* unique_id, | 57 std::string* unique_id, |
54 string16* name, | 58 string16* name, |
55 bool* removable); | 59 bool* removable); |
56 | 60 |
57 static LRESULT CALLBACK WndProcThunk(HWND hwnd, UINT message, WPARAM wparam, | 61 static LRESULT CALLBACK WndProcThunk(HWND hwnd, UINT message, WPARAM wparam, |
58 LPARAM lparam); | 62 LPARAM lparam); |
59 | 63 |
60 LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wparam, | 64 LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wparam, |
61 LPARAM lparam); | 65 LPARAM lparam); |
62 | 66 |
63 void OnDeviceChange(UINT event_type, LPARAM data); | 67 void OnDeviceChange(UINT event_type, LPARAM data); |
64 | 68 |
65 // The window class of |window_|. | 69 // The window class of |window_|. |
66 ATOM window_class_; | 70 ATOM window_class_; |
67 | 71 |
68 // The handle of the module that contains the window procedure of |window_|. | 72 // The handle of the module that contains the window procedure of |window_|. |
69 HMODULE instance_; | 73 HMODULE instance_; |
70 HWND window_; | 74 HWND window_; |
71 | 75 |
76 // Manages portable device notification handle for | |
77 // RemovableDeviceNotificationsWindowWin. | |
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 |