| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/file_manager/volume_manager.h" | 5 #include "chrome/browser/chromeos/file_manager/volume_manager.h" |
| 6 | 6 |
| 7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/callback.h" | 9 #include "base/callback.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| 11 #include "base/files/file_path.h" | 11 #include "base/files/file_path.h" |
| 12 #include "base/logging.h" | 12 #include "base/logging.h" |
| 13 #include "base/memory/singleton.h" | 13 #include "base/memory/singleton.h" |
| 14 #include "base/metrics/histogram.h" | 14 #include "base/metrics/histogram.h" |
| 15 #include "base/prefs/pref_service.h" | 15 #include "base/prefs/pref_service.h" |
| 16 #include "base/strings/stringprintf.h" | 16 #include "base/strings/stringprintf.h" |
| 17 #include "base/strings/utf_string_conversions.h" | 17 #include "base/strings/utf_string_conversions.h" |
| 18 #include "base/sys_info.h" |
| 18 #include "chrome/browser/chromeos/drive/drive_integration_service.h" | 19 #include "chrome/browser/chromeos/drive/drive_integration_service.h" |
| 19 #include "chrome/browser/chromeos/drive/file_errors.h" | 20 #include "chrome/browser/chromeos/drive/file_errors.h" |
| 20 #include "chrome/browser/chromeos/drive/file_system_interface.h" | 21 #include "chrome/browser/chromeos/drive/file_system_interface.h" |
| 21 #include "chrome/browser/chromeos/drive/file_system_util.h" | 22 #include "chrome/browser/chromeos/drive/file_system_util.h" |
| 22 #include "chrome/browser/chromeos/file_manager/mounted_disk_monitor.h" | 23 #include "chrome/browser/chromeos/file_manager/mounted_disk_monitor.h" |
| 23 #include "chrome/browser/chromeos/file_manager/path_util.h" | 24 #include "chrome/browser/chromeos/file_manager/path_util.h" |
| 24 #include "chrome/browser/chromeos/file_manager/volume_manager_factory.h" | 25 #include "chrome/browser/chromeos/file_manager/volume_manager_factory.h" |
| 25 #include "chrome/browser/chromeos/file_manager/volume_manager_observer.h" | 26 #include "chrome/browser/chromeos/file_manager/volume_manager_observer.h" |
| 26 #include "chrome/browser/chromeos/file_system_provider/provided_file_system_info
.h" | 27 #include "chrome/browser/chromeos/file_system_provider/provided_file_system_info
.h" |
| 27 #include "chrome/browser/chromeos/profiles/profile_helper.h" | 28 #include "chrome/browser/chromeos/profiles/profile_helper.h" |
| (...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 282 const base::FilePath old_path = | 283 const base::FilePath old_path = |
| 283 profile_->GetPrefs()->GetFilePath(prefs::kSelectFileLastDirectory); | 284 profile_->GetPrefs()->GetFilePath(prefs::kSelectFileLastDirectory); |
| 284 base::FilePath new_path; | 285 base::FilePath new_path; |
| 285 if (!old_path.empty() && | 286 if (!old_path.empty() && |
| 286 file_manager::util::MigratePathFromOldFormat(profile_, | 287 file_manager::util::MigratePathFromOldFormat(profile_, |
| 287 old_path, &new_path)) { | 288 old_path, &new_path)) { |
| 288 profile_->GetPrefs()->SetFilePath(prefs::kSelectFileLastDirectory, | 289 profile_->GetPrefs()->SetFilePath(prefs::kSelectFileLastDirectory, |
| 289 new_path); | 290 new_path); |
| 290 } | 291 } |
| 291 | 292 |
| 292 // Register 'Downloads' folder for the profile to the file system. | 293 static bool added_downloads = false; |
| 293 const base::FilePath downloads = | 294 if (base::SysInfo::IsRunningOnChromeOS() || !added_downloads) { |
| 294 file_manager::util::GetDownloadsFolderForProfile(profile_); | 295 // Register 'Downloads' folder for the profile to the file system. |
| 295 const bool success = RegisterDownloadsMountPoint(profile_, downloads); | 296 // On non-ChromeOS system (test+development), we should do this only for |
| 296 DCHECK(success); | 297 // the first registered profile. |
| 298 const base::FilePath downloads = |
| 299 file_manager::util::GetDownloadsFolderForProfile(profile_); |
| 300 const bool success = RegisterDownloadsMountPoint(profile_, downloads); |
| 301 added_downloads = success; |
| 302 DCHECK(success); |
| 297 | 303 |
| 298 DoMountEvent(chromeos::MOUNT_ERROR_NONE, | 304 DoMountEvent(chromeos::MOUNT_ERROR_NONE, |
| 299 CreateDownloadsVolumeInfo(downloads), | 305 CreateDownloadsVolumeInfo(downloads), |
| 300 kNotRemounting); | 306 kNotRemounting); |
| 307 } |
| 301 | 308 |
| 302 // Subscribe to DriveIntegrationService. | 309 // Subscribe to DriveIntegrationService. |
| 303 if (drive_integration_service_) { | 310 if (drive_integration_service_) { |
| 304 drive_integration_service_->AddObserver(this); | 311 drive_integration_service_->AddObserver(this); |
| 305 if (drive_integration_service_->IsMounted()) { | 312 if (drive_integration_service_->IsMounted()) { |
| 306 DoMountEvent(chromeos::MOUNT_ERROR_NONE, | 313 DoMountEvent(chromeos::MOUNT_ERROR_NONE, |
| 307 CreateDriveVolumeInfo(profile_), | 314 CreateDriveVolumeInfo(profile_), |
| 308 kNotRemounting); | 315 kNotRemounting); |
| 309 } | 316 } |
| 310 } | 317 } |
| (...skipping 522 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 833 return; | 840 return; |
| 834 if (error_code == chromeos::MOUNT_ERROR_NONE) | 841 if (error_code == chromeos::MOUNT_ERROR_NONE) |
| 835 mounted_volumes_.erase(volume_info.volume_id); | 842 mounted_volumes_.erase(volume_info.volume_id); |
| 836 | 843 |
| 837 FOR_EACH_OBSERVER(VolumeManagerObserver, | 844 FOR_EACH_OBSERVER(VolumeManagerObserver, |
| 838 observers_, | 845 observers_, |
| 839 OnVolumeUnmounted(error_code, volume_info)); | 846 OnVolumeUnmounted(error_code, volume_info)); |
| 840 } | 847 } |
| 841 | 848 |
| 842 } // namespace file_manager | 849 } // namespace file_manager |
| OLD | NEW |