OLD | NEW |
| (Empty) |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef CHROME_BROWSER_STORAGE_MONITOR_REMOVABLE_DEVICE_NOTIFICATIONS_WINDOW_WIN
_H_ | |
6 #define CHROME_BROWSER_STORAGE_MONITOR_REMOVABLE_DEVICE_NOTIFICATIONS_WINDOW_WIN
_H_ | |
7 | |
8 #include "base/basictypes.h" | |
9 #include "base/memory/ref_counted.h" | |
10 #include "base/memory/scoped_ptr.h" | |
11 #include "chrome/browser/storage_monitor/storage_monitor.h" | |
12 | |
13 namespace base { | |
14 class FilePath; | |
15 } | |
16 | |
17 namespace chrome { | |
18 | |
19 namespace test { | |
20 class TestRemovableDeviceNotificationsWindowWin; | |
21 } | |
22 | |
23 class PortableDeviceWatcherWin; | |
24 class VolumeMountWatcherWin; | |
25 | |
26 class RemovableDeviceNotificationsWindowWin : public StorageMonitor { | |
27 public: | |
28 // Creates an instance of RemovableDeviceNotificationsWindowWin. Should only | |
29 // be called by browser start up code. Use GetInstance() instead. | |
30 static RemovableDeviceNotificationsWindowWin* Create(); | |
31 | |
32 virtual ~RemovableDeviceNotificationsWindowWin(); | |
33 | |
34 // Must be called after the file thread is created. | |
35 void Init(); | |
36 | |
37 // StorageMonitor: | |
38 virtual bool GetStorageInfoForPath( | |
39 const base::FilePath& path, | |
40 StorageInfo* device_info) const OVERRIDE; | |
41 virtual bool GetMTPStorageInfoFromDeviceId( | |
42 const std::string& storage_device_id, | |
43 string16* device_location, | |
44 string16* storage_object_id) const OVERRIDE; | |
45 | |
46 virtual uint64 GetStorageSize( | |
47 const base::FilePath::StringType& location) const OVERRIDE; | |
48 | |
49 private: | |
50 class PortableDeviceNotifications; | |
51 friend class test::TestRemovableDeviceNotificationsWindowWin; | |
52 | |
53 // To support unit tests, this constructor takes |volume_mount_watcher| and | |
54 // |portable_device_watcher| objects. These params are either constructed in | |
55 // unit tests or in RemovableDeviceNotificationsWindowWin::Create() function. | |
56 RemovableDeviceNotificationsWindowWin( | |
57 VolumeMountWatcherWin* volume_mount_watcher, | |
58 PortableDeviceWatcherWin* portable_device_watcher); | |
59 | |
60 // Gets the removable storage information given a |device_path|. On success, | |
61 // returns true and fills in |device_location|, |unique_id|, |name| and | |
62 // |removable|, and |total_size_in_bytes|. | |
63 bool GetDeviceInfo(const base::FilePath& device_path, | |
64 string16* device_location, | |
65 std::string* unique_id, | |
66 string16* name, | |
67 bool* removable, | |
68 uint64* total_size_in_bytes) const; | |
69 | |
70 static LRESULT CALLBACK WndProcThunk(HWND hwnd, UINT message, WPARAM wparam, | |
71 LPARAM lparam); | |
72 | |
73 LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wparam, | |
74 LPARAM lparam); | |
75 | |
76 void OnDeviceChange(UINT event_type, LPARAM data); | |
77 | |
78 // The window class of |window_|. | |
79 ATOM window_class_; | |
80 | |
81 // The handle of the module that contains the window procedure of |window_|. | |
82 HMODULE instance_; | |
83 HWND window_; | |
84 | |
85 // The volume mount point watcher, used to manage the mounted devices. | |
86 scoped_ptr<VolumeMountWatcherWin> volume_mount_watcher_; | |
87 | |
88 // The portable device watcher, used to manage media transfer protocol | |
89 // devices. | |
90 scoped_ptr<PortableDeviceWatcherWin> portable_device_watcher_; | |
91 | |
92 DISALLOW_COPY_AND_ASSIGN(RemovableDeviceNotificationsWindowWin); | |
93 }; | |
94 | |
95 } // namespace chrome | |
96 | |
97 #endif // CHROME_BROWSER_STORAGE_MONITOR_REMOVABLE_DEVICE_NOTIFICATIONS_WINDOW_
WIN_H_ | |
OLD | NEW |