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

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: Sync to ToT and reformat. 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 bool read_only =
140 profile->GetPrefs()->GetBoolean(prefs::kExternalStorageReadOnly);
yamaguchi 2016/08/04 09:43:31 GetBoolean returns false when the value did not ex
141 return read_only ? chromeos::MOUNT_ACCESS_MODE_READ_ONLY
142 : chromeos::MOUNT_ACCESS_MODE_READ_WRITE;
143 }
144
138 } // namespace 145 } // namespace
139 146
140 Volume::Volume() 147 Volume::Volume()
141 : source_(SOURCE_FILE), 148 : source_(SOURCE_FILE),
142 type_(VOLUME_TYPE_GOOGLE_DRIVE), 149 type_(VOLUME_TYPE_GOOGLE_DRIVE),
143 device_type_(chromeos::DEVICE_TYPE_UNKNOWN), 150 device_type_(chromeos::DEVICE_TYPE_UNKNOWN),
144 mount_condition_(chromeos::disks::MOUNT_CONDITION_NONE), 151 mount_condition_(chromeos::disks::MOUNT_CONDITION_NONE),
145 mount_context_(MOUNT_CONTEXT_UNKNOWN), 152 mount_context_(MOUNT_CONTEXT_UNKNOWN),
146 is_parent_(false), 153 is_parent_(false),
147 is_read_only_(false), 154 is_read_only_(false),
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after
487 } 494 }
488 495
489 bool mounting = false; 496 bool mounting = false;
490 if (disk->mount_path().empty() && disk->has_media() && 497 if (disk->mount_path().empty() && disk->has_media() &&
491 !profile_->GetPrefs()->GetBoolean(prefs::kExternalStorageDisabled)) { 498 !profile_->GetPrefs()->GetBoolean(prefs::kExternalStorageDisabled)) {
492 // If disk is not mounted yet and it has media and there is no policy 499 // If disk is not mounted yet and it has media and there is no policy
493 // forbidding external storage, give it a try. 500 // forbidding external storage, give it a try.
494 // Initiate disk mount operation. MountPath auto-detects the filesystem 501 // Initiate disk mount operation. MountPath auto-detects the filesystem
495 // format if the second argument is empty. The third argument (mount 502 // format if the second argument is empty. The third argument (mount
496 // label) is not used in a disk mount operation. 503 // label) is not used in a disk mount operation.
497 disk_mount_manager_->MountPath( 504 disk_mount_manager_->MountPath(disk->device_path(), std::string(),
498 disk->device_path(), std::string(), std::string(), 505 std::string(),
499 chromeos::MOUNT_TYPE_DEVICE); 506 chromeos::MOUNT_TYPE_DEVICE,
507 GetExternalStorageAccessMode(profile_));
500 mounting = true; 508 mounting = true;
501 } 509 }
502 510
503 // Notify to observers. 511 // Notify to observers.
504 FOR_EACH_OBSERVER(VolumeManagerObserver, observers_, 512 FOR_EACH_OBSERVER(VolumeManagerObserver, observers_,
505 OnDiskAdded(*disk, mounting)); 513 OnDiskAdded(*disk, mounting));
506 return; 514 return;
507 } 515 }
508 516
509 case chromeos::disks::DiskMountManager::DISK_REMOVED: 517 case chromeos::disks::DiskMountManager::DISK_REMOVED:
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
602 VolumeManagerObserver, observers_, 610 VolumeManagerObserver, observers_,
603 OnFormatStarted(device_path, 611 OnFormatStarted(device_path,
604 error_code == chromeos::FORMAT_ERROR_NONE)); 612 error_code == chromeos::FORMAT_ERROR_NONE));
605 return; 613 return;
606 case chromeos::disks::DiskMountManager::FORMAT_COMPLETED: 614 case chromeos::disks::DiskMountManager::FORMAT_COMPLETED:
607 if (error_code == chromeos::FORMAT_ERROR_NONE) { 615 if (error_code == chromeos::FORMAT_ERROR_NONE) {
608 // If format is completed successfully, try to mount the device. 616 // If format is completed successfully, try to mount the device.
609 // MountPath auto-detects filesystem format if second argument is 617 // MountPath auto-detects filesystem format if second argument is
610 // empty. The third argument (mount label) is not used in a disk mount 618 // empty. The third argument (mount label) is not used in a disk mount
611 // operation. 619 // operation.
612 disk_mount_manager_->MountPath( 620 disk_mount_manager_->MountPath(device_path, std::string(),
613 device_path, std::string(), std::string(), 621 std::string(),
614 chromeos::MOUNT_TYPE_DEVICE); 622 chromeos::MOUNT_TYPE_DEVICE,
623 GetExternalStorageAccessMode(profile_));
615 } 624 }
616 625
617 FOR_EACH_OBSERVER( 626 FOR_EACH_OBSERVER(
618 VolumeManagerObserver, observers_, 627 VolumeManagerObserver, observers_,
619 OnFormatCompleted(device_path, 628 OnFormatCompleted(device_path,
620 error_code == chromeos::FORMAT_ERROR_NONE)); 629 error_code == chromeos::FORMAT_ERROR_NONE));
621 630
622 return; 631 return;
623 } 632 }
624 NOTREACHED(); 633 NOTREACHED();
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after
875 if (mounted_volumes_.find(volume->volume_id()) == mounted_volumes_.end()) 884 if (mounted_volumes_.find(volume->volume_id()) == mounted_volumes_.end())
876 return; 885 return;
877 if (error_code == chromeos::MOUNT_ERROR_NONE) 886 if (error_code == chromeos::MOUNT_ERROR_NONE)
878 mounted_volumes_.erase(volume->volume_id()); 887 mounted_volumes_.erase(volume->volume_id());
879 888
880 FOR_EACH_OBSERVER(VolumeManagerObserver, observers_, 889 FOR_EACH_OBSERVER(VolumeManagerObserver, observers_,
881 OnVolumeUnmounted(error_code, *volume.get())); 890 OnVolumeUnmounted(error_code, *volume.get()));
882 } 891 }
883 892
884 } // namespace file_manager 893 } // namespace file_manager
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698