| 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_CHROMEOS_EXTENSIONS_FILE_BROWSER_EVENT_ROUTER_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_EXTENSIONS_FILE_MANAGER_FILE_MANAGER_EVENT_ROUTE
R_H_ |
| 6 #define CHROME_BROWSER_CHROMEOS_EXTENSIONS_FILE_BROWSER_EVENT_ROUTER_H_ | 6 #define CHROME_BROWSER_CHROMEOS_EXTENSIONS_FILE_MANAGER_FILE_MANAGER_EVENT_ROUTE
R_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <set> | 9 #include <set> |
| 10 #include <string> | 10 #include <string> |
| 11 | 11 |
| 12 #include "base/files/file_path_watcher.h" | 12 #include "base/files/file_path_watcher.h" |
| 13 #include "base/memory/linked_ptr.h" | 13 #include "base/memory/linked_ptr.h" |
| 14 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
| 15 #include "base/string16.h" | 15 #include "base/string16.h" |
| 16 #include "base/synchronization/lock.h" | 16 #include "base/synchronization/lock.h" |
| 17 #include "chrome/browser/chromeos/drive/drive_file_system_observer.h" | 17 #include "chrome/browser/chromeos/drive/drive_file_system_observer.h" |
| 18 #include "chrome/browser/chromeos/drive/drive_resource_metadata.h" | 18 #include "chrome/browser/chromeos/drive/drive_resource_metadata.h" |
| 19 #include "chrome/browser/chromeos/net/connectivity_state_helper_observer.h" | 19 #include "chrome/browser/chromeos/net/connectivity_state_helper_observer.h" |
| 20 #include "chrome/browser/chromeos/system_key_event_listener.h" | 20 #include "chrome/browser/chromeos/system_key_event_listener.h" |
| 21 #include "chrome/browser/google_apis/drive_service_interface.h" | 21 #include "chrome/browser/google_apis/drive_service_interface.h" |
| 22 #include "chrome/browser/google_apis/operation_registry.h" | 22 #include "chrome/browser/google_apis/operation_registry.h" |
| 23 #include "chromeos/disks/disk_mount_manager.h" | 23 #include "chromeos/disks/disk_mount_manager.h" |
| 24 | 24 |
| 25 class FileBrowserNotifications; | 25 class FileManagerNotifications; |
| 26 class PrefChangeRegistrar; | 26 class PrefChangeRegistrar; |
| 27 class Profile; | 27 class Profile; |
| 28 | 28 |
| 29 namespace drive { | 29 namespace drive { |
| 30 class DriveEntryProto; | 30 class DriveEntryProto; |
| 31 class DriveFileSystemInterface; | 31 class DriveFileSystemInterface; |
| 32 } | 32 } |
| 33 | 33 |
| 34 // Monitors changes in disk mounts, network connection state and preferences | 34 // Monitors changes in disk mounts, network connection state and preferences |
| 35 // affecting File Manager. Dispatches appropriate File Browser events. | 35 // affecting File Manager. Dispatches appropriate File Browser events. |
| 36 class FileBrowserEventRouter | 36 class FileManagerEventRouter |
| 37 : public chromeos::disks::DiskMountManager::Observer, | 37 : public chromeos::disks::DiskMountManager::Observer, |
| 38 public chromeos::ConnectivityStateHelperObserver, | 38 public chromeos::ConnectivityStateHelperObserver, |
| 39 public chromeos::SystemKeyEventListener::ModifiersObserver, | 39 public chromeos::SystemKeyEventListener::ModifiersObserver, |
| 40 public drive::DriveFileSystemObserver, | 40 public drive::DriveFileSystemObserver, |
| 41 public google_apis::DriveServiceObserver { | 41 public google_apis::DriveServiceObserver { |
| 42 public: | 42 public: |
| 43 // Interface that should keep track of the system state in regards to system | 43 // Interface that should keep track of the system state in regards to system |
| 44 // suspend and resume events. | 44 // suspend and resume events. |
| 45 // When the |IsResuming()| returns true, it should be able to check if a | 45 // When the |IsResuming()| returns true, it should be able to check if a |
| 46 // removable device was present before the was system suspended. | 46 // removable device was present before the was system suspended. |
| 47 class SuspendStateDelegate { | 47 class SuspendStateDelegate { |
| 48 public: | 48 public: |
| 49 virtual ~SuspendStateDelegate() {} | 49 virtual ~SuspendStateDelegate() {} |
| 50 | 50 |
| 51 // Returns true if the system has recently woken up. | 51 // Returns true if the system has recently woken up. |
| 52 virtual bool SystemIsResuming() const = 0; | 52 virtual bool SystemIsResuming() const = 0; |
| 53 // If system is resuming, returns true if the disk was present before the | 53 // If system is resuming, returns true if the disk was present before the |
| 54 // system suspend. Should return false if the system is not resuming. | 54 // system suspend. Should return false if the system is not resuming. |
| 55 virtual bool DiskWasPresentBeforeSuspend( | 55 virtual bool DiskWasPresentBeforeSuspend( |
| 56 const chromeos::disks::DiskMountManager::Disk& disk) const = 0; | 56 const chromeos::disks::DiskMountManager::Disk& disk) const = 0; |
| 57 }; | 57 }; |
| 58 | 58 |
| 59 explicit FileBrowserEventRouter(Profile* profile); | 59 explicit FileManagerEventRouter(Profile* profile); |
| 60 virtual ~FileBrowserEventRouter(); | 60 virtual ~FileManagerEventRouter(); |
| 61 | 61 |
| 62 void Shutdown(); | 62 void Shutdown(); |
| 63 | 63 |
| 64 // Starts observing file system change events. | 64 // Starts observing file system change events. |
| 65 void ObserveFileSystemEvents(); | 65 void ObserveFileSystemEvents(); |
| 66 | 66 |
| 67 typedef base::Callback<void(bool success)> BoolCallback; | 67 typedef base::Callback<void(bool success)> BoolCallback; |
| 68 | 68 |
| 69 // Adds a file watch at |local_path|, associated with |virtual_path|, for | 69 // Adds a file watch at |local_path|, associated with |virtual_path|, for |
| 70 // an extension with |extension_id|. | 70 // an extension with |extension_id|. |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 176 void OnDiskUnmounted(const chromeos::disks::DiskMountManager::Disk* disk); | 176 void OnDiskUnmounted(const chromeos::disks::DiskMountManager::Disk* disk); |
| 177 void OnDeviceAdded(const std::string& device_path); | 177 void OnDeviceAdded(const std::string& device_path); |
| 178 void OnDeviceRemoved(const std::string& device_path); | 178 void OnDeviceRemoved(const std::string& device_path); |
| 179 void OnDeviceScanned(const std::string& device_path); | 179 void OnDeviceScanned(const std::string& device_path); |
| 180 void OnFormatStarted(const std::string& device_path, bool success); | 180 void OnFormatStarted(const std::string& device_path, bool success); |
| 181 void OnFormatCompleted(const std::string& device_path, bool success); | 181 void OnFormatCompleted(const std::string& device_path, bool success); |
| 182 | 182 |
| 183 // Called on change to kExternalStorageDisabled pref. | 183 // Called on change to kExternalStorageDisabled pref. |
| 184 void OnExternalStorageDisabledChanged(); | 184 void OnExternalStorageDisabledChanged(); |
| 185 | 185 |
| 186 // Called when prefs related to file browser change. | 186 // Called when prefs related to file manager change. |
| 187 void OnFileBrowserPrefsChanged(); | 187 void OnFileManagerPrefsChanged(); |
| 188 | 188 |
| 189 // Process file watch notifications. | 189 // Process file watch notifications. |
| 190 void HandleFileWatchNotification(const base::FilePath& path, | 190 void HandleFileWatchNotification(const base::FilePath& path, |
| 191 bool got_error); | 191 bool got_error); |
| 192 | 192 |
| 193 // Sends directory change event. | 193 // Sends directory change event. |
| 194 void DispatchDirectoryChangeEvent(const base::FilePath& path, bool error, | 194 void DispatchDirectoryChangeEvent(const base::FilePath& path, bool error, |
| 195 const ExtensionUsageRegistry& extensions); | 195 const ExtensionUsageRegistry& extensions); |
| 196 | 196 |
| 197 void DispatchMountEvent( | 197 void DispatchMountEvent( |
| (...skipping 11 matching lines...) Expand all Loading... |
| 209 // Returns the DriveFileSystem for the current profile. | 209 // Returns the DriveFileSystem for the current profile. |
| 210 drive::DriveFileSystemInterface* GetRemoteFileSystem() const; | 210 drive::DriveFileSystemInterface* GetRemoteFileSystem() const; |
| 211 | 211 |
| 212 // Handles requests to start and stop periodic updates on remote file system. | 212 // Handles requests to start and stop periodic updates on remote file system. |
| 213 // When |start| is set to true, this function starts periodic updates only if | 213 // When |start| is set to true, this function starts periodic updates only if |
| 214 // it is not yet started; when |start| is set to false, this function stops | 214 // it is not yet started; when |start| is set to false, this function stops |
| 215 // periodic updates only if the number of outstanding update requests reaches | 215 // periodic updates only if the number of outstanding update requests reaches |
| 216 // zero. | 216 // zero. |
| 217 void HandleRemoteUpdateRequestOnUIThread(bool start); | 217 void HandleRemoteUpdateRequestOnUIThread(bool start); |
| 218 | 218 |
| 219 base::WeakPtrFactory<FileBrowserEventRouter> weak_factory_; | 219 base::WeakPtrFactory<FileManagerEventRouter> weak_factory_; |
| 220 base::FilePathWatcher::Callback file_watcher_callback_; | 220 base::FilePathWatcher::Callback file_watcher_callback_; |
| 221 WatcherMap file_watchers_; | 221 WatcherMap file_watchers_; |
| 222 scoped_ptr<FileBrowserNotifications> notifications_; | 222 scoped_ptr<FileManagerNotifications> notifications_; |
| 223 scoped_ptr<PrefChangeRegistrar> pref_change_registrar_; | 223 scoped_ptr<PrefChangeRegistrar> pref_change_registrar_; |
| 224 scoped_ptr<SuspendStateDelegate> suspend_state_delegate_; | 224 scoped_ptr<SuspendStateDelegate> suspend_state_delegate_; |
| 225 Profile* profile_; | 225 Profile* profile_; |
| 226 | 226 |
| 227 // Number of active update requests on the remote file system. | 227 // Number of active update requests on the remote file system. |
| 228 int num_remote_update_requests_; | 228 int num_remote_update_requests_; |
| 229 | 229 |
| 230 // Event router behavior depends on shift modifier status. This is designed | 230 // Event router behavior depends on shift modifier status. This is designed |
| 231 // for power users. | 231 // for power users. |
| 232 bool shift_pressed_; | 232 bool shift_pressed_; |
| 233 | 233 |
| 234 DISALLOW_COPY_AND_ASSIGN(FileBrowserEventRouter); | 234 DISALLOW_COPY_AND_ASSIGN(FileManagerEventRouter); |
| 235 }; | 235 }; |
| 236 | 236 |
| 237 #endif // CHROME_BROWSER_CHROMEOS_EXTENSIONS_FILE_BROWSER_EVENT_ROUTER_H_ | 237 #endif // CHROME_BROWSER_CHROMEOS_EXTENSIONS_FILE_MANAGER_FILE_MANAGER_EVENT_RO
UTER_H_ |
| OLD | NEW |