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/command_line.h" | |
10 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
11 #include "base/logging.h" | 10 #include "base/logging.h" |
12 #include "base/metrics/histogram.h" | 11 #include "base/metrics/histogram.h" |
13 #include "base/prefs/pref_service.h" | 12 #include "base/prefs/pref_service.h" |
14 #include "base/strings/stringprintf.h" | 13 #include "base/strings/stringprintf.h" |
15 #include "base/strings/utf_string_conversions.h" | 14 #include "base/strings/utf_string_conversions.h" |
16 #include "chrome/browser/chromeos/drive/drive_integration_service.h" | 15 #include "chrome/browser/chromeos/drive/drive_integration_service.h" |
17 #include "chrome/browser/chromeos/drive/file_system_interface.h" | 16 #include "chrome/browser/chromeos/drive/file_system_interface.h" |
18 #include "chrome/browser/chromeos/drive/file_system_util.h" | 17 #include "chrome/browser/chromeos/drive/file_system_util.h" |
19 #include "chrome/browser/chromeos/file_manager/path_util.h" | 18 #include "chrome/browser/chromeos/file_manager/path_util.h" |
20 #include "chrome/browser/chromeos/file_manager/snapshot_manager.h" | 19 #include "chrome/browser/chromeos/file_manager/snapshot_manager.h" |
21 #include "chrome/browser/chromeos/file_manager/volume_manager_factory.h" | 20 #include "chrome/browser/chromeos/file_manager/volume_manager_factory.h" |
22 #include "chrome/browser/chromeos/file_manager/volume_manager_observer.h" | 21 #include "chrome/browser/chromeos/file_manager/volume_manager_observer.h" |
23 #include "chrome/browser/chromeos/file_system_provider/provided_file_system_info
.h" | 22 #include "chrome/browser/chromeos/file_system_provider/provided_file_system_info
.h" |
24 #include "chrome/browser/chromeos/profiles/profile_helper.h" | 23 #include "chrome/browser/chromeos/profiles/profile_helper.h" |
25 #include "chrome/browser/media_galleries/fileapi/mtp_device_map_service.h" | 24 #include "chrome/browser/media_galleries/fileapi/mtp_device_map_service.h" |
26 #include "chrome/browser/profiles/profile.h" | 25 #include "chrome/browser/profiles/profile.h" |
27 #include "chrome/common/chrome_switches.h" | |
28 #include "chrome/common/pref_names.h" | 26 #include "chrome/common/pref_names.h" |
29 #include "chromeos/chromeos_switches.h" | |
30 #include "chromeos/disks/disk_mount_manager.h" | 27 #include "chromeos/disks/disk_mount_manager.h" |
31 #include "components/storage_monitor/storage_monitor.h" | 28 #include "components/storage_monitor/storage_monitor.h" |
32 #include "content/public/browser/browser_context.h" | 29 #include "content/public/browser/browser_context.h" |
33 #include "content/public/browser/browser_thread.h" | 30 #include "content/public/browser/browser_thread.h" |
34 #include "webkit/browser/fileapi/external_mount_points.h" | 31 #include "webkit/browser/fileapi/external_mount_points.h" |
35 | 32 |
36 namespace file_manager { | 33 namespace file_manager { |
37 namespace { | 34 namespace { |
38 | 35 |
39 const char kFileManagerMTPMountNamePrefix[] = "fileman-mtp-"; | 36 const char kFileManagerMTPMountNamePrefix[] = "fileman-mtp-"; |
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
311 } | 308 } |
312 | 309 |
313 // Subscribe to Profile Preference change. | 310 // Subscribe to Profile Preference change. |
314 pref_change_registrar_.Init(profile_->GetPrefs()); | 311 pref_change_registrar_.Init(profile_->GetPrefs()); |
315 pref_change_registrar_.Add( | 312 pref_change_registrar_.Add( |
316 prefs::kExternalStorageDisabled, | 313 prefs::kExternalStorageDisabled, |
317 base::Bind(&VolumeManager::OnExternalStorageDisabledChanged, | 314 base::Bind(&VolumeManager::OnExternalStorageDisabledChanged, |
318 weak_ptr_factory_.GetWeakPtr())); | 315 weak_ptr_factory_.GetWeakPtr())); |
319 | 316 |
320 // Subscribe to storage monitor for MTP notifications. | 317 // Subscribe to storage monitor for MTP notifications. |
321 const bool disable_mtp = | 318 if (storage_monitor::StorageMonitor::GetInstance()) { |
322 CommandLine::ForCurrentProcess()->GetSwitchValueASCII( | |
323 chromeos::switches::kEnableFileManagerMTP) == "false"; | |
324 if (!disable_mtp && storage_monitor::StorageMonitor::GetInstance()) { | |
325 storage_monitor::StorageMonitor::GetInstance()->EnsureInitialized( | 319 storage_monitor::StorageMonitor::GetInstance()->EnsureInitialized( |
326 base::Bind(&VolumeManager::OnStorageMonitorInitialized, | 320 base::Bind(&VolumeManager::OnStorageMonitorInitialized, |
327 weak_ptr_factory_.GetWeakPtr())); | 321 weak_ptr_factory_.GetWeakPtr())); |
328 } | 322 } |
329 } | 323 } |
330 | 324 |
331 void VolumeManager::Shutdown() { | 325 void VolumeManager::Shutdown() { |
332 weak_ptr_factory_.InvalidateWeakPtrs(); | 326 weak_ptr_factory_.InvalidateWeakPtrs(); |
333 | 327 |
334 snapshot_manager_.reset(); | 328 snapshot_manager_.reset(); |
(...skipping 462 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
797 return; | 791 return; |
798 if (error_code == chromeos::MOUNT_ERROR_NONE) | 792 if (error_code == chromeos::MOUNT_ERROR_NONE) |
799 mounted_volumes_.erase(volume_info.volume_id); | 793 mounted_volumes_.erase(volume_info.volume_id); |
800 | 794 |
801 FOR_EACH_OBSERVER(VolumeManagerObserver, | 795 FOR_EACH_OBSERVER(VolumeManagerObserver, |
802 observers_, | 796 observers_, |
803 OnVolumeUnmounted(error_code, volume_info)); | 797 OnVolumeUnmounted(error_code, volume_info)); |
804 } | 798 } |
805 | 799 |
806 } // namespace file_manager | 800 } // namespace file_manager |
OLD | NEW |