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

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

Issue 2642783003: Move more utility functions to arc_util. (Closed)
Patch Set: Revert IsIntentHelperAvailable fix. Created 3 years, 11 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/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"
11 #include "base/command_line.h" 11 #include "base/command_line.h"
12 #include "base/feature_list.h" 12 #include "base/feature_list.h"
13 #include "base/files/file_path.h" 13 #include "base/files/file_path.h"
14 #include "base/logging.h" 14 #include "base/logging.h"
15 #include "base/memory/weak_ptr.h" 15 #include "base/memory/weak_ptr.h"
16 #include "base/metrics/histogram_macros.h" 16 #include "base/metrics/histogram_macros.h"
17 #include "base/strings/string_util.h" 17 #include "base/strings/string_util.h"
18 #include "base/strings/stringprintf.h" 18 #include "base/strings/stringprintf.h"
19 #include "base/strings/utf_string_conversions.h" 19 #include "base/strings/utf_string_conversions.h"
20 #include "chrome/browser/chromeos/arc/arc_session_manager.h" 20 #include "chrome/browser/chromeos/arc/arc_util.h"
21 #include "chrome/browser/chromeos/arc/fileapi/arc_documents_provider_util.h" 21 #include "chrome/browser/chromeos/arc/fileapi/arc_documents_provider_util.h"
22 #include "chrome/browser/chromeos/arc/fileapi/arc_file_system_service.h" 22 #include "chrome/browser/chromeos/arc/fileapi/arc_file_system_service.h"
23 #include "chrome/browser/chromeos/arc/fileapi/arc_media_view_util.h" 23 #include "chrome/browser/chromeos/arc/fileapi/arc_media_view_util.h"
24 #include "chrome/browser/chromeos/drive/drive_integration_service.h" 24 #include "chrome/browser/chromeos/drive/drive_integration_service.h"
25 #include "chrome/browser/chromeos/drive/file_system_util.h" 25 #include "chrome/browser/chromeos/drive/file_system_util.h"
26 #include "chrome/browser/chromeos/file_manager/path_util.h" 26 #include "chrome/browser/chromeos/file_manager/path_util.h"
27 #include "chrome/browser/chromeos/file_manager/snapshot_manager.h" 27 #include "chrome/browser/chromeos/file_manager/snapshot_manager.h"
28 #include "chrome/browser/chromeos/file_manager/volume_manager_factory.h" 28 #include "chrome/browser/chromeos/file_manager/volume_manager_factory.h"
29 #include "chrome/browser/chromeos/file_manager/volume_manager_observer.h" 29 #include "chrome/browser/chromeos/file_manager/volume_manager_observer.h"
30 #include "chrome/browser/chromeos/file_system_provider/provided_file_system_info .h" 30 #include "chrome/browser/chromeos/file_system_provider/provided_file_system_info .h"
(...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after
402 402
403 // Subscribe to storage monitor for MTP notifications. 403 // Subscribe to storage monitor for MTP notifications.
404 if (storage_monitor::StorageMonitor::GetInstance()) { 404 if (storage_monitor::StorageMonitor::GetInstance()) {
405 storage_monitor::StorageMonitor::GetInstance()->EnsureInitialized( 405 storage_monitor::StorageMonitor::GetInstance()->EnsureInitialized(
406 base::Bind(&VolumeManager::OnStorageMonitorInitialized, 406 base::Bind(&VolumeManager::OnStorageMonitorInitialized,
407 weak_ptr_factory_.GetWeakPtr())); 407 weak_ptr_factory_.GetWeakPtr()));
408 } 408 }
409 409
410 // Subscribe to ARC file system events. 410 // Subscribe to ARC file system events.
411 if (base::FeatureList::IsEnabled(arc::kMediaViewFeature) && 411 if (base::FeatureList::IsEnabled(arc::kMediaViewFeature) &&
412 arc::ArcSessionManager::IsAllowedForProfile(profile_)) { 412 arc::util::IsArcAllowedForProfile(profile_)) {
413 arc::ArcServiceManager::GetGlobalService<arc::ArcFileSystemService>() 413 arc::ArcServiceManager::GetGlobalService<arc::ArcFileSystemService>()
414 ->AddObserver(this); 414 ->AddObserver(this);
415 } 415 }
416 } 416 }
417 417
418 void VolumeManager::Shutdown() { 418 void VolumeManager::Shutdown() {
419 weak_ptr_factory_.InvalidateWeakPtrs(); 419 weak_ptr_factory_.InvalidateWeakPtrs();
420 420
421 snapshot_manager_.reset(); 421 snapshot_manager_.reset();
422 pref_change_registrar_.RemoveAll(); 422 pref_change_registrar_.RemoveAll();
423 disk_mount_manager_->RemoveObserver(this); 423 disk_mount_manager_->RemoveObserver(this);
424 if (storage_monitor::StorageMonitor::GetInstance()) 424 if (storage_monitor::StorageMonitor::GetInstance())
425 storage_monitor::StorageMonitor::GetInstance()->RemoveObserver(this); 425 storage_monitor::StorageMonitor::GetInstance()->RemoveObserver(this);
426 426
427 if (drive_integration_service_) 427 if (drive_integration_service_)
428 drive_integration_service_->RemoveObserver(this); 428 drive_integration_service_->RemoveObserver(this);
429 429
430 if (file_system_provider_service_) 430 if (file_system_provider_service_)
431 file_system_provider_service_->RemoveObserver(this); 431 file_system_provider_service_->RemoveObserver(this);
432 432
433 // Unsubscribe from ARC file system events. 433 // Unsubscribe from ARC file system events.
434 if (base::FeatureList::IsEnabled(arc::kMediaViewFeature) && 434 if (base::FeatureList::IsEnabled(arc::kMediaViewFeature) &&
435 arc::ArcSessionManager::IsAllowedForProfile(profile_)) { 435 arc::util::IsArcAllowedForProfile(profile_)) {
436 arc::ArcFileSystemService* file_system_service = 436 arc::ArcFileSystemService* file_system_service =
437 arc::ArcServiceManager::GetGlobalService<arc::ArcFileSystemService>(); 437 arc::ArcServiceManager::GetGlobalService<arc::ArcFileSystemService>();
438 // TODO(crbug.com/672829): We need nullptr check here because 438 // TODO(crbug.com/672829): We need nullptr check here because
439 // ArcServiceManager may or may not be alive at this point. 439 // ArcServiceManager may or may not be alive at this point.
440 if (file_system_service) 440 if (file_system_service)
441 file_system_service->RemoveObserver(this); 441 file_system_service->RemoveObserver(this);
442 } 442 }
443 } 443 }
444 444
445 void VolumeManager::AddObserver(VolumeManagerObserver* observer) { 445 void VolumeManager::AddObserver(VolumeManagerObserver* observer) {
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after
740 disk_mount_manager_->UnmountPath( 740 disk_mount_manager_->UnmountPath(
741 mount_path, chromeos::UNMOUNT_OPTIONS_NONE, 741 mount_path, chromeos::UNMOUNT_OPTIONS_NONE,
742 base::Bind( 742 base::Bind(
743 &VolumeManager::OnExternalStorageDisabledChangedUnmountCallback, 743 &VolumeManager::OnExternalStorageDisabledChangedUnmountCallback,
744 weak_ptr_factory_.GetWeakPtr())); 744 weak_ptr_factory_.GetWeakPtr()));
745 } 745 }
746 746
747 void VolumeManager::OnFileSystemsReady() { 747 void VolumeManager::OnFileSystemsReady() {
748 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 748 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
749 DCHECK(base::FeatureList::IsEnabled(arc::kMediaViewFeature)); 749 DCHECK(base::FeatureList::IsEnabled(arc::kMediaViewFeature));
750 DCHECK(arc::ArcSessionManager::IsAllowedForProfile(profile_)); 750 DCHECK(arc::util::IsArcAllowedForProfile(profile_));
751 751
752 DoMountEvent(chromeos::MOUNT_ERROR_NONE, 752 DoMountEvent(chromeos::MOUNT_ERROR_NONE,
753 linked_ptr<Volume>( 753 linked_ptr<Volume>(
754 Volume::CreateForMediaView(arc::kImagesRootDocumentId))); 754 Volume::CreateForMediaView(arc::kImagesRootDocumentId)));
755 DoMountEvent(chromeos::MOUNT_ERROR_NONE, 755 DoMountEvent(chromeos::MOUNT_ERROR_NONE,
756 linked_ptr<Volume>( 756 linked_ptr<Volume>(
757 Volume::CreateForMediaView(arc::kVideosRootDocumentId))); 757 Volume::CreateForMediaView(arc::kVideosRootDocumentId)));
758 DoMountEvent(chromeos::MOUNT_ERROR_NONE, 758 DoMountEvent(chromeos::MOUNT_ERROR_NONE,
759 linked_ptr<Volume>( 759 linked_ptr<Volume>(
760 Volume::CreateForMediaView(arc::kAudioRootDocumentId))); 760 Volume::CreateForMediaView(arc::kAudioRootDocumentId)));
761 } 761 }
762 762
763 void VolumeManager::OnFileSystemsClosed() { 763 void VolumeManager::OnFileSystemsClosed() {
764 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 764 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
765 DCHECK(base::FeatureList::IsEnabled(arc::kMediaViewFeature)); 765 DCHECK(base::FeatureList::IsEnabled(arc::kMediaViewFeature));
766 DCHECK(arc::ArcSessionManager::IsAllowedForProfile(profile_)); 766 DCHECK(arc::util::IsArcAllowedForProfile(profile_));
767 767
768 DoUnmountEvent(chromeos::MOUNT_ERROR_NONE, 768 DoUnmountEvent(chromeos::MOUNT_ERROR_NONE,
769 linked_ptr<Volume>( 769 linked_ptr<Volume>(
770 Volume::CreateForMediaView(arc::kImagesRootDocumentId))); 770 Volume::CreateForMediaView(arc::kImagesRootDocumentId)));
771 DoUnmountEvent(chromeos::MOUNT_ERROR_NONE, 771 DoUnmountEvent(chromeos::MOUNT_ERROR_NONE,
772 linked_ptr<Volume>( 772 linked_ptr<Volume>(
773 Volume::CreateForMediaView(arc::kVideosRootDocumentId))); 773 Volume::CreateForMediaView(arc::kVideosRootDocumentId)));
774 DoUnmountEvent(chromeos::MOUNT_ERROR_NONE, 774 DoUnmountEvent(chromeos::MOUNT_ERROR_NONE,
775 linked_ptr<Volume>( 775 linked_ptr<Volume>(
776 Volume::CreateForMediaView(arc::kAudioRootDocumentId))); 776 Volume::CreateForMediaView(arc::kAudioRootDocumentId)));
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
987 if (mounted_volumes_.find(volume->volume_id()) == mounted_volumes_.end()) 987 if (mounted_volumes_.find(volume->volume_id()) == mounted_volumes_.end())
988 return; 988 return;
989 if (error_code == chromeos::MOUNT_ERROR_NONE) 989 if (error_code == chromeos::MOUNT_ERROR_NONE)
990 mounted_volumes_.erase(volume->volume_id()); 990 mounted_volumes_.erase(volume->volume_id());
991 991
992 for (auto& observer : observers_) 992 for (auto& observer : observers_)
993 observer.OnVolumeUnmounted(error_code, *volume.get()); 993 observer.OnVolumeUnmounted(error_code, *volume.get());
994 } 994 }
995 995
996 } // namespace file_manager 996 } // namespace file_manager
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698