Index: chrome/browser/chromeos/file_manager/volume_manager.cc |
diff --git a/chrome/browser/chromeos/file_manager/volume_manager.cc b/chrome/browser/chromeos/file_manager/volume_manager.cc |
index 4464bb60c0cb9c27c5c8e5bd8ed3986cf3e1eee1..5bb672f3d382a9f236e5d46a0ab0f7c30b71611f 100644 |
--- a/chrome/browser/chromeos/file_manager/volume_manager.cc |
+++ b/chrome/browser/chromeos/file_manager/volume_manager.cc |
@@ -9,6 +9,7 @@ |
#include "base/bind.h" |
#include "base/command_line.h" |
+#include "base/feature_list.h" |
#include "base/files/file_path.h" |
#include "base/logging.h" |
#include "base/memory/weak_ptr.h" |
@@ -16,6 +17,10 @@ |
#include "base/strings/string_util.h" |
#include "base/strings/stringprintf.h" |
#include "base/strings/utf_string_conversions.h" |
+#include "chrome/browser/chromeos/arc/arc_session_manager.h" |
+#include "chrome/browser/chromeos/arc/fileapi/arc_documents_provider_util.h" |
+#include "chrome/browser/chromeos/arc/fileapi/arc_file_system_service.h" |
+#include "chrome/browser/chromeos/arc/fileapi/arc_media_view_util.h" |
#include "chrome/browser/chromeos/drive/drive_integration_service.h" |
#include "chrome/browser/chromeos/drive/file_system_util.h" |
#include "chrome/browser/chromeos/file_manager/path_util.h" |
@@ -111,6 +116,8 @@ std::string VolumeTypeToString(VolumeType type) { |
return "provided"; |
case VOLUME_TYPE_MTP: |
return "mtp"; |
+ case VOLUME_TYPE_MEDIA_VIEW: |
+ return "media_view"; |
case VOLUME_TYPE_TESTING: |
return "testing"; |
case NUM_VOLUME_TYPE: |
@@ -271,6 +278,22 @@ Volume* Volume::CreateForMTP(const base::FilePath& mount_path, |
} |
// static |
+Volume* Volume::CreateForMediaView(const std::string& root_document_id) { |
+ Volume* const volume = new Volume; |
+ volume->type_ = VOLUME_TYPE_MEDIA_VIEW; |
+ volume->device_type_ = chromeos::DEVICE_TYPE_UNKNOWN; |
+ volume->source_ = SOURCE_SYSTEM; |
+ volume->mount_path_ = arc::GetDocumentsProviderMountPath( |
+ arc::kMediaDocumentsProviderAuthority, root_document_id); |
+ volume->mount_condition_ = chromeos::disks::MOUNT_CONDITION_NONE; |
+ volume->volume_label_ = root_document_id; |
+ volume->is_read_only_ = true; |
+ volume->watchable_ = false; |
+ volume->volume_id_ = arc::GetMediaViewVolumeId(root_document_id); |
+ return volume; |
+} |
+ |
+// static |
Volume* Volume::CreateForTesting(const base::FilePath& path, |
VolumeType volume_type, |
chromeos::DeviceType device_type, |
@@ -382,6 +405,13 @@ void VolumeManager::Initialize() { |
base::Bind(&VolumeManager::OnStorageMonitorInitialized, |
weak_ptr_factory_.GetWeakPtr())); |
} |
+ |
+ // Subscribe to ARC events. |
+ if (base::FeatureList::IsEnabled(arc::kMediaViewFeature) && |
+ arc::ArcSessionManager::IsAllowedForProfile(profile_)) { |
+ arc::ArcServiceManager::Get()->AddObserver(this); |
+ arc::ArcServiceManager::Get()->file_system_service()->AddObserver(this); |
+ } |
} |
void VolumeManager::Shutdown() { |
@@ -702,6 +732,42 @@ void VolumeManager::OnExternalStorageDisabledChangedUnmountCallback( |
weak_ptr_factory_.GetWeakPtr())); |
} |
+void VolumeManager::OnFileSystemsReady() { |
+ DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
+ DCHECK(base::FeatureList::IsEnabled(arc::kMediaViewFeature)); |
+ DCHECK(arc::ArcSessionManager::IsAllowedForProfile(profile_)); |
+ |
+ DoMountEvent(chromeos::MOUNT_ERROR_NONE, |
+ linked_ptr<Volume>( |
+ Volume::CreateForMediaView(arc::kImagesRootDocumentId))); |
+ DoMountEvent(chromeos::MOUNT_ERROR_NONE, |
+ linked_ptr<Volume>( |
+ Volume::CreateForMediaView(arc::kVideosRootDocumentId))); |
+ DoMountEvent(chromeos::MOUNT_ERROR_NONE, |
+ linked_ptr<Volume>( |
+ Volume::CreateForMediaView(arc::kAudioRootDocumentId))); |
+} |
+ |
+void VolumeManager::OnArcShutdown() { |
Luis Héctor Chávez
2017/01/10 18:51:35
Unfortunately this was reverted :(
Shuhei Takahashi
2017/01/11 15:20:43
Thanks for heads-up. Rebased on tot.
|
+ DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
+ DCHECK(base::FeatureList::IsEnabled(arc::kMediaViewFeature)); |
+ DCHECK(arc::ArcSessionManager::IsAllowedForProfile(profile_)); |
+ |
+ DoUnmountEvent(chromeos::MOUNT_ERROR_NONE, |
Luis Héctor Chávez
2017/01/10 18:51:35
What happens if OnFileSystemsReady() was never cal
Shuhei Takahashi
2017/01/11 15:20:43
It is okay to call DoUnmountEvent() even if mounts
|
+ linked_ptr<Volume>( |
+ Volume::CreateForMediaView(arc::kImagesRootDocumentId))); |
+ DoUnmountEvent(chromeos::MOUNT_ERROR_NONE, |
+ linked_ptr<Volume>( |
+ Volume::CreateForMediaView(arc::kVideosRootDocumentId))); |
+ DoUnmountEvent(chromeos::MOUNT_ERROR_NONE, |
+ linked_ptr<Volume>( |
+ Volume::CreateForMediaView(arc::kAudioRootDocumentId))); |
+ |
+ // Unsubscribe from ARC events. |
+ arc::ArcServiceManager::Get()->RemoveObserver(this); |
+ arc::ArcServiceManager::Get()->file_system_service()->RemoveObserver(this); |
Luis Héctor Chávez
2017/01/10 18:51:35
nit: unsubscribe in the reverse order in which you
Shuhei Takahashi
2017/01/11 15:20:43
Done (actually we now observe only one instance).
|
+} |
+ |
void VolumeManager::OnExternalStorageDisabledChanged() { |
// If the policy just got disabled we have to unmount every device currently |
// mounted. The opposite is fine - we can let the user re-plug their device to |