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

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

Issue 2451713002: Propagate the read_only_hardware flag of volumes to js. (Closed)
Patch Set: Apply default value for others than removable disk volume. Created 4 years, 1 month 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 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 } // namespace 144 } // namespace
145 145
146 Volume::Volume() 146 Volume::Volume()
147 : source_(SOURCE_FILE), 147 : source_(SOURCE_FILE),
148 type_(VOLUME_TYPE_GOOGLE_DRIVE), 148 type_(VOLUME_TYPE_GOOGLE_DRIVE),
149 device_type_(chromeos::DEVICE_TYPE_UNKNOWN), 149 device_type_(chromeos::DEVICE_TYPE_UNKNOWN),
150 mount_condition_(chromeos::disks::MOUNT_CONDITION_NONE), 150 mount_condition_(chromeos::disks::MOUNT_CONDITION_NONE),
151 mount_context_(MOUNT_CONTEXT_UNKNOWN), 151 mount_context_(MOUNT_CONTEXT_UNKNOWN),
152 is_parent_(false), 152 is_parent_(false),
153 is_read_only_(false), 153 is_read_only_(false),
154 is_read_only_hardware_(false),
154 has_media_(false), 155 has_media_(false),
155 configurable_(false), 156 configurable_(false),
156 watchable_(false) { 157 watchable_(false) {}
fukino 2016/10/26 07:23:31 nit: looks unnecessary change (the style is not co
yamaguchi 2016/10/26 11:14:20 Done.
157 }
158 158
159 Volume::~Volume() { 159 Volume::~Volume() {
160 } 160 }
161 161
162 // static 162 // static
163 Volume* Volume::CreateForDrive(Profile* profile) { 163 Volume* Volume::CreateForDrive(Profile* profile) {
164 const base::FilePath& drive_path = 164 const base::FilePath& drive_path =
165 drive::util::GetDriveMountPointPath(profile); 165 drive::util::GetDriveMountPointPath(profile);
166 Volume* const volume = new Volume; 166 Volume* const volume = new Volume;
167 volume->type_ = VOLUME_TYPE_GOOGLE_DRIVE; 167 volume->type_ = VOLUME_TYPE_GOOGLE_DRIVE;
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 ? SOURCE_FILE 200 ? SOURCE_FILE
201 : SOURCE_DEVICE; 201 : SOURCE_DEVICE;
202 volume->mount_path_ = base::FilePath(mount_point.mount_path); 202 volume->mount_path_ = base::FilePath(mount_point.mount_path);
203 volume->mount_condition_ = mount_point.mount_condition; 203 volume->mount_condition_ = mount_point.mount_condition;
204 volume->volume_label_ = volume->mount_path().BaseName().AsUTF8Unsafe(); 204 volume->volume_label_ = volume->mount_path().BaseName().AsUTF8Unsafe();
205 if (disk) { 205 if (disk) {
206 volume->device_type_ = disk->device_type(); 206 volume->device_type_ = disk->device_type();
207 volume->system_path_prefix_ = base::FilePath(disk->system_path_prefix()); 207 volume->system_path_prefix_ = base::FilePath(disk->system_path_prefix());
208 volume->is_parent_ = disk->is_parent(); 208 volume->is_parent_ = disk->is_parent();
209 volume->is_read_only_ = disk->is_read_only(); 209 volume->is_read_only_ = disk->is_read_only();
210 volume->is_read_only_hardware_ = disk->is_read_only_hardware();
210 volume->has_media_ = disk->has_media(); 211 volume->has_media_ = disk->has_media();
211 } else { 212 } else {
212 volume->device_type_ = chromeos::DEVICE_TYPE_UNKNOWN; 213 volume->device_type_ = chromeos::DEVICE_TYPE_UNKNOWN;
213 volume->is_read_only_ = 214 volume->is_read_only_ = volume->is_read_only_hardware_ =
214 (mount_point.mount_type == chromeos::MOUNT_TYPE_ARCHIVE); 215 (mount_point.mount_type == chromeos::MOUNT_TYPE_ARCHIVE);
215 } 216 }
216 volume->volume_id_ = GenerateVolumeId(*volume); 217 volume->volume_id_ = GenerateVolumeId(*volume);
217 volume->watchable_ = true; 218 volume->watchable_ = true;
218 return volume; 219 return volume;
219 } 220 }
220 221
221 // static 222 // static
222 Volume* Volume::CreateForProvidedFileSystem( 223 Volume* Volume::CreateForProvidedFileSystem(
223 const chromeos::file_system_provider::ProvidedFileSystemInfo& 224 const chromeos::file_system_provider::ProvidedFileSystemInfo&
(...skipping 13 matching lines...) Expand all
237 volume->source_ = SOURCE_NETWORK; 238 volume->source_ = SOURCE_NETWORK;
238 break; 239 break;
239 } 240 }
240 volume->volume_label_ = file_system_info.display_name(); 241 volume->volume_label_ = file_system_info.display_name();
241 volume->type_ = VOLUME_TYPE_PROVIDED; 242 volume->type_ = VOLUME_TYPE_PROVIDED;
242 volume->mount_path_ = file_system_info.mount_path(); 243 volume->mount_path_ = file_system_info.mount_path();
243 volume->mount_condition_ = chromeos::disks::MOUNT_CONDITION_NONE; 244 volume->mount_condition_ = chromeos::disks::MOUNT_CONDITION_NONE;
244 volume->mount_context_ = mount_context; 245 volume->mount_context_ = mount_context;
245 volume->is_parent_ = true; 246 volume->is_parent_ = true;
246 volume->is_read_only_ = !file_system_info.writable(); 247 volume->is_read_only_ = !file_system_info.writable();
248 volume->is_read_only_hardware_ = volume->is_read_only_;
247 volume->configurable_ = file_system_info.configurable(); 249 volume->configurable_ = file_system_info.configurable();
248 volume->watchable_ = file_system_info.watchable(); 250 volume->watchable_ = file_system_info.watchable();
249 volume->volume_id_ = GenerateVolumeId(*volume); 251 volume->volume_id_ = GenerateVolumeId(*volume);
250 return volume; 252 return volume;
251 } 253 }
252 254
253 // static 255 // static
254 Volume* Volume::CreateForMTP(const base::FilePath& mount_path, 256 Volume* Volume::CreateForMTP(const base::FilePath& mount_path,
255 const std::string& label, 257 const std::string& label,
256 bool read_only) { 258 bool read_only) {
(...skipping 645 matching lines...) Expand 10 before | Expand all | Expand 10 after
902 if (mounted_volumes_.find(volume->volume_id()) == mounted_volumes_.end()) 904 if (mounted_volumes_.find(volume->volume_id()) == mounted_volumes_.end())
903 return; 905 return;
904 if (error_code == chromeos::MOUNT_ERROR_NONE) 906 if (error_code == chromeos::MOUNT_ERROR_NONE)
905 mounted_volumes_.erase(volume->volume_id()); 907 mounted_volumes_.erase(volume->volume_id());
906 908
907 for (auto& observer : observers_) 909 for (auto& observer : observers_)
908 observer.OnVolumeUnmounted(error_code, *volume.get()); 910 observer.OnVolumeUnmounted(error_code, *volume.get());
909 } 911 }
910 912
911 } // namespace file_manager 913 } // namespace file_manager
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698