| 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_manager/file_manager_event_rou
ter.h" | 5 #include "chrome/browser/chromeos/extensions/file_manager/file_manager_event_rou
ter.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
| 9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
| 10 #include "base/prefs/pref_change_registrar.h" | 10 #include "base/prefs/pref_change_registrar.h" |
| (...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 383 error_code == chromeos::MOUNT_ERROR_NONE, | 383 error_code == chromeos::MOUNT_ERROR_NONE, |
| 384 error_code == chromeos::MOUNT_ERROR_UNSUPPORTED_FILESYSTEM); | 384 error_code == chromeos::MOUNT_ERROR_UNSUPPORTED_FILESYSTEM); |
| 385 | 385 |
| 386 // If a new device was mounted, a new File manager window may need to be | 386 // If a new device was mounted, a new File manager window may need to be |
| 387 // opened. | 387 // opened. |
| 388 if (error_code == chromeos::MOUNT_ERROR_NONE) | 388 if (error_code == chromeos::MOUNT_ERROR_NONE) |
| 389 ShowRemovableDeviceInFileManager( | 389 ShowRemovableDeviceInFileManager( |
| 390 *disk, | 390 *disk, |
| 391 base::FilePath::FromUTF8Unsafe(mount_info.mount_path)); | 391 base::FilePath::FromUTF8Unsafe(mount_info.mount_path)); |
| 392 } else if (mount_info.mount_type == chromeos::MOUNT_TYPE_ARCHIVE) { | 392 } else if (mount_info.mount_type == chromeos::MOUNT_TYPE_ARCHIVE) { |
| 393 // Clear the "mounted" state for archive files in gdata cache | 393 // Clear the "mounted" state for archive files in drive cache |
| 394 // when mounting failed or unmounting succeeded. | 394 // when mounting failed or unmounting succeeded. |
| 395 if ((event == DiskMountManager::MOUNTING) != | 395 if ((event == DiskMountManager::MOUNTING) != |
| 396 (error_code == chromeos::MOUNT_ERROR_NONE)) { | 396 (error_code == chromeos::MOUNT_ERROR_NONE)) { |
| 397 DriveIntegrationService* integration_service = | 397 DriveIntegrationService* integration_service = |
| 398 DriveIntegrationServiceFactory::GetForProfile(profile_); | 398 DriveIntegrationServiceFactory::GetForProfile(profile_); |
| 399 drive::FileSystemInterface* file_system = | 399 drive::FileSystemInterface* file_system = |
| 400 integration_service ? integration_service->file_system() : NULL; | 400 integration_service ? integration_service->file_system() : NULL; |
| 401 if (file_system) { | 401 if (file_system) { |
| 402 file_system->MarkCacheFileAsUnmounted( | 402 file_system->MarkCacheFileAsUnmounted( |
| 403 base::FilePath(mount_info.source_path), | 403 base::FilePath(mount_info.source_path), |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 566 // We can pass chromeos::MOUNT_ERROR_NONE even when authentication is failed | 566 // We can pass chromeos::MOUNT_ERROR_NONE even when authentication is failed |
| 567 // or network is unreachable. These two errors will be handled later. | 567 // or network is unreachable. These two errors will be handled later. |
| 568 OnMountEvent(DiskMountManager::MOUNTING, chromeos::MOUNT_ERROR_NONE, | 568 OnMountEvent(DiskMountManager::MOUNTING, chromeos::MOUNT_ERROR_NONE, |
| 569 mount_info); | 569 mount_info); |
| 570 } | 570 } |
| 571 | 571 |
| 572 void FileManagerEventRouter::OnFileSystemBeingUnmounted() { | 572 void FileManagerEventRouter::OnFileSystemBeingUnmounted() { |
| 573 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 573 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 574 | 574 |
| 575 // Raise a mount event to notify the File Manager. | 575 // Raise a mount event to notify the File Manager. |
| 576 const std::string& gdata_path = drive::util::GetDriveMountPointPathAsString(); | 576 const std::string& drive_path = drive::util::GetDriveMountPointPathAsString(); |
| 577 DiskMountManager::MountPointInfo mount_info( | 577 DiskMountManager::MountPointInfo mount_info( |
| 578 gdata_path, | 578 drive_path, |
| 579 gdata_path, | 579 drive_path, |
| 580 chromeos::MOUNT_TYPE_GOOGLE_DRIVE, | 580 chromeos::MOUNT_TYPE_GOOGLE_DRIVE, |
| 581 chromeos::disks::MOUNT_CONDITION_NONE); | 581 chromeos::disks::MOUNT_CONDITION_NONE); |
| 582 OnMountEvent(DiskMountManager::UNMOUNTING, chromeos::MOUNT_ERROR_NONE, | 582 OnMountEvent(DiskMountManager::UNMOUNTING, chromeos::MOUNT_ERROR_NONE, |
| 583 mount_info); | 583 mount_info); |
| 584 } | 584 } |
| 585 | 585 |
| 586 void FileManagerEventRouter::OnRefreshTokenInvalid() { | 586 void FileManagerEventRouter::OnRefreshTokenInvalid() { |
| 587 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 587 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 588 | 588 |
| 589 // Raise a DriveConnectionStatusChanged event to notify the status offline. | 589 // Raise a DriveConnectionStatusChanged event to notify the status offline. |
| (...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 834 DiskMountManager::GetInstance()->MountPath(device_path, std::string(), | 834 DiskMountManager::GetInstance()->MountPath(device_path, std::string(), |
| 835 std::string(), | 835 std::string(), |
| 836 chromeos::MOUNT_TYPE_DEVICE); | 836 chromeos::MOUNT_TYPE_DEVICE); |
| 837 } else { | 837 } else { |
| 838 notifications_->HideNotification(FileManagerNotifications::FORMAT_START, | 838 notifications_->HideNotification(FileManagerNotifications::FORMAT_START, |
| 839 device_path); | 839 device_path); |
| 840 notifications_->ShowNotification(FileManagerNotifications::FORMAT_FAIL, | 840 notifications_->ShowNotification(FileManagerNotifications::FORMAT_FAIL, |
| 841 device_path); | 841 device_path); |
| 842 } | 842 } |
| 843 } | 843 } |
| OLD | NEW |