OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_CHROMEOS_EXTENSIONS_FILE_BROWSER_EVENT_ROUTER_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_EXTENSIONS_FILE_BROWSER_EVENT_ROUTER_H_ |
6 #define CHROME_BROWSER_CHROMEOS_EXTENSIONS_FILE_BROWSER_EVENT_ROUTER_H_ | 6 #define CHROME_BROWSER_CHROMEOS_EXTENSIONS_FILE_BROWSER_EVENT_ROUTER_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 #include <map> | 10 #include <map> |
11 | 11 |
12 #include "base/memory/linked_ptr.h" | 12 #include "base/memory/linked_ptr.h" |
13 #include "base/string16.h" | 13 #include "base/string16.h" |
14 #include "chrome/browser/chromeos/cros/mount_library.h" | 14 #include "chrome/browser/chromeos/cros/mount_library.h" |
15 | 15 |
16 class Profile; | 16 class Profile; |
17 | 17 |
18 namespace chromeos { | 18 namespace chromeos { |
19 class SystemNotification; | 19 class SystemNotification; |
20 } | 20 } |
21 | 21 |
22 // Used to monitor disk mount changes and signal when new mounted usb device is | 22 // Used to monitor disk mount changes and signal when new mounted usb device is |
23 // found. | 23 // found. |
24 class ExtensionFileBrowserEventRouter | 24 class ExtensionFileBrowserEventRouter |
25 : public chromeos::MountLibrary::Observer { | 25 : public chromeos::MountLibrary::Observer { |
26 public: | 26 public: |
27 static ExtensionFileBrowserEventRouter* GetInstance(); | 27 explicit ExtensionFileBrowserEventRouter(Profile* profile); |
| 28 virtual ~ExtensionFileBrowserEventRouter(); |
28 | 29 |
29 // Starts/stops observing file system change events. Currently only | 30 // Starts/stops observing file system change events. Currently only |
30 // MountLibrary events are being observed. | 31 // MountLibrary events are being observed. |
31 void ObserveFileSystemEvents(Profile* profile); | 32 void ObserveFileSystemEvents(Profile* profile); |
32 void StopObservingFileSystemEvents(); | 33 void StopObservingFileSystemEvents(); |
33 | 34 |
34 // MountLibrary::Observer overrides. | 35 // MountLibrary::Observer overrides. |
35 virtual void DiskChanged(chromeos::MountLibraryEventType event, | 36 virtual void DiskChanged(chromeos::MountLibraryEventType event, |
36 const chromeos::MountLibrary::Disk* disk); | 37 const chromeos::MountLibrary::Disk* disk); |
37 virtual void DeviceChanged(chromeos::MountLibraryEventType event, | 38 virtual void DeviceChanged(chromeos::MountLibraryEventType event, |
38 const std::string& device_path); | 39 const std::string& device_path); |
39 | 40 |
40 private: | 41 private: |
41 friend struct DefaultSingletonTraits<ExtensionFileBrowserEventRouter>; | |
42 typedef std::map<std::string, linked_ptr<chromeos::SystemNotification> > | 42 typedef std::map<std::string, linked_ptr<chromeos::SystemNotification> > |
43 NotificationMap; | 43 NotificationMap; |
44 typedef std::map<std::string, std::string> MountPointMap; | 44 typedef std::map<std::string, std::string> MountPointMap; |
45 | 45 |
46 ExtensionFileBrowserEventRouter(); | |
47 virtual ~ExtensionFileBrowserEventRouter(); | |
48 | |
49 // USB mount event handlers. | 46 // USB mount event handlers. |
50 void OnDiskAdded(const chromeos::MountLibrary::Disk* disk); | 47 void OnDiskAdded(const chromeos::MountLibrary::Disk* disk); |
51 void OnDiskRemoved(const chromeos::MountLibrary::Disk* disk); | 48 void OnDiskRemoved(const chromeos::MountLibrary::Disk* disk); |
52 void OnDiskChanged(const chromeos::MountLibrary::Disk* disk); | 49 void OnDiskChanged(const chromeos::MountLibrary::Disk* disk); |
53 void OnDeviceAdded(const std::string& device_path); | 50 void OnDeviceAdded(const std::string& device_path); |
54 void OnDeviceRemoved(const std::string& device_path); | 51 void OnDeviceRemoved(const std::string& device_path); |
55 void OnDeviceScanned(const std::string& device_path); | 52 void OnDeviceScanned(const std::string& device_path); |
56 | 53 |
57 // Finds first notifications corresponding to the same device. Ensures that | 54 // Finds first notifications corresponding to the same device. Ensures that |
58 // we don't pop up multiple notifications for the same device. | 55 // we don't pop up multiple notifications for the same device. |
(...skipping 17 matching lines...) Expand all Loading... |
76 void HideDeviceNotification(const std::string& system_path); | 73 void HideDeviceNotification(const std::string& system_path); |
77 | 74 |
78 MountPointMap mounted_devices_; | 75 MountPointMap mounted_devices_; |
79 NotificationMap notifications_; | 76 NotificationMap notifications_; |
80 Profile* profile_; | 77 Profile* profile_; |
81 | 78 |
82 DISALLOW_COPY_AND_ASSIGN(ExtensionFileBrowserEventRouter); | 79 DISALLOW_COPY_AND_ASSIGN(ExtensionFileBrowserEventRouter); |
83 }; | 80 }; |
84 | 81 |
85 #endif // CHROME_BROWSER_CHROMEOS_EXTENSIONS_FILE_BROWSER_EVENT_ROUTER_H_ | 82 #endif // CHROME_BROWSER_CHROMEOS_EXTENSIONS_FILE_BROWSER_EVENT_ROUTER_H_ |
OLD | NEW |