Commit 4b8fa62a authored by nya's avatar nya Committed by Commit bot

mediaview: Mount ARC documents provider file system volumes.

New media view volumes are added to chromeos::VolumeManager so that they are
available to Files.app. UI patches are coming later, so at this point it looks like
unusable unknown volumes appear in Files.app. To hide them from users for now,
the feature is guarded with base::FeatureList. Once UI is ready I will make them
enabled by default.

BUG=chromium:671511
TEST=New (unusable) volumes are shown with --enable-features=ArcMediaView
TEST=Media views work with local pending UI patches

Review-Url: https://codereview.chromium.org/2580303002
Cr-Commit-Position: refs/heads/master@{#443205}
parent 9b7705c2
...@@ -263,6 +263,8 @@ source_set("chromeos") { ...@@ -263,6 +263,8 @@ source_set("chromeos") {
"arc/fileapi/arc_file_system_instance_util.h", "arc/fileapi/arc_file_system_instance_util.h",
"arc/fileapi/arc_file_system_service.cc", "arc/fileapi/arc_file_system_service.cc",
"arc/fileapi/arc_file_system_service.h", "arc/fileapi/arc_file_system_service.h",
"arc/fileapi/arc_media_view_util.cc",
"arc/fileapi/arc_media_view_util.h",
"arc/intent_helper/arc_external_protocol_dialog.cc", "arc/intent_helper/arc_external_protocol_dialog.cc",
"arc/intent_helper/arc_external_protocol_dialog.h", "arc/intent_helper/arc_external_protocol_dialog.h",
"arc/intent_helper/arc_navigation_throttle.cc", "arc/intent_helper/arc_navigation_throttle.cc",
......
...@@ -14,11 +14,48 @@ ...@@ -14,11 +14,48 @@
namespace arc { namespace arc {
// This is based on net/base/escape.cc: net::(anonymous namespace)::Escape.
// TODO(nya): Consider consolidating this function with EscapeFileSystemId() in
// chrome/browser/chromeos/file_system_provider/mount_path_util.cc.
// This version differs from the other one in the point that dots are not always
// escaped because authorities often contain harmless dots.
std::string EscapePathComponent(const std::string& name) {
std::string escaped;
// Escape dots only when they forms a special file name.
if (name == "." || name == "..") {
base::ReplaceChars(name, ".", "%2E", &escaped);
return escaped;
}
// Escape % and / only.
for (size_t i = 0; i < name.size(); ++i) {
const char c = name[i];
if (c == '%' || c == '/')
base::StringAppendF(&escaped, "%%%02X", c);
else
escaped.push_back(c);
}
return escaped;
}
std::string UnescapePathComponent(const std::string& escaped) {
return net::UnescapeURLComponent(
escaped, net::UnescapeRule::PATH_SEPARATORS |
net::UnescapeRule::URL_SPECIAL_CHARS_EXCEPT_PATH_SEPARATORS);
}
const char kDocumentsProviderMountPointName[] = "arc-documents-provider"; const char kDocumentsProviderMountPointName[] = "arc-documents-provider";
const base::FilePath::CharType kDocumentsProviderMountPointPath[] = const base::FilePath::CharType kDocumentsProviderMountPointPath[] =
"/special/arc-documents-provider"; "/special/arc-documents-provider";
const char kAndroidDirectoryMimeType[] = "vnd.android.document/directory"; const char kAndroidDirectoryMimeType[] = "vnd.android.document/directory";
base::FilePath GetDocumentsProviderMountPath(
const std::string& authority,
const std::string& root_document_id) {
return base::FilePath(kDocumentsProviderMountPointPath)
.Append(EscapePathComponent(authority))
.Append(EscapePathComponent(root_document_id));
}
bool ParseDocumentsProviderUrl(const storage::FileSystemURL& url, bool ParseDocumentsProviderUrl(const storage::FileSystemURL& url,
std::string* authority, std::string* authority,
std::string* root_document_id, std::string* root_document_id,
...@@ -39,12 +76,11 @@ bool ParseDocumentsProviderUrl(const storage::FileSystemURL& url, ...@@ -39,12 +76,11 @@ bool ParseDocumentsProviderUrl(const storage::FileSystemURL& url,
if (components.size() < 5) if (components.size() < 5)
return false; return false;
*authority = components[3]; *authority = UnescapePathComponent(components[3]);
*root_document_id = components[4]; *root_document_id = UnescapePathComponent(components[4]);
base::FilePath root_path = base::FilePath(kDocumentsProviderMountPointPath) base::FilePath root_path =
.Append(*authority) GetDocumentsProviderMountPath(*authority, *root_document_id);
.Append(*root_document_id);
// Special case: AppendRelativePath() fails for identical paths. // Special case: AppendRelativePath() fails for identical paths.
if (url_path_stripped == root_path) { if (url_path_stripped == root_path) {
path->clear(); path->clear();
......
...@@ -29,7 +29,28 @@ extern const base::FilePath::CharType kDocumentsProviderMountPointPath[]; ...@@ -29,7 +29,28 @@ extern const base::FilePath::CharType kDocumentsProviderMountPointPath[];
// Defined as DocumentsContract.Document.MIME_TYPE_DIR in Android. // Defined as DocumentsContract.Document.MIME_TYPE_DIR in Android.
extern const char kAndroidDirectoryMimeType[]; extern const char kAndroidDirectoryMimeType[];
// Escapes a string so it can be used as a file/directory name.
// [%/.] are escaped with percent-encoding.
// NOTE: This function is visible only for unit testing. Usually you should not
// call this function directly.
std::string EscapePathComponent(const std::string& name);
// Unescapes a string escaped by EscapePathComponent().
// NOTE: This function is visible only for unit testing. Usually you should not
// call this function directly.
std::string UnescapePathComponent(const std::string& escaped);
// Returns the path of a directory where the specified DocumentsProvider is
// mounted.
// Appropriate escaping is done to embed |authority| and |root_document_id| in
// a file path.
base::FilePath GetDocumentsProviderMountPath(
const std::string& authority,
const std::string& root_document_id);
// Parses a FileSystemURL pointing to ARC documents provider file system. // Parses a FileSystemURL pointing to ARC documents provider file system.
// Appropriate unescaping is done to extract |authority| and |root_document_id|
// from |url|.
// On success, true is returned. All arguments must not be nullptr. // On success, true is returned. All arguments must not be nullptr.
bool ParseDocumentsProviderUrl(const storage::FileSystemURL& url, bool ParseDocumentsProviderUrl(const storage::FileSystemURL& url,
std::string* authority, std::string* authority,
......
...@@ -12,6 +12,45 @@ namespace arc { ...@@ -12,6 +12,45 @@ namespace arc {
namespace { namespace {
TEST(ArcDocumentsProviderUtilTest, EscapePathComponent) {
EXPECT_EQ("", EscapePathComponent(""));
EXPECT_EQ("%2E", EscapePathComponent("."));
EXPECT_EQ("%2E%2E", EscapePathComponent(".."));
EXPECT_EQ("...", EscapePathComponent("..."));
EXPECT_EQ("example.com", EscapePathComponent("example.com"));
EXPECT_EQ("%2F%2F%2F", EscapePathComponent("///"));
EXPECT_EQ("100%25", EscapePathComponent("100%"));
EXPECT_EQ("a b", EscapePathComponent("a b"));
EXPECT_EQ("ねこ", EscapePathComponent("ねこ"));
}
TEST(ArcDocumentsProviderUtilTest, UnescapePathComponent) {
EXPECT_EQ("", UnescapePathComponent(""));
EXPECT_EQ(".", UnescapePathComponent("%2E"));
EXPECT_EQ("..", UnescapePathComponent("%2E%2E"));
EXPECT_EQ("...", UnescapePathComponent("..."));
EXPECT_EQ("example.com", UnescapePathComponent("example.com"));
EXPECT_EQ("///", UnescapePathComponent("%2F%2F%2F"));
EXPECT_EQ("100%", UnescapePathComponent("100%25"));
EXPECT_EQ("a b", UnescapePathComponent("a b"));
EXPECT_EQ("ねこ", UnescapePathComponent("ねこ"));
}
TEST(ArcDocumentsProviderUtilTest, GetDocumentsProviderMountPath) {
EXPECT_EQ("/special/arc-documents-provider/authority/document_id",
GetDocumentsProviderMountPath("authority", "document_id").value());
EXPECT_EQ("/special/arc-documents-provider/a b/a b",
GetDocumentsProviderMountPath("a b", "a b").value());
EXPECT_EQ("/special/arc-documents-provider/a%2Fb/a%2Fb",
GetDocumentsProviderMountPath("a/b", "a/b").value());
EXPECT_EQ("/special/arc-documents-provider/%2E/%2E",
GetDocumentsProviderMountPath(".", ".").value());
EXPECT_EQ("/special/arc-documents-provider/%2E%2E/%2E%2E",
GetDocumentsProviderMountPath("..", "..").value());
EXPECT_EQ("/special/arc-documents-provider/.../...",
GetDocumentsProviderMountPath("...", "...").value());
}
TEST(ArcDocumentsProviderUtilTest, ParseDocumentsProviderUrl) { TEST(ArcDocumentsProviderUtilTest, ParseDocumentsProviderUrl) {
std::string authority; std::string authority;
std::string root_document_id; std::string root_document_id;
...@@ -118,6 +157,22 @@ TEST(ArcDocumentsProviderUtilTest, ParseDocumentsProviderUrlInvalidPath) { ...@@ -118,6 +157,22 @@ TEST(ArcDocumentsProviderUtilTest, ParseDocumentsProviderUrlInvalidPath) {
&authority, &root_document_id, &path)); &authority, &root_document_id, &path));
} }
TEST(ArcDocumentsProviderUtilTest, ParseDocumentsProviderUrlUnescape) {
std::string authority;
std::string root_document_id;
base::FilePath path;
EXPECT_TRUE(ParseDocumentsProviderUrl(
storage::FileSystemURL::CreateForTest(
GURL(), storage::kFileSystemTypeArcDocumentsProvider,
base::FilePath(
"/special/arc-documents-provider/cats/ro%2Fot/home/calico.jpg")),
&authority, &root_document_id, &path));
EXPECT_EQ("cats", authority);
EXPECT_EQ("ro/ot", root_document_id);
EXPECT_EQ(FILE_PATH_LITERAL("home/calico.jpg"), path.value());
}
TEST(ArcDocumentsProviderUtilTest, ParseDocumentsProviderUrlUtf8) { TEST(ArcDocumentsProviderUtilTest, ParseDocumentsProviderUrlUtf8) {
std::string authority; std::string authority;
std::string root_document_id; std::string root_document_id;
...@@ -135,8 +190,13 @@ TEST(ArcDocumentsProviderUtilTest, ParseDocumentsProviderUrlUtf8) { ...@@ -135,8 +190,13 @@ TEST(ArcDocumentsProviderUtilTest, ParseDocumentsProviderUrlUtf8) {
} }
TEST(ArcDocumentsProviderUtilTest, BuildDocumentUrl) { TEST(ArcDocumentsProviderUtilTest, BuildDocumentUrl) {
EXPECT_EQ("content://Cat%20Provider/document/C%2B%2B", EXPECT_EQ("content://authority/document/document_id",
BuildDocumentUrl("Cat Provider", "C++").spec()); BuildDocumentUrl("authority", "document_id").spec());
EXPECT_EQ("content://a%20b/document/a%20b",
BuildDocumentUrl("a b", "a b").spec());
EXPECT_EQ("content://a%2Fb/document/a%2Fb",
BuildDocumentUrl("a/b", "a/b").spec());
EXPECT_EQ("content://../document/..", BuildDocumentUrl("..", "..").spec());
} }
} // namespace } // namespace
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#include "chrome/browser/chromeos/arc/fileapi/arc_content_file_system_url_util.h" #include "chrome/browser/chromeos/arc/fileapi/arc_content_file_system_url_util.h"
#include "chrome/browser/chromeos/arc/fileapi/arc_documents_provider_util.h" #include "chrome/browser/chromeos/arc/fileapi/arc_documents_provider_util.h"
#include "components/arc/arc_bridge_service.h" #include "components/arc/arc_bridge_service.h"
#include "components/arc/file_system/arc_file_system_observer.h"
#include "content/public/browser/browser_thread.h" #include "content/public/browser/browser_thread.h"
#include "storage/browser/fileapi/external_mount_points.h" #include "storage/browser/fileapi/external_mount_points.h"
...@@ -15,6 +16,10 @@ using content::BrowserThread; ...@@ -15,6 +16,10 @@ using content::BrowserThread;
namespace arc { namespace arc {
// static
const char ArcFileSystemService::kArcServiceName[] =
"arc::ArcFileSystemService";
ArcFileSystemService::ArcFileSystemService(ArcBridgeService* bridge_service) ArcFileSystemService::ArcFileSystemService(ArcBridgeService* bridge_service)
: ArcService(bridge_service) { : ArcService(bridge_service) {
DCHECK_CURRENTLY_ON(BrowserThread::UI); DCHECK_CURRENTLY_ON(BrowserThread::UI);
...@@ -31,11 +36,15 @@ ArcFileSystemService::ArcFileSystemService(ArcBridgeService* bridge_service) ...@@ -31,11 +36,15 @@ ArcFileSystemService::ArcFileSystemService(ArcBridgeService* bridge_service)
storage::kFileSystemTypeArcDocumentsProvider, storage::kFileSystemTypeArcDocumentsProvider,
storage::FileSystemMountOption(), storage::FileSystemMountOption(),
base::FilePath(kDocumentsProviderMountPointPath)); base::FilePath(kDocumentsProviderMountPointPath));
arc_bridge_service()->file_system()->AddObserver(this);
} }
ArcFileSystemService::~ArcFileSystemService() { ArcFileSystemService::~ArcFileSystemService() {
DCHECK_CURRENTLY_ON(BrowserThread::UI); DCHECK_CURRENTLY_ON(BrowserThread::UI);
arc_bridge_service()->file_system()->RemoveObserver(this);
storage::ExternalMountPoints* mount_points = storage::ExternalMountPoints* mount_points =
storage::ExternalMountPoints::GetSystemInstance(); storage::ExternalMountPoints::GetSystemInstance();
...@@ -43,4 +52,22 @@ ArcFileSystemService::~ArcFileSystemService() { ...@@ -43,4 +52,22 @@ ArcFileSystemService::~ArcFileSystemService() {
mount_points->RevokeFileSystem(kDocumentsProviderMountPointPath); mount_points->RevokeFileSystem(kDocumentsProviderMountPointPath);
} }
void ArcFileSystemService::AddObserver(ArcFileSystemObserver* observer) {
observer_list_.AddObserver(observer);
}
void ArcFileSystemService::RemoveObserver(ArcFileSystemObserver* observer) {
observer_list_.RemoveObserver(observer);
}
void ArcFileSystemService::OnInstanceReady() {
for (auto& observer : observer_list_)
observer.OnFileSystemsReady();
}
void ArcFileSystemService::OnInstanceClosed() {
for (auto& observer : observer_list_)
observer.OnFileSystemsClosed();
}
} // namespace arc } // namespace arc
...@@ -6,19 +6,37 @@ ...@@ -6,19 +6,37 @@
#define CHROME_BROWSER_CHROMEOS_ARC_FILEAPI_ARC_FILE_SYSTEM_SERVICE_H_ #define CHROME_BROWSER_CHROMEOS_ARC_FILEAPI_ARC_FILE_SYSTEM_SERVICE_H_
#include "base/macros.h" #include "base/macros.h"
#include "base/observer_list.h"
#include "components/arc/arc_service.h" #include "components/arc/arc_service.h"
#include "components/arc/common/file_system.mojom.h"
#include "components/arc/instance_holder.h"
namespace arc { namespace arc {
class ArcBridgeService; class ArcBridgeService;
class ArcFileSystemObserver;
// ArcFileSystemService registers ARC file systems to the system. // ArcFileSystemService registers ARC file systems to the system.
class ArcFileSystemService : public ArcService { class ArcFileSystemService
: public ArcService,
public InstanceHolder<mojom::FileSystemInstance>::Observer {
public: public:
explicit ArcFileSystemService(ArcBridgeService* bridge_service); explicit ArcFileSystemService(ArcBridgeService* bridge_service);
~ArcFileSystemService() override; ~ArcFileSystemService() override;
void AddObserver(ArcFileSystemObserver* observer);
void RemoveObserver(ArcFileSystemObserver* observer);
// InstanceHolder<mojom::FileSystemInstance>::Observer overrides:
void OnInstanceReady() override;
void OnInstanceClosed() override;
// For supporting ArcServiceManager::GetService<T>().
static const char kArcServiceName[];
private: private:
base::ObserverList<ArcFileSystemObserver> observer_list_;
DISALLOW_COPY_AND_ASSIGN(ArcFileSystemService); DISALLOW_COPY_AND_ASSIGN(ArcFileSystemService);
}; };
......
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/chromeos/arc/fileapi/arc_media_view_util.h"
namespace arc {
namespace {
constexpr char kMediaViewVolumeIdPrefix[] = "media_view:";
} // namespace
const base::Feature kMediaViewFeature{"ArcMediaView",
base::FEATURE_DISABLED_BY_DEFAULT};
const char kMediaDocumentsProviderAuthority[] =
"com.android.providers.media.documents";
const char kImagesRootDocumentId[] = "images_root";
const char kVideosRootDocumentId[] = "videos_root";
const char kAudioRootDocumentId[] = "audio_root";
std::string GetMediaViewVolumeId(const std::string& root_document_id) {
return std::string(kMediaViewVolumeIdPrefix) + root_document_id;
}
} // namespace arc
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// Utilities for ARC Media View.
#ifndef CHROME_BROWSER_CHROMEOS_ARC_FILEAPI_ARC_MEDIA_VIEW_UTIL_H_
#define CHROME_BROWSER_CHROMEOS_ARC_FILEAPI_ARC_MEDIA_VIEW_UTIL_H_
#include <string>
#include "base/feature_list.h"
namespace arc {
// base::FeatureList feature for ARC media view.
extern const base::Feature kMediaViewFeature;
// Authority of MediaDocumentsProvider in Android.
extern const char kMediaDocumentsProviderAuthority[];
// Document IDs of file system roots in MediaDocumentsProvider.
extern const char kImagesRootDocumentId[];
extern const char kVideosRootDocumentId[];
extern const char kAudioRootDocumentId[];
// Returns an ID of a Media View volume.
std::string GetMediaViewVolumeId(const std::string& root_document_id);
} // namespace arc
#endif // CHROME_BROWSER_CHROMEOS_ARC_FILEAPI_ARC_MEDIA_VIEW_UTIL_H_
...@@ -242,6 +242,10 @@ void VolumeToVolumeMetadata( ...@@ -242,6 +242,10 @@ void VolumeToVolumeMetadata(
case VOLUME_TYPE_MTP: case VOLUME_TYPE_MTP:
volume_metadata->volume_type = file_manager_private::VOLUME_TYPE_MTP; volume_metadata->volume_type = file_manager_private::VOLUME_TYPE_MTP;
break; break;
case VOLUME_TYPE_MEDIA_VIEW:
volume_metadata->volume_type =
file_manager_private::VOLUME_TYPE_MEDIA_VIEW;
break;
case VOLUME_TYPE_TESTING: case VOLUME_TYPE_TESTING:
volume_metadata->volume_type = volume_metadata->volume_type =
file_manager_private::VOLUME_TYPE_TESTING; file_manager_private::VOLUME_TYPE_TESTING;
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#include "base/bind.h" #include "base/bind.h"
#include "base/command_line.h" #include "base/command_line.h"
#include "base/feature_list.h"
#include "base/files/file_path.h" #include "base/files/file_path.h"
#include "base/logging.h" #include "base/logging.h"
#include "base/memory/weak_ptr.h" #include "base/memory/weak_ptr.h"
...@@ -16,6 +17,10 @@ ...@@ -16,6 +17,10 @@
#include "base/strings/string_util.h" #include "base/strings/string_util.h"
#include "base/strings/stringprintf.h" #include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.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/drive_integration_service.h"
#include "chrome/browser/chromeos/drive/file_system_util.h" #include "chrome/browser/chromeos/drive/file_system_util.h"
#include "chrome/browser/chromeos/file_manager/path_util.h" #include "chrome/browser/chromeos/file_manager/path_util.h"
...@@ -29,6 +34,7 @@ ...@@ -29,6 +34,7 @@
#include "chrome/common/pref_names.h" #include "chrome/common/pref_names.h"
#include "chromeos/chromeos_switches.h" #include "chromeos/chromeos_switches.h"
#include "chromeos/disks/disk_mount_manager.h" #include "chromeos/disks/disk_mount_manager.h"
#include "components/arc/arc_service_manager.h"
#include "components/drive/chromeos/file_system_interface.h" #include "components/drive/chromeos/file_system_interface.h"
#include "components/drive/file_system_core_util.h" #include "components/drive/file_system_core_util.h"
#include "components/prefs/pref_service.h" #include "components/prefs/pref_service.h"
...@@ -111,6 +117,8 @@ std::string VolumeTypeToString(VolumeType type) { ...@@ -111,6 +117,8 @@ std::string VolumeTypeToString(VolumeType type) {
return "provided"; return "provided";
case VOLUME_TYPE_MTP: case VOLUME_TYPE_MTP:
return "mtp"; return "mtp";
case VOLUME_TYPE_MEDIA_VIEW:
return "media_view";
case VOLUME_TYPE_TESTING: case VOLUME_TYPE_TESTING:
return "testing"; return "testing";
case NUM_VOLUME_TYPE: case NUM_VOLUME_TYPE:
...@@ -270,6 +278,22 @@ Volume* Volume::CreateForMTP(const base::FilePath& mount_path, ...@@ -270,6 +278,22 @@ Volume* Volume::CreateForMTP(const base::FilePath& mount_path,
return volume; return volume;
} }
// 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 // static
Volume* Volume::CreateForTesting(const base::FilePath& path, Volume* Volume::CreateForTesting(const base::FilePath& path,
VolumeType volume_type, VolumeType volume_type,
...@@ -382,6 +406,13 @@ void VolumeManager::Initialize() { ...@@ -382,6 +406,13 @@ void VolumeManager::Initialize() {
base::Bind(&VolumeManager::OnStorageMonitorInitialized, base::Bind(&VolumeManager::OnStorageMonitorInitialized,
weak_ptr_factory_.GetWeakPtr())); weak_ptr_factory_.GetWeakPtr()));
} }
// Subscribe to ARC file system events.
if (base::FeatureList::IsEnabled(arc::kMediaViewFeature) &&
arc::ArcSessionManager::IsAllowedForProfile(profile_)) {
arc::ArcServiceManager::GetGlobalService<arc::ArcFileSystemService>()
->AddObserver(this);
}
} }
void VolumeManager::Shutdown() { void VolumeManager::Shutdown() {
...@@ -398,6 +429,17 @@ void VolumeManager::Shutdown() { ...@@ -398,6 +429,17 @@ void VolumeManager::Shutdown() {
if (file_system_provider_service_) if (file_system_provider_service_)
file_system_provider_service_->RemoveObserver(this); file_system_provider_service_->RemoveObserver(this);
// Unsubscribe from ARC file system events.
if (base::FeatureList::IsEnabled(arc::kMediaViewFeature) &&
arc::ArcSessionManager::IsAllowedForProfile(profile_)) {
arc::ArcFileSystemService* file_system_service =
arc::ArcServiceManager::GetGlobalService<arc::ArcFileSystemService>();
// TODO(crbug.com/672829): We need nullptr check here because
// ArcServiceManager may or may not be alive at this point.
if (file_system_service)
file_system_service->RemoveObserver(this);
}
} }
void VolumeManager::AddObserver(VolumeManagerObserver* observer) { void VolumeManager::AddObserver(VolumeManagerObserver* observer) {
...@@ -702,6 +744,38 @@ void VolumeManager::OnExternalStorageDisabledChangedUnmountCallback( ...@@ -702,6 +744,38 @@ void VolumeManager::OnExternalStorageDisabledChangedUnmountCallback(
weak_ptr_factory_.GetWeakPtr())); 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::OnFileSystemsClosed() {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
DCHECK(base::FeatureList::IsEnabled(arc::kMediaViewFeature));
DCHECK(arc::ArcSessionManager::IsAllowedForProfile(profile_));
DoUnmountEvent(chromeos::MOUNT_ERROR_NONE,
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)));
}
void VolumeManager::OnExternalStorageDisabledChanged() { void VolumeManager::OnExternalStorageDisabledChanged() {
// If the policy just got disabled we have to unmount every device currently // 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 // mounted. The opposite is fine - we can let the user re-plug their device to
......
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
#include "chrome/browser/chromeos/file_system_provider/service.h" #include "chrome/browser/chromeos/file_system_provider/service.h"
#include "chromeos/dbus/cros_disks_client.h" #include "chromeos/dbus/cros_disks_client.h"
#include "chromeos/disks/disk_mount_manager.h" #include "chromeos/disks/disk_mount_manager.h"
#include "components/arc/file_system/arc_file_system_observer.h"
#include "components/keyed_service/core/keyed_service.h" #include "components/keyed_service/core/keyed_service.h"
#include "components/prefs/pref_change_registrar.h" #include "components/prefs/pref_change_registrar.h"
#include "components/storage_monitor/removable_storage_observer.h" #include "components/storage_monitor/removable_storage_observer.h"
...@@ -51,6 +52,7 @@ enum VolumeType { ...@@ -51,6 +52,7 @@ enum VolumeType {
VOLUME_TYPE_MOUNTED_ARCHIVE_FILE, VOLUME_TYPE_MOUNTED_ARCHIVE_FILE,
VOLUME_TYPE_PROVIDED, // File system provided by the FileSystemProvider API. VOLUME_TYPE_PROVIDED, // File system provided by the FileSystemProvider API.
VOLUME_TYPE_MTP, VOLUME_TYPE_MTP,
VOLUME_TYPE_MEDIA_VIEW,
// The enum values must be kept in sync with FileManagerVolumeType in // The enum values must be kept in sync with FileManagerVolumeType in
// tools/metrics/histograms/histograms.xml. Since enums for histograms are // tools/metrics/histograms/histograms.xml. Since enums for histograms are
// append-only (for keeping the number consistent across versions), new values // append-only (for keeping the number consistent across versions), new values
...@@ -90,6 +92,7 @@ class Volume : public base::SupportsWeakPtr<Volume> { ...@@ -90,6 +92,7 @@ class Volume : public base::SupportsWeakPtr<Volume> {
static Volume* CreateForMTP(const base::FilePath& mount_path, static Volume* CreateForMTP(const base::FilePath& mount_path,
const std::string& label, const std::string& label,
bool read_only); bool read_only);
static Volume* CreateForMediaView(const std::string& root_document_id);
static Volume* CreateForTesting(const base::FilePath& path, static Volume* CreateForTesting(const base::FilePath& path,
VolumeType volume_type, VolumeType volume_type,
chromeos::DeviceType device_type, chromeos::DeviceType device_type,
...@@ -211,6 +214,7 @@ class Volume : public base::SupportsWeakPtr<Volume> { ...@@ -211,6 +214,7 @@ class Volume : public base::SupportsWeakPtr<Volume> {
// for a device). // for a device).
// - Mounted zip archives. // - Mounted zip archives.
class VolumeManager : public KeyedService, class VolumeManager : public KeyedService,
public arc::ArcFileSystemObserver,
public drive::DriveIntegrationServiceObserver, public drive::DriveIntegrationServiceObserver,
public chromeos::disks::DiskMountManager::Observer, public chromeos::disks::DiskMountManager::Observer,
public chromeos::file_system_provider::Observer, public chromeos::file_system_provider::Observer,
...@@ -297,6 +301,10 @@ class VolumeManager : public KeyedService, ...@@ -297,6 +301,10 @@ class VolumeManager : public KeyedService,
file_system_info, file_system_info,
base::File::Error error) override; base::File::Error error) override;
// arc::ArcFileSystemObserver overrides.
void OnFileSystemsReady() override;
void OnFileSystemsClosed() override;
// Called on change to kExternalStorageDisabled pref. // Called on change to kExternalStorageDisabled pref.
void OnExternalStorageDisabledChanged(); void OnExternalStorageDisabledChanged();
......
...@@ -11,12 +11,14 @@ ...@@ -11,12 +11,14 @@
#include "base/command_line.h" #include "base/command_line.h"
#include "base/logging.h" #include "base/logging.h"
#include "base/memory/ptr_util.h" #include "base/memory/ptr_util.h"
#include "chrome/browser/chromeos/arc/fileapi/arc_documents_provider_util.h"
#include "chrome/browser/chromeos/fileapi/file_access_permissions.h" #include "chrome/browser/chromeos/fileapi/file_access_permissions.h"
#include "chrome/browser/chromeos/fileapi/file_system_backend_delegate.h" #include "chrome/browser/chromeos/fileapi/file_system_backend_delegate.h"
#include "chrome/browser/media_galleries/fileapi/media_file_system_backend.h" #include "chrome/browser/media_galleries/fileapi/media_file_system_backend.h"
#include "chrome/common/url_constants.h" #include "chrome/common/url_constants.h"
#include "chromeos/chromeos_switches.h" #include "chromeos/chromeos_switches.h"
#include "chromeos/dbus/cros_disks_client.h" #include "chromeos/dbus/cros_disks_client.h"
#include "net/base/escape.h"
#include "storage/browser/fileapi/async_file_util.h" #include "storage/browser/fileapi/async_file_util.h"
#include "storage/browser/fileapi/external_mount_points.h" #include "storage/browser/fileapi/external_mount_points.h"
#include "storage/browser/fileapi/file_stream_reader.h" #include "storage/browser/fileapi/file_stream_reader.h"
...@@ -26,6 +28,7 @@ ...@@ -26,6 +28,7 @@
#include "storage/browser/fileapi/file_system_operation_context.h" #include "storage/browser/fileapi/file_system_operation_context.h"
#include "storage/browser/fileapi/file_system_url.h" #include "storage/browser/fileapi/file_system_url.h"
#include "storage/common/fileapi/file_system_mount_option.h" #include "storage/common/fileapi/file_system_mount_option.h"
#include "storage/common/fileapi/file_system_util.h"
namespace chromeos { namespace chromeos {
namespace { namespace {
...@@ -156,6 +159,27 @@ void FileSystemBackend::ResolveURL(const storage::FileSystemURL& url, ...@@ -156,6 +159,27 @@ void FileSystemBackend::ResolveURL(const storage::FileSystemURL& url,
std::string inner_mount_name = components[1]; std::string inner_mount_name = components[1];
root_url += inner_mount_name + "/"; root_url += inner_mount_name + "/";
name = inner_mount_name; name = inner_mount_name;
} else if (id == arc::kDocumentsProviderMountPointName) {
// For ARC documents provider file system, volumes are mounted per document
// provider root, so we need to fix up |root_url| to point to an individual
// root.
std::string authority;
std::string root_document_id;
base::FilePath unused_path;
if (!arc::ParseDocumentsProviderUrl(url, &authority, &root_document_id,
&unused_path)) {
callback.Run(GURL(root_url), std::string(),
base::File::FILE_ERROR_SECURITY);
return;
}
base::FilePath mount_path =
arc::GetDocumentsProviderMountPath(authority, root_document_id);
base::FilePath relative_mount_path;
base::FilePath(arc::kDocumentsProviderMountPointPath)
.AppendRelativePath(mount_path, &relative_mount_path);
root_url +=
net::EscapePath(storage::FilePathToString(relative_mount_path)) + "/";
name = authority + ":" + root_document_id;
} else { } else {
name = id; name = id;
} }
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
namespace fileManagerPrivate { namespace fileManagerPrivate {
// Type of the mounted volume. // Type of the mounted volume.
enum VolumeType { drive, downloads, removable, archive, provided, mtp, enum VolumeType { drive, downloads, removable, archive, provided, mtp,
testing }; media_view, testing };
// Device type. Available if this is removable volume. // Device type. Available if this is removable volume.
enum DeviceType { usb, sd, optical, mobile, unknown }; enum DeviceType { usb, sd, optical, mobile, unknown };
......
...@@ -21,6 +21,7 @@ static_library("arc") { ...@@ -21,6 +21,7 @@ static_library("arc") {
"clipboard/arc_clipboard_bridge.h", "clipboard/arc_clipboard_bridge.h",
"crash_collector/arc_crash_collector_bridge.cc", "crash_collector/arc_crash_collector_bridge.cc",
"crash_collector/arc_crash_collector_bridge.h", "crash_collector/arc_crash_collector_bridge.h",
"file_system/arc_file_system_observer.h",
"ime/arc_ime_bridge.h", "ime/arc_ime_bridge.h",
"ime/arc_ime_bridge_impl.cc", "ime/arc_ime_bridge_impl.cc",
"ime/arc_ime_bridge_impl.h", "ime/arc_ime_bridge_impl.h",
......
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef COMPONENTS_ARC_FILE_SYSTEM_ARC_FILE_SYSTEM_OBSERVER_H_
#define COMPONENTS_ARC_FILE_SYSTEM_ARC_FILE_SYSTEM_OBSERVER_H_
namespace arc {
class ArcFileSystemObserver {
public:
virtual ~ArcFileSystemObserver() = default;
// Called when ARC file systems are ready.
virtual void OnFileSystemsReady() = 0;
// Called when ARC file systems are closed.
virtual void OnFileSystemsClosed() = 0;
};
} // namespace arc
#endif // COMPONENTS_ARC_FILE_SYSTEM_ARC_FILE_SYSTEM_OBSERVER_H_
// Copyright 2014 The Chromium Authors. All rights reserved. // Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// This file was generated by:
// tools/json_schema_compiler/compiler.py.
// NOTE: The format of types has changed. 'FooType' is now
// 'chrome.fileManagerPrivate.FooType'.
// Please run the closure compiler before committing changes.
// See https://chromium.googlesource.com/chromium/src/+/master/docs/closure_compilation.md
/** @fileoverview Externs generated from namespace: fileManagerPrivate */ /** @fileoverview Externs generated from namespace: fileManagerPrivate */
/**
* @const
*/
chrome.fileManagerPrivate = {};
/**
* @enum {string}
* @see https://developer.chrome.com/extensions/fileManagerPrivate#type-VolumeType
*/
chrome.fileManagerPrivate.VolumeType = {
DRIVE: 'drive',
DOWNLOADS: 'downloads',
REMOVABLE: 'removable',
ARCHIVE: 'archive',
PROVIDED: 'provided',
MTP: 'mtp',
MEDIA_VIEW: 'media_view',
TESTING: 'testing',
};
/**
* @enum {string}
* @see https://developer.chrome.com/extensions/fileManagerPrivate#type-DeviceType
*/
chrome.fileManagerPrivate.DeviceType = {
USB: 'usb',
SD: 'sd',
OPTICAL: 'optical',
MOBILE: 'mobile',
UNKNOWN: 'unknown',
};
/**
* @enum {string}
* @see https://developer.chrome.com/extensions/fileManagerPrivate#type-MountCondition
*/
chrome.fileManagerPrivate.MountCondition = {
UNKNOWN: 'unknown',
UNSUPPORTED: 'unsupported',
};
/**
* @enum {string}
* @see https://developer.chrome.com/extensions/fileManagerPrivate#type-MountContext
*/
chrome.fileManagerPrivate.MountContext = {
USER: 'user',
AUTO: 'auto',
};
/**
* @enum {string}
* @see https://developer.chrome.com/extensions/fileManagerPrivate#type-MountCompletedEventType
*/
chrome.fileManagerPrivate.MountCompletedEventType = {
MOUNT: 'mount',
UNMOUNT: 'unmount',
};
/**
* @enum {string}
* @see https://developer.chrome.com/extensions/fileManagerPrivate#type-MountCompletedStatus
*/
chrome.fileManagerPrivate.MountCompletedStatus = {
SUCCESS: 'success',
ERROR_UNKNOWN: 'error_unknown',
ERROR_INTERNAL: 'error_internal',
ERROR_INVALID_ARGUMENT: 'error_invalid_argument',
ERROR_INVALID_PATH: 'error_invalid_path',
ERROR_PATH_ALREADY_MOUNTED: 'error_path_already_mounted',
ERROR_PATH_NOT_MOUNTED: 'error_path_not_mounted',
ERROR_DIRECTORY_CREATION_FAILED: 'error_directory_creation_failed',
ERROR_INVALID_MOUNT_OPTIONS: 'error_invalid_mount_options',
ERROR_INVALID_UNMOUNT_OPTIONS: 'error_invalid_unmount_options',
ERROR_INSUFFICIENT_PERMISSIONS: 'error_insufficient_permissions',
ERROR_MOUNT_PROGRAM_NOT_FOUND: 'error_mount_program_not_found',
ERROR_MOUNT_PROGRAM_FAILED: 'error_mount_program_failed',
ERROR_INVALID_DEVICE_PATH: 'error_invalid_device_path',
ERROR_UNKNOWN_FILESYSTEM: 'error_unknown_filesystem',
ERROR_UNSUPPORTED_FILESYSTEM: 'error_unsupported_filesystem',
ERROR_INVALID_ARCHIVE: 'error_invalid_archive',
ERROR_AUTHENTICATION: 'error_authentication',
ERROR_PATH_UNMOUNTED: 'error_path_unmounted',
};
/**
* @enum {string}
* @see https://developer.chrome.com/extensions/fileManagerPrivate#type-TransferState
*/
chrome.fileManagerPrivate.TransferState = {
IN_PROGRESS: 'in_progress',
COMPLETED: 'completed',
FAILED: 'failed',
};
/**
* @enum {string}
* @see https://developer.chrome.com/extensions/fileManagerPrivate#type-TransferType
*/
chrome.fileManagerPrivate.TransferType = {
UPLOAD: 'upload',
DOWNLOAD: 'download',
};
/**
* @enum {string}
* @see https://developer.chrome.com/extensions/fileManagerPrivate#type-CopyProgressStatusType
*/
chrome.fileManagerPrivate.CopyProgressStatusType = {
BEGIN_COPY_ENTRY: 'begin_copy_entry',
END_COPY_ENTRY: 'end_copy_entry',
PROGRESS: 'progress',
SUCCESS: 'success',
ERROR: 'error',
};
/**
* @enum {string}
* @see https://developer.chrome.com/extensions/fileManagerPrivate#type-FileWatchEventType
*/
chrome.fileManagerPrivate.FileWatchEventType = {
CHANGED: 'changed',
ERROR: 'error',
};
/**
* @enum {string}
* @see https://developer.chrome.com/extensions/fileManagerPrivate#type-ChangeType
*/
chrome.fileManagerPrivate.ChangeType = {
ADD_OR_UPDATE: 'add_or_update',
DELETE: 'delete',
};
/**
* @enum {string}
* @see https://developer.chrome.com/extensions/fileManagerPrivate#type-SearchType
*/
chrome.fileManagerPrivate.SearchType = {
EXCLUDE_DIRECTORIES: 'EXCLUDE_DIRECTORIES',
SHARED_WITH_ME: 'SHARED_WITH_ME',
OFFLINE: 'OFFLINE',
ALL: 'ALL',
};
/**
* @enum {string}
* @see https://developer.chrome.com/extensions/fileManagerPrivate#type-ZoomOperationType
*/
chrome.fileManagerPrivate.ZoomOperationType = {
IN: 'in',
OUT: 'out',
RESET: 'reset',
};
/**
* @enum {string}
* @see https://developer.chrome.com/extensions/fileManagerPrivate#type-InspectionType
*/
chrome.fileManagerPrivate.InspectionType = {
NORMAL: 'normal',
CONSOLE: 'console',
ELEMENT: 'element',
BACKGROUND: 'background',
};
/**
* @enum {string}
* @see https://developer.chrome.com/extensions/fileManagerPrivate#type-DeviceEventType
*/
chrome.fileManagerPrivate.DeviceEventType = {
DISABLED: 'disabled',
REMOVED: 'removed',
HARD_UNPLUGGED: 'hard_unplugged',
FORMAT_START: 'format_start',
FORMAT_SUCCESS: 'format_success',
FORMAT_FAIL: 'format_fail',
};
/**
* @enum {string}
* @see https://developer.chrome.com/extensions/fileManagerPrivate#type-DriveSyncErrorType
*/
chrome.fileManagerPrivate.DriveSyncErrorType = {
DELETE_WITHOUT_PERMISSION: 'delete_without_permission',
SERVICE_UNAVAILABLE: 'service_unavailable',
NO_SERVER_SPACE: 'no_server_space',
MISC: 'misc',
};
/**
* @enum {string}
* @see https://developer.chrome.com/extensions/fileManagerPrivate#type-TaskResult
*/
chrome.fileManagerPrivate.TaskResult = {
OPENED: 'opened',
MESSAGE_SENT: 'message_sent',
FAILED: 'failed',
EMPTY: 'empty',
};
/**
* @enum {string}
* @see https://developer.chrome.com/extensions/fileManagerPrivate#type-DriveShareType
*/
chrome.fileManagerPrivate.DriveShareType = {
CAN_EDIT: 'can_edit',
CAN_COMMENT: 'can_comment',
CAN_VIEW: 'can_view',
};
/**
* @enum {string}
* @see https://developer.chrome.com/extensions/fileManagerPrivate#type-EntryPropertyName
*/
chrome.fileManagerPrivate.EntryPropertyName = {
SIZE: 'size',
MODIFICATION_TIME: 'modificationTime',
THUMBNAIL_URL: 'thumbnailUrl',
CROPPED_THUMBNAIL_URL: 'croppedThumbnailUrl',
IMAGE_WIDTH: 'imageWidth',
IMAGE_HEIGHT: 'imageHeight',
IMAGE_ROTATION: 'imageRotation',
PINNED: 'pinned',
PRESENT: 'present',
HOSTED: 'hosted',
AVAILABLE_OFFLINE: 'availableOffline',
AVAILABLE_WHEN_METERED: 'availableWhenMetered',
DIRTY: 'dirty',
CUSTOM_ICON_URL: 'customIconUrl',
CONTENT_MIME_TYPE: 'contentMimeType',
SHARED_WITH_ME: 'sharedWithMe',
SHARED: 'shared',
STARRED: 'starred',
EXTERNAL_FILE_URL: 'externalFileUrl',
};
/**
* @enum {string}
* @see https://developer.chrome.com/extensions/fileManagerPrivate#type-EntryTagVisibility
*/
chrome.fileManagerPrivate.EntryTagVisibility = {
PRIVATE: 'private',
PUBLIC: 'public',
};
/**
* @enum {string}
* @see https://developer.chrome.com/extensions/fileManagerPrivate#type-Source
*/
chrome.fileManagerPrivate.Source = {
FILE: 'file',
DEVICE: 'device',
NETWORK: 'network',
SYSTEM: 'system',
};
/**
* @enum {string}
* @see https://developer.chrome.com/extensions/fileManagerPrivate#type-Verb
*/
chrome.fileManagerPrivate.Verb = {
OPEN_WITH: 'open_with',
ADD_TO: 'add_to',
PACK_WITH: 'pack_with',
SHARE_WITH: 'share_with',
};
/** /**
* @typedef {{ * @typedef {{
* taskId: string, * taskId: string,
* title: string, * title: string,
* verb: (!chrome.fileManagerPrivate.Verb|undefined),
* iconUrl: string, * iconUrl: string,
* isDefault: boolean * isDefault: boolean,
* isGenericFileHandler: boolean
* }} * }}
* @see https://developer.chrome.com/extensions/fileManagerPrivate#type-FileTask
*/ */
var FileTask; chrome.fileManagerPrivate.FileTask;
/** /**
* @typedef {{ * @typedef {{
...@@ -20,31 +298,34 @@ var FileTask; ...@@ -20,31 +298,34 @@ var FileTask;
* modificationTime: (number|undefined), * modificationTime: (number|undefined),
* thumbnailUrl: (string|undefined), * thumbnailUrl: (string|undefined),
* croppedThumbnailUrl: (string|undefined), * croppedThumbnailUrl: (string|undefined),
* externalFileUrl: (string|undefined),
* imageWidth: (number|undefined), * imageWidth: (number|undefined),
* imageHeight: (number|undefined), * imageHeight: (number|undefined),
* imageRotation: (number|undefined), * imageRotation: (number|undefined),
* pinned: (boolean|undefined), * pinned: (boolean|undefined),
* present: (boolean|undefined), * present: (boolean|undefined),
* hosted: (boolean|undefined), * hosted: (boolean|undefined),
* dirty: (boolean|undefined),
* availableOffline: (boolean|undefined), * availableOffline: (boolean|undefined),
* availableWhenMetered: (boolean|undefined), * availableWhenMetered: (boolean|undefined),
* dirty: (boolean|undefined),
* customIconUrl: (string|undefined), * customIconUrl: (string|undefined),
* contentMimeType: (string|undefined), * contentMimeType: (string|undefined),
* sharedWithMe: (boolean|undefined), * sharedWithMe: (boolean|undefined),
* shared: (boolean|undefined) * shared: (boolean|undefined),
* starred: (boolean|undefined),
* externalFileUrl: (string|undefined)
* }} * }}
* @see https://developer.chrome.com/extensions/fileManagerPrivate#type-EntryProperties
*/ */
var EntryProperties; chrome.fileManagerPrivate.EntryProperties;
/** /**
* @typedef {{ * @typedef {{
* totalSize: number, * totalSize: number,
* remainingSize: number * remainingSize: number
* }} * }}
* @see https://developer.chrome.com/extensions/fileManagerPrivate#type-MountPointSizeStats
*/ */
var MountPointSizeStats; chrome.fileManagerPrivate.MountPointSizeStats;
/** /**
* @typedef {{ * @typedef {{
...@@ -52,20 +333,21 @@ var MountPointSizeStats; ...@@ -52,20 +333,21 @@ var MountPointSizeStats;
* displayName: string, * displayName: string,
* isCurrentProfile: boolean * isCurrentProfile: boolean
* }} * }}
* @see https://developer.chrome.com/extensions/fileManagerPrivate#type-ProfileInfo
*/ */
var ProfileInfo; chrome.fileManagerPrivate.ProfileInfo;
/** /**
* @typedef {{ * @typedef {{
* volumeId: string, * volumeId: string,
* fileSystemId: (string|undefined), * fileSystemId: (string|undefined),
* extensionId: (string|undefined), * extensionId: (string|undefined),
* source: string, * source: !chrome.fileManagerPrivate.Source,
* volumeLabel: (string|undefined), * volumeLabel: (string|undefined),
* profile: ProfileInfo, * profile: !chrome.fileManagerPrivate.ProfileInfo,
* sourcePath: (string|undefined), * sourcePath: (string|undefined),
* volumeType: string, * volumeType: !chrome.fileManagerPrivate.VolumeType,
* deviceType: (string|undefined), * deviceType: (!chrome.fileManagerPrivate.DeviceType|undefined),
* devicePath: (string|undefined), * devicePath: (string|undefined),
* isParentDevice: (boolean|undefined), * isParentDevice: (boolean|undefined),
* isReadOnly: boolean, * isReadOnly: boolean,
...@@ -73,69 +355,76 @@ var ProfileInfo; ...@@ -73,69 +355,76 @@ var ProfileInfo;
* hasMedia: boolean, * hasMedia: boolean,
* configurable: boolean, * configurable: boolean,
* watchable: boolean, * watchable: boolean,
* mountCondition: (string|undefined), * mountCondition: (!chrome.fileManagerPrivate.MountCondition|undefined),
* mountContext: (string|undefined) * mountContext: (!chrome.fileManagerPrivate.MountContext|undefined)
* }} * }}
* @see https://developer.chrome.com/extensions/fileManagerPrivate#type-VolumeMetadata
*/ */
var VolumeMetadata; chrome.fileManagerPrivate.VolumeMetadata;
/** /**
* @typedef {{ * @typedef {{
* eventType: string, * eventType: !chrome.fileManagerPrivate.MountCompletedEventType,
* status: string, * status: !chrome.fileManagerPrivate.MountCompletedStatus,
* volumeMetadata: VolumeMetadata, * volumeMetadata: !chrome.fileManagerPrivate.VolumeMetadata,
* shouldNotify: boolean * shouldNotify: boolean
* }} * }}
* @see https://developer.chrome.com/extensions/fileManagerPrivate#type-MountCompletedEvent
*/ */
var MountCompletedEvent; chrome.fileManagerPrivate.MountCompletedEvent;
/** /**
* @typedef {{ * @typedef {{
* fileUrl: string, * fileUrl: string,
* transferState: string, * transferState: !chrome.fileManagerPrivate.TransferState,
* transferType: string, * transferType: !chrome.fileManagerPrivate.TransferType,
* processed: number, * processed: number,
* total: number, * total: number,
* num_total_jobs: number * num_total_jobs: number
* }} * }}
* @see https://developer.chrome.com/extensions/fileManagerPrivate#type-FileTransferStatus
*/ */
var FileTransferStatus; chrome.fileManagerPrivate.FileTransferStatus;
/** /**
* @typedef {{ * @typedef {{
* type: string, * type: !chrome.fileManagerPrivate.DriveSyncErrorType,
* fileUrl: string * fileUrl: string
* }} * }}
* @see https://developer.chrome.com/extensions/fileManagerPrivate#type-DriveSyncErrorEvent
*/ */
var DriveSyncErrorEvent; chrome.fileManagerPrivate.DriveSyncErrorEvent;
/** /**
* @typedef {{ * @typedef {{
* type: string, * type: !chrome.fileManagerPrivate.CopyProgressStatusType,
* sourceUrl: (string|undefined), * sourceUrl: (string|undefined),
* destinationUrl: (string|undefined), * destinationUrl: (string|undefined),
* size: (number|undefined), * size: (number|undefined),
* error: (string|undefined) * error: (string|undefined)
* }} * }}
* @see https://developer.chrome.com/extensions/fileManagerPrivate#type-CopyProgressStatus
*/ */
var CopyProgressStatus; chrome.fileManagerPrivate.CopyProgressStatus;
/** /**
* @typedef {{ * @typedef {{
* url: string, * url: string,
* changes: Array * changes: !Array<!chrome.fileManagerPrivate.ChangeType>
* }} * }}
* @see https://developer.chrome.com/extensions/fileManagerPrivate#type-FileChange
*/ */
var FileChange; chrome.fileManagerPrivate.FileChange;
/** /**
* @typedef {{ * @typedef {{
* eventType: string, * eventType: !chrome.fileManagerPrivate.FileWatchEventType,
* entry: Object, * entry: Object,
* changedFiles: (Array|undefined) * changedFiles: (!Array<!chrome.fileManagerPrivate.FileChange>|undefined)
* }} * }}
* @see https://developer.chrome.com/extensions/fileManagerPrivate#type-FileWatchEvent
*/ */
var FileWatchEvent; chrome.fileManagerPrivate.FileWatchEvent;
/** /**
* @typedef {{ * @typedef {{
...@@ -147,57 +436,65 @@ var FileWatchEvent; ...@@ -147,57 +436,65 @@ var FileWatchEvent;
* allowRedeemOffers: boolean, * allowRedeemOffers: boolean,
* timezone: string * timezone: string
* }} * }}
* @see https://developer.chrome.com/extensions/fileManagerPrivate#type-Preferences
*/ */
var Preferences; chrome.fileManagerPrivate.Preferences;
/** /**
* @typedef {{ * @typedef {{
* cellularDisabled: (boolean|undefined), * cellularDisabled: (boolean|undefined),
* hostedFilesDisabled: (boolean|undefined) * hostedFilesDisabled: (boolean|undefined)
* }} * }}
* @see https://developer.chrome.com/extensions/fileManagerPrivate#type-PreferencesChange
*/ */
var PreferencesChange; chrome.fileManagerPrivate.PreferencesChange;
/** /**
* @typedef {{ * @typedef {{
* query: string, * query: string,
* nextFeed: string * nextFeed: string
* }} * }}
* @see https://developer.chrome.com/extensions/fileManagerPrivate#type-SearchParams
*/ */
var SearchParams; chrome.fileManagerPrivate.SearchParams;
/** /**
* @typedef {{ * @typedef {{
* query: string, * query: string,
* types: string, * types: !chrome.fileManagerPrivate.SearchType,
* maxResults: number * maxResults: number
* }} * }}
* @see https://developer.chrome.com/extensions/fileManagerPrivate#type-SearchMetadataParams
*/ */
var SearchMetadataParams; chrome.fileManagerPrivate.SearchMetadataParams;
/** /**
* @typedef {{ * @typedef {{
* entry: Object, * entry: Object,
* highlightedBaseName: string * highlightedBaseName: string
* }} * }}
* @see https://developer.chrome.com/extensions/fileManagerPrivate#type-SearchResult
*/ */
var SearchResult; chrome.fileManagerPrivate.SearchResult;
/** /**
* @typedef {{ * @typedef {{
* type: string, * type: string,
* reason: (string|undefined) * reason: (string|undefined),
* hasCellularNetworkAccess: boolean
* }} * }}
* @see https://developer.chrome.com/extensions/fileManagerPrivate#type-DriveConnectionState
*/ */
var DriveConnectionState; chrome.fileManagerPrivate.DriveConnectionState;
/** /**
* @typedef {{ * @typedef {{
* type: string, * type: !chrome.fileManagerPrivate.DeviceEventType,
* devicePath: string * devicePath: string
* }} * }}
* @see https://developer.chrome.com/extensions/fileManagerPrivate#type-DeviceEvent
*/ */
var DeviceEvent; chrome.fileManagerPrivate.DeviceEvent;
/** /**
* @typedef {{ * @typedef {{
...@@ -206,103 +503,109 @@ var DeviceEvent; ...@@ -206,103 +503,109 @@ var DeviceEvent;
* configurable: boolean, * configurable: boolean,
* watchable: boolean, * watchable: boolean,
* multipleMounts: boolean, * multipleMounts: boolean,
* source: string * source: !chrome.fileManagerPrivate.manifestTypes.FileSystemProviderSource
* }}
*/
var ProvidingExtension;
/**
* @typedef {{
* id: string,
* title: (string|undefined)
* }} * }}
* @see https://developer.chrome.com/extensions/fileManagerPrivate#type-ProvidingExtension
*/ */
var EntryAction; chrome.fileManagerPrivate.ProvidingExtension;
/**
* @const
*/
chrome.fileManagerPrivate = {};
/** /**
* Logout the current user for navigating to the re-authentication screen for * Logout the current user for navigating to the re-authentication screen for
* the Google account. * the Google account.
* @see https://developer.chrome.com/extensions/fileManagerPrivate#method-logoutUserForReauthentication
*/ */
chrome.fileManagerPrivate.logoutUserForReauthentication = function() {}; chrome.fileManagerPrivate.logoutUserForReauthentication = function() {};
/** /**
* Cancels file selection. * Cancels file selection.
* @see https://developer.chrome.com/extensions/fileManagerPrivate#method-cancelDialog
*/ */
chrome.fileManagerPrivate.cancelDialog = function() {}; chrome.fileManagerPrivate.cancelDialog = function() {};
/** /**
* Executes file browser task over selected files. |taskId| The unique * Executes file browser task over selected files. |taskId| The unique
* identifier of task to execute. |entries| Array of file entries |callback| * identifier of task to execute. |entries| Array of entries |callback|
* @param {string} taskId * @param {string} taskId
* @param {!Array<!Entry>} entries * @param {!Array<Object>} entries
* @param {function((boolean|undefined))} callback |result| Result of the task * @param {function(!chrome.fileManagerPrivate.TaskResult):void} callback
* execution. * |result| Result of the task execution.
* @see https://developer.chrome.com/extensions/fileManagerPrivate#method-executeTask
*/ */
chrome.fileManagerPrivate.executeTask = function(taskId, entries, callback) {}; chrome.fileManagerPrivate.executeTask = function(taskId, entries, callback) {};
/** /**
* Sets the default task for the supplied MIME types and path extensions. * Sets the default task for the supplied MIME types and path extensions. Lists
* Lists of MIME types and entries may contain duplicates. * of MIME types and URLs may contain duplicates. Additionally, the list of MIME
* |taskId| The unique identifier of task to mark as default. |entries| Array * types can be empty. |taskId| The unique identifier of task to mark as
* of selected file entries to extract path extensions from. |mimeTypes| Array * default. |entries| Array of selected entries to extract path extensions from.
* of selected file MIME types. |callback| * |mimeTypes| Array of selected file MIME types. |callback|
* @param {string} taskId * @param {string} taskId
* @param {!Array<!Entry>} entries * @param {!Array<Object>} entries
* @param {!Array<string>} mimeTypes * @param {!Array<string>} mimeTypes
* @param {!function()} callback Callback that does not take arguments. * @param {function():void} callback Callback that does not take arguments.
* @see https://developer.chrome.com/extensions/fileManagerPrivate#method-setDefaultTask
*/ */
chrome.fileManagerPrivate.setDefaultTask = function(taskId, entries, mimeTypes, chrome.fileManagerPrivate.setDefaultTask = function(taskId, entries, mimeTypes, callback) {};
callback) {};
/** /**
* Gets the list of tasks that can be performed over selected files. |entries| * Gets the list of tasks that can be performed over selected files. |entries|
* Array of selected entries |callback| * Array of selected entries |callback|
* @param {!Array<!Entry>} entries * @param {!Array<Object>} entries
* @param {function((!Array<!FileTask>|undefined))} callback |tasks| The list of * @param {function(!Array<!chrome.fileManagerPrivate.FileTask>):void} callback
* matched file entries for this task. * |tasks| The list of matched file entries for this task.
* @see https://developer.chrome.com/extensions/fileManagerPrivate#method-getFileTasks
*/ */
chrome.fileManagerPrivate.getFileTasks = function(entries, callback) {}; chrome.fileManagerPrivate.getFileTasks = function(entries, callback) {};
/**
* Gets the MIME type of a file. |entry| Entry to be checked. |callback|
* @param {Object} entry
* @param {function(string):void} callback |result| Mime type of the file.
* @see https://developer.chrome.com/extensions/fileManagerPrivate#method-getMimeType
*/
chrome.fileManagerPrivate.getMimeType = function(entry, callback) {};
/** /**
* Gets localized strings and initialization data. |callback| * Gets localized strings and initialization data. |callback|
* @param {function((!Object|undefined))} callback |result| Hash containing the * @param {function(Object):void} callback |result| Hash containing the string
* string assets. * assets.
* @see https://developer.chrome.com/extensions/fileManagerPrivate#method-getStrings
*/ */
chrome.fileManagerPrivate.getStrings = function(callback) {}; chrome.fileManagerPrivate.getStrings = function(callback) {};
/** /**
* Adds file watch. |entry| Entry of file to watch |callback| * Adds file watch. |entry| Entry to watch |callback|
* @param {!Entry} entry * @param {Object} entry
* @param {function((boolean|undefined))} callback |success| True when file * @param {function(boolean):void} callback |success| True when file watch is
* watch is successfully added. * successfully added.
* @see https://developer.chrome.com/extensions/fileManagerPrivate#method-addFileWatch
*/ */
chrome.fileManagerPrivate.addFileWatch = function(entry, callback) {}; chrome.fileManagerPrivate.addFileWatch = function(entry, callback) {};
/** /**
* Removes file watch. |entry| Entry of watched file to remove |callback| * Removes file watch. |entry| Watched entry |callback|
* @param {!Entry} entry * @param {Object} entry
* @param {function((boolean|undefined))} callback |success| True when file * @param {function(boolean):void} callback |success| True when file watch is
* watch is successfully * successfully removed.
* removed. * @see https://developer.chrome.com/extensions/fileManagerPrivate#method-removeFileWatch
*/ */
chrome.fileManagerPrivate.removeFileWatch = function(entry, callback) {}; chrome.fileManagerPrivate.removeFileWatch = function(entry, callback) {};
/** /**
* Enables the extenal file scheme necessary to initiate drags to the browser * Enables the extenal file scheme necessary to initiate drags to the browser
* window for files on the external backend. * window for files on the external backend.
* @see https://developer.chrome.com/extensions/fileManagerPrivate#method-enableExternalFileScheme
*/ */
chrome.fileManagerPrivate.enableExternalFileScheme = function() {}; chrome.fileManagerPrivate.enableExternalFileScheme = function() {};
/** /**
* Requests R/W access to the specified entries as |entryUrls|. Note, that only * Requests granting R/W permissions for the passed entries. It's a best effort
* files backed by external file system backend will be granted the access. * operation. Some files may not be granted access if the url is invalid or not
* backed by the external file system. |entryUrls| Urls for the entries to be
* accessed. |callback|
* @param {!Array<string>} entryUrls * @param {!Array<string>} entryUrls
* @param {function()} callback Completion callback. * @param {function():void} callback Callback that does not take arguments.
* @see https://developer.chrome.com/extensions/fileManagerPrivate#method-grantAccess
*/ */
chrome.fileManagerPrivate.grantAccess = function(entryUrls, callback) {}; chrome.fileManagerPrivate.grantAccess = function(entryUrls, callback) {};
...@@ -312,10 +615,10 @@ chrome.fileManagerPrivate.grantAccess = function(entryUrls, callback) {}; ...@@ -312,10 +615,10 @@ chrome.fileManagerPrivate.grantAccess = function(entryUrls, callback) {};
* |callback| * |callback|
* @param {!Array<string>} selectedPaths * @param {!Array<string>} selectedPaths
* @param {boolean} shouldReturnLocalPath * @param {boolean} shouldReturnLocalPath
* @param {function()} callback Callback that does not take arguments. * @param {function():void} callback Callback that does not take arguments.
* @see https://developer.chrome.com/extensions/fileManagerPrivate#method-selectFiles
*/ */
chrome.fileManagerPrivate.selectFiles = function(selectedPaths, chrome.fileManagerPrivate.selectFiles = function(selectedPaths, shouldReturnLocalPath, callback) {};
shouldReturnLocalPath, callback) {};
/** /**
* Selects a file. |selectedPath| A selected path |index| Index of Filter * Selects a file. |selectedPath| A selected path |index| Index of Filter
...@@ -326,100 +629,112 @@ chrome.fileManagerPrivate.selectFiles = function(selectedPaths, ...@@ -326,100 +629,112 @@ chrome.fileManagerPrivate.selectFiles = function(selectedPaths,
* @param {number} index * @param {number} index
* @param {boolean} forOpening * @param {boolean} forOpening
* @param {boolean} shouldReturnLocalPath * @param {boolean} shouldReturnLocalPath
* @param {function()} callback Callback that does not take arguments. * @param {function():void} callback Callback that does not take arguments.
* @see https://developer.chrome.com/extensions/fileManagerPrivate#method-selectFile
*/ */
chrome.fileManagerPrivate.selectFile = function(selectedPath, index, forOpening, chrome.fileManagerPrivate.selectFile = function(selectedPath, index, forOpening, shouldReturnLocalPath, callback) {};
shouldReturnLocalPath, callback) {};
/** /**
* Requests additional properties for files. |entries| list of entries of files * Requests additional properties for files. |entries| list of entries |names|
* |callback| * list of requested properties by their names. |callback| Completion callback.
* @param {!Array<!Entry>} entries * May return less than requested properties if some are not available. In
* @param {!Array<string>} names * the same time, it can return properties which were not requested (if it's
* @param {function((!Array<!EntryProperties>|undefined))} callback * cheap to compute them).
* |entryProperties| A dictionary containing properties of the requested * @param {!Array<Object>} entries
* entries. * @param {!Array<!chrome.fileManagerPrivate.EntryPropertyName>} names
* @param {function(!Array<!chrome.fileManagerPrivate.EntryProperties>):void}
* callback |entryProperties| A dictionary containing properties of the
* requested entries.
* @see https://developer.chrome.com/extensions/fileManagerPrivate#method-getEntryProperties
*/ */
chrome.fileManagerPrivate.getEntryProperties = function(entries, names, chrome.fileManagerPrivate.getEntryProperties = function(entries, names, callback) {};
callback) {};
/** /**
* Pins/unpins a Drive file in the cache. |entry| Entry of a file to pin/unpin. * Pins/unpins a Drive file in the cache. |entry| Entry to pin/unpin. |pin| Pass
* |pin| Pass true to pin the file. |callback| Completion callback. * true to pin the file. |callback| Completion callback.
* $(ref:runtime.lastError) will be set if there was an error. * $(ref:runtime.lastError) will be set if there was an error.
* @param {!Entry} entry * @param {Object} entry
* @param {boolean} pin * @param {boolean} pin
* @param {function()} callback Callback that does not take arguments. * @param {function():void} callback Callback that does not take arguments.
* @see https://developer.chrome.com/extensions/fileManagerPrivate#method-pinDriveFile
*/ */
chrome.fileManagerPrivate.pinDriveFile = function(entry, pin, callback) {}; chrome.fileManagerPrivate.pinDriveFile = function(entry, pin, callback) {};
/** /**
* Resolves file entries in the isolated file system and returns corresponding * Resolves entries in the isolated file system and returns corresponding
* entries in the external file system mounted to Chrome OS file manager * entries in the external file system mounted to Chrome OS file manager
* backend. If resolving entry fails, the entry will be just ignored and the * backend. If resolving entry fails, the entry will be just ignored and the
* corresponding entry does not appear in the result. * corresponding entry does not appear in the result.
* @param {!Array<!Entry>} entries * @param {!Array<Object>} entries
* @param {function((!Array<!Entry>|undefined))} callback Completion callback * @param {function(!Array<Object>):void} callback |entries| External entries.
* with resolved entries. * @see https://developer.chrome.com/extensions/fileManagerPrivate#method-resolveIsolatedEntries
*/ */
chrome.fileManagerPrivate.resolveIsolatedEntries = function(entries, chrome.fileManagerPrivate.resolveIsolatedEntries = function(entries, callback) {};
callback) {};
/** /**
* Mount a resource or a file. |source| Mount point source. For compressed * Mount a resource or a file. |source| Mount point source. For compressed files
* files it is relative file path within external file system |callback| * it is relative file path within external file system |callback|
* @param {string} source * @param {string} source
* @param {function((string|undefined))} callback Callback with source path of * @param {function(string):void} callback |sourcePath| Source path of the
* the mount. * mount.
* @see https://developer.chrome.com/extensions/fileManagerPrivate#method-addMount
*/ */
chrome.fileManagerPrivate.addMount = function(source, callback) {}; chrome.fileManagerPrivate.addMount = function(source, callback) {};
/** /**
* Unmounts a mounted resource. |volumeId| An ID of the volume. * Unmounts a mounted resource. |volumeId| An ID of the volume.
* @param {string} volumeId * @param {string} volumeId
* @see https://developer.chrome.com/extensions/fileManagerPrivate#method-removeMount
*/ */
chrome.fileManagerPrivate.removeMount = function(volumeId) {}; chrome.fileManagerPrivate.removeMount = function(volumeId) {};
/** /**
* Get the list of mounted volumes. |callback| * Get the list of mounted volumes. |callback|
* @param {function((!Array<!VolumeMetadata>|undefined))} callback Callback with * @param {function(!Array<!chrome.fileManagerPrivate.VolumeMetadata>):void}
* the list of VolumeMetadata representing mounted volumes. * callback |volumeMetadataList| The list of VolumeMetadata representing
* mounted volumes.
* @see https://developer.chrome.com/extensions/fileManagerPrivate#method-getVolumeMetadataList
*/ */
chrome.fileManagerPrivate.getVolumeMetadataList = function(callback) {}; chrome.fileManagerPrivate.getVolumeMetadataList = function(callback) {};
/** /**
* Cancels ongoing file transfers for selected files. |entries| Array of files * Cancels ongoing file transfers for selected files. |entries| Array of files
* for which ongoing transfer should be canceled. * for which ongoing transfer should be canceled. |callback| Completion callback
* @param {!Array<!FileEntry>} entries * of the cancel.
* @param {function()} callback * @param {!Array<Object>} entries
* @param {function():void} callback Callback that does not take arguments.
* @see https://developer.chrome.com/extensions/fileManagerPrivate#method-cancelFileTransfers
*/ */
chrome.fileManagerPrivate.cancelFileTransfers = function(entries, callback) {}; chrome.fileManagerPrivate.cancelFileTransfers = function(entries, callback) {};
/** /**
* Cancels all ongoing file transfers. * Cancels all ongoing file transfers. |callback| Completion callback of the
* @param {function()} callback * cancel.
* @param {function():void} callback Callback that does not take arguments.
* @see https://developer.chrome.com/extensions/fileManagerPrivate#method-cancelAllFileTransfers
*/ */
chrome.fileManagerPrivate.cancelAllFileTransfers = function(callback) {}; chrome.fileManagerPrivate.cancelAllFileTransfers = function(callback) {};
/** /**
* Starts to copy an entry. If the source is a directory, the copy is done * Starts to copy an entry. If the source is a directory, the copy is done
* recursively. |entry| Entry of the source entry to be copied. |parent| Entry * recursively. |entry| Entry of the source entry to be copied. |parentEntry|
* of the destination directory. |newName| Name of the new entry. It must not * Entry for the destination (parent) directory. |newName| Name of the new
* contain '/'. |callback| Completion callback. * entry. It must not contain '/'. |callback| Completion callback.
* @param {!Entry} entry * @param {Object} entry
* @param {!DirectoryEntry} parentEntry * @param {Object} parentEntry
* @param {string} newName * @param {string} newName
* @param {function((number|undefined))} callback |copyId| ID of the copy task. * @param {function(number):void} callback |copyId| ID of the copy task. Can be
* Can be used to identify the progress, and to cancel the task. * used to identify the progress, and to cancel the task.
* @see https://developer.chrome.com/extensions/fileManagerPrivate#method-startCopy
*/ */
chrome.fileManagerPrivate.startCopy = function(entry, parentEntry, newName, chrome.fileManagerPrivate.startCopy = function(entry, parentEntry, newName, callback) {};
callback) {};
/** /**
* Cancels the running copy task. |copyId| ID of the copy task to be cancelled. * Cancels the running copy task. |copyId| ID of the copy task to be cancelled.
* |callback| Completion callback of the cancel. * |callback| Completion callback of the cancel.
* @param {number} copyId * @param {number} copyId
* @param {function()} callback Callback that does not take arguments. * @param {function():void} callback Callback that does not take arguments.
* @see https://developer.chrome.com/extensions/fileManagerPrivate#method-cancelCopy
*/ */
chrome.fileManagerPrivate.cancelCopy = function(copyId, callback) {}; chrome.fileManagerPrivate.cancelCopy = function(copyId, callback) {};
...@@ -427,91 +742,105 @@ chrome.fileManagerPrivate.cancelCopy = function(copyId, callback) {}; ...@@ -427,91 +742,105 @@ chrome.fileManagerPrivate.cancelCopy = function(copyId, callback) {};
* Retrieves total and remaining size of a mount point. |volumeId| ID of the * Retrieves total and remaining size of a mount point. |volumeId| ID of the
* volume to be checked. |callback| * volume to be checked. |callback|
* @param {string} volumeId * @param {string} volumeId
* @param {function((!MountPointSizeStats|undefined))} callback Name/value pairs * @param {function(!chrome.fileManagerPrivate.MountPointSizeStats):void}
* of size stats. Will be undefined if stats could not be determined. * callback |sizeStats| Name/value pairs of size stats. Will be undefined if
* stats could not be determined.
* @see https://developer.chrome.com/extensions/fileManagerPrivate#method-getSizeStats
*/ */
chrome.fileManagerPrivate.getSizeStats = function(volumeId, callback) {}; chrome.fileManagerPrivate.getSizeStats = function(volumeId, callback) {};
/** /**
* Formats a mounted volume. |volumeId| ID of the volume to be formatted. * Formats a mounted volume. |volumeId| ID of the volume to be formatted.
* @param {string} volumeId * @param {string} volumeId
* @see https://developer.chrome.com/extensions/fileManagerPrivate#method-formatVolume
*/ */
chrome.fileManagerPrivate.formatVolume = function(volumeId) {}; chrome.fileManagerPrivate.formatVolume = function(volumeId) {};
/** /**
* Retrieves file manager preferences. |callback| * Retrieves file manager preferences. |callback|
* @param {function((!Preferences|undefined))} callback * @param {function(!chrome.fileManagerPrivate.Preferences):void} callback
* @see https://developer.chrome.com/extensions/fileManagerPrivate#method-getPreferences
*/ */
chrome.fileManagerPrivate.getPreferences = function(callback) {}; chrome.fileManagerPrivate.getPreferences = function(callback) {};
/** /**
* Sets file manager preferences. |changeInfo| * Sets file manager preferences. |changeInfo|
* @param {PreferencesChange} changeInfo * @param {!chrome.fileManagerPrivate.PreferencesChange} changeInfo
* @see https://developer.chrome.com/extensions/fileManagerPrivate#method-setPreferences
*/ */
chrome.fileManagerPrivate.setPreferences = function(changeInfo) {}; chrome.fileManagerPrivate.setPreferences = function(changeInfo) {};
/** /**
* Performs drive content search. |searchParams| |callback| * Performs drive content search. |searchParams| |callback|
* @param {SearchParams} searchParams * @param {!chrome.fileManagerPrivate.SearchParams} searchParams
* @param {function((!Array<Entry>|undefined), (string|undefined))} callback * @param {function(!Array<Object>, string):void} callback |entries| |nextFeed|
* Entries and ID of the feed that contains next chunk of the search result. * ID of the feed that contains next chunk of the search result. Should
* Should be sent to the next searchDrive request to perform incremental search. * be sent to the next searchDrive request to perform incremental
* search.
* @see https://developer.chrome.com/extensions/fileManagerPrivate#method-searchDrive
*/ */
chrome.fileManagerPrivate.searchDrive = function(searchParams, callback) {}; chrome.fileManagerPrivate.searchDrive = function(searchParams, callback) {};
/** /**
* Performs drive metadata search. |searchParams| |callback| * Performs drive metadata search. |searchParams| |callback|
* @param {SearchMetadataParams} searchParams * @param {!chrome.fileManagerPrivate.SearchMetadataParams} searchParams
* @param {function((!Array<!SearchResult>|undefined))} callback * @param {function(!Array<!chrome.fileManagerPrivate.SearchResult>):void}
* callback
* @see https://developer.chrome.com/extensions/fileManagerPrivate#method-searchDriveMetadata
*/ */
chrome.fileManagerPrivate.searchDriveMetadata = function(searchParams, chrome.fileManagerPrivate.searchDriveMetadata = function(searchParams, callback) {};
callback) {};
/** /**
* Search for files in the given volume, whose content hash matches the list of * Search files in the volume having |volumeId| by using |hashList|.
* given hashes. * sub-directories) the given |targetDirectoryUrl|.
* @param {string} volumeId * @param {string} volumeId
* @param {!Array<string>} hashes * @param {!Array<string>} hashList
* @param {function((!Object<string, !Array<string>>|undefined))} callback * @param {function(Object):void} callback |urls| The map of hash and array of
* FileEntry's URL. The array can be empty if the corresponding file is not
* found.
* @see https://developer.chrome.com/extensions/fileManagerPrivate#method-searchFilesByHashes
*/ */
chrome.fileManagerPrivate.searchFilesByHashes = function(volumeId, hashes, chrome.fileManagerPrivate.searchFilesByHashes = function(volumeId, hashList, callback) {};
callback) {};
/** /**
* Create a zip file for the selected files. |parentEntry| Entry of the * Create a zip file for the selected files. |parentEntry| Entry of the
* directory containing the selected files. |entries| Selected entries. * directory containing the selected files. |entries| Entries of the selected
* The files must be under the directory specified by |parentEntry|. |destName| * files. The files must be under the directory specified by |parentEntry|.
* Name of the destination zip file. The zip file will be created under the * |destName| Name of the destination zip file. The zip file will be created
* directory specified by |parentEntry|. * under the directory specified by |parentEntry|. |callback| TODO(mtomasz):
* @param {!DirectoryEntry} parentEntry * Swap order of |entries| and |parentEntry|.
* @param {!Array<!Entry>} entries * @param {Object} parentEntry
* @param {!Array<Object>} entries
* @param {string} destName * @param {string} destName
* @param {function((boolean|undefined))} callback * @param {function(boolean):void} callback
* @see https://developer.chrome.com/extensions/fileManagerPrivate#method-zipSelection
*/ */
chrome.fileManagerPrivate.zipSelection = function(parentEntry, entries, chrome.fileManagerPrivate.zipSelection = function(parentEntry, entries, destName, callback) {};
destName, callback) {};
/** /**
* Retrieves the state of the current drive connection. |callback| * Retrieves the state of the current drive connection. |callback|
* @param {function((!DriveConnectionState|undefined))} callback * @param {function(!chrome.fileManagerPrivate.DriveConnectionState):void}
* callback
* @see https://developer.chrome.com/extensions/fileManagerPrivate#method-getDriveConnectionState
*/ */
chrome.fileManagerPrivate.getDriveConnectionState = function(callback) {}; chrome.fileManagerPrivate.getDriveConnectionState = function(callback) {};
/** /**
* Checks whether the path name length fits in the limit of the filesystem. * Checks whether the path name length fits in the limit of the filesystem.
* |parentEntry| The parent directory entry. |name| The name of the file. * |parentEntry| The entry of the parent directory entry. |name| The name of the
* |callback| Called back when the check is finished. * file. |callback| Called back when the check is finished.
* @param {!DirectoryEntry} parentEntry * @param {Object} parentEntry
* @param {string} name * @param {string} name
* @param {function((boolean|undefined))} callback |result| true if the length * @param {function(boolean):void} callback |result| true if the length is in
* is in the valid range, false otherwise. * the valid range, false otherwise.
* @see https://developer.chrome.com/extensions/fileManagerPrivate#method-validatePathNameLength
*/ */
chrome.fileManagerPrivate.validatePathNameLength = function( chrome.fileManagerPrivate.validatePathNameLength = function(parentEntry, name, callback) {};
parentEntry, name, callback) {};
/** /**
* Changes the zoom factor of the Files.app. |operation| Zooming mode. * Changes the zoom factor of the Files.app. |operation| Zooming mode.
* @param {string} operation * @param {!chrome.fileManagerPrivate.ZoomOperationType} operation
* @see https://developer.chrome.com/extensions/fileManagerPrivate#method-zoom
*/ */
chrome.fileManagerPrivate.zoom = function(operation) {}; chrome.fileManagerPrivate.zoom = function(operation) {};
...@@ -519,186 +848,207 @@ chrome.fileManagerPrivate.zoom = function(operation) {}; ...@@ -519,186 +848,207 @@ chrome.fileManagerPrivate.zoom = function(operation) {};
* Requests a Drive API OAuth2 access token. |refresh| Whether the token should * Requests a Drive API OAuth2 access token. |refresh| Whether the token should
* be refetched instead of using the cached one. |callback| * be refetched instead of using the cached one. |callback|
* @param {boolean} refresh * @param {boolean} refresh
* @param {function((string|undefined))} callback |accessToken| OAuth2 access * @param {function(string):void} callback |accessToken| OAuth2 access token, or
* token, or an empty string if failed to fetch. * an empty string if failed to fetch.
* @see https://developer.chrome.com/extensions/fileManagerPrivate#method-requestAccessToken
*/ */
chrome.fileManagerPrivate.requestAccessToken = function(refresh, callback) {}; chrome.fileManagerPrivate.requestAccessToken = function(refresh, callback) {};
/** /**
* Requests a Webstore API OAuth2 access token. |callback| * Requests a Webstore API OAuth2 access token. |callback|
* @param {function((string|undefined))} callback |accessToken| OAuth2 access * @param {function(string):void} callback |accessToken| OAuth2 access token, or
* token, or an empty string if failed to fetch. * an empty string if failed to fetch.
* @see https://developer.chrome.com/extensions/fileManagerPrivate#method-requestWebStoreAccessToken
*/ */
chrome.fileManagerPrivate.requestWebStoreAccessToken = function(callback) {}; chrome.fileManagerPrivate.requestWebStoreAccessToken = function(callback) {};
/** /**
* Requests a share dialog url for the specified file. * Requests a share dialog url for the specified file. |entry| The entry to
* @param {!Entry} entry * share. |callback|
* @param {function((string|undefined))} callback Callback with the result url. * @param {Object} entry
* @param {function(string):void} callback |url| Result url.
* @see https://developer.chrome.com/extensions/fileManagerPrivate#method-getShareUrl
*/ */
chrome.fileManagerPrivate.getShareUrl = function(entry, callback) {}; chrome.fileManagerPrivate.getShareUrl = function(entry, callback) {};
/** /**
* Requests a download url to download the file contents. * Requests a download url to download the file contents. |entry| The entry to
* @param {!Entry} entry * download. |callback|
* @param {function((string|undefined))} callback Callback with the result url. * @param {Object} entry
* @param {function(string):void} callback |url| Result url.
* @see https://developer.chrome.com/extensions/fileManagerPrivate#method-getDownloadUrl
*/ */
chrome.fileManagerPrivate.getDownloadUrl = function(entry, callback) {}; chrome.fileManagerPrivate.getDownloadUrl = function(entry, callback) {};
/** /**
* Requests to share drive files. * Requests to share drive files. |entry| Entry to be shared. |shareType| Type
* @param {!Entry} entry * of access that is getting granted.
* @param {string} shareType * @param {Object} entry
* @param {function()} callback Callback that does not take arguments. * @param {!chrome.fileManagerPrivate.DriveShareType} shareType
* @param {function():void} callback Callback that does not take arguments.
* @see https://developer.chrome.com/extensions/fileManagerPrivate#method-requestDriveShare
*/ */
chrome.fileManagerPrivate.requestDriveShare = function(entry, shareType, chrome.fileManagerPrivate.requestDriveShare = function(entry, shareType, callback) {};
callback) {};
/**
* Requests to install a webstore item. |item_id| The id of the item to
* install. |silentInstallation| False to show installation prompt. True not to
* show. |callback|
* @param {string} itemId
* @param {boolean} silentInstallation
* @param {function()} callback Callback that does not take arguments.
*/
chrome.fileManagerPrivate.installWebstoreItem = function(itemId,
silentInstallation, callback) {};
/** /**
* Obtains a list of profiles that are logged-in. * Obtains a list of profiles that are logged-in.
* @param {function((!Array<!ProfileInfo>|undefined), (string|undefined), * @param {function(!Array<!chrome.fileManagerPrivate.ProfileInfo>, string, string):void}
* (string|undefined))} callback Callback with list of profile information, * callback |profiles| List of profile information. |runningProfile| ID of
* |runningProfile| ID of the profile that runs the application instance. * the profile that runs the application instance. |showingProfile| ID of
* |showingProfile| ID of the profile that shows the application window. * the profile that shows the application window.
* @see https://developer.chrome.com/extensions/fileManagerPrivate#method-getProfiles
*/ */
chrome.fileManagerPrivate.getProfiles = function(callback) {}; chrome.fileManagerPrivate.getProfiles = function(callback) {};
/** /**
* Opens inspector window. |type| InspectionType which specifies how to open * Opens inspector window. |type| InspectionType which specifies how to open
* inspector. * inspector.
* @param {string} type * @param {!chrome.fileManagerPrivate.InspectionType} type
* @see https://developer.chrome.com/extensions/fileManagerPrivate#method-openInspector
*/ */
chrome.fileManagerPrivate.openInspector = function(type) {}; chrome.fileManagerPrivate.openInspector = function(type) {};
/** /**
* Computes an MD5 checksum for the given file. * Computes an MD5 checksum for the given file. |entry| The entry of the file to
* @param {!Entry} entry * checksum. |callback|
* @param {function((string|undefined))} callback * @param {Object} entry
* @param {function(string):void} callback |checksum| Result checksum.
* @see https://developer.chrome.com/extensions/fileManagerPrivate#method-computeChecksum
*/ */
chrome.fileManagerPrivate.computeChecksum = function(entry, callback) {}; chrome.fileManagerPrivate.computeChecksum = function(entry, callback) {};
/** /**
* Gets the MIME type of a file. * Is UMA enabled?
* @param {!Entry} entry * @param {function(boolean):void} callback |result| Boolean result returned by
* @param {function((string|undefined))} callback Callback that MIME type of the * the invoked function.
* file is passed. * @see https://developer.chrome.com/extensions/fileManagerPrivate#method-isUMAEnabled
*/
chrome.fileManagerPrivate.getMimeType = function(entry, callback) {};
/**
* Gets a flag indicating whether user metrics reporting is enabled.
* @param {function((boolean|undefined))} callback
*/ */
chrome.fileManagerPrivate.isUMAEnabled = function(callback) {}; chrome.fileManagerPrivate.isUMAEnabled = function(callback) {};
/** /**
* Sets a tag on a file or a directory. Only Drive files are supported. * Sets a tag on a file or a directory. Only Drive files are supported.
* @param {!Entry} entry * @param {Object} entry
* @param {string} visibility 'private' or 'public' * @param {!chrome.fileManagerPrivate.EntryTagVisibility} visibility
* @param {string} key * @param {string} key
* @param {string} value * @param {string} value
* @param {function()} callback * @param {function():void} callback Callback that does not take arguments.
* @see https://developer.chrome.com/extensions/fileManagerPrivate#method-setEntryTag
*/ */
chrome.fileManagerPrivate.setEntryTag = function(entry, visibility, key, chrome.fileManagerPrivate.setEntryTag = function(entry, visibility, key, value, callback) {};
value, callback) {};
/** /**
* Gets a flag indicating whether PiexLoader is enabled. * Returns if Piex loader is enabled.
* @param {function((boolean|undefined))} callback * @param {function(boolean):void} callback |result| Boolean result returned by
* the invoked function.
* @see https://developer.chrome.com/extensions/fileManagerPrivate#method-isPiexLoaderEnabled
*/ */
chrome.fileManagerPrivate.isPiexLoaderEnabled = function(callback) {}; chrome.fileManagerPrivate.isPiexLoaderEnabled = function(callback) {};
/** /**
* Returns list of available providing extensions. * Returns list of available providing extensions.
* @param {function((!Array<!ProvidingExtension>|undefined))} callback * @param {function(!Array<!chrome.fileManagerPrivate.ProvidingExtension>):void}
* callback |extensions| List of providing extensions.
* @see https://developer.chrome.com/extensions/fileManagerPrivate#method-getProvidingExtensions
*/ */
chrome.fileManagerPrivate.getProvidingExtensions = function(callback) {}; chrome.fileManagerPrivate.getProvidingExtensions = function(callback) {};
/** /**
* Requests adding a new provided file system. If not possible, then an error * Requests adding a new provided file system. If not possible, then an error
* via chrome.runtime.lastError is returned. * via chrome.runtime.lastError is returned.
* @param {string} extensionId * @param {string} extension_id
* @param {function()} callback * @param {function():void} callback Callback that does not take arguments.
* @see https://developer.chrome.com/extensions/fileManagerPrivate#method-addProvidedFileSystem
*/ */
chrome.fileManagerPrivate.addProvidedFileSystem = chrome.fileManagerPrivate.addProvidedFileSystem = function(extension_id, callback) {};
function(extensionId, callback) {};
/** /**
* Requests configuring an existing file system. If not possible, then returns * Requests configuring an existing volume. If not possible, then returns an
* an error via chrome.runtime.lastError. * error via chrome.runtime.lastError.
* @param {string} volumeId * @param {string} volumeId
* @param {function()} callback * @param {function():void} callback Callback that does not take arguments.
* @see https://developer.chrome.com/extensions/fileManagerPrivate#method-configureVolume
*/ */
chrome.fileManagerPrivate.configureVolume = function(volumeId, callback) {}; chrome.fileManagerPrivate.configureVolume = function(volumeId, callback) {};
/** /**
* Requests fetching list of actions for the specified set of entries. If not * Requests list of custom actions for the specified entries. If not possible,
* possible, then returns an error via chrome.runtime.lastError. * then an error via chrome.runtime.lastError is returned.
* @param {!Array<!Entry>} entries * @param {!Array<Object>} entries
* @param {function((!Array<!EntryAction>|undefined))} callback * @param {function(!Array<!chrome.fileManagerPrivate.fileSystemProvider.Action>):void}
* callback |actions| List of actions.
* @see https://developer.chrome.com/extensions/fileManagerPrivate#method-getCustomActions
*/ */
chrome.fileManagerPrivate.getCustomActions = function(entries, callback) {}; chrome.fileManagerPrivate.getCustomActions = function(entries, callback) {};
/**
* Executes a custom action for a set of entries. If not possible, then an error
* via chrome.runtime.lastError is returned.
* @param {!Array<Object>} entries
* @param {string} actionId
* @param {function():void} callback Callback that does not take arguments.
* @see https://developer.chrome.com/extensions/fileManagerPrivate#method-executeCustomAction
*/
chrome.fileManagerPrivate.executeCustomAction = function(entries, actionId, callback) {};
/** /**
* Get the total size of a directory. |entry| Entry of the target directory. * Get the total size of a directory. |entry| Entry of the target directory.
* |callback| * |callback|
* @param {!DirectoryEntry} entry * @param {Object} entry
* @param {function(number)} callback * @param {function(number):void} callback |size| result size.
* @see https://developer.chrome.com/extensions/fileManagerPrivate#method-getDirectorySize
*/ */
chrome.fileManagerPrivate.getDirectorySize = function(entry, callback) {}; chrome.fileManagerPrivate.getDirectorySize = function(entry, callback) {};
/** /**
* Executes the action on the specified set of entries. If not possible, then * @type {!ChromeEvent}
* returns an error via chrome.runtime.lastError. * @see https://developer.chrome.com/extensions/fileManagerPrivate#event-onMountCompleted
* @param {!Array<!Entry>} entries
* @param {string} actionId
* @param {function()} callback
*/ */
chrome.fileManagerPrivate.executeCustomAction = function(
entries, actionId, callback) {};
/** @type {!ChromeEvent} */
chrome.fileManagerPrivate.onMountCompleted; chrome.fileManagerPrivate.onMountCompleted;
/** @type {!ChromeEvent} */ /**
* @type {!ChromeEvent}
* @see https://developer.chrome.com/extensions/fileManagerPrivate#event-onFileTransfersUpdated
*/
chrome.fileManagerPrivate.onFileTransfersUpdated; chrome.fileManagerPrivate.onFileTransfersUpdated;
/** @type {!ChromeEvent} */ /**
* @type {!ChromeEvent}
* @see https://developer.chrome.com/extensions/fileManagerPrivate#event-onCopyProgress
*/
chrome.fileManagerPrivate.onCopyProgress; chrome.fileManagerPrivate.onCopyProgress;
/** @type {!ChromeEvent} */ /**
* @type {!ChromeEvent}
* @see https://developer.chrome.com/extensions/fileManagerPrivate#event-onDirectoryChanged
*/
chrome.fileManagerPrivate.onDirectoryChanged; chrome.fileManagerPrivate.onDirectoryChanged;
/** @type {!ChromeEvent} */ /**
* @type {!ChromeEvent}
* @see https://developer.chrome.com/extensions/fileManagerPrivate#event-onPreferencesChanged
*/
chrome.fileManagerPrivate.onPreferencesChanged; chrome.fileManagerPrivate.onPreferencesChanged;
/** @type {!ChromeEvent} */ /**
* @type {!ChromeEvent}
* @see https://developer.chrome.com/extensions/fileManagerPrivate#event-onDriveConnectionStatusChanged
*/
chrome.fileManagerPrivate.onDriveConnectionStatusChanged; chrome.fileManagerPrivate.onDriveConnectionStatusChanged;
/** @type {!ChromeEvent} */ /**
* @type {!ChromeEvent}
* @see https://developer.chrome.com/extensions/fileManagerPrivate#event-onDeviceChanged
*/
chrome.fileManagerPrivate.onDeviceChanged; chrome.fileManagerPrivate.onDeviceChanged;
/** @type {!ChromeEvent} */ /**
* @type {!ChromeEvent}
* @see https://developer.chrome.com/extensions/fileManagerPrivate#event-onDriveSyncError
*/
chrome.fileManagerPrivate.onDriveSyncError; chrome.fileManagerPrivate.onDriveSyncError;
/** @type {!ChromeEvent} */ /**
* @type {!ChromeEvent}
* @see https://developer.chrome.com/extensions/fileManagerPrivate#event-onAppsUpdated
*/
chrome.fileManagerPrivate.onAppsUpdated; chrome.fileManagerPrivate.onAppsUpdated;
/** @enum {string} */
chrome.fileManagerPrivate.Verb = {
OPEN_WITH: 'open_with',
ADD_TO: 'add_to',
PACK_WITH: 'pack_with',
SHARE_WITH: 'share_with',
};
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment