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/files/file_path.h" | 10 #include "base/files/file_path.h" |
11 #include "base/logging.h" | 11 #include "base/logging.h" |
12 #include "base/memory/singleton.h" | 12 #include "base/memory/singleton.h" |
13 #include "base/prefs/pref_service.h" | 13 #include "base/prefs/pref_service.h" |
14 #include "chrome/browser/chromeos/drive/drive_integration_service.h" | 14 #include "chrome/browser/chromeos/drive/drive_integration_service.h" |
15 #include "chrome/browser/chromeos/drive/file_errors.h" | 15 #include "chrome/browser/chromeos/drive/file_errors.h" |
16 #include "chrome/browser/chromeos/drive/file_system_interface.h" | 16 #include "chrome/browser/chromeos/drive/file_system_interface.h" |
17 #include "chrome/browser/chromeos/drive/file_system_util.h" | 17 #include "chrome/browser/chromeos/drive/file_system_util.h" |
18 #include "chrome/browser/chromeos/file_manager/mounted_disk_monitor.h" | 18 #include "chrome/browser/chromeos/file_manager/mounted_disk_monitor.h" |
19 #include "chrome/browser/chromeos/file_manager/path_util.h" | 19 #include "chrome/browser/chromeos/file_manager/path_util.h" |
20 #include "chrome/browser/chromeos/file_manager/volume_manager_factory.h" | 20 #include "chrome/browser/chromeos/file_manager/volume_manager_factory.h" |
21 #include "chrome/browser/chromeos/file_manager/volume_manager_observer.h" | 21 #include "chrome/browser/chromeos/file_manager/volume_manager_observer.h" |
| 22 #include "chrome/browser/chromeos/profiles/profile_helper.h" |
22 #include "chrome/browser/profiles/profile.h" | 23 #include "chrome/browser/profiles/profile.h" |
23 #include "chrome/common/pref_names.h" | 24 #include "chrome/common/pref_names.h" |
24 #include "chromeos/dbus/cros_disks_client.h" | 25 #include "chromeos/dbus/cros_disks_client.h" |
25 #include "chromeos/disks/disk_mount_manager.h" | 26 #include "chromeos/disks/disk_mount_manager.h" |
26 #include "content/public/browser/browser_thread.h" | 27 #include "content/public/browser/browser_thread.h" |
27 #include "webkit/browser/fileapi/external_mount_points.h" | 28 #include "webkit/browser/fileapi/external_mount_points.h" |
28 | 29 |
29 namespace file_manager { | 30 namespace file_manager { |
30 namespace { | 31 namespace { |
31 | 32 |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
173 const base::FilePath old_path = | 174 const base::FilePath old_path = |
174 profile_->GetPrefs()->GetFilePath(kPathPreference[i]); | 175 profile_->GetPrefs()->GetFilePath(kPathPreference[i]); |
175 base::FilePath new_path; | 176 base::FilePath new_path; |
176 if (!old_path.empty() && | 177 if (!old_path.empty() && |
177 file_manager::util::MigratePathFromOldFormat(profile_, | 178 file_manager::util::MigratePathFromOldFormat(profile_, |
178 old_path, &new_path)) { | 179 old_path, &new_path)) { |
179 profile_->GetPrefs()->SetFilePath(kPathPreference[i], new_path); | 180 profile_->GetPrefs()->SetFilePath(kPathPreference[i], new_path); |
180 } | 181 } |
181 } | 182 } |
182 | 183 |
| 184 // If in Sign in profile, then skip mounting and listening for mount events. |
| 185 if (chromeos::ProfileHelper::IsSigninProfile(profile_)) |
| 186 return; |
| 187 |
183 // Register 'Downloads' folder for the profile to the file system. | 188 // Register 'Downloads' folder for the profile to the file system. |
184 fileapi::ExternalMountPoints* mount_points = | 189 fileapi::ExternalMountPoints* mount_points = |
185 content::BrowserContext::GetMountPoints(profile_); | 190 content::BrowserContext::GetMountPoints(profile_); |
186 DCHECK(mount_points); | 191 DCHECK(mount_points); |
187 | 192 |
188 const base::FilePath downloads_folder = | 193 const base::FilePath downloads_folder = |
189 file_manager::util::GetDownloadsFolderForProfile(profile_); | 194 file_manager::util::GetDownloadsFolderForProfile(profile_); |
190 bool success = mount_points->RegisterFileSystem( | 195 bool success = mount_points->RegisterFileSystem( |
191 downloads_folder.BaseName().AsUTF8Unsafe(), | 196 downloads_folder.BaseName().AsUTF8Unsafe(), |
192 fileapi::kFileSystemTypeNativeLocal, | 197 fileapi::kFileSystemTypeNativeLocal, |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
305 void VolumeManager::OnDiskEvent( | 310 void VolumeManager::OnDiskEvent( |
306 chromeos::disks::DiskMountManager::DiskEvent event, | 311 chromeos::disks::DiskMountManager::DiskEvent event, |
307 const chromeos::disks::DiskMountManager::Disk* disk) { | 312 const chromeos::disks::DiskMountManager::Disk* disk) { |
308 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | 313 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); |
309 | 314 |
310 // Disregard hidden devices. | 315 // Disregard hidden devices. |
311 if (disk->is_hidden()) | 316 if (disk->is_hidden()) |
312 return; | 317 return; |
313 | 318 |
314 switch (event) { | 319 switch (event) { |
315 case chromeos::disks::DiskMountManager::DISK_ADDED: { | 320 case chromeos::disks::DiskMountManager::DISK_ADDED: |
| 321 case chromeos::disks::DiskMountManager::DISK_CHANGED: { |
316 if (disk->device_path().empty()) { | 322 if (disk->device_path().empty()) { |
317 DVLOG(1) << "Empty system path for " << disk->device_path(); | 323 DVLOG(1) << "Empty system path for " << disk->device_path(); |
318 return; | 324 return; |
319 } | 325 } |
320 | 326 |
321 bool mounting = false; | 327 bool mounting = false; |
322 if (disk->mount_path().empty() && disk->has_media() && | 328 if (disk->mount_path().empty() && disk->has_media() && |
323 !profile_->GetPrefs()->GetBoolean(prefs::kExternalStorageDisabled)) { | 329 !profile_->GetPrefs()->GetBoolean(prefs::kExternalStorageDisabled)) { |
324 // If disk is not mounted yet and it has media and there is no policy | 330 // If disk is not mounted yet and it has media and there is no policy |
325 // forbidding external storage, give it a try. | 331 // forbidding external storage, give it a try. |
(...skipping 18 matching lines...) Expand all Loading... |
344 disk_mount_manager_->UnmountPath( | 350 disk_mount_manager_->UnmountPath( |
345 disk->mount_path(), | 351 disk->mount_path(), |
346 chromeos::UNMOUNT_OPTIONS_LAZY, | 352 chromeos::UNMOUNT_OPTIONS_LAZY, |
347 chromeos::disks::DiskMountManager::UnmountPathCallback()); | 353 chromeos::disks::DiskMountManager::UnmountPathCallback()); |
348 } | 354 } |
349 | 355 |
350 // Notify to observers. | 356 // Notify to observers. |
351 FOR_EACH_OBSERVER(VolumeManagerObserver, observers_, | 357 FOR_EACH_OBSERVER(VolumeManagerObserver, observers_, |
352 OnDiskRemoved(*disk)); | 358 OnDiskRemoved(*disk)); |
353 return; | 359 return; |
354 | |
355 case chromeos::disks::DiskMountManager::DISK_CHANGED: | |
356 DVLOG(1) << "Ignore CHANGED event."; | |
357 return; | |
358 } | 360 } |
359 NOTREACHED(); | 361 NOTREACHED(); |
360 } | 362 } |
361 | 363 |
362 void VolumeManager::OnDeviceEvent( | 364 void VolumeManager::OnDeviceEvent( |
363 chromeos::disks::DiskMountManager::DeviceEvent event, | 365 chromeos::disks::DiskMountManager::DeviceEvent event, |
364 const std::string& device_path) { | 366 const std::string& device_path) { |
365 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | 367 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); |
366 DVLOG(1) << "OnDeviceEvent: " << event << ", " << device_path; | 368 DVLOG(1) << "OnDeviceEvent: " << event << ", " << device_path; |
367 | 369 |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
478 disk_mount_manager_->mount_points().begin()->second.mount_path; | 480 disk_mount_manager_->mount_points().begin()->second.mount_path; |
479 disk_mount_manager_->UnmountPath( | 481 disk_mount_manager_->UnmountPath( |
480 mount_path, | 482 mount_path, |
481 chromeos::UNMOUNT_OPTIONS_NONE, | 483 chromeos::UNMOUNT_OPTIONS_NONE, |
482 chromeos::disks::DiskMountManager::UnmountPathCallback()); | 484 chromeos::disks::DiskMountManager::UnmountPathCallback()); |
483 } | 485 } |
484 } | 486 } |
485 } | 487 } |
486 | 488 |
487 } // namespace file_manager | 489 } // namespace file_manager |
OLD | NEW |