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 #include "chrome/browser/chromeos/extensions/file_browser_event_router.h" | 5 #include "chrome/browser/chromeos/extensions/file_browser_event_router.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/json/json_writer.h" | 8 #include "base/json/json_writer.h" |
9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
10 #include "base/stl_util.h" | 10 #include "base/stl_util.h" |
11 #include "base/values.h" | 11 #include "base/values.h" |
12 #include "chrome/browser/chromeos/cros/cros_library.h" | |
13 #include "chrome/browser/chromeos/extensions/file_browser_notifications.h" | 12 #include "chrome/browser/chromeos/extensions/file_browser_notifications.h" |
14 #include "chrome/browser/chromeos/login/user_manager.h" | 13 #include "chrome/browser/chromeos/login/user_manager.h" |
15 #include "chrome/browser/extensions/extension_event_names.h" | 14 #include "chrome/browser/extensions/extension_event_names.h" |
16 #include "chrome/browser/extensions/extension_event_router.h" | 15 #include "chrome/browser/extensions/extension_event_router.h" |
17 #include "chrome/browser/extensions/extension_service.h" | 16 #include "chrome/browser/extensions/extension_service.h" |
18 #include "chrome/browser/extensions/file_manager_util.h" | 17 #include "chrome/browser/extensions/file_manager_util.h" |
19 #include "chrome/browser/profiles/profile.h" | 18 #include "chrome/browser/profiles/profile.h" |
20 #include "grit/generated_resources.h" | 19 #include "grit/generated_resources.h" |
21 #include "webkit/fileapi/file_system_types.h" | 20 #include "webkit/fileapi/file_system_types.h" |
22 #include "webkit/fileapi/file_system_util.h" | 21 #include "webkit/fileapi/file_system_util.h" |
(...skipping 15 matching lines...) Expand all Loading... | |
38 return "hdd"; | 37 return "hdd"; |
39 case chromeos::OPTICAL: | 38 case chromeos::OPTICAL: |
40 return "optical"; | 39 return "optical"; |
41 default: | 40 default: |
42 break; | 41 break; |
43 } | 42 } |
44 return "undefined"; | 43 return "undefined"; |
45 } | 44 } |
46 | 45 |
47 DictionaryValue* DiskToDictionaryValue( | 46 DictionaryValue* DiskToDictionaryValue( |
48 const chromeos::MountLibrary::Disk* disk) { | 47 const chromeos::disks::DiskMountManager::Disk* disk) { |
49 DictionaryValue* result = new DictionaryValue(); | 48 DictionaryValue* result = new DictionaryValue(); |
50 result->SetString("mountPath", disk->mount_path()); | 49 result->SetString("mountPath", disk->mount_path()); |
51 result->SetString("devicePath", disk->device_path()); | 50 result->SetString("devicePath", disk->device_path()); |
52 result->SetString("label", disk->device_label()); | 51 result->SetString("label", disk->device_label()); |
53 result->SetString("deviceType", DeviceTypeToString(disk->device_type())); | 52 result->SetString("deviceType", DeviceTypeToString(disk->device_type())); |
54 result->SetInteger("totalSizeKB", disk->total_size() / 1024); | 53 result->SetInteger("totalSizeKB", disk->total_size_in_bytes() / 1024); |
55 result->SetBoolean("readOnly", disk->is_read_only()); | 54 result->SetBoolean("readOnly", disk->is_read_only()); |
56 return result; | 55 return result; |
57 } | 56 } |
58 } | 57 } |
59 | 58 |
60 const char* MountErrorToString(chromeos::MountError error) { | 59 const char* MountErrorToString(chromeos::MountError error) { |
61 switch (error) { | 60 switch (error) { |
62 case chromeos::MOUNT_ERROR_NONE: | 61 case chromeos::MOUNT_ERROR_NONE: |
63 return "success"; | 62 return "success"; |
64 case chromeos::MOUNT_ERROR_UNKNOWN: | 63 case chromeos::MOUNT_ERROR_UNKNOWN: |
(...skipping 23 matching lines...) Expand all Loading... | |
88 | 87 |
89 ExtensionFileBrowserEventRouter::~ExtensionFileBrowserEventRouter() { | 88 ExtensionFileBrowserEventRouter::~ExtensionFileBrowserEventRouter() { |
90 DCHECK(file_watchers_.empty()); | 89 DCHECK(file_watchers_.empty()); |
91 STLDeleteValues(&file_watchers_); | 90 STLDeleteValues(&file_watchers_); |
92 | 91 |
93 if (!profile_) { | 92 if (!profile_) { |
94 NOTREACHED(); | 93 NOTREACHED(); |
95 return; | 94 return; |
96 } | 95 } |
97 profile_ = NULL; | 96 profile_ = NULL; |
98 if (!chromeos::CrosLibrary::Get()->EnsureLoaded()) | 97 chromeos::disks::DiskMountManager* disk_mount_manager = |
99 return; | 98 chromeos::disks::DiskMountManager::GetInstance(); |
100 chromeos::MountLibrary* lib = | 99 disk_mount_manager->RemoveObserver(this); |
satorux1
2011/11/15 21:20:24
nit.
chromeos::disks::DiskMountManager::GetInstan
hashimoto
2011/11/16 04:28:15
Done.
| |
101 chromeos::CrosLibrary::Get()->GetMountLibrary(); | |
102 lib->RemoveObserver(this); | |
103 } | 100 } |
104 | 101 |
105 void ExtensionFileBrowserEventRouter::ObserveFileSystemEvents() { | 102 void ExtensionFileBrowserEventRouter::ObserveFileSystemEvents() { |
106 if (!profile_) { | 103 if (!profile_) { |
107 NOTREACHED(); | 104 NOTREACHED(); |
108 return; | 105 return; |
109 } | 106 } |
110 if (!chromeos::CrosLibrary::Get()->EnsureLoaded()) | |
111 return; | |
112 if (chromeos::UserManager::Get()->user_is_logged_in()) { | 107 if (chromeos::UserManager::Get()->user_is_logged_in()) { |
113 chromeos::MountLibrary* lib = | 108 chromeos::disks::DiskMountManager* disk_mount_manager = |
114 chromeos::CrosLibrary::Get()->GetMountLibrary(); | 109 chromeos::disks::DiskMountManager::GetInstance(); |
115 lib->RemoveObserver(this); | 110 disk_mount_manager->RemoveObserver(this); |
116 lib->AddObserver(this); | 111 disk_mount_manager->AddObserver(this); |
117 lib->RequestMountInfoRefresh(); | 112 disk_mount_manager->RequestMountInfoRefresh(); |
118 } | 113 } |
119 } | 114 } |
120 | 115 |
121 // File watch setup routines. | 116 // File watch setup routines. |
122 bool ExtensionFileBrowserEventRouter::AddFileWatch( | 117 bool ExtensionFileBrowserEventRouter::AddFileWatch( |
123 const FilePath& local_path, | 118 const FilePath& local_path, |
124 const FilePath& virtual_path, | 119 const FilePath& virtual_path, |
125 const std::string& extension_id) { | 120 const std::string& extension_id) { |
126 base::AutoLock lock(lock_); | 121 base::AutoLock lock(lock_); |
127 WatcherMap::iterator iter = file_watchers_.find(local_path); | 122 WatcherMap::iterator iter = file_watchers_.find(local_path); |
(...skipping 20 matching lines...) Expand all Loading... | |
148 return; | 143 return; |
149 // Remove the renderer process for this watch. | 144 // Remove the renderer process for this watch. |
150 iter->second->RemoveExtension(extension_id); | 145 iter->second->RemoveExtension(extension_id); |
151 if (iter->second->GetRefCount() == 0) { | 146 if (iter->second->GetRefCount() == 0) { |
152 delete iter->second; | 147 delete iter->second; |
153 file_watchers_.erase(iter); | 148 file_watchers_.erase(iter); |
154 } | 149 } |
155 } | 150 } |
156 | 151 |
157 void ExtensionFileBrowserEventRouter::DiskChanged( | 152 void ExtensionFileBrowserEventRouter::DiskChanged( |
158 chromeos::MountLibraryEventType event, | 153 chromeos::disks::DiskMountManagerEventType event, |
159 const chromeos::MountLibrary::Disk* disk) { | 154 const chromeos::disks::DiskMountManager::Disk* disk) { |
160 // Disregard hidden devices. | 155 // Disregard hidden devices. |
161 if (disk->is_hidden()) | 156 if (disk->is_hidden()) |
162 return; | 157 return; |
163 if (event == chromeos::MOUNT_DISK_ADDED) { | 158 if (event == chromeos::disks::MOUNT_DISK_ADDED) { |
164 OnDiskAdded(disk); | 159 OnDiskAdded(disk); |
165 } else if (event == chromeos::MOUNT_DISK_REMOVED) { | 160 } else if (event == chromeos::disks::MOUNT_DISK_REMOVED) { |
166 OnDiskRemoved(disk); | 161 OnDiskRemoved(disk); |
167 } | 162 } |
168 } | 163 } |
169 | 164 |
170 void ExtensionFileBrowserEventRouter::DeviceChanged( | 165 void ExtensionFileBrowserEventRouter::DeviceChanged( |
171 chromeos::MountLibraryEventType event, | 166 chromeos::disks::DiskMountManagerEventType event, |
172 const std::string& device_path) { | 167 const std::string& device_path) { |
173 if (event == chromeos::MOUNT_DEVICE_ADDED) { | 168 if (event == chromeos::disks::MOUNT_DEVICE_ADDED) { |
174 OnDeviceAdded(device_path); | 169 OnDeviceAdded(device_path); |
175 } else if (event == chromeos::MOUNT_DEVICE_REMOVED) { | 170 } else if (event == chromeos::disks::MOUNT_DEVICE_REMOVED) { |
176 OnDeviceRemoved(device_path); | 171 OnDeviceRemoved(device_path); |
177 } else if (event == chromeos::MOUNT_DEVICE_SCANNED) { | 172 } else if (event == chromeos::disks::MOUNT_DEVICE_SCANNED) { |
178 OnDeviceScanned(device_path); | 173 OnDeviceScanned(device_path); |
179 } else if (event == chromeos::MOUNT_FORMATTING_STARTED) { | 174 } else if (event == chromeos::disks::MOUNT_FORMATTING_STARTED) { |
180 // TODO(tbarzic): get rid of '!'. | 175 // TODO(tbarzic): get rid of '!'. |
181 if (device_path[0] == '!') { | 176 if (device_path[0] == '!') { |
182 OnFormattingStarted(device_path.substr(1), false); | 177 OnFormattingStarted(device_path.substr(1), false); |
183 } else { | 178 } else { |
184 OnFormattingStarted(device_path, true); | 179 OnFormattingStarted(device_path, true); |
185 } | 180 } |
186 } else if (event == chromeos::MOUNT_FORMATTING_FINISHED) { | 181 } else if (event == chromeos::disks::MOUNT_FORMATTING_FINISHED) { |
187 if (device_path[0] == '!') { | 182 if (device_path[0] == '!') { |
188 OnFormattingFinished(device_path.substr(1), false); | 183 OnFormattingFinished(device_path.substr(1), false); |
189 } else { | 184 } else { |
190 OnFormattingFinished(device_path, true); | 185 OnFormattingFinished(device_path, true); |
191 } | 186 } |
192 } | 187 } |
193 } | 188 } |
194 | 189 |
195 void ExtensionFileBrowserEventRouter::MountCompleted( | 190 void ExtensionFileBrowserEventRouter::MountCompleted( |
196 chromeos::MountLibrary::MountEvent event_type, | 191 chromeos::disks::DiskMountManager::MountEvent event_type, |
197 chromeos::MountError error_code, | 192 chromeos::MountError error_code, |
198 const chromeos::MountLibrary::MountPointInfo& mount_info) { | 193 const chromeos::disks::DiskMountManager::MountPointInfo& mount_info) { |
199 DispatchMountCompletedEvent(event_type, error_code, mount_info); | 194 DispatchMountCompletedEvent(event_type, error_code, mount_info); |
200 | 195 |
201 if (mount_info.mount_type == chromeos::MOUNT_TYPE_DEVICE && | 196 if (mount_info.mount_type == chromeos::MOUNT_TYPE_DEVICE && |
202 event_type == chromeos::MountLibrary::MOUNTING) { | 197 event_type == chromeos::disks::DiskMountManager::MOUNTING) { |
203 chromeos::MountLibrary* mount_lib = | 198 chromeos::disks::DiskMountManager* disk_mount_manager = |
204 chromeos::CrosLibrary::Get()->GetMountLibrary(); | 199 chromeos::disks::DiskMountManager::GetInstance(); |
205 chromeos::MountLibrary::DiskMap::const_iterator disk_it = | 200 chromeos::disks::DiskMountManager::DiskMap::const_iterator disk_it = |
206 mount_lib->disks().find(mount_info.source_path); | 201 disk_mount_manager->disks().find(mount_info.source_path); |
207 if (disk_it == mount_lib->disks().end()) { | 202 if (disk_it == disk_mount_manager->disks().end()) { |
208 return; | 203 return; |
209 } | 204 } |
210 chromeos::MountLibrary::Disk* disk = disk_it->second; | 205 chromeos::disks::DiskMountManager::Disk* disk = disk_it->second; |
211 | 206 |
212 notifications_->ManageNotificationsOnMountCompleted( | 207 notifications_->ManageNotificationsOnMountCompleted( |
213 disk->system_path_prefix(), disk->drive_label(), disk->is_parent(), | 208 disk->system_path_prefix(), disk->drive_label(), disk->is_parent(), |
214 error_code == chromeos::MOUNT_ERROR_NONE, | 209 error_code == chromeos::MOUNT_ERROR_NONE, |
215 error_code == chromeos::MOUNT_ERROR_UNSUPORTED_FILESYSTEM); | 210 error_code == chromeos::MOUNT_ERROR_UNSUPORTED_FILESYSTEM); |
216 } | 211 } |
217 } | 212 } |
218 | 213 |
219 void ExtensionFileBrowserEventRouter::HandleFileWatchNotification( | 214 void ExtensionFileBrowserEventRouter::HandleFileWatchNotification( |
220 const FilePath& local_path, bool got_error) { | 215 const FilePath& local_path, bool got_error) { |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
253 std::string args_json; | 248 std::string args_json; |
254 base::JSONWriter::Write(&args, false /* pretty_print */, &args_json); | 249 base::JSONWriter::Write(&args, false /* pretty_print */, &args_json); |
255 | 250 |
256 profile_->GetExtensionEventRouter()->DispatchEventToExtension( | 251 profile_->GetExtensionEventRouter()->DispatchEventToExtension( |
257 iter->first, extension_event_names::kOnFileChanged, args_json, | 252 iter->first, extension_event_names::kOnFileChanged, args_json, |
258 NULL, GURL()); | 253 NULL, GURL()); |
259 } | 254 } |
260 } | 255 } |
261 | 256 |
262 void ExtensionFileBrowserEventRouter::DispatchDiskEvent( | 257 void ExtensionFileBrowserEventRouter::DispatchDiskEvent( |
263 const chromeos::MountLibrary::Disk* disk, bool added) { | 258 const chromeos::disks::DiskMountManager::Disk* disk, bool added) { |
264 if (!profile_) { | 259 if (!profile_) { |
265 NOTREACHED(); | 260 NOTREACHED(); |
266 return; | 261 return; |
267 } | 262 } |
268 | 263 |
269 ListValue args; | 264 ListValue args; |
270 DictionaryValue* mount_info = new DictionaryValue(); | 265 DictionaryValue* mount_info = new DictionaryValue(); |
271 args.Append(mount_info); | 266 args.Append(mount_info); |
272 mount_info->SetString("eventType", | 267 mount_info->SetString("eventType", |
273 added ? kDiskAddedEventType : kDiskRemovedEventType); | 268 added ? kDiskAddedEventType : kDiskRemovedEventType); |
274 DictionaryValue* disk_info = DiskToDictionaryValue(disk); | 269 DictionaryValue* disk_info = DiskToDictionaryValue(disk); |
275 mount_info->Set("volumeInfo", disk_info); | 270 mount_info->Set("volumeInfo", disk_info); |
276 | 271 |
277 std::string args_json; | 272 std::string args_json; |
278 base::JSONWriter::Write(&args, false /* pretty_print */, &args_json); | 273 base::JSONWriter::Write(&args, false /* pretty_print */, &args_json); |
279 profile_->GetExtensionEventRouter()->DispatchEventToRenderers( | 274 profile_->GetExtensionEventRouter()->DispatchEventToRenderers( |
280 extension_event_names::kOnFileBrowserDiskChanged, args_json, NULL, | 275 extension_event_names::kOnFileBrowserDiskChanged, args_json, NULL, |
281 GURL()); | 276 GURL()); |
282 } | 277 } |
283 | 278 |
284 void ExtensionFileBrowserEventRouter::DispatchMountCompletedEvent( | 279 void ExtensionFileBrowserEventRouter::DispatchMountCompletedEvent( |
285 chromeos::MountLibrary::MountEvent event, | 280 chromeos::disks::DiskMountManager::MountEvent event, |
286 chromeos::MountError error_code, | 281 chromeos::MountError error_code, |
287 const chromeos::MountLibrary::MountPointInfo& mount_info) { | 282 const chromeos::disks::DiskMountManager::MountPointInfo& mount_info) { |
288 if (!profile_ || mount_info.mount_type == chromeos::MOUNT_TYPE_INVALID) { | 283 if (!profile_ || mount_info.mount_type == chromeos::MOUNT_TYPE_INVALID) { |
289 NOTREACHED(); | 284 NOTREACHED(); |
290 return; | 285 return; |
291 } | 286 } |
292 | 287 |
293 ListValue args; | 288 ListValue args; |
294 DictionaryValue* mount_info_value = new DictionaryValue(); | 289 DictionaryValue* mount_info_value = new DictionaryValue(); |
295 args.Append(mount_info_value); | 290 args.Append(mount_info_value); |
296 if (event == chromeos::MountLibrary::MOUNTING) { | 291 if (event == chromeos::disks::DiskMountManager::MOUNTING) { |
297 mount_info_value->SetString("eventType", "mount"); | 292 mount_info_value->SetString("eventType", "mount"); |
298 } else { | 293 } else { |
299 mount_info_value->SetString("eventType", "unmount"); | 294 mount_info_value->SetString("eventType", "unmount"); |
300 } | 295 } |
301 mount_info_value->SetString("status", MountErrorToString(error_code)); | 296 mount_info_value->SetString("status", MountErrorToString(error_code)); |
302 mount_info_value->SetString("mountType", | 297 mount_info_value->SetString( |
303 chromeos::MountLibrary::MountTypeToString(mount_info.mount_type)); | 298 "mountType", |
299 chromeos::disks::DiskMountManager::MountTypeToString( | |
300 mount_info.mount_type)); | |
304 | 301 |
305 if (mount_info.mount_type == chromeos::MOUNT_TYPE_ARCHIVE) { | 302 if (mount_info.mount_type == chromeos::MOUNT_TYPE_ARCHIVE) { |
306 GURL source_url; | 303 GURL source_url; |
307 if (FileManagerUtil::ConvertFileToFileSystemUrl(profile_, | 304 if (FileManagerUtil::ConvertFileToFileSystemUrl(profile_, |
308 FilePath(mount_info.source_path), | 305 FilePath(mount_info.source_path), |
309 FileManagerUtil::GetFileBrowserExtensionUrl().GetOrigin(), | 306 FileManagerUtil::GetFileBrowserExtensionUrl().GetOrigin(), |
310 &source_url)) { | 307 &source_url)) { |
311 mount_info_value->SetString("sourceUrl", source_url.spec()); | 308 mount_info_value->SetString("sourceUrl", source_url.spec()); |
312 } | 309 } |
313 } else { | 310 } else { |
(...skipping 20 matching lines...) Expand all Loading... | |
334 | 331 |
335 std::string args_json; | 332 std::string args_json; |
336 base::JSONWriter::Write(&args, false /* pretty_print */, &args_json); | 333 base::JSONWriter::Write(&args, false /* pretty_print */, &args_json); |
337 profile_->GetExtensionEventRouter()->DispatchEventToRenderers( | 334 profile_->GetExtensionEventRouter()->DispatchEventToRenderers( |
338 extension_event_names::kOnFileBrowserMountCompleted, args_json, NULL, | 335 extension_event_names::kOnFileBrowserMountCompleted, args_json, NULL, |
339 GURL()); | 336 GURL()); |
340 | 337 |
341 if (relative_mount_path_set && | 338 if (relative_mount_path_set && |
342 mount_info.mount_type == chromeos::MOUNT_TYPE_DEVICE && | 339 mount_info.mount_type == chromeos::MOUNT_TYPE_DEVICE && |
343 !mount_info.mount_condition && | 340 !mount_info.mount_condition && |
344 event == chromeos::MountLibrary::MOUNTING) { | 341 event == chromeos::disks::DiskMountManager::MOUNTING) { |
345 FileManagerUtil::ViewFolder(FilePath(mount_info.mount_path)); | 342 FileManagerUtil::ViewFolder(FilePath(mount_info.mount_path)); |
346 } | 343 } |
347 } | 344 } |
348 | 345 |
349 void ExtensionFileBrowserEventRouter::OnDiskAdded( | 346 void ExtensionFileBrowserEventRouter::OnDiskAdded( |
350 const chromeos::MountLibrary::Disk* disk) { | 347 const chromeos::disks::DiskMountManager::Disk* disk) { |
351 VLOG(1) << "Disk added: " << disk->device_path(); | 348 VLOG(1) << "Disk added: " << disk->device_path(); |
352 if (disk->device_path().empty()) { | 349 if (disk->device_path().empty()) { |
353 VLOG(1) << "Empty system path for " << disk->device_path(); | 350 VLOG(1) << "Empty system path for " << disk->device_path(); |
354 return; | 351 return; |
355 } | 352 } |
356 | 353 |
357 // If disk is not mounted yet, give it a try. | 354 // If disk is not mounted yet, give it a try. |
358 if (disk->mount_path().empty()) { | 355 if (disk->mount_path().empty()) { |
359 // Initiate disk mount operation. | 356 // Initiate disk mount operation. |
360 chromeos::MountLibrary* lib = | 357 chromeos::disks::DiskMountManager* disk_mount_manager = |
361 chromeos::CrosLibrary::Get()->GetMountLibrary(); | 358 chromeos::disks::DiskMountManager::GetInstance(); |
362 lib->MountPath(disk->device_path().c_str(), | 359 disk_mount_manager->MountPath( |
363 chromeos::MOUNT_TYPE_DEVICE, | 360 disk->device_path().c_str(), |
satorux1
2011/11/15 21:20:24
Please remove .c_str()
hashimoto
2011/11/16 04:28:15
Done.
| |
364 chromeos::MountPathOptions()); // Unused. | 361 chromeos::MOUNT_TYPE_DEVICE); |
365 } | 362 } |
366 DispatchDiskEvent(disk, true); | 363 DispatchDiskEvent(disk, true); |
367 } | 364 } |
368 | 365 |
369 void ExtensionFileBrowserEventRouter::OnDiskRemoved( | 366 void ExtensionFileBrowserEventRouter::OnDiskRemoved( |
370 const chromeos::MountLibrary::Disk* disk) { | 367 const chromeos::disks::DiskMountManager::Disk* disk) { |
371 VLOG(1) << "Disk removed: " << disk->device_path(); | 368 VLOG(1) << "Disk removed: " << disk->device_path(); |
372 | 369 |
373 if (!disk->mount_path().empty()) { | 370 if (!disk->mount_path().empty()) { |
374 chromeos::MountLibrary* lib = | 371 chromeos::disks::DiskMountManager* disk_mount_manager = |
375 chromeos::CrosLibrary::Get()->GetMountLibrary(); | 372 chromeos::disks::DiskMountManager::GetInstance(); |
376 lib->UnmountPath(disk->mount_path().c_str()); | 373 disk_mount_manager->UnmountPath(disk->mount_path().c_str()); |
satorux1
2011/11/15 21:20:24
ditto.
hashimoto
2011/11/16 04:28:15
Done.
| |
377 } | 374 } |
378 DispatchDiskEvent(disk, false); | 375 DispatchDiskEvent(disk, false); |
379 } | 376 } |
380 | 377 |
381 void ExtensionFileBrowserEventRouter::OnDeviceAdded( | 378 void ExtensionFileBrowserEventRouter::OnDeviceAdded( |
382 const std::string& device_path) { | 379 const std::string& device_path) { |
383 VLOG(1) << "Device added : " << device_path; | 380 VLOG(1) << "Device added : " << device_path; |
384 | 381 |
385 notifications_->RegisterDevice(device_path); | 382 notifications_->RegisterDevice(device_path); |
386 notifications_->ShowNotificationDelayed(FileBrowserNotifications::DEVICE, | 383 notifications_->ShowNotificationDelayed(FileBrowserNotifications::DEVICE, |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
418 const std::string& device_path, bool success) { | 415 const std::string& device_path, bool success) { |
419 if (success) { | 416 if (success) { |
420 notifications_->HideNotification(FileBrowserNotifications::FORMAT_START, | 417 notifications_->HideNotification(FileBrowserNotifications::FORMAT_START, |
421 device_path); | 418 device_path); |
422 notifications_->ShowNotification(FileBrowserNotifications::FORMAT_SUCCESS, | 419 notifications_->ShowNotification(FileBrowserNotifications::FORMAT_SUCCESS, |
423 device_path); | 420 device_path); |
424 // Hide it after a couple of seconds. | 421 // Hide it after a couple of seconds. |
425 notifications_->HideNotificationDelayed( | 422 notifications_->HideNotificationDelayed( |
426 FileBrowserNotifications::FORMAT_SUCCESS, device_path, 4000); | 423 FileBrowserNotifications::FORMAT_SUCCESS, device_path, 4000); |
427 | 424 |
428 chromeos::MountLibrary* lib = | 425 chromeos::disks::DiskMountManager* disk_mount_manager = |
429 chromeos::CrosLibrary::Get()->GetMountLibrary(); | 426 chromeos::disks::DiskMountManager::GetInstance(); |
430 lib->MountPath(device_path.c_str(), | 427 disk_mount_manager->MountPath( |
431 chromeos::MOUNT_TYPE_DEVICE, | 428 device_path.c_str(), |
satorux1
2011/11/15 21:20:24
ditto.
hashimoto
2011/11/16 04:28:15
Done.
| |
432 chromeos::MountPathOptions()); // Unused. | 429 chromeos::MOUNT_TYPE_DEVICE); |
433 } else { | 430 } else { |
434 notifications_->HideNotification(FileBrowserNotifications::FORMAT_START, | 431 notifications_->HideNotification(FileBrowserNotifications::FORMAT_START, |
435 device_path); | 432 device_path); |
436 notifications_->ShowNotification(FileBrowserNotifications::FORMAT_FAIL, | 433 notifications_->ShowNotification(FileBrowserNotifications::FORMAT_FAIL, |
437 device_path); | 434 device_path); |
438 } | 435 } |
439 } | 436 } |
440 | 437 |
441 // ExtensionFileBrowserEventRouter::WatcherDelegate methods. | 438 // ExtensionFileBrowserEventRouter::WatcherDelegate methods. |
442 ExtensionFileBrowserEventRouter::FileWatcherDelegate::FileWatcherDelegate( | 439 ExtensionFileBrowserEventRouter::FileWatcherDelegate::FileWatcherDelegate( |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
519 | 516 |
520 const FilePath& | 517 const FilePath& |
521 ExtensionFileBrowserEventRouter::FileWatcherExtensions::GetVirtualPath() const { | 518 ExtensionFileBrowserEventRouter::FileWatcherExtensions::GetVirtualPath() const { |
522 return virtual_path; | 519 return virtual_path; |
523 } | 520 } |
524 | 521 |
525 bool ExtensionFileBrowserEventRouter::FileWatcherExtensions::Watch | 522 bool ExtensionFileBrowserEventRouter::FileWatcherExtensions::Watch |
526 (const FilePath& path, FileWatcherDelegate* delegate) { | 523 (const FilePath& path, FileWatcherDelegate* delegate) { |
527 return file_watcher->Watch(path, delegate); | 524 return file_watcher->Watch(path, delegate); |
528 } | 525 } |
OLD | NEW |