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

Side by Side Diff: chromeos/disks/disk_mount_manager.h

Issue 2440443003: Preserve the hardware read-only flag in Disk object. (Closed)
Patch Set: Use auto. Created 4 years, 2 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 #ifndef CHROMEOS_DISKS_DISK_MOUNT_MANAGER_H_ 5 #ifndef CHROMEOS_DISKS_DISK_MOUNT_MANAGER_H_
6 #define CHROMEOS_DISKS_DISK_MOUNT_MANAGER_H_ 6 #define CHROMEOS_DISKS_DISK_MOUNT_MANAGER_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <map> 10 #include <map>
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 enum FormatEvent { 49 enum FormatEvent {
50 FORMAT_STARTED, 50 FORMAT_STARTED,
51 FORMAT_COMPLETED 51 FORMAT_COMPLETED
52 }; 52 };
53 53
54 // Used to house an instance of each found mount device. 54 // Used to house an instance of each found mount device.
55 class Disk { 55 class Disk {
56 public: 56 public:
57 Disk(const std::string& device_path, 57 Disk(const std::string& device_path,
58 const std::string& mount_path, 58 const std::string& mount_path,
59 bool write_disabled_by_policy,
satorux1 2016/10/24 01:39:55 any reason why this should be added here? i though
yamaguchi 2016/10/24 01:53:30 I think that the parameter is tied to the mount_pa
satorux1 2016/10/24 02:00:11 Ah OK. Then please add a comment that explains the
yamaguchi 2016/10/24 04:43:23 Done.
59 const std::string& system_path, 60 const std::string& system_path,
60 const std::string& file_path, 61 const std::string& file_path,
61 const std::string& device_label, 62 const std::string& device_label,
62 const std::string& drive_label, 63 const std::string& drive_label,
63 const std::string& vendor_id, 64 const std::string& vendor_id,
64 const std::string& vendor_name, 65 const std::string& vendor_name,
65 const std::string& product_id, 66 const std::string& product_id,
66 const std::string& product_name, 67 const std::string& product_name,
67 const std::string& fs_uuid, 68 const std::string& fs_uuid,
68 const std::string& system_path_prefix, 69 const std::string& system_path_prefix,
69 DeviceType device_type, 70 DeviceType device_type,
70 uint64_t total_size_in_bytes, 71 uint64_t total_size_in_bytes,
71 bool is_parent, 72 bool is_parent,
72 bool is_read_only, 73 bool is_read_only_hardware,
73 bool has_media, 74 bool has_media,
74 bool on_boot_device, 75 bool on_boot_device,
75 bool on_removable_device, 76 bool on_removable_device,
76 bool is_hidden); 77 bool is_hidden);
77 Disk(const Disk& other); 78 Disk(const Disk& other);
78 ~Disk(); 79 ~Disk();
79 80
80 // The path of the device, used by devicekit-disks. 81 // The path of the device, used by devicekit-disks.
81 // (e.g. /sys/devices/pci0000:00/.../8:0:0:0/block/sdb/sdb1) 82 // (e.g. /sys/devices/pci0000:00/.../8:0:0:0/block/sdb/sdb1)
82 const std::string& device_path() const { return device_path_; } 83 const std::string& device_path() const { return device_path_; }
83 84
84 // The path to the mount point of this device. Will be empty if not mounted. 85 // The path to the mount point of this device. Will be empty if not mounted.
85 // (e.g. /media/removable/VOLUME) 86 // (e.g. /media/removable/VOLUME)
86 const std::string& mount_path() const { return mount_path_; } 87 const std::string& mount_path() const { return mount_path_; }
87 88
88 // The path of the device according to the udev system. 89 // The path of the device according to the udev system.
89 // (e.g. /sys/devices/pci0000:00/.../8:0:0:0/block/sdb/sdb1) 90 // (e.g. /sys/devices/pci0000:00/.../8:0:0:0/block/sdb/sdb1)
90 const std::string& system_path() const { return system_path_; } 91 const std::string& system_path() const { return system_path_; }
91 92
92 // The path of the device according to filesystem. 93 // The path of the device according to filesystem.
93 // (e.g. /dev/sdb) 94 // (e.g. /dev/sdb)
94 const std::string& file_path() const { return file_path_; } 95 const std::string& file_path() const { return file_path_; }
95 96
96 // Device's label. 97 // Device's label.
(...skipping 26 matching lines...) Expand all
123 124
124 // Device type. 125 // Device type.
125 DeviceType device_type() const { return device_type_; } 126 DeviceType device_type() const { return device_type_; }
126 127
127 // Total size of the device in bytes. 128 // Total size of the device in bytes.
128 uint64_t total_size_in_bytes() const { return total_size_in_bytes_; } 129 uint64_t total_size_in_bytes() const { return total_size_in_bytes_; }
129 130
130 // Is the device is a parent device (i.e. sdb rather than sdb1). 131 // Is the device is a parent device (i.e. sdb rather than sdb1).
131 bool is_parent() const { return is_parent_; } 132 bool is_parent() const { return is_parent_; }
132 133
134 // Whether the user can write to the device. True if read-only.
135 bool is_read_only() const {
136 return is_read_only_hardware_ || write_disabled_by_policy_;
137 }
138
133 // Is the device read only. 139 // Is the device read only.
134 bool is_read_only() const { return is_read_only_; } 140 bool is_read_only_hardware() const { return is_read_only_hardware_; }
135 141
136 // Does the device contains media. 142 // Does the device contains media.
137 bool has_media() const { return has_media_; } 143 bool has_media() const { return has_media_; }
138 144
139 // Is the device on the boot device. 145 // Is the device on the boot device.
140 bool on_boot_device() const { return on_boot_device_; } 146 bool on_boot_device() const { return on_boot_device_; }
141 147
142 // Is the device on the removable device. 148 // Is the device on the removable device.
143 bool on_removable_device() const { return on_removable_device_; } 149 bool on_removable_device() const { return on_removable_device_; }
144 150
145 // Shoud the device be shown in the UI, or automounted. 151 // Shoud the device be shown in the UI, or automounted.
146 bool is_hidden() const { return is_hidden_; } 152 bool is_hidden() const { return is_hidden_; }
147 153
148 void set_mount_path(const std::string& mount_path) { 154 void set_mount_path(const std::string& mount_path) {
149 mount_path_ = mount_path; 155 mount_path_ = mount_path;
150 } 156 }
151 157
152 void set_read_only(bool is_read_only) { is_read_only_ = is_read_only; } 158 void set_write_disabled_by_policy(bool disable) {
159 write_disabled_by_policy_ = disable;
160 }
153 161
154 void clear_mount_path() { mount_path_.clear(); } 162 void clear_mount_path() { mount_path_.clear(); }
155 163
156 private: 164 private:
157 std::string device_path_; 165 std::string device_path_;
158 std::string mount_path_; 166 std::string mount_path_;
satorux1 2016/10/24 01:39:55 ditto.
yamaguchi 2016/10/24 04:43:23 Done.
167 bool write_disabled_by_policy_;
159 std::string system_path_; 168 std::string system_path_;
160 std::string file_path_; 169 std::string file_path_;
161 std::string device_label_; 170 std::string device_label_;
162 std::string drive_label_; 171 std::string drive_label_;
163 std::string vendor_id_; 172 std::string vendor_id_;
164 std::string vendor_name_; 173 std::string vendor_name_;
165 std::string product_id_; 174 std::string product_id_;
166 std::string product_name_; 175 std::string product_name_;
167 std::string fs_uuid_; 176 std::string fs_uuid_;
168 std::string system_path_prefix_; 177 std::string system_path_prefix_;
169 DeviceType device_type_; 178 DeviceType device_type_;
170 uint64_t total_size_in_bytes_; 179 uint64_t total_size_in_bytes_;
171 bool is_parent_; 180 bool is_parent_;
172 bool is_read_only_; 181 bool is_read_only_hardware_;
173 bool has_media_; 182 bool has_media_;
174 bool on_boot_device_; 183 bool on_boot_device_;
175 bool on_removable_device_; 184 bool on_removable_device_;
176 bool is_hidden_; 185 bool is_hidden_;
177 }; 186 };
178 typedef std::map<std::string, std::unique_ptr<Disk>> DiskMap; 187 typedef std::map<std::string, std::unique_ptr<Disk>> DiskMap;
179 188
180 // A struct to store information about mount point. 189 // A struct to store information about mount point.
181 struct MountPointInfo { 190 struct MountPointInfo {
182 // Device's path. 191 // Device's path.
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
315 324
316 // Returns a pointer to the global DiskMountManager instance. 325 // Returns a pointer to the global DiskMountManager instance.
317 // Initialize() should already have been called. 326 // Initialize() should already have been called.
318 static DiskMountManager* GetInstance(); 327 static DiskMountManager* GetInstance();
319 }; 328 };
320 329
321 } // namespace disks 330 } // namespace disks
322 } // namespace chromeos 331 } // namespace chromeos
323 332
324 #endif // CHROMEOS_DISKS_DISK_MOUNT_MANAGER_H_ 333 #endif // CHROMEOS_DISKS_DISK_MOUNT_MANAGER_H_
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/file_manager/volume_manager_unittest.cc ('k') | chromeos/disks/disk_mount_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698