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_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 | 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/cros/network_library.h" | 17 #include "chrome/browser/chromeos/cros/network_library.h" |
18 #include "chrome/browser/chromeos/disks/disk_mount_manager.h" | 18 #include "chrome/browser/chromeos/disks/disk_mount_manager.h" |
19 #include "chrome/browser/chromeos/gdata/gdata_file_system_interface.h" | 19 #include "chrome/browser/chromeos/gdata/drive_file_system_interface.h" |
20 #include "chrome/browser/chromeos/gdata/operation_registry.h" | 20 #include "chrome/browser/chromeos/gdata/operation_registry.h" |
21 #include "chrome/browser/profiles/refcounted_profile_keyed_service.h" | 21 #include "chrome/browser/profiles/refcounted_profile_keyed_service.h" |
22 #include "chrome/browser/profiles/refcounted_profile_keyed_service_factory.h" | 22 #include "chrome/browser/profiles/refcounted_profile_keyed_service_factory.h" |
23 #include "content/public/browser/notification_details.h" | 23 #include "content/public/browser/notification_details.h" |
24 #include "content/public/browser/notification_observer.h" | 24 #include "content/public/browser/notification_observer.h" |
25 #include "content/public/browser/notification_source.h" | 25 #include "content/public/browser/notification_source.h" |
26 | 26 |
27 class FileBrowserNotifications; | 27 class FileBrowserNotifications; |
28 class PrefChangeRegistrar; | 28 class PrefChangeRegistrar; |
29 class Profile; | 29 class Profile; |
30 | 30 |
31 // Monitors changes in disk mounts, network connection state and preferences | 31 // Monitors changes in disk mounts, network connection state and preferences |
32 // affecting File Manager. Dispatches appropriate File Browser events. | 32 // affecting File Manager. Dispatches appropriate File Browser events. |
33 class FileBrowserEventRouter | 33 class FileBrowserEventRouter |
34 : public RefcountedProfileKeyedService, | 34 : public RefcountedProfileKeyedService, |
35 public chromeos::disks::DiskMountManager::Observer, | 35 public chromeos::disks::DiskMountManager::Observer, |
36 public chromeos::NetworkLibrary::NetworkManagerObserver, | 36 public chromeos::NetworkLibrary::NetworkManagerObserver, |
37 public content::NotificationObserver, | 37 public content::NotificationObserver, |
38 public gdata::OperationRegistry::Observer, | 38 public gdata::OperationRegistry::Observer, |
39 public gdata::GDataFileSystemInterface::Observer { | 39 public gdata::DriveFileSystemInterface::Observer { |
40 public: | 40 public: |
41 // RefcountedProfileKeyedService overrides. | 41 // RefcountedProfileKeyedService overrides. |
42 virtual void ShutdownOnUIThread() OVERRIDE; | 42 virtual void ShutdownOnUIThread() OVERRIDE; |
43 | 43 |
44 // Starts observing file system change events. Currently only | 44 // Starts observing file system change events. Currently only |
45 // CrosDisksClient events are being observed. | 45 // CrosDisksClient events are being observed. |
46 void ObserveFileSystemEvents(); | 46 void ObserveFileSystemEvents(); |
47 | 47 |
48 // File watch setup routines. | 48 // File watch setup routines. |
49 bool AddFileWatch(const FilePath& file_path, | 49 bool AddFileWatch(const FilePath& file_path, |
(...skipping 26 matching lines...) Expand all Loading... |
76 virtual void Observe(int type, | 76 virtual void Observe(int type, |
77 const content::NotificationSource& source, | 77 const content::NotificationSource& source, |
78 const content::NotificationDetails& details) OVERRIDE; | 78 const content::NotificationDetails& details) OVERRIDE; |
79 | 79 |
80 // OperationRegistry::Observer overrides. | 80 // OperationRegistry::Observer overrides. |
81 virtual void OnProgressUpdate( | 81 virtual void OnProgressUpdate( |
82 const std::vector<gdata::OperationRegistry::ProgressStatus>& list) | 82 const std::vector<gdata::OperationRegistry::ProgressStatus>& list) |
83 OVERRIDE; | 83 OVERRIDE; |
84 virtual void OnAuthenticationFailed() OVERRIDE; | 84 virtual void OnAuthenticationFailed() OVERRIDE; |
85 | 85 |
86 // gdata::GDataFileSystemInterface::Observer overrides. | 86 // gdata::DriveFileSystemInterface::Observer overrides. |
87 virtual void OnDirectoryChanged(const FilePath& directory_path) OVERRIDE; | 87 virtual void OnDirectoryChanged(const FilePath& directory_path) OVERRIDE; |
88 virtual void OnDocumentFeedFetched(int num_accumulated_entries) OVERRIDE; | 88 virtual void OnDocumentFeedFetched(int num_accumulated_entries) OVERRIDE; |
89 virtual void OnFileSystemMounted() OVERRIDE; | 89 virtual void OnFileSystemMounted() OVERRIDE; |
90 virtual void OnFileSystemBeingUnmounted() OVERRIDE; | 90 virtual void OnFileSystemBeingUnmounted() OVERRIDE; |
91 | 91 |
92 private: | 92 private: |
93 friend class FileBrowserEventRouterFactory; | 93 friend class FileBrowserEventRouterFactory; |
94 | 94 |
95 // Helper class for passing through file watch notification events. | 95 // Helper class for passing through file watch notification events. |
96 class FileWatcherDelegate : public base::files::FilePathWatcher::Delegate { | 96 class FileWatcherDelegate : public base::files::FilePathWatcher::Delegate { |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
175 const chromeos::disks::DiskMountManager::MountPointInfo& mount_info); | 175 const chromeos::disks::DiskMountManager::MountPointInfo& mount_info); |
176 | 176 |
177 void RemoveBrowserFromVector(const std::string& path); | 177 void RemoveBrowserFromVector(const std::string& path); |
178 | 178 |
179 // Used to create a window of a standard size, and add it to a list | 179 // Used to create a window of a standard size, and add it to a list |
180 // of tracked browser windows in case that device goes away. | 180 // of tracked browser windows in case that device goes away. |
181 void OpenFileBrowse(const std::string& url, | 181 void OpenFileBrowse(const std::string& url, |
182 const std::string& device_path, | 182 const std::string& device_path, |
183 bool small); | 183 bool small); |
184 | 184 |
185 // Returns the GDataFileSystem for the current profile. | 185 // Returns the DriveFileSystem for the current profile. |
186 gdata::GDataFileSystemInterface* GetRemoteFileSystem() const; | 186 gdata::DriveFileSystemInterface* GetRemoteFileSystem() const; |
187 | 187 |
188 // Handles requests to start and stop periodic updates on remote file system. | 188 // Handles requests to start and stop periodic updates on remote file system. |
189 // When |start| is set to true, this function starts periodic updates only if | 189 // When |start| is set to true, this function starts periodic updates only if |
190 // it is not yet started; when |start| is set to false, this function stops | 190 // it is not yet started; when |start| is set to false, this function stops |
191 // periodic updates only if the number of outstanding update requests reaches | 191 // periodic updates only if the number of outstanding update requests reaches |
192 // zero. | 192 // zero. |
193 void HandleRemoteUpdateRequestOnUIThread(bool start); | 193 void HandleRemoteUpdateRequestOnUIThread(bool start); |
194 | 194 |
195 // Used to implement MountDrive(). Called after the authentication. | 195 // Used to implement MountDrive(). Called after the authentication. |
196 void OnAuthenticated(const base::Closure& callback, | 196 void OnAuthenticated(const base::Closure& callback, |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
234 | 234 |
235 FileBrowserEventRouterFactory(); | 235 FileBrowserEventRouterFactory(); |
236 virtual ~FileBrowserEventRouterFactory(); | 236 virtual ~FileBrowserEventRouterFactory(); |
237 | 237 |
238 // ProfileKeyedServiceFactory: | 238 // ProfileKeyedServiceFactory: |
239 virtual scoped_refptr<RefcountedProfileKeyedService> BuildServiceInstanceFor( | 239 virtual scoped_refptr<RefcountedProfileKeyedService> BuildServiceInstanceFor( |
240 Profile* profile) const OVERRIDE; | 240 Profile* profile) const OVERRIDE; |
241 }; | 241 }; |
242 | 242 |
243 #endif // CHROME_BROWSER_CHROMEOS_EXTENSIONS_FILE_BROWSER_EVENT_ROUTER_H_ | 243 #endif // CHROME_BROWSER_CHROMEOS_EXTENSIONS_FILE_BROWSER_EVENT_ROUTER_H_ |
OLD | NEW |