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

Side by Side Diff: chrome/browser/chromeos/extensions/file_manager/private_api_mount.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: 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/extensions/file_manager/private_api_mount.h" 5 #include "chrome/browser/chromeos/extensions/file_manager/private_api_mount.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/files/file_util.h" 9 #include "base/files/file_util.h"
10 #include "base/format_macros.h" 10 #include "base/format_macros.h"
11 #include "base/memory/ptr_util.h" 11 #include "base/memory/ptr_util.h"
12 #include "base/memory/weak_ptr.h" 12 #include "base/memory/weak_ptr.h"
13 #include "chrome/browser/chromeos/drive/file_system_util.h" 13 #include "chrome/browser/chromeos/drive/file_system_util.h"
14 #include "chrome/browser/chromeos/extensions/file_manager/private_api_util.h" 14 #include "chrome/browser/chromeos/extensions/file_manager/private_api_util.h"
15 #include "chrome/browser/chromeos/file_manager/fileapi_util.h" 15 #include "chrome/browser/chromeos/file_manager/fileapi_util.h"
16 #include "chrome/browser/chromeos/file_manager/volume_manager.h" 16 #include "chrome/browser/chromeos/file_manager/volume_manager.h"
17 #include "chrome/browser/profiles/profile.h" 17 #include "chrome/browser/profiles/profile.h"
18 #include "chrome/common/extensions/api/file_manager_private.h" 18 #include "chrome/common/extensions/api/file_manager_private.h"
19 #include "chrome/common/pref_names.h"
19 #include "chromeos/disks/disk_mount_manager.h" 20 #include "chromeos/disks/disk_mount_manager.h"
20 #include "components/drive/chromeos/file_system_interface.h" 21 #include "components/drive/chromeos/file_system_interface.h"
21 #include "components/drive/event_logger.h" 22 #include "components/drive/event_logger.h"
23 #include "components/prefs/pref_service.h"
22 #include "content/public/browser/browser_thread.h" 24 #include "content/public/browser/browser_thread.h"
23 #include "google_apis/drive/task_util.h" 25 #include "google_apis/drive/task_util.h"
24 #include "ui/shell_dialogs/selected_file_info.h" 26 #include "ui/shell_dialogs/selected_file_info.h"
25 27
26 using chromeos::disks::DiskMountManager; 28 using chromeos::disks::DiskMountManager;
27 using content::BrowserThread; 29 using content::BrowserThread;
28 namespace file_manager_private = extensions::api::file_manager_private; 30 namespace file_manager_private = extensions::api::file_manager_private;
29 31
30 namespace extensions { 32 namespace extensions {
31 33
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 SendResponse(false); 155 SendResponse(false);
154 return; 156 return;
155 } 157 }
156 158
157 // Pass back the actual source path of the mount point. 159 // Pass back the actual source path of the mount point.
158 SetResult(base::MakeUnique<base::StringValue>(file_path.AsUTF8Unsafe())); 160 SetResult(base::MakeUnique<base::StringValue>(file_path.AsUTF8Unsafe()));
159 SendResponse(true); 161 SendResponse(true);
160 162
161 // MountPath() takes a std::string. 163 // MountPath() takes a std::string.
162 DiskMountManager* disk_mount_manager = DiskMountManager::GetInstance(); 164 DiskMountManager* disk_mount_manager = DiskMountManager::GetInstance();
165 bool read_only =
166 GetProfile()->GetPrefs()->GetBoolean(prefs::kExternalStorageReadOnly);
167 chromeos::MountAccessMode access_mode =
168 read_only ? chromeos::MOUNT_ACCESS_MODE_READ_ONLY
169 : chromeos::MOUNT_ACCESS_MODE_READ_WRITE;
163 disk_mount_manager->MountPath( 170 disk_mount_manager->MountPath(
164 file_path.AsUTF8Unsafe(), 171 file_path.AsUTF8Unsafe(),
165 base::FilePath(display_name.Extension()).AsUTF8Unsafe(), 172 base::FilePath(display_name.Extension()).AsUTF8Unsafe(),
166 display_name.AsUTF8Unsafe(), 173 display_name.AsUTF8Unsafe(), chromeos::MOUNT_TYPE_ARCHIVE, access_mode);
fukino 2016/08/03 07:18:19 Should we specify access mode for mounted archive
yamaguchi 2016/08/03 10:22:14 Done. Mounted archives are treated as read-only by
167 chromeos::MOUNT_TYPE_ARCHIVE);
168 } 174 }
169 175
170 bool FileManagerPrivateRemoveMountFunction::RunAsync() { 176 bool FileManagerPrivateRemoveMountFunction::RunAsync() {
171 using file_manager_private::RemoveMount::Params; 177 using file_manager_private::RemoveMount::Params;
172 const std::unique_ptr<Params> params(Params::Create(*args_)); 178 const std::unique_ptr<Params> params(Params::Create(*args_));
173 EXTENSION_FUNCTION_VALIDATE(params); 179 EXTENSION_FUNCTION_VALIDATE(params);
174 180
175 drive::EventLogger* logger = file_manager::util::GetLogger(GetProfile()); 181 drive::EventLogger* logger = file_manager::util::GetLogger(GetProfile());
176 if (logger) { 182 if (logger) {
177 logger->Log(logging::LOG_INFO, "%s[%d] called. (volume_id: '%s')", name(), 183 logger->Log(logging::LOG_INFO, "%s[%d] called. (volume_id: '%s')", name(),
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
246 name(), request_id(), log_string.c_str(), result.size()); 252 name(), request_id(), log_string.c_str(), result.size());
247 } 253 }
248 254
249 results_ = 255 results_ =
250 file_manager_private::GetVolumeMetadataList::Results::Create(result); 256 file_manager_private::GetVolumeMetadataList::Results::Create(result);
251 SendResponse(true); 257 SendResponse(true);
252 return true; 258 return true;
253 } 259 }
254 260
255 } // namespace extensions 261 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698