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 #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" |
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
232 disk_mount_manager->disks().find(mount_info.source_path); | 232 disk_mount_manager->disks().find(mount_info.source_path); |
233 if (disk_it == disk_mount_manager->disks().end()) { | 233 if (disk_it == disk_mount_manager->disks().end()) { |
234 return; | 234 return; |
235 } | 235 } |
236 DiskMountManager::Disk* disk = disk_it->second; | 236 DiskMountManager::Disk* disk = disk_it->second; |
237 | 237 |
238 notifications_->ManageNotificationsOnMountCompleted( | 238 notifications_->ManageNotificationsOnMountCompleted( |
239 disk->system_path_prefix(), disk->drive_label(), disk->is_parent(), | 239 disk->system_path_prefix(), disk->drive_label(), disk->is_parent(), |
240 error_code == chromeos::MOUNT_ERROR_NONE, | 240 error_code == chromeos::MOUNT_ERROR_NONE, |
241 error_code == chromeos::MOUNT_ERROR_UNSUPORTED_FILESYSTEM); | 241 error_code == chromeos::MOUNT_ERROR_UNSUPORTED_FILESYSTEM); |
| 242 } else if (mount_info.mount_type == chromeos::MOUNT_TYPE_ARCHIVE) { |
| 243 // Clear the "mounted" state for archive files in gdata cache |
| 244 // when mounting failed or unmounting succeeded. |
| 245 if ((event_type == DiskMountManager::MOUNTING) != |
| 246 (error_code == chromeos::MOUNT_ERROR_NONE)) { |
| 247 FilePath source_path(mount_info.source_path); |
| 248 gdata::GDataSystemService* system_service = |
| 249 gdata::GDataSystemServiceFactory::GetForProfile(profile_); |
| 250 gdata::GDataFileSystem* file_system = |
| 251 system_service ? system_service->file_system() : NULL; |
| 252 if (file_system && file_system->IsUnderGDataCacheDirectory(source_path)) |
| 253 file_system->SetMountedState(source_path, false, |
| 254 gdata::SetMountedStateCallback()); |
| 255 } |
242 } | 256 } |
243 } | 257 } |
244 | 258 |
245 void FileBrowserEventRouter::OnProgressUpdate( | 259 void FileBrowserEventRouter::OnProgressUpdate( |
246 const std::vector<gdata::GDataOperationRegistry::ProgressStatus>& list) { | 260 const std::vector<gdata::GDataOperationRegistry::ProgressStatus>& list) { |
247 scoped_ptr<ListValue> event_list( | 261 scoped_ptr<ListValue> event_list( |
248 file_manager_util::ProgressStatusVectorToListValue( | 262 file_manager_util::ProgressStatusVectorToListValue( |
249 profile_, | 263 profile_, |
250 file_manager_util::GetFileBrowserExtensionUrl().GetOrigin(), | 264 file_manager_util::GetFileBrowserExtensionUrl().GetOrigin(), |
251 list)); | 265 list)); |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
407 void FileBrowserEventRouter::OnDiskAdded( | 421 void FileBrowserEventRouter::OnDiskAdded( |
408 const DiskMountManager::Disk* disk) { | 422 const DiskMountManager::Disk* disk) { |
409 VLOG(1) << "Disk added: " << disk->device_path(); | 423 VLOG(1) << "Disk added: " << disk->device_path(); |
410 if (disk->device_path().empty()) { | 424 if (disk->device_path().empty()) { |
411 VLOG(1) << "Empty system path for " << disk->device_path(); | 425 VLOG(1) << "Empty system path for " << disk->device_path(); |
412 return; | 426 return; |
413 } | 427 } |
414 | 428 |
415 // If disk is not mounted yet and it has media, give it a try. | 429 // If disk is not mounted yet and it has media, give it a try. |
416 if (disk->mount_path().empty() && disk->has_media()) { | 430 if (disk->mount_path().empty() && disk->has_media()) { |
417 // Initiate disk mount operation. | 431 // Initiate disk mount operation. MountPath auto-detects the filesystem |
| 432 // format if the second argument is empty. |
418 DiskMountManager::GetInstance()->MountPath( | 433 DiskMountManager::GetInstance()->MountPath( |
419 disk->device_path(), chromeos::MOUNT_TYPE_DEVICE); | 434 disk->device_path(), std::string(), chromeos::MOUNT_TYPE_DEVICE); |
420 } else { | 435 } else { |
421 // Either the disk was mounted or it has no media. In both cases we don't | 436 // Either the disk was mounted or it has no media. In both cases we don't |
422 // want the Scanning notification to persist. | 437 // want the Scanning notification to persist. |
423 notifications_->HideNotification(FileBrowserNotifications::DEVICE, | 438 notifications_->HideNotification(FileBrowserNotifications::DEVICE, |
424 disk->system_path_prefix()); | 439 disk->system_path_prefix()); |
425 } | 440 } |
426 DispatchDiskEvent(disk, true); | 441 DispatchDiskEvent(disk, true); |
427 } | 442 } |
428 | 443 |
429 void FileBrowserEventRouter::OnDiskRemoved( | 444 void FileBrowserEventRouter::OnDiskRemoved( |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
475 void FileBrowserEventRouter::OnFormattingFinished( | 490 void FileBrowserEventRouter::OnFormattingFinished( |
476 const std::string& device_path, bool success) { | 491 const std::string& device_path, bool success) { |
477 if (success) { | 492 if (success) { |
478 notifications_->HideNotification(FileBrowserNotifications::FORMAT_START, | 493 notifications_->HideNotification(FileBrowserNotifications::FORMAT_START, |
479 device_path); | 494 device_path); |
480 notifications_->ShowNotification(FileBrowserNotifications::FORMAT_SUCCESS, | 495 notifications_->ShowNotification(FileBrowserNotifications::FORMAT_SUCCESS, |
481 device_path); | 496 device_path); |
482 // Hide it after a couple of seconds. | 497 // Hide it after a couple of seconds. |
483 notifications_->HideNotificationDelayed( | 498 notifications_->HideNotificationDelayed( |
484 FileBrowserNotifications::FORMAT_SUCCESS, device_path, 4000); | 499 FileBrowserNotifications::FORMAT_SUCCESS, device_path, 4000); |
485 | 500 // MountPath auto-detects filesystem format if second argument is empty. |
486 DiskMountManager::GetInstance()->MountPath(device_path, | 501 DiskMountManager::GetInstance()->MountPath(device_path, std::string(), |
487 chromeos::MOUNT_TYPE_DEVICE); | 502 chromeos::MOUNT_TYPE_DEVICE); |
488 } else { | 503 } else { |
489 notifications_->HideNotification(FileBrowserNotifications::FORMAT_START, | 504 notifications_->HideNotification(FileBrowserNotifications::FORMAT_START, |
490 device_path); | 505 device_path); |
491 notifications_->ShowNotification(FileBrowserNotifications::FORMAT_FAIL, | 506 notifications_->ShowNotification(FileBrowserNotifications::FORMAT_FAIL, |
492 device_path); | 507 device_path); |
493 } | 508 } |
494 } | 509 } |
495 | 510 |
496 // FileBrowserEventRouter::WatcherDelegate methods. | 511 // FileBrowserEventRouter::WatcherDelegate methods. |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
617 return scoped_refptr<RefcountedProfileKeyedService>( | 632 return scoped_refptr<RefcountedProfileKeyedService>( |
618 new FileBrowserEventRouter(profile)); | 633 new FileBrowserEventRouter(profile)); |
619 } | 634 } |
620 | 635 |
621 bool FileBrowserEventRouterFactory::ServiceHasOwnInstanceInIncognito() { | 636 bool FileBrowserEventRouterFactory::ServiceHasOwnInstanceInIncognito() { |
622 // Explicitly and always allow this router in guest login mode. see | 637 // Explicitly and always allow this router in guest login mode. see |
623 // chrome/browser/profiles/profile_keyed_base_factory.h comment | 638 // chrome/browser/profiles/profile_keyed_base_factory.h comment |
624 // for the details. | 639 // for the details. |
625 return true; | 640 return true; |
626 } | 641 } |
OLD | NEW |