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 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(); |
32 void StopObservingFileSystemEvents(); | |
33 | 33 |
34 // MountLibrary::Observer overrides. | 34 // MountLibrary::Observer overrides. |
35 virtual void DiskChanged(chromeos::MountLibraryEventType event, | 35 virtual void DiskChanged(chromeos::MountLibraryEventType event, |
36 const chromeos::MountLibrary::Disk* disk); | 36 const chromeos::MountLibrary::Disk* disk); |
37 virtual void DeviceChanged(chromeos::MountLibraryEventType event, | 37 virtual void DeviceChanged(chromeos::MountLibraryEventType event, |
38 const std::string& device_path); | 38 const std::string& device_path); |
39 | 39 |
40 private: | 40 private: |
41 friend struct DefaultSingletonTraits<ExtensionFileBrowserEventRouter>; | |
42 typedef std::map<std::string, linked_ptr<chromeos::SystemNotification> > | 41 typedef std::map<std::string, linked_ptr<chromeos::SystemNotification> > |
43 NotificationMap; | 42 NotificationMap; |
44 typedef std::map<std::string, std::string> MountPointMap; | 43 typedef std::map<std::string, std::string> MountPointMap; |
45 | 44 |
46 ExtensionFileBrowserEventRouter(); | |
47 virtual ~ExtensionFileBrowserEventRouter(); | |
48 | |
49 // USB mount event handlers. | 45 // USB mount event handlers. |
50 void OnDiskAdded(const chromeos::MountLibrary::Disk* disk); | 46 void OnDiskAdded(const chromeos::MountLibrary::Disk* disk); |
51 void OnDiskRemoved(const chromeos::MountLibrary::Disk* disk); | 47 void OnDiskRemoved(const chromeos::MountLibrary::Disk* disk); |
52 void OnDiskChanged(const chromeos::MountLibrary::Disk* disk); | 48 void OnDiskChanged(const chromeos::MountLibrary::Disk* disk); |
53 void OnDeviceAdded(const std::string& device_path); | 49 void OnDeviceAdded(const std::string& device_path); |
54 void OnDeviceRemoved(const std::string& device_path); | 50 void OnDeviceRemoved(const std::string& device_path); |
55 void OnDeviceScanned(const std::string& device_path); | 51 void OnDeviceScanned(const std::string& device_path); |
56 | 52 |
57 // Finds first notifications corresponding to the same device. Ensures that | 53 // Finds first notifications corresponding to the same device. Ensures that |
58 // we don't pop up multiple notifications for the same device. | 54 // 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); | 72 void HideDeviceNotification(const std::string& system_path); |
77 | 73 |
78 MountPointMap mounted_devices_; | 74 MountPointMap mounted_devices_; |
79 NotificationMap notifications_; | 75 NotificationMap notifications_; |
80 Profile* profile_; | 76 Profile* profile_; |
81 | 77 |
82 DISALLOW_COPY_AND_ASSIGN(ExtensionFileBrowserEventRouter); | 78 DISALLOW_COPY_AND_ASSIGN(ExtensionFileBrowserEventRouter); |
83 }; | 79 }; |
84 | 80 |
85 #endif // CHROME_BROWSER_CHROMEOS_EXTENSIONS_FILE_BROWSER_EVENT_ROUTER_H_ | 81 #endif // CHROME_BROWSER_CHROMEOS_EXTENSIONS_FILE_BROWSER_EVENT_ROUTER_H_ |
OLD | NEW |