| 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 <map> | 9 #include <map> |
| 10 #include <set> | 10 #include <set> |
| (...skipping 28 matching lines...) Expand all Loading... |
| 39 const FilePath& virtual_path, | 39 const FilePath& virtual_path, |
| 40 const std::string& extension_id); | 40 const std::string& extension_id); |
| 41 void RemoveFileWatch(const FilePath& file_path, | 41 void RemoveFileWatch(const FilePath& file_path, |
| 42 const std::string& extension_id); | 42 const std::string& extension_id); |
| 43 | 43 |
| 44 // MountLibrary::Observer overrides. | 44 // MountLibrary::Observer overrides. |
| 45 virtual void DiskChanged(chromeos::MountLibraryEventType event, | 45 virtual void DiskChanged(chromeos::MountLibraryEventType event, |
| 46 const chromeos::MountLibrary::Disk* disk) OVERRIDE; | 46 const chromeos::MountLibrary::Disk* disk) OVERRIDE; |
| 47 virtual void DeviceChanged(chromeos::MountLibraryEventType event, | 47 virtual void DeviceChanged(chromeos::MountLibraryEventType event, |
| 48 const std::string& device_path) OVERRIDE; | 48 const std::string& device_path) OVERRIDE; |
| 49 | |
| 50 virtual void MountCompleted(chromeos::MountLibrary::MountEvent event_type, | 49 virtual void MountCompleted(chromeos::MountLibrary::MountEvent event_type, |
| 51 chromeos::MountError error_code, | 50 chromeos::MountError error_code, |
| 52 const chromeos::MountLibrary::MountPointInfo& mount_info) OVERRIDE; | 51 const chromeos::MountLibrary::MountPointInfo& mount_info) OVERRIDE; |
| 53 | 52 |
| 54 private: | 53 private: |
| 55 typedef std::map<std::string, linked_ptr<chromeos::SystemNotification> > | 54 typedef std::map<std::string, linked_ptr<chromeos::SystemNotification> > |
| 56 NotificationMap; | 55 NotificationMap; |
| 57 typedef std::map<std::string, std::string> MountPointMap; | 56 typedef std::map<std::string, std::string> MountPointMap; |
| 58 typedef struct FileWatcherExtensions { | 57 typedef struct FileWatcherExtensions { |
| 59 FileWatcherExtensions(const FilePath& path, const std::string& extension_id)
{ | 58 FileWatcherExtensions(const FilePath& path, |
| 59 const std::string& extension_id) { |
| 60 file_watcher.reset(new base::files::FilePathWatcher()); | 60 file_watcher.reset(new base::files::FilePathWatcher()); |
| 61 virtual_path = path; | 61 virtual_path = path; |
| 62 extensions.insert(extension_id); | 62 extensions.insert(extension_id); |
| 63 } | 63 } |
| 64 ~FileWatcherExtensions() {} | 64 ~FileWatcherExtensions() {} |
| 65 linked_ptr<base::files::FilePathWatcher> file_watcher; | 65 linked_ptr<base::files::FilePathWatcher> file_watcher; |
| 66 FilePath local_path; | 66 FilePath local_path; |
| 67 FilePath virtual_path; | 67 FilePath virtual_path; |
| 68 std::set<std::string> extensions; | 68 std::set<std::string> extensions; |
| 69 } FileWatcherProcess; | 69 } FileWatcherProcess; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 80 virtual void OnFilePathError(const FilePath& path) OVERRIDE; | 80 virtual void OnFilePathError(const FilePath& path) OVERRIDE; |
| 81 | 81 |
| 82 void HandleFileWatchOnUIThread(const FilePath& local_path, bool got_error); | 82 void HandleFileWatchOnUIThread(const FilePath& local_path, bool got_error); |
| 83 | 83 |
| 84 ExtensionFileBrowserEventRouter* router_; | 84 ExtensionFileBrowserEventRouter* router_; |
| 85 }; | 85 }; |
| 86 | 86 |
| 87 // USB mount event handlers. | 87 // USB mount event handlers. |
| 88 void OnDiskAdded(const chromeos::MountLibrary::Disk* disk); | 88 void OnDiskAdded(const chromeos::MountLibrary::Disk* disk); |
| 89 void OnDiskRemoved(const chromeos::MountLibrary::Disk* disk); | 89 void OnDiskRemoved(const chromeos::MountLibrary::Disk* disk); |
| 90 void OnDiskChanged(const chromeos::MountLibrary::Disk* disk); | |
| 91 void OnDeviceAdded(const std::string& device_path); | 90 void OnDeviceAdded(const std::string& device_path); |
| 92 void OnDeviceRemoved(const std::string& device_path); | 91 void OnDeviceRemoved(const std::string& device_path); |
| 93 void OnDeviceScanned(const std::string& device_path); | 92 void OnDeviceScanned(const std::string& device_path); |
| 94 | 93 |
| 95 // Finds first notifications corresponding to the same device. Ensures that | 94 // Finds first notifications corresponding to the same device. Ensures that |
| 96 // we don't pop up multiple notifications for the same device. | 95 // we don't pop up multiple notifications for the same device. |
| 97 NotificationMap::iterator FindNotificationForPath(const std::string& path); | 96 NotificationMap::iterator FindNotificationForPath(const std::string& path); |
| 98 | 97 |
| 99 // Process file watch notifications. | 98 // Process file watch notifications. |
| 100 void HandleFileWatchNotification(const FilePath& path, | 99 void HandleFileWatchNotification(const FilePath& path, |
| 101 bool got_error); | 100 bool got_error); |
| 102 | 101 |
| 103 // Sends folder change event. | 102 // Sends folder change event. |
| 104 void DispatchFolderChangeEvent(const FilePath& path, bool error, | 103 void DispatchFolderChangeEvent(const FilePath& path, bool error, |
| 105 const std::set<std::string>& extensions); | 104 const std::set<std::string>& extensions); |
| 106 | 105 |
| 107 // Sends filesystem changed extension message to all renderers. | 106 // Sends filesystem changed extension message to all renderers. |
| 108 void DispatchMountEvent(const chromeos::MountLibrary::Disk* disk, bool added); | 107 void DispatchDiskEvent(const chromeos::MountLibrary::Disk* disk, bool added); |
| 109 | 108 |
| 110 void DispatchMountCompletedEvent(chromeos::MountLibrary::MountEvent event, | 109 void DispatchMountCompletedEvent(chromeos::MountLibrary::MountEvent event, |
| 111 chromeos::MountError error_code, | 110 chromeos::MountError error_code, |
| 112 const chromeos::MountLibrary::MountPointInfo& mount_info); | 111 const chromeos::MountLibrary::MountPointInfo& mount_info); |
| 113 | 112 |
| 114 void RemoveBrowserFromVector(const std::string& path); | 113 void RemoveBrowserFromVector(const std::string& path); |
| 115 | 114 |
| 116 // Used to create a window of a standard size, and add it to a list | 115 // Used to create a window of a standard size, and add it to a list |
| 117 // of tracked browser windows in case that device goes away. | 116 // of tracked browser windows in case that device goes away. |
| 118 void OpenFileBrowse(const std::string& url, | 117 void OpenFileBrowse(const std::string& url, |
| (...skipping 10 matching lines...) Expand all Loading... |
| 129 MountPointMap mounted_devices_; | 128 MountPointMap mounted_devices_; |
| 130 NotificationMap notifications_; | 129 NotificationMap notifications_; |
| 131 WatcherMap file_watchers_; | 130 WatcherMap file_watchers_; |
| 132 Profile* profile_; | 131 Profile* profile_; |
| 133 base::Lock lock_; | 132 base::Lock lock_; |
| 134 | 133 |
| 135 DISALLOW_COPY_AND_ASSIGN(ExtensionFileBrowserEventRouter); | 134 DISALLOW_COPY_AND_ASSIGN(ExtensionFileBrowserEventRouter); |
| 136 }; | 135 }; |
| 137 | 136 |
| 138 #endif // CHROME_BROWSER_CHROMEOS_EXTENSIONS_FILE_BROWSER_EVENT_ROUTER_H_ | 137 #endif // CHROME_BROWSER_CHROMEOS_EXTENSIONS_FILE_BROWSER_EVENT_ROUTER_H_ |
| OLD | NEW |