Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(298)

Side by Side Diff: chrome/browser/chromeos/extensions/file_browser_event_router.h

Issue 7599015: Revert 94812 - Formatting feature initial commit for ChromeOS Tree (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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>
11 #include <string> 11 #include <string>
12 12
13 #include "base/files/file_path_watcher.h" 13 #include "base/files/file_path_watcher.h"
14 #include "base/memory/linked_ptr.h" 14 #include "base/memory/linked_ptr.h"
15 #include "base/memory/scoped_ptr.h" 15 #include "base/memory/scoped_ptr.h"
16 #include "base/string16.h" 16 #include "base/string16.h"
17 #include "base/synchronization/lock.h" 17 #include "base/synchronization/lock.h"
18 #include "chrome/browser/chromeos/cros/mount_library.h" 18 #include "chrome/browser/chromeos/cros/mount_library.h"
19 19
20 class Profile; 20 class Profile;
21 21
22 namespace chromeos { 22 namespace chromeos {
23 class SystemNotification; 23 class SystemNotification;
24 } 24 }
25 25
26 // Used to monitor disk mount changes and signal when new mounted usb device is 26 // Used to monitor disk mount changes and signal when new mounted usb device is
27 // found. 27 // found.
28 class ExtensionFileBrowserEventRouter 28 class ExtensionFileBrowserEventRouter
29 : public chromeos::MountLibrary::Observer { 29 : public chromeos::MountLibrary::Observer {
30
31 friend void HideFileBrowserNotificationExternally(
32 const std::string& category, const std::string& system_path,
33 ExtensionFileBrowserEventRouter* that);
34
35 public: 30 public:
36 explicit ExtensionFileBrowserEventRouter(Profile* profile); 31 explicit ExtensionFileBrowserEventRouter(Profile* profile);
37 virtual ~ExtensionFileBrowserEventRouter(); 32 virtual ~ExtensionFileBrowserEventRouter();
38 // Starts observing file system change events. Currently only 33 // Starts observing file system change events. Currently only
39 // MountLibrary events are being observed. 34 // MountLibrary events are being observed.
40 void ObserveFileSystemEvents(); 35 void ObserveFileSystemEvents();
41 36
42 // File watch setup routines. 37 // File watch setup routines.
43 bool AddFileWatch(const FilePath& file_path, 38 bool AddFileWatch(const FilePath& file_path,
44 const FilePath& virtual_path, 39 const FilePath& virtual_path,
45 const std::string& extension_id); 40 const std::string& extension_id);
46 void RemoveFileWatch(const FilePath& file_path, 41 void RemoveFileWatch(const FilePath& file_path,
47 const std::string& extension_id); 42 const std::string& extension_id);
48 43
49 // MountLibrary::Observer overrides. 44 // MountLibrary::Observer overrides.
50 virtual void DiskChanged(chromeos::MountLibraryEventType event, 45 virtual void DiskChanged(chromeos::MountLibraryEventType event,
51 const chromeos::MountLibrary::Disk* disk) OVERRIDE; 46 const chromeos::MountLibrary::Disk* disk) OVERRIDE;
52 virtual void DeviceChanged(chromeos::MountLibraryEventType event, 47 virtual void DeviceChanged(chromeos::MountLibraryEventType event,
53 const std::string& device_path) OVERRIDE; 48 const std::string& device_path) OVERRIDE;
54 49
55 virtual void MountCompleted(chromeos::MountLibrary::MountEvent event_type, 50 virtual void MountCompleted(chromeos::MountLibrary::MountEvent event_type,
56 chromeos::MountError error_code, 51 chromeos::MountError error_code,
57 const chromeos::MountLibrary::MountPointInfo& mount_info) OVERRIDE; 52 const chromeos::MountLibrary::MountPointInfo& mount_info) OVERRIDE;
58 53
59 private: 54 private:
60 typedef std::map<std::string, linked_ptr<chromeos::SystemNotification> > 55 typedef std::map<std::string, linked_ptr<chromeos::SystemNotification> >
61 NotificationMap; 56 NotificationMap;
62 typedef std::map<std::string, std::string> MountPointMap; 57 typedef std::map<std::string, std::string> MountPointMap;
63 typedef struct FileWatcherExtensions { 58 typedef struct FileWatcherExtensions {
64 FileWatcherExtensions(const FilePath& path, 59 FileWatcherExtensions(const FilePath& path, const std::string& extension_id) {
65 const std::string& extension_id) {
66 file_watcher.reset(new base::files::FilePathWatcher()); 60 file_watcher.reset(new base::files::FilePathWatcher());
67 virtual_path = path; 61 virtual_path = path;
68 extensions.insert(extension_id); 62 extensions.insert(extension_id);
69 } 63 }
70 ~FileWatcherExtensions() {} 64 ~FileWatcherExtensions() {}
71 linked_ptr<base::files::FilePathWatcher> file_watcher; 65 linked_ptr<base::files::FilePathWatcher> file_watcher;
72 FilePath local_path; 66 FilePath local_path;
73 FilePath virtual_path; 67 FilePath virtual_path;
74 std::set<std::string> extensions; 68 std::set<std::string> extensions;
75 } FileWatcherProcess; 69 } FileWatcherProcess;
(...skipping 11 matching lines...) Expand all
87 81
88 void HandleFileWatchOnUIThread(const FilePath& local_path, bool got_error); 82 void HandleFileWatchOnUIThread(const FilePath& local_path, bool got_error);
89 83
90 ExtensionFileBrowserEventRouter* router_; 84 ExtensionFileBrowserEventRouter* router_;
91 }; 85 };
92 86
93 // USB mount event handlers. 87 // USB mount event handlers.
94 void OnDiskAdded(const chromeos::MountLibrary::Disk* disk); 88 void OnDiskAdded(const chromeos::MountLibrary::Disk* disk);
95 void OnDiskRemoved(const chromeos::MountLibrary::Disk* disk); 89 void OnDiskRemoved(const chromeos::MountLibrary::Disk* disk);
96 void OnDiskChanged(const chromeos::MountLibrary::Disk* disk); 90 void OnDiskChanged(const chromeos::MountLibrary::Disk* disk);
97 void OnDiskMounted(const chromeos::MountLibrary::Disk* disk);
98 void OnDiskUnmounted(const chromeos::MountLibrary::Disk* disk);
99 void OnDeviceAdded(const std::string& device_path); 91 void OnDeviceAdded(const std::string& device_path);
100 void OnDeviceRemoved(const std::string& device_path); 92 void OnDeviceRemoved(const std::string& device_path);
101 void OnDeviceScanned(const std::string& device_path); 93 void OnDeviceScanned(const std::string& device_path);
102 void OnFormattingStarted(const std::string& device_path);
103 void OnFormattingFinished(const std::string& device_path);
104 94
105 // Finds first notifications corresponding to the same device. Ensures that 95 // Finds first notifications corresponding to the same device. Ensures that
106 // we don't pop up multiple notifications for the same device. 96 // we don't pop up multiple notifications for the same device.
107 NotificationMap::iterator FindNotificationForId(const std::string& path); 97 NotificationMap::iterator FindNotificationForPath(const std::string& path);
108 98
109 // Process file watch notifications. 99 // Process file watch notifications.
110 void HandleFileWatchNotification(const FilePath& path, 100 void HandleFileWatchNotification(const FilePath& path,
111 bool got_error); 101 bool got_error);
112 102
113 // Sends folder change event. 103 // Sends folder change event.
114 void DispatchFolderChangeEvent(const FilePath& path, bool error, 104 void DispatchFolderChangeEvent(const FilePath& path, bool error,
115 const std::set<std::string>& extensions); 105 const std::set<std::string>& extensions);
116 106
117 // Sends filesystem changed extension message to all renderers. 107 // Sends filesystem changed extension message to all renderers.
118 void DispatchMountEvent(const chromeos::MountLibrary::Disk* disk, bool added); 108 void DispatchMountEvent(const chromeos::MountLibrary::Disk* disk, bool added);
119 109
120 void DispatchMountCompletedEvent(chromeos::MountLibrary::MountEvent event, 110 void DispatchMountCompletedEvent(chromeos::MountLibrary::MountEvent event,
121 chromeos::MountError error_code, 111 chromeos::MountError error_code,
122 const chromeos::MountLibrary::MountPointInfo& mount_info); 112 const chromeos::MountLibrary::MountPointInfo& mount_info);
123 113
124 void RemoveBrowserFromVector(const std::string& path); 114 void RemoveBrowserFromVector(const std::string& path);
125 115
126 // Used to create a window of a standard size, and add it to a list 116 // Used to create a window of a standard size, and add it to a list
127 // of tracked browser windows in case that device goes away. 117 // of tracked browser windows in case that device goes away.
128 void OpenFileBrowse(const std::string& url, 118 void OpenFileBrowse(const std::string& url,
129 const std::string& device_path, 119 const std::string& device_path,
130 bool small); 120 bool small);
131 121
132 // Show/hide desktop notifications. 122 // Show/hide desktop notifications.
133 void ShowFileBrowserNotification(const std::string& category, 123 void ShowDeviceNotification(const std::string& system_path,
134 const std::string& system_path, 124 int icon_resource_id,
135 int icon_resource_id, 125 const string16& message);
136 const string16& title, 126 void HideDeviceNotification(const std::string& system_path);
137 const string16& message);
138 void HideFileBrowserNotification(const std::string& category,
139 const std::string& system_path);
140 127
141 scoped_refptr<FileWatcherDelegate> delegate_; 128 scoped_refptr<FileWatcherDelegate> delegate_;
142 MountPointMap mounted_devices_; 129 MountPointMap mounted_devices_;
143 NotificationMap notifications_; 130 NotificationMap notifications_;
144 WatcherMap file_watchers_; 131 WatcherMap file_watchers_;
145 Profile* profile_; 132 Profile* profile_;
146 base::Lock lock_; 133 base::Lock lock_;
147 134
148 DISALLOW_COPY_AND_ASSIGN(ExtensionFileBrowserEventRouter); 135 DISALLOW_COPY_AND_ASSIGN(ExtensionFileBrowserEventRouter);
149 }; 136 };
150 137
151 #endif // CHROME_BROWSER_CHROMEOS_EXTENSIONS_FILE_BROWSER_EVENT_ROUTER_H_ 138 #endif // CHROME_BROWSER_CHROMEOS_EXTENSIONS_FILE_BROWSER_EVENT_ROUTER_H_
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/cros/mount_library.cc ('k') | chrome/browser/chromeos/extensions/file_browser_event_router.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698