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

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

Issue 492693004: Delete Privet filesystem code (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 3 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 | Annotate | Revision Log
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 "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/files/file_path.h" 10 #include "base/files/file_path.h"
11 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "base/metrics/histogram.h" 12 #include "base/metrics/histogram.h"
13 #include "base/prefs/pref_service.h" 13 #include "base/prefs/pref_service.h"
14 #include "base/strings/stringprintf.h" 14 #include "base/strings/stringprintf.h"
15 #include "base/strings/utf_string_conversions.h" 15 #include "base/strings/utf_string_conversions.h"
16 #include "chrome/browser/chromeos/drive/drive_integration_service.h" 16 #include "chrome/browser/chromeos/drive/drive_integration_service.h"
17 #include "chrome/browser/chromeos/drive/file_system_interface.h" 17 #include "chrome/browser/chromeos/drive/file_system_interface.h"
18 #include "chrome/browser/chromeos/drive/file_system_util.h" 18 #include "chrome/browser/chromeos/drive/file_system_util.h"
19 #include "chrome/browser/chromeos/file_manager/path_util.h" 19 #include "chrome/browser/chromeos/file_manager/path_util.h"
20 #include "chrome/browser/chromeos/file_manager/snapshot_manager.h" 20 #include "chrome/browser/chromeos/file_manager/snapshot_manager.h"
21 #include "chrome/browser/chromeos/file_manager/volume_manager_factory.h" 21 #include "chrome/browser/chromeos/file_manager/volume_manager_factory.h"
22 #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/chromeos/file_system_provider/provided_file_system_info .h" 23 #include "chrome/browser/chromeos/file_system_provider/provided_file_system_info .h"
24 #include "chrome/browser/chromeos/profiles/profile_helper.h" 24 #include "chrome/browser/chromeos/profiles/profile_helper.h"
25 #include "chrome/browser/local_discovery/storage/privet_filesystem_constants.h"
26 #include "chrome/browser/media_galleries/fileapi/mtp_device_map_service.h" 25 #include "chrome/browser/media_galleries/fileapi/mtp_device_map_service.h"
27 #include "chrome/browser/profiles/profile.h" 26 #include "chrome/browser/profiles/profile.h"
28 #include "chrome/common/chrome_switches.h" 27 #include "chrome/common/chrome_switches.h"
29 #include "chrome/common/pref_names.h" 28 #include "chrome/common/pref_names.h"
30 #include "chromeos/chromeos_switches.h" 29 #include "chromeos/chromeos_switches.h"
31 #include "chromeos/disks/disk_mount_manager.h" 30 #include "chromeos/disks/disk_mount_manager.h"
32 #include "components/storage_monitor/storage_monitor.h" 31 #include "components/storage_monitor/storage_monitor.h"
33 #include "content/public/browser/browser_context.h" 32 #include "content/public/browser/browser_context.h"
34 #include "content/public/browser/browser_thread.h" 33 #include "content/public/browser/browser_thread.h"
35 #include "webkit/browser/fileapi/external_mount_points.h" 34 #include "webkit/browser/fileapi/external_mount_points.h"
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 volume_info.device_type = chromeos::DEVICE_TYPE_UNKNOWN; 186 volume_info.device_type = chromeos::DEVICE_TYPE_UNKNOWN;
188 volume_info.is_parent = false; 187 volume_info.is_parent = false;
189 volume_info.is_read_only = 188 volume_info.is_read_only =
190 (mount_point.mount_type == chromeos::MOUNT_TYPE_ARCHIVE); 189 (mount_point.mount_type == chromeos::MOUNT_TYPE_ARCHIVE);
191 } 190 }
192 volume_info.volume_id = GenerateVolumeId(volume_info); 191 volume_info.volume_id = GenerateVolumeId(volume_info);
193 192
194 return volume_info; 193 return volume_info;
195 } 194 }
196 195
197 VolumeInfo CreatePrivetVolumeInfo(
198 const local_discovery::PrivetVolumeLister::VolumeInfo& privet_volume_info) {
199 VolumeInfo volume_info;
200 volume_info.type = VOLUME_TYPE_CLOUD_DEVICE;
201 volume_info.mount_path = privet_volume_info.volume_path;
202 volume_info.mount_condition = chromeos::disks::MOUNT_CONDITION_NONE;
203 volume_info.is_parent = true;
204 volume_info.is_read_only = true;
205 volume_info.volume_id = GenerateVolumeId(volume_info);
206 return volume_info;
207 }
208
209 VolumeInfo CreateProvidedFileSystemVolumeInfo( 196 VolumeInfo CreateProvidedFileSystemVolumeInfo(
210 const chromeos::file_system_provider::ProvidedFileSystemInfo& 197 const chromeos::file_system_provider::ProvidedFileSystemInfo&
211 file_system_info) { 198 file_system_info) {
212 VolumeInfo volume_info; 199 VolumeInfo volume_info;
213 volume_info.file_system_id = file_system_info.file_system_id(); 200 volume_info.file_system_id = file_system_info.file_system_id();
214 volume_info.extension_id = file_system_info.extension_id(); 201 volume_info.extension_id = file_system_info.extension_id();
215 volume_info.volume_label = file_system_info.display_name(); 202 volume_info.volume_label = file_system_info.display_name();
216 volume_info.type = VOLUME_TYPE_PROVIDED; 203 volume_info.type = VOLUME_TYPE_PROVIDED;
217 volume_info.mount_path = file_system_info.mount_path(); 204 volume_info.mount_path = file_system_info.mount_path();
218 volume_info.mount_condition = chromeos::disks::MOUNT_CONDITION_NONE; 205 volume_info.mount_condition = chromeos::disks::MOUNT_CONDITION_NONE;
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
323 } 310 }
324 } 311 }
325 312
326 // Subscribe to Profile Preference change. 313 // Subscribe to Profile Preference change.
327 pref_change_registrar_.Init(profile_->GetPrefs()); 314 pref_change_registrar_.Init(profile_->GetPrefs());
328 pref_change_registrar_.Add( 315 pref_change_registrar_.Add(
329 prefs::kExternalStorageDisabled, 316 prefs::kExternalStorageDisabled,
330 base::Bind(&VolumeManager::OnExternalStorageDisabledChanged, 317 base::Bind(&VolumeManager::OnExternalStorageDisabledChanged,
331 weak_ptr_factory_.GetWeakPtr())); 318 weak_ptr_factory_.GetWeakPtr()));
332 319
333 // Subscribe to Privet volume lister.
334 if (CommandLine::ForCurrentProcess()->HasSwitch(
335 switches::kEnablePrivetStorage)) {
336 privet_volume_lister_.reset(new local_discovery::PrivetVolumeLister(
337 base::Bind(&VolumeManager::OnPrivetVolumesAvailable,
338 weak_ptr_factory_.GetWeakPtr())));
339 privet_volume_lister_->Start();
340 }
341
342 // Subscribe to storage monitor for MTP notifications. 320 // Subscribe to storage monitor for MTP notifications.
343 const bool disable_mtp = 321 const bool disable_mtp =
344 CommandLine::ForCurrentProcess()->GetSwitchValueASCII( 322 CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
345 chromeos::switches::kEnableFileManagerMTP) == "false"; 323 chromeos::switches::kEnableFileManagerMTP) == "false";
346 if (!disable_mtp && storage_monitor::StorageMonitor::GetInstance()) { 324 if (!disable_mtp && storage_monitor::StorageMonitor::GetInstance()) {
347 storage_monitor::StorageMonitor::GetInstance()->EnsureInitialized( 325 storage_monitor::StorageMonitor::GetInstance()->EnsureInitialized(
348 base::Bind(&VolumeManager::OnStorageMonitorInitialized, 326 base::Bind(&VolumeManager::OnStorageMonitorInitialized,
349 weak_ptr_factory_.GetWeakPtr())); 327 weak_ptr_factory_.GetWeakPtr()));
350 } 328 }
351 } 329 }
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after
640 std::string mount_path = 618 std::string mount_path =
641 disk_mount_manager_->mount_points().begin()->second.mount_path; 619 disk_mount_manager_->mount_points().begin()->second.mount_path;
642 disk_mount_manager_->UnmountPath( 620 disk_mount_manager_->UnmountPath(
643 mount_path, 621 mount_path,
644 chromeos::UNMOUNT_OPTIONS_NONE, 622 chromeos::UNMOUNT_OPTIONS_NONE,
645 chromeos::disks::DiskMountManager::UnmountPathCallback()); 623 chromeos::disks::DiskMountManager::UnmountPathCallback());
646 } 624 }
647 } 625 }
648 } 626 }
649 627
650 void VolumeManager::OnPrivetVolumesAvailable(
651 const local_discovery::PrivetVolumeLister::VolumeList& volumes) {
652 for (local_discovery::PrivetVolumeLister::VolumeList::const_iterator i =
653 volumes.begin(); i != volumes.end(); i++) {
654 VolumeInfo volume_info = CreatePrivetVolumeInfo(*i);
655 DoMountEvent(chromeos::MOUNT_ERROR_NONE, volume_info);
656 }
657 }
658
659 void VolumeManager::OnRemovableStorageAttached( 628 void VolumeManager::OnRemovableStorageAttached(
660 const storage_monitor::StorageInfo& info) { 629 const storage_monitor::StorageInfo& info) {
661 if (!storage_monitor::StorageInfo::IsMTPDevice(info.device_id())) 630 if (!storage_monitor::StorageInfo::IsMTPDevice(info.device_id()))
662 return; 631 return;
663 if (profile_->GetPrefs()->GetBoolean(prefs::kExternalStorageDisabled)) 632 if (profile_->GetPrefs()->GetBoolean(prefs::kExternalStorageDisabled))
664 return; 633 return;
665 634
666 const base::FilePath path = base::FilePath::FromUTF8Unsafe(info.location()); 635 const base::FilePath path = base::FilePath::FromUTF8Unsafe(info.location());
667 const std::string fsid = GetMountPointNameForMediaStorage(info); 636 const std::string fsid = GetMountPointNameForMediaStorage(info);
668 const std::string base_name = base::UTF16ToUTF8(info.model_name()); 637 const std::string base_name = base::UTF16ToUTF8(info.model_name());
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
828 return; 797 return;
829 if (error_code == chromeos::MOUNT_ERROR_NONE) 798 if (error_code == chromeos::MOUNT_ERROR_NONE)
830 mounted_volumes_.erase(volume_info.volume_id); 799 mounted_volumes_.erase(volume_info.volume_id);
831 800
832 FOR_EACH_OBSERVER(VolumeManagerObserver, 801 FOR_EACH_OBSERVER(VolumeManagerObserver,
833 observers_, 802 observers_,
834 OnVolumeUnmounted(error_code, volume_info)); 803 OnVolumeUnmounted(error_code, volume_info));
835 } 804 }
836 805
837 } // namespace file_manager 806 } // namespace file_manager
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/file_manager/volume_manager.h ('k') | chrome/browser/local_discovery/privet_http.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698