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/files/file_path.h" | 9 #include "base/files/file_path.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
246 | 246 |
247 VolumeManager* VolumeManager::Get(content::BrowserContext* context) { | 247 VolumeManager* VolumeManager::Get(content::BrowserContext* context) { |
248 return VolumeManagerFactory::Get(context); | 248 return VolumeManagerFactory::Get(context); |
249 } | 249 } |
250 | 250 |
251 void VolumeManager::Initialize() { | 251 void VolumeManager::Initialize() { |
252 // If in Sign in profile, then skip mounting and listening for mount events. | 252 // If in Sign in profile, then skip mounting and listening for mount events. |
253 if (chromeos::ProfileHelper::IsSigninProfile(profile_)) | 253 if (chromeos::ProfileHelper::IsSigninProfile(profile_)) |
254 return; | 254 return; |
255 | 255 |
256 // Path to mount user folders have changed several times. We need to migrate | |
257 // the old preferences on paths to the new format when needed. For the detail, | |
258 // see the comments in file_manager::util::MigratePathFromOldFormat, | |
259 // Note: Preferences related to downloads are handled in download_prefs.cc. | |
260 // TODO(kinaba): Remove this after several rounds of releases. | |
261 const base::FilePath old_path = | |
262 profile_->GetPrefs()->GetFilePath(prefs::kSelectFileLastDirectory); | |
263 base::FilePath new_path; | |
264 if (!old_path.empty() && | |
265 file_manager::util::MigratePathFromOldFormat(profile_, | |
266 old_path, &new_path)) { | |
267 profile_->GetPrefs()->SetFilePath(prefs::kSelectFileLastDirectory, | |
268 new_path); | |
269 } | |
270 | |
271 // Register 'Downloads' folder for the profile to the file system. | 256 // Register 'Downloads' folder for the profile to the file system. |
272 const base::FilePath downloads = | 257 const base::FilePath downloads = |
273 file_manager::util::GetDownloadsFolderForProfile(profile_); | 258 file_manager::util::GetDownloadsFolderForProfile(profile_); |
274 const bool success = RegisterDownloadsMountPoint(profile_, downloads); | 259 const bool success = RegisterDownloadsMountPoint(profile_, downloads); |
275 DCHECK(success); | 260 DCHECK(success); |
276 | 261 |
277 DoMountEvent(chromeos::MOUNT_ERROR_NONE, | 262 DoMountEvent(chromeos::MOUNT_ERROR_NONE, |
278 CreateDownloadsVolumeInfo(downloads)); | 263 CreateDownloadsVolumeInfo(downloads)); |
279 | 264 |
280 // Subscribe to DriveIntegrationService. | 265 // Subscribe to DriveIntegrationService. |
(...skipping 510 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
791 return; | 776 return; |
792 if (error_code == chromeos::MOUNT_ERROR_NONE) | 777 if (error_code == chromeos::MOUNT_ERROR_NONE) |
793 mounted_volumes_.erase(volume_info.volume_id); | 778 mounted_volumes_.erase(volume_info.volume_id); |
794 | 779 |
795 FOR_EACH_OBSERVER(VolumeManagerObserver, | 780 FOR_EACH_OBSERVER(VolumeManagerObserver, |
796 observers_, | 781 observers_, |
797 OnVolumeUnmounted(error_code, volume_info)); | 782 OnVolumeUnmounted(error_code, volume_info)); |
798 } | 783 } |
799 | 784 |
800 } // namespace file_manager | 785 } // namespace file_manager |
OLD | NEW |