| 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_MANAGER_EVENT_ROUTER_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_EXTENSIONS_FILE_MANAGER_EVENT_ROUTER_H_ |
| 6 #define CHROME_BROWSER_CHROMEOS_EXTENSIONS_FILE_MANAGER_EVENT_ROUTER_H_ | 6 #define CHROME_BROWSER_CHROMEOS_EXTENSIONS_FILE_MANAGER_EVENT_ROUTER_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| 11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
| 12 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
| 13 #include "base/files/file_path_watcher.h" | 13 #include "base/files/file_path_watcher.h" |
| 14 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
| 15 #include "chrome/browser/chromeos/drive/drive_integration_service.h" | 15 #include "chrome/browser/chromeos/drive/drive_integration_service.h" |
| 16 #include "chrome/browser/chromeos/drive/file_system_observer.h" | 16 #include "chrome/browser/chromeos/drive/file_system_observer.h" |
| 17 #include "chrome/browser/chromeos/drive/job_list.h" | 17 #include "chrome/browser/chromeos/drive/job_list.h" |
| 18 #include "chrome/browser/chromeos/drive/sync_client.h" | 18 #include "chrome/browser/chromeos/drive/sync_client.h" |
| 19 #include "chrome/browser/chromeos/file_manager/file_watcher.h" | 19 #include "chrome/browser/chromeos/file_manager/file_watcher.h" |
| 20 #include "chrome/browser/chromeos/file_manager/fileapi_util.h" | 20 #include "chrome/browser/chromeos/file_manager/fileapi_util.h" |
| 21 #include "chrome/browser/chromeos/file_manager/volume_manager.h" | 21 #include "chrome/browser/chromeos/file_manager/volume_manager.h" |
| 22 #include "chrome/browser/chromeos/file_manager/volume_manager_observer.h" | 22 #include "chrome/browser/chromeos/file_manager/volume_manager_observer.h" |
| 23 #include "chrome/browser/drive/drive_service_interface.h" | 23 #include "chrome/browser/drive/drive_service_interface.h" |
| 24 #include "chrome/browser/ui/ash/multi_user/multi_user_window_manager.h" | |
| 25 #include "chrome/common/extensions/api/file_browser_private.h" | 24 #include "chrome/common/extensions/api/file_browser_private.h" |
| 26 #include "chromeos/disks/disk_mount_manager.h" | 25 #include "chromeos/disks/disk_mount_manager.h" |
| 27 #include "chromeos/network/network_state_handler_observer.h" | 26 #include "chromeos/network/network_state_handler_observer.h" |
| 28 #include "content/public/browser/notification_observer.h" | |
| 29 #include "content/public/browser/notification_registrar.h" | |
| 30 #include "webkit/browser/fileapi/file_system_operation.h" | 27 #include "webkit/browser/fileapi/file_system_operation.h" |
| 31 | 28 |
| 32 class PrefChangeRegistrar; | 29 class PrefChangeRegistrar; |
| 33 class Profile; | 30 class Profile; |
| 34 | 31 |
| 35 using file_manager::util::EntryDefinition; | 32 using file_manager::util::EntryDefinition; |
| 36 | 33 |
| 37 namespace base { | 34 namespace base { |
| 38 class ListValue; | 35 class ListValue; |
| 39 } | 36 } |
| 40 | 37 |
| 41 namespace chromeos { | 38 namespace chromeos { |
| 42 class NetworkState; | 39 class NetworkState; |
| 43 } | 40 } |
| 44 | 41 |
| 45 namespace drive { | 42 namespace drive { |
| 46 class FileChange; | 43 class FileChange; |
| 47 } | 44 } |
| 48 | 45 |
| 49 namespace file_manager { | 46 namespace file_manager { |
| 50 class DeviceEventRouter; | 47 class DeviceEventRouter; |
| 51 | 48 |
| 52 // Monitors changes in disk mounts, network connection state and preferences | 49 // Monitors changes in disk mounts, network connection state and preferences |
| 53 // affecting File Manager. Dispatches appropriate File Browser events. | 50 // affecting File Manager. Dispatches appropriate File Browser events. |
| 54 class EventRouter | 51 class EventRouter : public chromeos::NetworkStateHandlerObserver, |
| 55 : public chromeos::NetworkStateHandlerObserver, | 52 public drive::FileSystemObserver, |
| 56 public drive::FileSystemObserver, | 53 public drive::JobListObserver, |
| 57 public drive::JobListObserver, | 54 public drive::DriveServiceObserver, |
| 58 public drive::DriveServiceObserver, | 55 public VolumeManagerObserver { |
| 59 public VolumeManagerObserver, | |
| 60 public content::NotificationObserver, | |
| 61 public chrome::MultiUserWindowManager::Observer { | |
| 62 public: | 56 public: |
| 63 explicit EventRouter(Profile* profile); | 57 explicit EventRouter(Profile* profile); |
| 64 virtual ~EventRouter(); | 58 virtual ~EventRouter(); |
| 65 | 59 |
| 66 void Shutdown(); | 60 void Shutdown(); |
| 67 | 61 |
| 68 // Starts observing file system change events. | 62 // Starts observing file system change events. |
| 69 void ObserveEvents(); | 63 void ObserveEvents(); |
| 70 | 64 |
| 71 typedef base::Callback<void(bool success)> BoolCallback; | 65 typedef base::Callback<void(bool success)> BoolCallback; |
| (...skipping 17 matching lines...) Expand all Loading... |
| 89 int copy_id, const GURL& source_url, const GURL& destination_url, | 83 int copy_id, const GURL& source_url, const GURL& destination_url, |
| 90 base::File::Error error); | 84 base::File::Error error); |
| 91 | 85 |
| 92 // Called when a copy task progress is updated. | 86 // Called when a copy task progress is updated. |
| 93 void OnCopyProgress(int copy_id, | 87 void OnCopyProgress(int copy_id, |
| 94 storage::FileSystemOperation::CopyProgressType type, | 88 storage::FileSystemOperation::CopyProgressType type, |
| 95 const GURL& source_url, | 89 const GURL& source_url, |
| 96 const GURL& destination_url, | 90 const GURL& destination_url, |
| 97 int64 size); | 91 int64 size); |
| 98 | 92 |
| 99 // Register observer to the multi user window manager. | |
| 100 void RegisterMultiUserWindowManagerObserver(); | |
| 101 | |
| 102 // chromeos::NetworkStateHandlerObserver overrides. | 93 // chromeos::NetworkStateHandlerObserver overrides. |
| 103 virtual void DefaultNetworkChanged( | 94 virtual void DefaultNetworkChanged( |
| 104 const chromeos::NetworkState* network) OVERRIDE; | 95 const chromeos::NetworkState* network) OVERRIDE; |
| 105 | 96 |
| 106 // drive::JobListObserver overrides. | 97 // drive::JobListObserver overrides. |
| 107 virtual void OnJobAdded(const drive::JobInfo& job_info) OVERRIDE; | 98 virtual void OnJobAdded(const drive::JobInfo& job_info) OVERRIDE; |
| 108 virtual void OnJobUpdated(const drive::JobInfo& job_info) OVERRIDE; | 99 virtual void OnJobUpdated(const drive::JobInfo& job_info) OVERRIDE; |
| 109 virtual void OnJobDone(const drive::JobInfo& job_info, | 100 virtual void OnJobDone(const drive::JobInfo& job_info, |
| 110 drive::FileError error) OVERRIDE; | 101 drive::FileError error) OVERRIDE; |
| 111 | 102 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 128 virtual void OnDeviceRemoved(const std::string& device_path) OVERRIDE; | 119 virtual void OnDeviceRemoved(const std::string& device_path) OVERRIDE; |
| 129 virtual void OnVolumeMounted(chromeos::MountError error_code, | 120 virtual void OnVolumeMounted(chromeos::MountError error_code, |
| 130 const VolumeInfo& volume_info) OVERRIDE; | 121 const VolumeInfo& volume_info) OVERRIDE; |
| 131 virtual void OnVolumeUnmounted(chromeos::MountError error_code, | 122 virtual void OnVolumeUnmounted(chromeos::MountError error_code, |
| 132 const VolumeInfo& volume_info) OVERRIDE; | 123 const VolumeInfo& volume_info) OVERRIDE; |
| 133 virtual void OnFormatStarted( | 124 virtual void OnFormatStarted( |
| 134 const std::string& device_path, bool success) OVERRIDE; | 125 const std::string& device_path, bool success) OVERRIDE; |
| 135 virtual void OnFormatCompleted( | 126 virtual void OnFormatCompleted( |
| 136 const std::string& device_path, bool success) OVERRIDE; | 127 const std::string& device_path, bool success) OVERRIDE; |
| 137 | 128 |
| 138 // content::NotificationObserver overrides. | |
| 139 virtual void Observe(int type, | |
| 140 const content::NotificationSource& source, | |
| 141 const content::NotificationDetails& details) OVERRIDE; | |
| 142 | |
| 143 // chrome::MultiUserWindowManager::Observer overrides: | |
| 144 virtual void OnOwnerEntryChanged(aura::Window* window) OVERRIDE; | |
| 145 | |
| 146 private: | 129 private: |
| 147 typedef std::map<base::FilePath, FileWatcher*> WatcherMap; | 130 typedef std::map<base::FilePath, FileWatcher*> WatcherMap; |
| 148 | 131 |
| 149 // Called when prefs related to file manager change. | 132 // Called when prefs related to file manager change. |
| 150 void OnFileManagerPrefsChanged(); | 133 void OnFileManagerPrefsChanged(); |
| 151 | 134 |
| 152 // Process file watch notifications. | 135 // Process file watch notifications. |
| 153 void HandleFileWatchNotification(const drive::FileChange* list, | 136 void HandleFileWatchNotification(const drive::FileChange* list, |
| 154 const base::FilePath& path, | 137 const base::FilePath& path, |
| 155 bool got_error); | 138 bool got_error); |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 195 std::string status; | 178 std::string status; |
| 196 }; | 179 }; |
| 197 std::map<drive::JobID, DriveJobInfoWithStatus> drive_jobs_; | 180 std::map<drive::JobID, DriveJobInfoWithStatus> drive_jobs_; |
| 198 base::Time last_file_transfer_event_; | 181 base::Time last_file_transfer_event_; |
| 199 base::Time last_copy_progress_event_; | 182 base::Time last_copy_progress_event_; |
| 200 | 183 |
| 201 WatcherMap file_watchers_; | 184 WatcherMap file_watchers_; |
| 202 scoped_ptr<PrefChangeRegistrar> pref_change_registrar_; | 185 scoped_ptr<PrefChangeRegistrar> pref_change_registrar_; |
| 203 Profile* profile_; | 186 Profile* profile_; |
| 204 | 187 |
| 205 content::NotificationRegistrar notification_registrar_; | |
| 206 bool multi_user_window_manager_observer_registered_; | |
| 207 | |
| 208 scoped_ptr<DeviceEventRouter> device_event_router_; | 188 scoped_ptr<DeviceEventRouter> device_event_router_; |
| 209 | 189 |
| 210 // Note: This should remain the last member so it'll be destroyed and | 190 // Note: This should remain the last member so it'll be destroyed and |
| 211 // invalidate the weak pointers before any other members are destroyed. | 191 // invalidate the weak pointers before any other members are destroyed. |
| 212 base::WeakPtrFactory<EventRouter> weak_factory_; | 192 base::WeakPtrFactory<EventRouter> weak_factory_; |
| 213 DISALLOW_COPY_AND_ASSIGN(EventRouter); | 193 DISALLOW_COPY_AND_ASSIGN(EventRouter); |
| 214 }; | 194 }; |
| 215 | 195 |
| 216 } // namespace file_manager | 196 } // namespace file_manager |
| 217 | 197 |
| 218 #endif // CHROME_BROWSER_CHROMEOS_EXTENSIONS_FILE_MANAGER_EVENT_ROUTER_H_ | 198 #endif // CHROME_BROWSER_CHROMEOS_EXTENSIONS_FILE_MANAGER_EVENT_ROUTER_H_ |
| OLD | NEW |