diff options
author | mtomasz <mtomasz@chromium.org> | 2015-07-06 23:07:40 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-07-07 06:08:30 +0000 |
commit | b577564f300f2cd67cf29e3cd02229f1fd7dd610 (patch) | |
tree | 2bcdf709883817c3ede7c5385426361fb94d3696 | |
parent | d5433f68e9a8c6a5ba09de89fb4a824623e16ad8 (diff) | |
download | chromium_src-b577564f300f2cd67cf29e3cd02229f1fd7dd610.zip chromium_src-b577564f300f2cd67cf29e3cd02229f1fd7dd610.tar.gz chromium_src-b577564f300f2cd67cf29e3cd02229f1fd7dd610.tar.bz2 |
Add support for refreshing contents of providers which don't support watchers.
This CL:
1. Adds a file_system_provider.watchable manifest option similar to the
existing file_system_provider.configurable.
2. Exposes this flag to Files app.
TEST=browser_tests: *FileSystemProvider*Mount*
BUG=501864
Review URL: https://codereview.chromium.org/1221093002
Cr-Commit-Position: refs/heads/master@{#337564}
44 files changed, 119 insertions, 41 deletions
diff --git a/chrome/browser/chromeos/extensions/file_manager/file_manager_private_apitest.cc b/chrome/browser/chromeos/extensions/file_manager/file_manager_private_apitest.cc index d16c876..92a6698 100644 --- a/chrome/browser/chromeos/extensions/file_manager/file_manager_private_apitest.cc +++ b/chrome/browser/chromeos/extensions/file_manager/file_manager_private_apitest.cc @@ -317,7 +317,8 @@ IN_PROC_BROWSER_TEST_F(FileManagerPrivateApiTest, Mount) { // |source| flags properly down to Files app. chromeos::file_system_provider::ProvidedFileSystemInfo info( "testing-extension-id", chromeos::file_system_provider::MountOptions(), - base::FilePath(), true /* configurable */, extensions::SOURCE_NETWORK); + base::FilePath(), true /* configurable */, false /* watchable */, + extensions::SOURCE_NETWORK); file_manager::VolumeManager::Get(browser()->profile()) ->AddVolumeForTesting( diff --git a/chrome/browser/chromeos/extensions/file_manager/private_api_misc.cc b/chrome/browser/chromeos/extensions/file_manager/private_api_misc.cc index eddfff2d..cd5c393 100644 --- a/chrome/browser/chromeos/extensions/file_manager/private_api_misc.cc +++ b/chrome/browser/chromeos/extensions/file_manager/private_api_misc.cc @@ -436,6 +436,7 @@ FileManagerPrivateGetProvidingExtensionsFunction::Run() { providing_extension->extension_id = info.extension_id; providing_extension->name = info.name; providing_extension->configurable = info.capabilities.configurable(); + providing_extension->watchable = info.capabilities.watchable(); providing_extension->multiple_mounts = info.capabilities.multiple_mounts(); switch (info.capabilities.source()) { case SOURCE_FILE: diff --git a/chrome/browser/chromeos/extensions/file_manager/private_api_util.cc b/chrome/browser/chromeos/extensions/file_manager/private_api_util.cc index 0f4ed53a..81a89f9 100644 --- a/chrome/browser/chromeos/extensions/file_manager/private_api_util.cc +++ b/chrome/browser/chromeos/extensions/file_manager/private_api_util.cc @@ -200,6 +200,7 @@ void VolumeToVolumeMetadata( } volume_metadata->configurable = volume.configurable(); + volume_metadata->watchable = volume.watchable(); if (volume.type() == VOLUME_TYPE_PROVIDED) { volume_metadata->extension_id.reset(new std::string(volume.extension_id())); diff --git a/chrome/browser/chromeos/file_manager/volume_manager.cc b/chrome/browser/chromeos/file_manager/volume_manager.cc index d0b0896..73bc754 100644 --- a/chrome/browser/chromeos/file_manager/volume_manager.cc +++ b/chrome/browser/chromeos/file_manager/volume_manager.cc @@ -144,7 +144,8 @@ Volume::Volume() is_parent_(false), is_read_only_(false), has_media_(false), - configurable_(false) { + configurable_(false), + watchable_(false) { } Volume::~Volume() { @@ -162,6 +163,7 @@ Volume* Volume::CreateForDrive(Profile* profile) { volume->mount_path_ = drive_path; volume->mount_condition_ = chromeos::disks::MOUNT_CONDITION_NONE; volume->volume_id_ = GenerateVolumeId(*volume); + volume->watchable_ = true; return volume; } @@ -175,6 +177,7 @@ Volume* Volume::CreateForDownloads(const base::FilePath& downloads_path) { volume->mount_path_ = downloads_path; volume->mount_condition_ = chromeos::disks::MOUNT_CONDITION_NONE; volume->volume_id_ = GenerateVolumeId(*volume); + volume->watchable_ = true; return volume; } @@ -203,6 +206,7 @@ Volume* Volume::CreateForRemovable( (mount_point.mount_type == chromeos::MOUNT_TYPE_ARCHIVE); } volume->volume_id_ = GenerateVolumeId(*volume); + volume->watchable_ = true; return volume; } @@ -233,6 +237,7 @@ Volume* Volume::CreateForProvidedFileSystem( volume->is_parent_ = true; volume->is_read_only_ = !file_system_info.writable(); volume->configurable_ = file_system_info.configurable(); + volume->watchable_ = file_system_info.watchable(); volume->volume_id_ = GenerateVolumeId(*volume); return volume; } diff --git a/chrome/browser/chromeos/file_manager/volume_manager.h b/chrome/browser/chromeos/file_manager/volume_manager.h index 81166f4..33e0554 100644 --- a/chrome/browser/chromeos/file_manager/volume_manager.h +++ b/chrome/browser/chromeos/file_manager/volume_manager.h @@ -119,6 +119,7 @@ class Volume : public base::SupportsWeakPtr<Volume> { bool is_read_only() const { return is_read_only_; } bool has_media() const { return has_media_; } bool configurable() const { return configurable_; } + bool watchable() const { return watchable_; } private: Volume(); @@ -183,6 +184,9 @@ class Volume : public base::SupportsWeakPtr<Volume> { // True if the volume is configurable. bool configurable_; + // True if the volume notifies about changes via file/directory watchers. + bool watchable_; + DISALLOW_COPY_AND_ASSIGN(Volume); }; diff --git a/chrome/browser/chromeos/file_system_provider/mount_path_util_unittest.cc b/chrome/browser/chromeos/file_system_provider/mount_path_util_unittest.cc index 570f0b9..1d1f838 100644 --- a/chrome/browser/chromeos/file_system_provider/mount_path_util_unittest.cc +++ b/chrome/browser/chromeos/file_system_provider/mount_path_util_unittest.cc @@ -166,7 +166,7 @@ TEST_F(FileSystemProviderMountPathUtilTest, Parser_WrongUrl) { const ProvidedFileSystemInfo file_system_info( kExtensionId, MountOptions(kFileSystemId, kDisplayName), GetMountPath(profile_, kExtensionId, kFileSystemId), - false /* configurable */, extensions::SOURCE_FILE); + false /* configurable */, true /* watchable */, extensions::SOURCE_FILE); const base::FilePath kFilePath = base::FilePath(FILE_PATH_LITERAL("/hello")); const storage::FileSystemURL url = diff --git a/chrome/browser/chromeos/file_system_provider/operations/abort_unittest.cc b/chrome/browser/chromeos/file_system_provider/operations/abort_unittest.cc index 27b016f..87bd1e23 100644 --- a/chrome/browser/chromeos/file_system_provider/operations/abort_unittest.cc +++ b/chrome/browser/chromeos/file_system_provider/operations/abort_unittest.cc @@ -40,7 +40,8 @@ class FileSystemProviderOperationsAbortTest : public testing::Test { void SetUp() override { file_system_info_ = ProvidedFileSystemInfo( kExtensionId, MountOptions(kFileSystemId, "" /* display_name */), - base::FilePath(), false /* configurable */, extensions::SOURCE_FILE); + base::FilePath(), false /* configurable */, true /* watchable */, + extensions::SOURCE_FILE); } ProvidedFileSystemInfo file_system_info_; diff --git a/chrome/browser/chromeos/file_system_provider/operations/add_watcher_unittest.cc b/chrome/browser/chromeos/file_system_provider/operations/add_watcher_unittest.cc index c076b00..7a7fd0e 100644 --- a/chrome/browser/chromeos/file_system_provider/operations/add_watcher_unittest.cc +++ b/chrome/browser/chromeos/file_system_provider/operations/add_watcher_unittest.cc @@ -41,7 +41,8 @@ class FileSystemProviderOperationsAddWatcherTest : public testing::Test { void SetUp() override { file_system_info_ = ProvidedFileSystemInfo( kExtensionId, MountOptions(kFileSystemId, "" /* display_name */), - base::FilePath(), false /* configurable */, extensions::SOURCE_FILE); + base::FilePath(), false /* configurable */, true /* watchable */, + extensions::SOURCE_FILE); } ProvidedFileSystemInfo file_system_info_; diff --git a/chrome/browser/chromeos/file_system_provider/operations/close_file_unittest.cc b/chrome/browser/chromeos/file_system_provider/operations/close_file_unittest.cc index e46657f..d73f346 100644 --- a/chrome/browser/chromeos/file_system_provider/operations/close_file_unittest.cc +++ b/chrome/browser/chromeos/file_system_provider/operations/close_file_unittest.cc @@ -39,7 +39,8 @@ class FileSystemProviderOperationsCloseFileTest : public testing::Test { void SetUp() override { file_system_info_ = ProvidedFileSystemInfo( kExtensionId, MountOptions(kFileSystemId, "" /* display_name */), - base::FilePath(), false /* configurable */, extensions::SOURCE_FILE); + base::FilePath(), false /* configurable */, true /* watchable */, + extensions::SOURCE_FILE); } ProvidedFileSystemInfo file_system_info_; diff --git a/chrome/browser/chromeos/file_system_provider/operations/configure_unittest.cc b/chrome/browser/chromeos/file_system_provider/operations/configure_unittest.cc index 03b52a6..cab8e51 100644 --- a/chrome/browser/chromeos/file_system_provider/operations/configure_unittest.cc +++ b/chrome/browser/chromeos/file_system_provider/operations/configure_unittest.cc @@ -37,7 +37,8 @@ class FileSystemProviderOperationsConfigureTest : public testing::Test { void SetUp() override { file_system_info_ = ProvidedFileSystemInfo( kExtensionId, MountOptions(kFileSystemId, "" /* display_name */), - base::FilePath(), false /* configurable */, extensions::SOURCE_FILE); + base::FilePath(), false /* configurable */, true /* watchable */, + extensions::SOURCE_FILE); } ProvidedFileSystemInfo file_system_info_; diff --git a/chrome/browser/chromeos/file_system_provider/operations/copy_entry_unittest.cc b/chrome/browser/chromeos/file_system_provider/operations/copy_entry_unittest.cc index f864780..90c8f39 100644 --- a/chrome/browser/chromeos/file_system_provider/operations/copy_entry_unittest.cc +++ b/chrome/browser/chromeos/file_system_provider/operations/copy_entry_unittest.cc @@ -45,7 +45,7 @@ class FileSystemProviderOperationsCopyEntryTest : public testing::Test { mount_options.writable = true; file_system_info_ = ProvidedFileSystemInfo( kExtensionId, mount_options, base::FilePath(), false /* configurable */, - extensions::SOURCE_FILE); + true /* watchable */, extensions::SOURCE_FILE); } ProvidedFileSystemInfo file_system_info_; @@ -106,7 +106,7 @@ TEST_F(FileSystemProviderOperationsCopyEntryTest, Execute_ReadOnly) { const ProvidedFileSystemInfo read_only_file_system_info( kExtensionId, MountOptions(kFileSystemId, "" /* display_name */), base::FilePath() /* mount_path */, false /* configurable */, - extensions::SOURCE_FILE); + true /* watchable */, extensions::SOURCE_FILE); CopyEntry copy_entry(NULL, read_only_file_system_info, base::FilePath(kSourcePath), base::FilePath(kTargetPath), diff --git a/chrome/browser/chromeos/file_system_provider/operations/create_directory_unittest.cc b/chrome/browser/chromeos/file_system_provider/operations/create_directory_unittest.cc index d7d2274..77d06a3 100644 --- a/chrome/browser/chromeos/file_system_provider/operations/create_directory_unittest.cc +++ b/chrome/browser/chromeos/file_system_provider/operations/create_directory_unittest.cc @@ -43,7 +43,7 @@ class FileSystemProviderOperationsCreateDirectoryTest : public testing::Test { mount_options.writable = true; file_system_info_ = ProvidedFileSystemInfo( kExtensionId, mount_options, base::FilePath(), false /* configurable */, - extensions::SOURCE_FILE); + true /* watchable */, extensions::SOURCE_FILE); } ProvidedFileSystemInfo file_system_info_; @@ -107,7 +107,7 @@ TEST_F(FileSystemProviderOperationsCreateDirectoryTest, Execute_ReadOnly) { const ProvidedFileSystemInfo read_only_file_system_info( kExtensionId, MountOptions(kFileSystemId, "" /* display_name */), base::FilePath() /* mount_path */, false /* configurable */, - extensions::SOURCE_FILE); + true /* watchable */, extensions::SOURCE_FILE); CreateDirectory create_directory( NULL, read_only_file_system_info, base::FilePath(kDirectoryPath), diff --git a/chrome/browser/chromeos/file_system_provider/operations/create_file_unittest.cc b/chrome/browser/chromeos/file_system_provider/operations/create_file_unittest.cc index 3e40b90..32d59d1 100644 --- a/chrome/browser/chromeos/file_system_provider/operations/create_file_unittest.cc +++ b/chrome/browser/chromeos/file_system_provider/operations/create_file_unittest.cc @@ -43,7 +43,7 @@ class FileSystemProviderOperationsCreateFileTest : public testing::Test { mount_options.writable = true; file_system_info_ = ProvidedFileSystemInfo( kExtensionId, mount_options, base::FilePath(), false /* configurable */, - extensions::SOURCE_FILE); + true /* watchable */, extensions::SOURCE_FILE); } ProvidedFileSystemInfo file_system_info_; @@ -102,7 +102,7 @@ TEST_F(FileSystemProviderOperationsCreateFileTest, Execute_ReadOnly) { const ProvidedFileSystemInfo read_only_file_system_info( kExtensionId, MountOptions(kFileSystemId, "" /* display_name */), base::FilePath() /* mount_path */, false /* configurable */, - extensions::SOURCE_FILE); + true /* watchable */, extensions::SOURCE_FILE); CreateFile create_file(NULL, read_only_file_system_info, base::FilePath(kFilePath), diff --git a/chrome/browser/chromeos/file_system_provider/operations/delete_entry_unittest.cc b/chrome/browser/chromeos/file_system_provider/operations/delete_entry_unittest.cc index a7067e1..906118b 100644 --- a/chrome/browser/chromeos/file_system_provider/operations/delete_entry_unittest.cc +++ b/chrome/browser/chromeos/file_system_provider/operations/delete_entry_unittest.cc @@ -43,7 +43,7 @@ class FileSystemProviderOperationsDeleteEntryTest : public testing::Test { mount_options.writable = true; file_system_info_ = ProvidedFileSystemInfo( kExtensionId, mount_options, base::FilePath(), false /* configurable */, - extensions::SOURCE_FILE); + true /* watchable */, extensions::SOURCE_FILE); } ProvidedFileSystemInfo file_system_info_; @@ -105,7 +105,7 @@ TEST_F(FileSystemProviderOperationsDeleteEntryTest, Execute_ReadOnly) { const ProvidedFileSystemInfo read_only_file_system_info( kExtensionId, MountOptions(kFileSystemId, "" /* display_name */), base::FilePath() /* mount_path */, false /* configurable */, - extensions::SOURCE_FILE); + true /* watchable */, extensions::SOURCE_FILE); DeleteEntry delete_entry(NULL, read_only_file_system_info, base::FilePath(kEntryPath), true /* recursive */, diff --git a/chrome/browser/chromeos/file_system_provider/operations/execute_action_unittest.cc b/chrome/browser/chromeos/file_system_provider/operations/execute_action_unittest.cc index 83eb352..f89c4d2 100644 --- a/chrome/browser/chromeos/file_system_provider/operations/execute_action_unittest.cc +++ b/chrome/browser/chromeos/file_system_provider/operations/execute_action_unittest.cc @@ -42,7 +42,8 @@ class FileSystemProviderOperationsExecuteActionTest : public testing::Test { void SetUp() override { file_system_info_ = ProvidedFileSystemInfo( kExtensionId, MountOptions(kFileSystemId, "" /* display_name */), - base::FilePath(), false /* configurable */, extensions::SOURCE_FILE); + base::FilePath(), false /* configurable */, true /* watchable */, + extensions::SOURCE_FILE); } ProvidedFileSystemInfo file_system_info_; diff --git a/chrome/browser/chromeos/file_system_provider/operations/get_actions_unittest.cc b/chrome/browser/chromeos/file_system_provider/operations/get_actions_unittest.cc index d06df2b..1ca010a 100644 --- a/chrome/browser/chromeos/file_system_provider/operations/get_actions_unittest.cc +++ b/chrome/browser/chromeos/file_system_provider/operations/get_actions_unittest.cc @@ -95,7 +95,8 @@ class FileSystemProviderOperationsGetActionsTest : public testing::Test { void SetUp() override { file_system_info_ = ProvidedFileSystemInfo( kExtensionId, MountOptions(kFileSystemId, "" /* display_name */), - base::FilePath(), false /* configurable */, extensions::SOURCE_FILE); + base::FilePath(), false /* configurable */, true /* watchable */, + extensions::SOURCE_FILE); } ProvidedFileSystemInfo file_system_info_; diff --git a/chrome/browser/chromeos/file_system_provider/operations/get_metadata_unittest.cc b/chrome/browser/chromeos/file_system_provider/operations/get_metadata_unittest.cc index 765e742..efdd499 100644 --- a/chrome/browser/chromeos/file_system_provider/operations/get_metadata_unittest.cc +++ b/chrome/browser/chromeos/file_system_provider/operations/get_metadata_unittest.cc @@ -100,7 +100,8 @@ class FileSystemProviderOperationsGetMetadataTest : public testing::Test { void SetUp() override { file_system_info_ = ProvidedFileSystemInfo( kExtensionId, MountOptions(kFileSystemId, "" /* display_name */), - base::FilePath(), false /* configurable */, extensions::SOURCE_FILE); + base::FilePath(), false /* configurable */, true /* watchable */, + extensions::SOURCE_FILE); } ProvidedFileSystemInfo file_system_info_; diff --git a/chrome/browser/chromeos/file_system_provider/operations/move_entry_unittest.cc b/chrome/browser/chromeos/file_system_provider/operations/move_entry_unittest.cc index 6351820..643f636 100644 --- a/chrome/browser/chromeos/file_system_provider/operations/move_entry_unittest.cc +++ b/chrome/browser/chromeos/file_system_provider/operations/move_entry_unittest.cc @@ -46,7 +46,7 @@ class FileSystemProviderOperationsMoveEntryTest : public testing::Test { mount_options.writable = true; file_system_info_ = ProvidedFileSystemInfo( kExtensionId, mount_options, base::FilePath(), false /* configurable */, - extensions::SOURCE_FILE); + true /* watchable */, extensions::SOURCE_FILE); } ProvidedFileSystemInfo file_system_info_; @@ -107,7 +107,7 @@ TEST_F(FileSystemProviderOperationsMoveEntryTest, Execute_ReadOnly) { const ProvidedFileSystemInfo read_only_file_system_info( kExtensionId, MountOptions(kFileSystemId, "" /* display_name */), base::FilePath() /* mount_path */, false /* configurable */, - extensions::SOURCE_FILE); + true /* watchable */, extensions::SOURCE_FILE); MoveEntry move_entry(NULL, read_only_file_system_info, base::FilePath(kSourcePath), base::FilePath(kTargetPath), diff --git a/chrome/browser/chromeos/file_system_provider/operations/open_file_unittest.cc b/chrome/browser/chromeos/file_system_provider/operations/open_file_unittest.cc index f6bd6d9..7250547 100644 --- a/chrome/browser/chromeos/file_system_provider/operations/open_file_unittest.cc +++ b/chrome/browser/chromeos/file_system_provider/operations/open_file_unittest.cc @@ -75,7 +75,8 @@ class FileSystemProviderOperationsOpenFileTest : public testing::Test { void SetUp() override { file_system_info_ = ProvidedFileSystemInfo( kExtensionId, MountOptions(kFileSystemId, "" /* display_name */), - base::FilePath(), false /* configurable */, extensions::SOURCE_FILE); + base::FilePath(), false /* configurable */, true /* watchable */, + extensions::SOURCE_FILE); } ProvidedFileSystemInfo file_system_info_; @@ -139,7 +140,7 @@ TEST_F(FileSystemProviderOperationsOpenFileTest, Execute_ReadOnly) { const ProvidedFileSystemInfo read_only_file_system_info( kExtensionId, MountOptions(kFileSystemId, "" /* display_name */), base::FilePath() /* mount_path */, false /* configurable */, - extensions::SOURCE_FILE); + true /* watchable */, extensions::SOURCE_FILE); // Opening for read on a read-only file system is allowed. { diff --git a/chrome/browser/chromeos/file_system_provider/operations/read_directory_unittest.cc b/chrome/browser/chromeos/file_system_provider/operations/read_directory_unittest.cc index ba1c19c..b763990 100644 --- a/chrome/browser/chromeos/file_system_provider/operations/read_directory_unittest.cc +++ b/chrome/browser/chromeos/file_system_provider/operations/read_directory_unittest.cc @@ -104,7 +104,8 @@ class FileSystemProviderOperationsReadDirectoryTest : public testing::Test { void SetUp() override { file_system_info_ = ProvidedFileSystemInfo( kExtensionId, MountOptions(kFileSystemId, "" /* display_name */), - base::FilePath(), false /* configurable */, extensions::SOURCE_FILE); + base::FilePath(), false /* configurable */, true /* watchable */, + extensions::SOURCE_FILE); } ProvidedFileSystemInfo file_system_info_; diff --git a/chrome/browser/chromeos/file_system_provider/operations/read_file_unittest.cc b/chrome/browser/chromeos/file_system_provider/operations/read_file_unittest.cc index b9d28f2..acfe462 100644 --- a/chrome/browser/chromeos/file_system_provider/operations/read_file_unittest.cc +++ b/chrome/browser/chromeos/file_system_provider/operations/read_file_unittest.cc @@ -79,7 +79,8 @@ class FileSystemProviderOperationsReadFileTest : public testing::Test { void SetUp() override { file_system_info_ = ProvidedFileSystemInfo( kExtensionId, MountOptions(kFileSystemId, "" /* display_name */), - base::FilePath(), false /* configurable */, extensions::SOURCE_FILE); + base::FilePath(), false /* configurable */, true /* watchable */, + extensions::SOURCE_FILE); io_buffer_ = make_scoped_refptr(new net::IOBuffer(kOffset + kLength)); } diff --git a/chrome/browser/chromeos/file_system_provider/operations/remove_watcher_unittest.cc b/chrome/browser/chromeos/file_system_provider/operations/remove_watcher_unittest.cc index 56f488d..cd03c3a 100644 --- a/chrome/browser/chromeos/file_system_provider/operations/remove_watcher_unittest.cc +++ b/chrome/browser/chromeos/file_system_provider/operations/remove_watcher_unittest.cc @@ -41,7 +41,8 @@ class FileSystemProviderOperationsRemoveWatcherTest : public testing::Test { void SetUp() override { file_system_info_ = ProvidedFileSystemInfo( kExtensionId, MountOptions(kFileSystemId, "" /* display_name */), - base::FilePath(), false /* configurable */, extensions::SOURCE_FILE); + base::FilePath(), false /* configurable */, true /* watchable */, + extensions::SOURCE_FILE); } ProvidedFileSystemInfo file_system_info_; diff --git a/chrome/browser/chromeos/file_system_provider/operations/truncate_unittest.cc b/chrome/browser/chromeos/file_system_provider/operations/truncate_unittest.cc index 6439602..007ba40 100644 --- a/chrome/browser/chromeos/file_system_provider/operations/truncate_unittest.cc +++ b/chrome/browser/chromeos/file_system_provider/operations/truncate_unittest.cc @@ -44,7 +44,7 @@ class FileSystemProviderOperationsTruncateTest : public testing::Test { mount_options.writable = true; file_system_info_ = ProvidedFileSystemInfo( kExtensionId, mount_options, base::FilePath(), false /* configurable */, - extensions::SOURCE_FILE); + true /* watchable */, extensions::SOURCE_FILE); } ProvidedFileSystemInfo file_system_info_; @@ -105,7 +105,7 @@ TEST_F(FileSystemProviderOperationsTruncateTest, Execute_ReadOnly) { const ProvidedFileSystemInfo read_only_file_system_info( kExtensionId, MountOptions(kFileSystemId, "" /* display_name */), base::FilePath() /* mount_path */, false /* configurable */, - extensions::SOURCE_FILE); + true /* watchable */, extensions::SOURCE_FILE); Truncate truncate(NULL, file_system_info_, base::FilePath(kFilePath), kTruncateLength, diff --git a/chrome/browser/chromeos/file_system_provider/operations/unmount_unittest.cc b/chrome/browser/chromeos/file_system_provider/operations/unmount_unittest.cc index 4ae1f94..28181ca 100644 --- a/chrome/browser/chromeos/file_system_provider/operations/unmount_unittest.cc +++ b/chrome/browser/chromeos/file_system_provider/operations/unmount_unittest.cc @@ -37,7 +37,8 @@ class FileSystemProviderOperationsUnmountTest : public testing::Test { void SetUp() override { file_system_info_ = ProvidedFileSystemInfo( kExtensionId, MountOptions(kFileSystemId, "" /* display_name */), - base::FilePath(), false /* configurable */, extensions::SOURCE_FILE); + base::FilePath(), false /* configurable */, true /* watchable */, + extensions::SOURCE_FILE); } ProvidedFileSystemInfo file_system_info_; diff --git a/chrome/browser/chromeos/file_system_provider/operations/write_file_unittest.cc b/chrome/browser/chromeos/file_system_provider/operations/write_file_unittest.cc index e6d576f..ecca037 100644 --- a/chrome/browser/chromeos/file_system_provider/operations/write_file_unittest.cc +++ b/chrome/browser/chromeos/file_system_provider/operations/write_file_unittest.cc @@ -47,7 +47,7 @@ class FileSystemProviderOperationsWriteFileTest : public testing::Test { mount_options.writable = true; file_system_info_ = ProvidedFileSystemInfo( kExtensionId, mount_options, base::FilePath(), false /* configurable */, - extensions::SOURCE_FILE); + true /* watchable */, extensions::SOURCE_FILE); io_buffer_ = make_scoped_refptr(new net::StringIOBuffer(kWriteData)); } @@ -121,7 +121,7 @@ TEST_F(FileSystemProviderOperationsWriteFileTest, Execute_ReadOnly) { const ProvidedFileSystemInfo read_only_file_system_info( kExtensionId, MountOptions(kFileSystemId, "" /* display_name */), base::FilePath() /* mount_path */, false /* configurable */, - extensions::SOURCE_FILE); + true /* watchable */, extensions::SOURCE_FILE); WriteFile write_file(NULL, read_only_file_system_info, diff --git a/chrome/browser/chromeos/file_system_provider/provided_file_system_info.cc b/chrome/browser/chromeos/file_system_provider/provided_file_system_info.cc index a35c5c5..607133b 100644 --- a/chrome/browser/chromeos/file_system_provider/provided_file_system_info.cc +++ b/chrome/browser/chromeos/file_system_provider/provided_file_system_info.cc @@ -28,6 +28,7 @@ ProvidedFileSystemInfo::ProvidedFileSystemInfo() : writable_(false), supports_notify_tag_(false), configurable_(false), + watchable_(false), source_(extensions::SOURCE_FILE) { } @@ -36,6 +37,7 @@ ProvidedFileSystemInfo::ProvidedFileSystemInfo( const MountOptions& mount_options, const base::FilePath& mount_path, bool configurable, + bool watchable, extensions::FileSystemProviderSource source) : extension_id_(extension_id), file_system_id_(mount_options.file_system_id), @@ -45,6 +47,7 @@ ProvidedFileSystemInfo::ProvidedFileSystemInfo( opened_files_limit_(mount_options.opened_files_limit), mount_path_(mount_path), configurable_(configurable), + watchable_(watchable), source_(source) { DCHECK_LE(0, mount_options.opened_files_limit); } diff --git a/chrome/browser/chromeos/file_system_provider/provided_file_system_info.h b/chrome/browser/chromeos/file_system_provider/provided_file_system_info.h index f2b51e6..677e839 100644 --- a/chrome/browser/chromeos/file_system_provider/provided_file_system_info.h +++ b/chrome/browser/chromeos/file_system_provider/provided_file_system_info.h @@ -37,6 +37,7 @@ class ProvidedFileSystemInfo { const MountOptions& mount_options, const base::FilePath& mount_path, bool configurable, + bool watchable, extensions::FileSystemProviderSource source); ~ProvidedFileSystemInfo(); @@ -49,6 +50,7 @@ class ProvidedFileSystemInfo { int opened_files_limit() const { return opened_files_limit_; } const base::FilePath& mount_path() const { return mount_path_; } const bool configurable() const { return configurable_; } + const bool watchable() const { return watchable_; } extensions::FileSystemProviderSource source() const { return source_; } private: @@ -76,6 +78,9 @@ class ProvidedFileSystemInfo { // Whether the file system is configurable. bool configurable_; + // Whether the file system is watchable. + bool watchable_; + // Source of the file system's data. extensions::FileSystemProviderSource source_; }; diff --git a/chrome/browser/chromeos/file_system_provider/provided_file_system_unittest.cc b/chrome/browser/chromeos/file_system_provider/provided_file_system_unittest.cc index 2a4488f..64be6fc 100644 --- a/chrome/browser/chromeos/file_system_provider/provided_file_system_unittest.cc +++ b/chrome/browser/chromeos/file_system_provider/provided_file_system_unittest.cc @@ -234,7 +234,7 @@ class FileSystemProviderProvidedFileSystemTest : public testing::Test { mount_options.writable = true; file_system_info_.reset(new ProvidedFileSystemInfo( kExtensionId, mount_options, mount_path, false /* configurable */, - extensions::SOURCE_FILE)); + true /* watchable */, extensions::SOURCE_FILE)); provided_file_system_.reset( new ProvidedFileSystem(profile_.get(), *file_system_info_.get())); event_router_.reset( @@ -414,7 +414,7 @@ TEST_F(FileSystemProviderProvidedFileSystemTest, AddWatcher_PersistentIllegal) { mount_options.supports_notify_tag = false; ProvidedFileSystemInfo file_system_info( kExtensionId, mount_options, mount_path, false /* configurable */, - extensions::SOURCE_FILE); + true /* watchable */, extensions::SOURCE_FILE); ProvidedFileSystem simple_provided_file_system(profile_.get(), file_system_info); simple_provided_file_system.SetEventRouterForTesting(event_router_.get()); diff --git a/chrome/browser/chromeos/file_system_provider/registry_unittest.cc b/chrome/browser/chromeos/file_system_provider/registry_unittest.cc index a2c914d..9ce453d 100644 --- a/chrome/browser/chromeos/file_system_provider/registry_unittest.cc +++ b/chrome/browser/chromeos/file_system_provider/registry_unittest.cc @@ -159,7 +159,7 @@ TEST_F(FileSystemProviderRegistryTest, RememberFileSystem) { ProvidedFileSystemInfo file_system_info( kExtensionId, options, base::FilePath(FILE_PATH_LITERAL("/a/b/c")), - false /* configurable */, extensions::SOURCE_FILE); + false /* configurable */, true /* watchable */, extensions::SOURCE_FILE); Watchers watchers; watchers[WatcherKey(fake_watcher_.entry_path, fake_watcher_.recursive)] = @@ -275,7 +275,7 @@ TEST_F(FileSystemProviderRegistryTest, UpdateWatcherTag) { ProvidedFileSystemInfo file_system_info( kExtensionId, options, base::FilePath(FILE_PATH_LITERAL("/a/b/c")), - false /* configurable */, extensions::SOURCE_FILE); + false /* configurable */, true /* watchable */, extensions::SOURCE_FILE); Watchers watchers; watchers[WatcherKey(fake_watcher_.entry_path, fake_watcher_.recursive)] = diff --git a/chrome/browser/chromeos/file_system_provider/service.cc b/chrome/browser/chromeos/file_system_provider/service.cc index 88e3764..8766a8a 100644 --- a/chrome/browser/chromeos/file_system_provider/service.cc +++ b/chrome/browser/chromeos/file_system_provider/service.cc @@ -172,10 +172,12 @@ base::File::Error Service::MountFileSystemInternal( // supports_notify_tag = false // mount_path = /provided/b33f1337-hello_world-5aa5 // configurable = true + // watchable = true // source = SOURCE_FILE ProvidedFileSystemInfo file_system_info( extension_id, options, mount_path, provider_info.capabilities.configurable(), + provider_info.capabilities.watchable(), provider_info.capabilities.source()); ProvidedFileSystemInterface* file_system = diff --git a/chrome/browser/chromeos/file_system_provider/service_unittest.cc b/chrome/browser/chromeos/file_system_provider/service_unittest.cc index 94765ee..a84598c 100644 --- a/chrome/browser/chromeos/file_system_provider/service_unittest.cc +++ b/chrome/browser/chromeos/file_system_provider/service_unittest.cc @@ -417,7 +417,7 @@ TEST_F(FileSystemProviderServiceTest, RestoreFileSystem_OnExtensionLoad) { options.supports_notify_tag = true; ProvidedFileSystemInfo file_system_info( kExtensionId, options, base::FilePath(FILE_PATH_LITERAL("/a/b/c")), - false /* configurable */, extensions::SOURCE_FILE); + false /* configurable */, false /* watchable */, extensions::SOURCE_FILE); Watchers fake_watchers; fake_watchers[WatcherKey(fake_watcher_.entry_path, fake_watcher_.recursive)] = fake_watcher_; @@ -437,7 +437,7 @@ TEST_F(FileSystemProviderServiceTest, RestoreFileSystem_OnExtensionLoad) { EXPECT_EQ(file_system_info.file_system_id(), observer.mounts[0].file_system_info().file_system_id()); EXPECT_EQ(file_system_info.writable(), - observer.mounts[0].file_system_info().writable()); + observer.mounts[0].file_system_info().watchable()); EXPECT_EQ(file_system_info.supports_notify_tag(), observer.mounts[0].file_system_info().supports_notify_tag()); @@ -481,6 +481,8 @@ TEST_F(FileSystemProviderServiceTest, RememberFileSystem_OnMount) { EXPECT_EQ(kFileSystemId, registry_->file_system_info()->file_system_id()); EXPECT_EQ(kDisplayName, registry_->file_system_info()->display_name()); EXPECT_FALSE(registry_->file_system_info()->writable()); + EXPECT_FALSE(registry_->file_system_info()->configurable()); + EXPECT_FALSE(registry_->file_system_info()->watchable()); EXPECT_FALSE(registry_->file_system_info()->supports_notify_tag()); ASSERT_TRUE(registry_->watchers()); diff --git a/chrome/browser/chromeos/file_system_provider/throttled_file_system_unittest.cc b/chrome/browser/chromeos/file_system_provider/throttled_file_system_unittest.cc index d933308..abf87ac 100644 --- a/chrome/browser/chromeos/file_system_provider/throttled_file_system_unittest.cc +++ b/chrome/browser/chromeos/file_system_provider/throttled_file_system_unittest.cc @@ -55,7 +55,8 @@ class FileSystemProviderThrottledFileSystemTest : public testing::Test { ProvidedFileSystemInfo file_system_info( kExtensionId, options, base::FilePath() /* mount_path */, - false /* configurable */, extensions::SOURCE_FILE); + false /* configurable */, true /* watchable */, + extensions::SOURCE_FILE); file_system_.reset(new ThrottledFileSystem( make_scoped_ptr(new FakeProvidedFileSystem(file_system_info)))); diff --git a/chrome/common/extensions/api/file_manager_private.idl b/chrome/common/extensions/api/file_manager_private.idl index 42eafba..d062f45 100644 --- a/chrome/common/extensions/api/file_manager_private.idl +++ b/chrome/common/extensions/api/file_manager_private.idl @@ -334,6 +334,9 @@ dictionary VolumeMetadata { // Flag that specifies whether the volume is configurable. boolean configurable; + // Flag that specifies whether the volume is watchable. + boolean watchable; + // Additional data about mount, for example, that the filesystem is not // supported. MountCondition? mountCondition; @@ -531,6 +534,9 @@ dictionary ProvidingExtension { // Whether supports configuration dialog. boolean configurable; + // Whether supports watching entries. + boolean watchable; + // Whether supports mounting multiple instances. boolean multipleMounts; diff --git a/chrome/common/extensions/api/file_system_provider.idl b/chrome/common/extensions/api/file_system_provider.idl index dedbb2a0..96ef449 100644 --- a/chrome/common/extensions/api/file_system_provider.idl +++ b/chrome/common/extensions/api/file_system_provider.idl @@ -544,6 +544,9 @@ namespace fileSystemProvider { // notification always reported, even if the system was shutdown. The last // tag can be obtained with $(ref:getAll). // + // To use, the <code>file_system_provider.notify</code> manifest option + // must be set to true. + // // Value of <code>tag</code> can be any string which is unique per call, // so it's possible to identify the last registered notification. Eg. if // the providing extension starts after a reboot, and the last registered diff --git a/chrome/common/extensions/api/file_system_provider_capabilities/file_system_provider_capabilities_handler.cc b/chrome/common/extensions/api/file_system_provider_capabilities/file_system_provider_capabilities_handler.cc index d959ad7..308aa8c 100644 --- a/chrome/common/extensions/api/file_system_provider_capabilities/file_system_provider_capabilities_handler.cc +++ b/chrome/common/extensions/api/file_system_provider_capabilities/file_system_provider_capabilities_handler.cc @@ -16,14 +16,19 @@ namespace extensions { FileSystemProviderCapabilities::FileSystemProviderCapabilities() - : configurable_(false), multiple_mounts_(false), source_(SOURCE_FILE) { + : configurable_(false), + watchable_(false), + multiple_mounts_(false), + source_(SOURCE_FILE) { } FileSystemProviderCapabilities::FileSystemProviderCapabilities( bool configurable, + bool watchable, bool multiple_mounts, FileSystemProviderSource source) : configurable_(configurable), + watchable_(watchable), multiple_mounts_(multiple_mounts), source_(source) { } @@ -99,6 +104,8 @@ bool FileSystemProviderCapabilitiesHandler::Parse(Extension* extension, idl_capabilities.configurable.get() ? *idl_capabilities.configurable.get() : false /* false by default */, + idl_capabilities.watchable.get() ? *idl_capabilities.watchable.get() + : false /* false by default */, idl_capabilities.multiple_mounts.get() ? *idl_capabilities.multiple_mounts.get() : false /* false by default */, diff --git a/chrome/common/extensions/api/file_system_provider_capabilities/file_system_provider_capabilities_handler.h b/chrome/common/extensions/api/file_system_provider_capabilities/file_system_provider_capabilities_handler.h index dcee628..762e435 100644 --- a/chrome/common/extensions/api/file_system_provider_capabilities/file_system_provider_capabilities_handler.h +++ b/chrome/common/extensions/api/file_system_provider_capabilities/file_system_provider_capabilities_handler.h @@ -22,6 +22,7 @@ class FileSystemProviderCapabilities : public Extension::ManifestData { public: FileSystemProviderCapabilities(); FileSystemProviderCapabilities(bool configurable, + bool watchable, bool multiple_mounts, FileSystemProviderSource source); ~FileSystemProviderCapabilities() override; @@ -31,11 +32,13 @@ class FileSystemProviderCapabilities : public Extension::ManifestData { static const FileSystemProviderCapabilities* Get(const Extension* extension); bool configurable() const { return configurable_; } + bool watchable() const { return watchable_; } bool multiple_mounts() const { return multiple_mounts_; } FileSystemProviderSource source() const { return source_; } private: bool configurable_; + bool watchable_; bool multiple_mounts_; FileSystemProviderSource source_; }; diff --git a/chrome/common/extensions/api/manifest_types.json b/chrome/common/extensions/api/manifest_types.json index ab5eaca..7faca68 100644 --- a/chrome/common/extensions/api/manifest_types.json +++ b/chrome/common/extensions/api/manifest_types.json @@ -191,6 +191,11 @@ "optional": true, "description": "Whether multiple (more than one) mounted file systems are supported. By default: <code>false</code>." }, + "watchable": { + "type": "boolean", + "optional": true, + "description": "Whether setting watchers and notifying about changes is supported. By default: <code>false</code>." + }, "source": { "$ref": "FileSystemProviderSource", "description": "Source of data for mounted file systems." diff --git a/chrome/common/extensions/docs/templates/intros/fileSystemProvider.html b/chrome/common/extensions/docs/templates/intros/fileSystemProvider.html index ea49a4b..3b61a8b 100644 --- a/chrome/common/extensions/docs/templates/intros/fileSystemProvider.html +++ b/chrome/common/extensions/docs/templates/intros/fileSystemProvider.html @@ -13,6 +13,7 @@ For example:</p> ... "file_system_provider_capabilities": { "configurable": true, + "watchable": false, "multiple_mounts": true, <span id="manifest-source">"source": "network"</span> }, @@ -30,7 +31,10 @@ Files app uses above information in order to render related UI elements approprietly. For example, if <code>configurable</code> is set to </code>true</code>, then a menu item for configuring volumes will be rendered. Similarly, if <code>multiple_mounts</code> is set to <code>true</code>, then -Files app will allow to add more than one mount points from the UI. +Files app will allow to add more than one mount points from the UI. If +<code>watchable</code> is <code>false</code>, then a refresh button will be +rendered. Note, that if possible you should add support for watchers, so +changes on the file system can be reflected immediately and automatically. </p> <h2 id="overview">Overview</h2> diff --git a/chrome/test/data/extensions/api_test/file_browser/mount_test/test.js b/chrome/test/data/extensions/api_test/file_browser/mount_test/test.js index e288fd5..3f73a9f 100644 --- a/chrome/test/data/extensions/api_test/file_browser/mount_test/test.js +++ b/chrome/test/data/extensions/api_test/file_browser/mount_test/test.js @@ -14,6 +14,7 @@ var expectedVolume1 = { isReadOnly: false, hasMedia: false, configurable: false, + watchable: true, source: 'device', profile: {profileId: '', displayName: '', isCurrentProfile: true}, }; @@ -29,6 +30,9 @@ var expectedVolume2 = { isReadOnly: true, hasMedia: true, configurable: false, + // This is not an MTP device, so it's watchable. + // TODO(mtomasz): Add a test for a real MTP device. + watchable: true, source: 'device', profile: {profileId: '', displayName: '', isCurrentProfile: true} }; @@ -44,6 +48,7 @@ var expectedVolume3 = { isReadOnly: false, hasMedia: false, configurable: false, + watchable: true, source: 'device', profile: {profileId: '', displayName: '', isCurrentProfile: true} }; @@ -55,6 +60,7 @@ var expectedDownloadsVolume = { isReadOnly: false, hasMedia: false, configurable: false, + watchable: true, source: 'system', profile: {profileId: '', displayName: '', isCurrentProfile: true} }; @@ -67,6 +73,7 @@ var expectedDriveVolume = { isReadOnly: false, hasMedia: false, configurable: false, + watchable: true, source: 'network', profile: {profileId: '', displayName: '', isCurrentProfile: true} }; @@ -79,6 +86,7 @@ var expectedArchiveVolume = { isReadOnly: true, hasMedia: false, configurable: false, + watchable: true, source: 'file', profile: {profileId: '', displayName: '', isCurrentProfile: true} }; @@ -90,6 +98,7 @@ var expectedProvidedVolume = { isReadOnly: true, hasMedia: false, configurable: true, + watchable: false, extensionId: 'testing-extension-id', source: 'network', mountContext: 'auto', diff --git a/chrome/test/data/extensions/api_test/file_system_provider/mount/manifest.json b/chrome/test/data/extensions/api_test/file_system_provider/mount/manifest.json index 4ef91b9..d703f8a 100644 --- a/chrome/test/data/extensions/api_test/file_system_provider/mount/manifest.json +++ b/chrome/test/data/extensions/api_test/file_system_provider/mount/manifest.json @@ -7,7 +7,6 @@ "description": "Test for chrome.fileSystemProvider.mount().", "permissions": ["fileSystemProvider", "fileManagerPrivate"], "file_system_provider_capabilities": { - "multiple_mounts": true, "source": "network" }, "app": { diff --git a/chrome/test/data/extensions/api_test/file_system_provider/mount/test.js b/chrome/test/data/extensions/api_test/file_system_provider/mount/test.js index 7c9aa3a..0a968c6 100644 --- a/chrome/test/data/extensions/api_test/file_system_provider/mount/test.js +++ b/chrome/test/data/extensions/api_test/file_system_provider/mount/test.js @@ -154,7 +154,8 @@ chrome.test.runTests([ chrome.test.assertEq( chrome.runtime.getManifest().name, extensions[0].name); chrome.test.assertFalse(extensions[0].configurable); - chrome.test.assertTrue(extensions[0].multipleMounts); + chrome.test.assertFalse(extensions[0].watchable); + chrome.test.assertFalse(extensions[0].multipleMounts); chrome.test.assertEq('network', extensions[0].source); })); diff --git a/chrome/test/data/extensions/manifest_tests/filesystemprovider_missing_permission.json b/chrome/test/data/extensions/manifest_tests/filesystemprovider_missing_permission.json index 8003fbc..85d6b6d 100644 --- a/chrome/test/data/extensions/manifest_tests/filesystemprovider_missing_permission.json +++ b/chrome/test/data/extensions/manifest_tests/filesystemprovider_missing_permission.json @@ -3,6 +3,7 @@ "version": "1", "file_system_provider_capabilities": { "configurable": false, + "watchable": false, "multiple_mounts": false, "source": "device" } diff --git a/chrome/test/data/extensions/manifest_tests/filesystemprovider_valid.json b/chrome/test/data/extensions/manifest_tests/filesystemprovider_valid.json index 6c04c69..4d0dc29 100644 --- a/chrome/test/data/extensions/manifest_tests/filesystemprovider_valid.json +++ b/chrome/test/data/extensions/manifest_tests/filesystemprovider_valid.json @@ -6,6 +6,7 @@ ], "file_system_provider_capabilities": { "configurable": false, + "watchable": false, "multiple_mounts": false, "source": "device" } diff --git a/third_party/closure_compiler/externs/file_manager_private.js b/third_party/closure_compiler/externs/file_manager_private.js index 0e75529..cd88c10 100644 --- a/third_party/closure_compiler/externs/file_manager_private.js +++ b/third_party/closure_compiler/externs/file_manager_private.js @@ -71,6 +71,7 @@ var ProfileInfo; * isReadOnly: boolean, * hasMedia: boolean, * configurable: boolean, + * watchable: boolean, * mountCondition: (string|undefined), * mountContext: (string|undefined) * }} @@ -209,6 +210,7 @@ var DeviceEvent; * extensionId: string, * name: string, * configurable: boolean, + * watchable: boolean, * multipleMounts: boolean, * source: string * }} |