Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(235)

Side by Side Diff: chrome/browser/chromeos/file_manager/volume_manager.cc

Issue 2201023002: Change access mode of disk devices when mounting based on config. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix typo. Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 volume.mount_path().BaseName().AsUTF8Unsafe()); 128 volume.mount_path().BaseName().AsUTF8Unsafe());
129 } 129 }
130 130
131 std::string GetMountPointNameForMediaStorage( 131 std::string GetMountPointNameForMediaStorage(
132 const storage_monitor::StorageInfo& info) { 132 const storage_monitor::StorageInfo& info) {
133 std::string name(kFileManagerMTPMountNamePrefix); 133 std::string name(kFileManagerMTPMountNamePrefix);
134 name += info.device_id(); 134 name += info.device_id();
135 return name; 135 return name;
136 } 136 }
137 137
138 chromeos::MountAccessMode GetExternalStorageAccessMode(const Profile* profile) {
139 return profile->GetPrefs()->GetBoolean(prefs::kExternalStorageReadOnly)
140 ? chromeos::MOUNT_ACCESS_MODE_READ_ONLY
141 : chromeos::MOUNT_ACCESS_MODE_READ_WRITE;
142 }
143
138 } // namespace 144 } // namespace
139 145
140 Volume::Volume() 146 Volume::Volume()
141 : source_(SOURCE_FILE), 147 : source_(SOURCE_FILE),
142 type_(VOLUME_TYPE_GOOGLE_DRIVE), 148 type_(VOLUME_TYPE_GOOGLE_DRIVE),
143 device_type_(chromeos::DEVICE_TYPE_UNKNOWN), 149 device_type_(chromeos::DEVICE_TYPE_UNKNOWN),
144 mount_condition_(chromeos::disks::MOUNT_CONDITION_NONE), 150 mount_condition_(chromeos::disks::MOUNT_CONDITION_NONE),
145 mount_context_(MOUNT_CONTEXT_UNKNOWN), 151 mount_context_(MOUNT_CONTEXT_UNKNOWN),
146 is_parent_(false), 152 is_parent_(false),
147 is_read_only_(false), 153 is_read_only_(false),
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after
487 } 493 }
488 494
489 bool mounting = false; 495 bool mounting = false;
490 if (disk->mount_path().empty() && disk->has_media() && 496 if (disk->mount_path().empty() && disk->has_media() &&
491 !profile_->GetPrefs()->GetBoolean(prefs::kExternalStorageDisabled)) { 497 !profile_->GetPrefs()->GetBoolean(prefs::kExternalStorageDisabled)) {
492 // If disk is not mounted yet and it has media and there is no policy 498 // If disk is not mounted yet and it has media and there is no policy
493 // forbidding external storage, give it a try. 499 // forbidding external storage, give it a try.
494 // Initiate disk mount operation. MountPath auto-detects the filesystem 500 // Initiate disk mount operation. MountPath auto-detects the filesystem
495 // format if the second argument is empty. The third argument (mount 501 // format if the second argument is empty. The third argument (mount
496 // label) is not used in a disk mount operation. 502 // label) is not used in a disk mount operation.
497 disk_mount_manager_->MountPath( 503 disk_mount_manager_->MountPath(disk->device_path(), std::string(),
498 disk->device_path(), std::string(), std::string(), 504 std::string(),
499 chromeos::MOUNT_TYPE_DEVICE); 505 chromeos::MOUNT_TYPE_DEVICE,
506 GetExternalStorageAccessMode(profile_));
500 mounting = true; 507 mounting = true;
501 } 508 }
502 509
503 // Notify to observers. 510 // Notify to observers.
504 FOR_EACH_OBSERVER(VolumeManagerObserver, observers_, 511 FOR_EACH_OBSERVER(VolumeManagerObserver, observers_,
505 OnDiskAdded(*disk, mounting)); 512 OnDiskAdded(*disk, mounting));
506 return; 513 return;
507 } 514 }
508 515
509 case chromeos::disks::DiskMountManager::DISK_REMOVED: 516 case chromeos::disks::DiskMountManager::DISK_REMOVED:
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
602 VolumeManagerObserver, observers_, 609 VolumeManagerObserver, observers_,
603 OnFormatStarted(device_path, 610 OnFormatStarted(device_path,
604 error_code == chromeos::FORMAT_ERROR_NONE)); 611 error_code == chromeos::FORMAT_ERROR_NONE));
605 return; 612 return;
606 case chromeos::disks::DiskMountManager::FORMAT_COMPLETED: 613 case chromeos::disks::DiskMountManager::FORMAT_COMPLETED:
607 if (error_code == chromeos::FORMAT_ERROR_NONE) { 614 if (error_code == chromeos::FORMAT_ERROR_NONE) {
608 // If format is completed successfully, try to mount the device. 615 // If format is completed successfully, try to mount the device.
609 // MountPath auto-detects filesystem format if second argument is 616 // MountPath auto-detects filesystem format if second argument is
610 // empty. The third argument (mount label) is not used in a disk mount 617 // empty. The third argument (mount label) is not used in a disk mount
611 // operation. 618 // operation.
612 disk_mount_manager_->MountPath( 619 disk_mount_manager_->MountPath(device_path, std::string(),
613 device_path, std::string(), std::string(), 620 std::string(),
614 chromeos::MOUNT_TYPE_DEVICE); 621 chromeos::MOUNT_TYPE_DEVICE,
622 GetExternalStorageAccessMode(profile_));
615 } 623 }
616 624
617 FOR_EACH_OBSERVER( 625 FOR_EACH_OBSERVER(
618 VolumeManagerObserver, observers_, 626 VolumeManagerObserver, observers_,
619 OnFormatCompleted(device_path, 627 OnFormatCompleted(device_path,
620 error_code == chromeos::FORMAT_ERROR_NONE)); 628 error_code == chromeos::FORMAT_ERROR_NONE));
621 629
622 return; 630 return;
623 } 631 }
624 NOTREACHED(); 632 NOTREACHED();
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after
875 if (mounted_volumes_.find(volume->volume_id()) == mounted_volumes_.end()) 883 if (mounted_volumes_.find(volume->volume_id()) == mounted_volumes_.end())
876 return; 884 return;
877 if (error_code == chromeos::MOUNT_ERROR_NONE) 885 if (error_code == chromeos::MOUNT_ERROR_NONE)
878 mounted_volumes_.erase(volume->volume_id()); 886 mounted_volumes_.erase(volume->volume_id());
879 887
880 FOR_EACH_OBSERVER(VolumeManagerObserver, observers_, 888 FOR_EACH_OBSERVER(VolumeManagerObserver, observers_,
881 OnVolumeUnmounted(error_code, *volume.get())); 889 OnVolumeUnmounted(error_code, *volume.get()));
882 } 890 }
883 891
884 } // namespace file_manager 892 } // namespace file_manager
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698