OLD | NEW |
---|---|
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 "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/callback.h" | 9 #include "base/callback.h" |
10 #include "base/command_line.h" | |
10 #include "base/files/file_path.h" | 11 #include "base/files/file_path.h" |
11 #include "base/logging.h" | 12 #include "base/logging.h" |
12 #include "base/memory/singleton.h" | 13 #include "base/memory/singleton.h" |
13 #include "base/prefs/pref_service.h" | 14 #include "base/prefs/pref_service.h" |
14 #include "chrome/browser/chromeos/drive/drive_integration_service.h" | 15 #include "chrome/browser/chromeos/drive/drive_integration_service.h" |
15 #include "chrome/browser/chromeos/drive/file_errors.h" | 16 #include "chrome/browser/chromeos/drive/file_errors.h" |
16 #include "chrome/browser/chromeos/drive/file_system_interface.h" | 17 #include "chrome/browser/chromeos/drive/file_system_interface.h" |
17 #include "chrome/browser/chromeos/drive/file_system_util.h" | 18 #include "chrome/browser/chromeos/drive/file_system_util.h" |
18 #include "chrome/browser/chromeos/file_manager/mounted_disk_monitor.h" | 19 #include "chrome/browser/chromeos/file_manager/mounted_disk_monitor.h" |
19 #include "chrome/browser/chromeos/file_manager/path_util.h" | 20 #include "chrome/browser/chromeos/file_manager/path_util.h" |
20 #include "chrome/browser/chromeos/file_manager/volume_manager_factory.h" | 21 #include "chrome/browser/chromeos/file_manager/volume_manager_factory.h" |
21 #include "chrome/browser/chromeos/file_manager/volume_manager_observer.h" | 22 #include "chrome/browser/chromeos/file_manager/volume_manager_observer.h" |
23 #include "chrome/browser/local_discovery/storage/privet_filesystem_constants.h" | |
22 #include "chrome/browser/profiles/profile.h" | 24 #include "chrome/browser/profiles/profile.h" |
25 #include "chrome/common/chrome_switches.h" | |
23 #include "chrome/common/pref_names.h" | 26 #include "chrome/common/pref_names.h" |
24 #include "chromeos/dbus/cros_disks_client.h" | 27 #include "chromeos/dbus/cros_disks_client.h" |
25 #include "chromeos/disks/disk_mount_manager.h" | 28 #include "chromeos/disks/disk_mount_manager.h" |
26 #include "content/public/browser/browser_thread.h" | 29 #include "content/public/browser/browser_thread.h" |
27 #include "webkit/browser/fileapi/external_mount_points.h" | 30 #include "webkit/browser/fileapi/external_mount_points.h" |
28 | 31 |
29 namespace file_manager { | 32 namespace file_manager { |
30 namespace { | 33 namespace { |
31 | 34 |
32 // Called on completion of MarkCacheFileAsUnmounted. | 35 // Called on completion of MarkCacheFileAsUnmounted. |
(...skipping 23 matching lines...) Expand all Loading... | |
56 std::string VolumeTypeToString(VolumeType type) { | 59 std::string VolumeTypeToString(VolumeType type) { |
57 switch (type) { | 60 switch (type) { |
58 case VOLUME_TYPE_GOOGLE_DRIVE: | 61 case VOLUME_TYPE_GOOGLE_DRIVE: |
59 return "drive"; | 62 return "drive"; |
60 case VOLUME_TYPE_DOWNLOADS_DIRECTORY: | 63 case VOLUME_TYPE_DOWNLOADS_DIRECTORY: |
61 return "downloads"; | 64 return "downloads"; |
62 case VOLUME_TYPE_REMOVABLE_DISK_PARTITION: | 65 case VOLUME_TYPE_REMOVABLE_DISK_PARTITION: |
63 return "removable"; | 66 return "removable"; |
64 case VOLUME_TYPE_MOUNTED_ARCHIVE_FILE: | 67 case VOLUME_TYPE_MOUNTED_ARCHIVE_FILE: |
65 return "archive"; | 68 return "archive"; |
69 case VOLUME_TYPE_PRIVET: | |
70 return "privet"; | |
66 } | 71 } |
67 NOTREACHED(); | 72 NOTREACHED(); |
68 return ""; | 73 return ""; |
69 } | 74 } |
70 | 75 |
71 // Generates a unique volume ID for the given volume info. | 76 // Generates a unique volume ID for the given volume info. |
72 std::string GenerateVolumeId(const VolumeInfo& volume_info) { | 77 std::string GenerateVolumeId(const VolumeInfo& volume_info) { |
73 // For the same volume type, base names are unique, as mount points are | 78 // For the same volume type, base names are unique, as mount points are |
74 // flat for the same volume type. | 79 // flat for the same volume type. |
75 return (VolumeTypeToString(volume_info.type) + ":" + | 80 return (VolumeTypeToString(volume_info.type) + ":" + |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
124 } else { | 129 } else { |
125 volume_info.device_type = chromeos::DEVICE_TYPE_UNKNOWN; | 130 volume_info.device_type = chromeos::DEVICE_TYPE_UNKNOWN; |
126 volume_info.is_parent = false; | 131 volume_info.is_parent = false; |
127 volume_info.is_read_only = false; | 132 volume_info.is_read_only = false; |
128 } | 133 } |
129 volume_info.volume_id = GenerateVolumeId(volume_info); | 134 volume_info.volume_id = GenerateVolumeId(volume_info); |
130 | 135 |
131 return volume_info; | 136 return volume_info; |
132 } | 137 } |
133 | 138 |
139 VolumeInfo CreatePrivetVolumeInfo() { | |
mtomasz
2014/01/08 09:35:24
Note, that in late M-34/early M-35 we will have a
Noam Samuel
2014/01/09 01:00:10
Agreed. This code should eventually be in JS.
| |
140 VolumeInfo volume_info; | |
141 volume_info.type = VOLUME_TYPE_PRIVET; | |
142 volume_info.mount_path = base::FilePath(local_discovery::kPrivetFilePath); | |
143 volume_info.mount_condition = chromeos::disks::MOUNT_CONDITION_NONE; | |
144 volume_info.is_parent = true; | |
145 volume_info.is_read_only = true; | |
146 volume_info.volume_id = GenerateVolumeId(volume_info); | |
147 return volume_info; | |
148 } | |
149 | |
134 } // namespace | 150 } // namespace |
135 | 151 |
136 VolumeInfo::VolumeInfo() { | 152 VolumeInfo::VolumeInfo() { |
137 } | 153 } |
138 | 154 |
139 VolumeInfo::~VolumeInfo() { | 155 VolumeInfo::~VolumeInfo() { |
140 } | 156 } |
141 | 157 |
142 VolumeManager::VolumeManager( | 158 VolumeManager::VolumeManager( |
143 Profile* profile, | 159 Profile* profile, |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
249 const chromeos::disks::DiskMountManager::MountPointMap& mount_points = | 265 const chromeos::disks::DiskMountManager::MountPointMap& mount_points = |
250 disk_mount_manager_->mount_points(); | 266 disk_mount_manager_->mount_points(); |
251 for (chromeos::disks::DiskMountManager::MountPointMap::const_iterator it = | 267 for (chromeos::disks::DiskMountManager::MountPointMap::const_iterator it = |
252 mount_points.begin(); | 268 mount_points.begin(); |
253 it != mount_points.end(); ++it) { | 269 it != mount_points.end(); ++it) { |
254 result.push_back(CreateVolumeInfoFromMountPointInfo( | 270 result.push_back(CreateVolumeInfoFromMountPointInfo( |
255 it->second, | 271 it->second, |
256 disk_mount_manager_->FindDiskBySourcePath(it->second.source_path))); | 272 disk_mount_manager_->FindDiskBySourcePath(it->second.source_path))); |
257 } | 273 } |
258 | 274 |
275 if (CommandLine::ForCurrentProcess()->HasSwitch( | |
276 switches::kEnablePrivetStorage)) { | |
277 result.push_back(CreatePrivetVolumeInfo()); | |
278 } | |
279 | |
259 return result; | 280 return result; |
260 } | 281 } |
261 | 282 |
262 bool VolumeManager::FindVolumeInfoById(const std::string& volume_id, | 283 bool VolumeManager::FindVolumeInfoById(const std::string& volume_id, |
263 VolumeInfo* result) const { | 284 VolumeInfo* result) const { |
264 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | 285 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); |
265 DCHECK(result); | 286 DCHECK(result); |
266 | 287 |
267 std::vector<VolumeInfo> info_list = GetVolumeInfoList(); | 288 std::vector<VolumeInfo> info_list = GetVolumeInfoList(); |
268 for (size_t i = 0; i < info_list.size(); ++i) { | 289 for (size_t i = 0; i < info_list.size(); ++i) { |
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
473 disk_mount_manager_->mount_points().begin()->second.mount_path; | 494 disk_mount_manager_->mount_points().begin()->second.mount_path; |
474 disk_mount_manager_->UnmountPath( | 495 disk_mount_manager_->UnmountPath( |
475 mount_path, | 496 mount_path, |
476 chromeos::UNMOUNT_OPTIONS_NONE, | 497 chromeos::UNMOUNT_OPTIONS_NONE, |
477 chromeos::disks::DiskMountManager::UnmountPathCallback()); | 498 chromeos::disks::DiskMountManager::UnmountPathCallback()); |
478 } | 499 } |
479 } | 500 } |
480 } | 501 } |
481 | 502 |
482 } // namespace file_manager | 503 } // namespace file_manager |
OLD | NEW |