Commit c5d0b60c authored by mtomasz's avatar mtomasz Committed by Commit bot

Move the check for fileBrowserHandler permission to FileBrowserHandler.

The previous check location was forcing all apps and extensions which call
the chrome.fileSystem.requestFileSystem API, to have "fileBrowserHandler"
permission as well.

That however doesn't make much sense, as those apps are not always handlers.
This CL moves the check to FileBrowserHandler::GetHandler() so simply the
permission has to be used only if the app wants to be a handler.

TEST=unit_test: FileBrowserHandlerManifestTest.GetHandlersRequiresPermission
BUG=470494

Review URL: https://codereview.chromium.org/1030133002

Cr-Commit-Position: refs/heads/master@{#322343}
parent d1ab7812
...@@ -2346,7 +2346,6 @@ void ChromeContentBrowserClient::GetAdditionalFileSystemBackends( ...@@ -2346,7 +2346,6 @@ void ChromeContentBrowserClient::GetAdditionalFileSystemBackends(
new drive::FileSystemBackendDelegate, new drive::FileSystemBackendDelegate,
new chromeos::file_system_provider::BackendDelegate, new chromeos::file_system_provider::BackendDelegate,
new chromeos::MTPFileSystemBackendDelegate(storage_partition_path), new chromeos::MTPFileSystemBackendDelegate(storage_partition_path),
browser_context->GetSpecialStoragePolicy(),
external_mount_points, external_mount_points,
storage::ExternalMountPoints::GetSystemInstance()); storage::ExternalMountPoints::GetSystemInstance());
backend->AddSystemMountPoints(); backend->AddSystemMountPoints();
......
...@@ -572,36 +572,41 @@ TEST_F(FileManagerFileTasksComplexTest, FindFileBrowserHandlerTasks) { ...@@ -572,36 +572,41 @@ TEST_F(FileManagerFileTasksComplexTest, FindFileBrowserHandlerTasks) {
// Foo.app can handle ".txt" and ".html". // Foo.app can handle ".txt" and ".html".
// This one is an extension, and has "file_browser_handlers" // This one is an extension, and has "file_browser_handlers"
extensions::ExtensionBuilder foo_app; extensions::ExtensionBuilder foo_app;
foo_app.SetManifest(extensions::DictionaryBuilder() foo_app.SetManifest(
.Set("name", "Foo") extensions::DictionaryBuilder()
.Set("version", "1.0.0") .Set("name", "Foo")
.Set("manifest_version", 2) .Set("version", "1.0.0")
.Set("file_browser_handlers", .Set("manifest_version", 2)
extensions::ListBuilder() .Set("permissions",
.Append(extensions::DictionaryBuilder() extensions::ListBuilder().Append("fileBrowserHandler"))
.Set("id", "open") .Set(
.Set("default_title", "open") "file_browser_handlers",
.Set("file_filters", extensions::ListBuilder().Append(
extensions::ListBuilder() extensions::DictionaryBuilder()
.Append("filesystem:*.txt") .Set("id", "open")
.Append("filesystem:*.html"))))); .Set("default_title", "open")
.Set("file_filters", extensions::ListBuilder()
.Append("filesystem:*.txt")
.Append("filesystem:*.html")))));
foo_app.SetID(kFooId); foo_app.SetID(kFooId);
extension_service_->AddExtension(foo_app.Build().get()); extension_service_->AddExtension(foo_app.Build().get());
// Bar.app can only handle ".txt". // Bar.app can only handle ".txt".
extensions::ExtensionBuilder bar_app; extensions::ExtensionBuilder bar_app;
bar_app.SetManifest(extensions::DictionaryBuilder() bar_app.SetManifest(
.Set("name", "Bar") extensions::DictionaryBuilder()
.Set("version", "1.0.0") .Set("name", "Bar")
.Set("manifest_version", 2) .Set("version", "1.0.0")
.Set("file_browser_handlers", .Set("manifest_version", 2)
extensions::ListBuilder() .Set("permissions",
.Append(extensions::DictionaryBuilder() extensions::ListBuilder().Append("fileBrowserHandler"))
.Set("id", "open") .Set("file_browser_handlers",
.Set("default_title", "open") extensions::ListBuilder().Append(
.Set("file_filters", extensions::DictionaryBuilder()
extensions::ListBuilder() .Set("id", "open")
.Append("filesystem:*.txt"))))); .Set("default_title", "open")
.Set("file_filters", extensions::ListBuilder().Append(
"filesystem:*.txt")))));
bar_app.SetID(kBarId); bar_app.SetID(kBarId);
extension_service_->AddExtension(bar_app.Build().get()); extension_service_->AddExtension(bar_app.Build().get());
...@@ -614,14 +619,15 @@ TEST_F(FileManagerFileTasksComplexTest, FindFileBrowserHandlerTasks) { ...@@ -614,14 +619,15 @@ TEST_F(FileManagerFileTasksComplexTest, FindFileBrowserHandlerTasks) {
.Set("name", "Ephemeral") .Set("name", "Ephemeral")
.Set("version", "1.0.0") .Set("version", "1.0.0")
.Set("manifest_version", 2) .Set("manifest_version", 2)
.Set("permissions",
extensions::ListBuilder().Append("fileBrowserHandler"))
.Set("file_browser_handlers", .Set("file_browser_handlers",
extensions::ListBuilder().Append( extensions::ListBuilder().Append(
extensions::DictionaryBuilder() extensions::DictionaryBuilder()
.Set("id", "open") .Set("id", "open")
.Set("default_title", "open") .Set("default_title", "open")
.Set("file_filters", .Set("file_filters", extensions::ListBuilder().Append(
extensions::ListBuilder().Append( "filesystem:*.txt")))));
"filesystem:*.txt")))));
ephemeral_app.SetID(kEphemeralId); ephemeral_app.SetID(kEphemeralId);
scoped_refptr<extensions::Extension> built_ephemeral_app( scoped_refptr<extensions::Extension> built_ephemeral_app(
ephemeral_app.Build()); ephemeral_app.Build());
...@@ -704,18 +710,20 @@ TEST_F(FileManagerFileTasksComplexTest, FindAllTypesOfTasks) { ...@@ -704,18 +710,20 @@ TEST_F(FileManagerFileTasksComplexTest, FindAllTypesOfTasks) {
// Bar.app can only handle ".txt". // Bar.app can only handle ".txt".
// This is an extension (file browser handler). // This is an extension (file browser handler).
extensions::ExtensionBuilder bar_app; extensions::ExtensionBuilder bar_app;
bar_app.SetManifest(extensions::DictionaryBuilder() bar_app.SetManifest(
.Set("name", "Bar") extensions::DictionaryBuilder()
.Set("version", "1.0.0") .Set("name", "Bar")
.Set("manifest_version", 2) .Set("version", "1.0.0")
.Set("file_browser_handlers", .Set("manifest_version", 2)
extensions::ListBuilder() .Set("permissions",
.Append(extensions::DictionaryBuilder() extensions::ListBuilder().Append("fileBrowserHandler"))
.Set("id", "open") .Set("file_browser_handlers",
.Set("default_title", "open") extensions::ListBuilder().Append(
.Set("file_filters", extensions::DictionaryBuilder()
extensions::ListBuilder() .Set("id", "open")
.Append("filesystem:*.txt"))))); .Set("default_title", "open")
.Set("file_filters", extensions::ListBuilder().Append(
"filesystem:*.txt")))));
bar_app.SetID(kBarId); bar_app.SetID(kBarId);
extension_service_->AddExtension(bar_app.Build().get()); extension_service_->AddExtension(bar_app.Build().get());
...@@ -793,18 +801,20 @@ TEST_F(FileManagerFileTasksComplexTest, FindAllTypesOfTasks_GoogleDocument) { ...@@ -793,18 +801,20 @@ TEST_F(FileManagerFileTasksComplexTest, FindAllTypesOfTasks_GoogleDocument) {
// Bar.app can handle ".gdoc" files. // Bar.app can handle ".gdoc" files.
// This is an extension (file browser handler). // This is an extension (file browser handler).
extensions::ExtensionBuilder bar_app; extensions::ExtensionBuilder bar_app;
bar_app.SetManifest(extensions::DictionaryBuilder() bar_app.SetManifest(
.Set("name", "Bar") extensions::DictionaryBuilder()
.Set("version", "1.0.0") .Set("name", "Bar")
.Set("manifest_version", 2) .Set("version", "1.0.0")
.Set("file_browser_handlers", .Set("manifest_version", 2)
extensions::ListBuilder() .Set("permissions",
.Append(extensions::DictionaryBuilder() extensions::ListBuilder().Append("fileBrowserHandler"))
.Set("id", "open") .Set("file_browser_handlers",
.Set("default_title", "open") extensions::ListBuilder().Append(
.Set("file_filters", extensions::DictionaryBuilder()
extensions::ListBuilder() .Set("id", "open")
.Append("filesystem:*.gdoc"))))); .Set("default_title", "open")
.Set("file_filters", extensions::ListBuilder().Append(
"filesystem:*.gdoc")))));
bar_app.SetID(kBarId); bar_app.SetID(kBarId);
extension_service_->AddExtension(bar_app.Build().get()); extension_service_->AddExtension(bar_app.Build().get());
...@@ -812,18 +822,20 @@ TEST_F(FileManagerFileTasksComplexTest, FindAllTypesOfTasks_GoogleDocument) { ...@@ -812,18 +822,20 @@ TEST_F(FileManagerFileTasksComplexTest, FindAllTypesOfTasks_GoogleDocument) {
// The ID "kFileManagerAppId" used here is precisely the one that identifies // The ID "kFileManagerAppId" used here is precisely the one that identifies
// the Chrome OS Files.app application. // the Chrome OS Files.app application.
extensions::ExtensionBuilder files_app; extensions::ExtensionBuilder files_app;
files_app.SetManifest(extensions::DictionaryBuilder() files_app.SetManifest(
.Set("name", "Files") extensions::DictionaryBuilder()
.Set("version", "1.0.0") .Set("name", "Files")
.Set("manifest_version", 2) .Set("version", "1.0.0")
.Set("file_browser_handlers", .Set("manifest_version", 2)
extensions::ListBuilder() .Set("permissions",
.Append(extensions::DictionaryBuilder() extensions::ListBuilder().Append("fileBrowserHandler"))
.Set("id", "open") .Set("file_browser_handlers",
.Set("default_title", "open") extensions::ListBuilder().Append(
.Set("file_filters", extensions::DictionaryBuilder()
extensions::ListBuilder() .Set("id", "open")
.Append("filesystem:*.gdoc"))))); .Set("default_title", "open")
.Set("file_filters", extensions::ListBuilder().Append(
"filesystem:*.gdoc")))));
files_app.SetID(kFileManagerAppId); files_app.SetID(kFileManagerAppId);
extension_service_->AddExtension(files_app.Build().get()); extension_service_->AddExtension(files_app.Build().get());
......
...@@ -39,11 +39,9 @@ FileSystemBackend::FileSystemBackend( ...@@ -39,11 +39,9 @@ FileSystemBackend::FileSystemBackend(
FileSystemBackendDelegate* drive_delegate, FileSystemBackendDelegate* drive_delegate,
FileSystemBackendDelegate* file_system_provider_delegate, FileSystemBackendDelegate* file_system_provider_delegate,
FileSystemBackendDelegate* mtp_delegate, FileSystemBackendDelegate* mtp_delegate,
scoped_refptr<storage::SpecialStoragePolicy> special_storage_policy,
scoped_refptr<storage::ExternalMountPoints> mount_points, scoped_refptr<storage::ExternalMountPoints> mount_points,
storage::ExternalMountPoints* system_mount_points) storage::ExternalMountPoints* system_mount_points)
: special_storage_policy_(special_storage_policy), : file_access_permissions_(new FileAccessPermissions()),
file_access_permissions_(new FileAccessPermissions()),
local_file_util_(storage::AsyncFileUtil::CreateForLocalFileSystem()), local_file_util_(storage::AsyncFileUtil::CreateForLocalFileSystem()),
drive_delegate_(drive_delegate), drive_delegate_(drive_delegate),
file_system_provider_delegate_(file_system_provider_delegate), file_system_provider_delegate_(file_system_provider_delegate),
...@@ -185,25 +183,12 @@ bool FileSystemBackend::IsAccessAllowed( ...@@ -185,25 +183,12 @@ bool FileSystemBackend::IsAccessAllowed(
return true; return true;
} }
// Check first to make sure this extension has fileBrowserHander permissions.
if (!special_storage_policy_.get() ||
!special_storage_policy_->IsFileHandler(extension_id))
return false;
return file_access_permissions_->HasAccessPermission(extension_id, return file_access_permissions_->HasAccessPermission(extension_id,
url.virtual_path()); url.virtual_path());
} }
void FileSystemBackend::GrantFileAccessToExtension( void FileSystemBackend::GrantFileAccessToExtension(
const std::string& extension_id, const base::FilePath& virtual_path) { const std::string& extension_id, const base::FilePath& virtual_path) {
if (!special_storage_policy_.get())
return;
// All we care about here is access from extensions for now.
if (!special_storage_policy_->IsFileHandler(extension_id)) {
NOTREACHED();
return;
}
std::string id; std::string id;
storage::FileSystemType type; storage::FileSystemType type;
std::string cracked_id; std::string cracked_id;
......
...@@ -14,7 +14,6 @@ ...@@ -14,7 +14,6 @@
#include "base/memory/scoped_ptr.h" #include "base/memory/scoped_ptr.h"
#include "storage/browser/fileapi/file_system_backend.h" #include "storage/browser/fileapi/file_system_backend.h"
#include "storage/browser/fileapi/task_runner_bound_observer_list.h" #include "storage/browser/fileapi/task_runner_bound_observer_list.h"
#include "storage/browser/quota/special_storage_policy.h"
#include "storage/common/fileapi/file_system_types.h" #include "storage/common/fileapi/file_system_types.h"
namespace storage { namespace storage {
...@@ -74,7 +73,6 @@ class FileSystemBackend : public storage::ExternalFileSystemBackend { ...@@ -74,7 +73,6 @@ class FileSystemBackend : public storage::ExternalFileSystemBackend {
FileSystemBackendDelegate* drive_delegate, FileSystemBackendDelegate* drive_delegate,
FileSystemBackendDelegate* file_system_provider_delegate, FileSystemBackendDelegate* file_system_provider_delegate,
FileSystemBackendDelegate* mtp_delegate, FileSystemBackendDelegate* mtp_delegate,
scoped_refptr<storage::SpecialStoragePolicy> special_storage_policy,
scoped_refptr<storage::ExternalMountPoints> mount_points, scoped_refptr<storage::ExternalMountPoints> mount_points,
storage::ExternalMountPoints* system_mount_points); storage::ExternalMountPoints* system_mount_points);
~FileSystemBackend() override; ~FileSystemBackend() override;
...@@ -142,7 +140,6 @@ class FileSystemBackend : public storage::ExternalFileSystemBackend { ...@@ -142,7 +140,6 @@ class FileSystemBackend : public storage::ExternalFileSystemBackend {
const base::FilePath& entry_path) const override; const base::FilePath& entry_path) const override;
private: private:
scoped_refptr<storage::SpecialStoragePolicy> special_storage_policy_;
scoped_ptr<FileAccessPermissions> file_access_permissions_; scoped_ptr<FileAccessPermissions> file_access_permissions_;
scoped_ptr<storage::AsyncFileUtil> local_file_util_; scoped_ptr<storage::AsyncFileUtil> local_file_util_;
......
...@@ -8,7 +8,6 @@ ...@@ -8,7 +8,6 @@
#include "base/files/file_path.h" #include "base/files/file_path.h"
#include "chromeos/dbus/cros_disks_client.h" #include "chromeos/dbus/cros_disks_client.h"
#include "content/public/test/mock_special_storage_policy.h"
#include "storage/browser/fileapi/external_mount_points.h" #include "storage/browser/fileapi/external_mount_points.h"
#include "storage/browser/fileapi/file_system_url.h" #include "storage/browser/fileapi/file_system_url.h"
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
...@@ -35,15 +34,12 @@ TEST(ChromeOSFileSystemBackendTest, DefaultMountPoints) { ...@@ -35,15 +34,12 @@ TEST(ChromeOSFileSystemBackendTest, DefaultMountPoints) {
// to avoid flakiness. // to avoid flakiness.
storage::ExternalMountPoints::GetSystemInstance()->RevokeAllFileSystems(); storage::ExternalMountPoints::GetSystemInstance()->RevokeAllFileSystems();
scoped_refptr<storage::SpecialStoragePolicy> storage_policy =
new content::MockSpecialStoragePolicy();
scoped_refptr<storage::ExternalMountPoints> mount_points( scoped_refptr<storage::ExternalMountPoints> mount_points(
storage::ExternalMountPoints::CreateRefCounted()); storage::ExternalMountPoints::CreateRefCounted());
chromeos::FileSystemBackend backend( chromeos::FileSystemBackend backend(
NULL, // drive_delegate NULL, // drive_delegate
NULL, // file_system_provider_delegate NULL, // file_system_provider_delegate
NULL, // mtp_delegate NULL, // mtp_delegate
storage_policy,
mount_points.get(), mount_points.get(),
storage::ExternalMountPoints::GetSystemInstance()); storage::ExternalMountPoints::GetSystemInstance());
backend.AddSystemMountPoints(); backend.AddSystemMountPoints();
...@@ -61,8 +57,6 @@ TEST(ChromeOSFileSystemBackendTest, DefaultMountPoints) { ...@@ -61,8 +57,6 @@ TEST(ChromeOSFileSystemBackendTest, DefaultMountPoints) {
} }
TEST(ChromeOSFileSystemBackendTest, GetRootDirectories) { TEST(ChromeOSFileSystemBackendTest, GetRootDirectories) {
scoped_refptr<storage::SpecialStoragePolicy> storage_policy =
new content::MockSpecialStoragePolicy();
scoped_refptr<storage::ExternalMountPoints> mount_points( scoped_refptr<storage::ExternalMountPoints> mount_points(
storage::ExternalMountPoints::CreateRefCounted()); storage::ExternalMountPoints::CreateRefCounted());
...@@ -72,7 +66,6 @@ TEST(ChromeOSFileSystemBackendTest, GetRootDirectories) { ...@@ -72,7 +66,6 @@ TEST(ChromeOSFileSystemBackendTest, GetRootDirectories) {
chromeos::FileSystemBackend backend(NULL, // drive_delegate chromeos::FileSystemBackend backend(NULL, // drive_delegate
NULL, // file_system_provider_delegate NULL, // file_system_provider_delegate
NULL, // mtp_delegate NULL, // mtp_delegate
storage_policy,
mount_points.get(), mount_points.get(),
system_mount_points.get()); system_mount_points.get());
...@@ -110,8 +103,6 @@ TEST(ChromeOSFileSystemBackendTest, GetRootDirectories) { ...@@ -110,8 +103,6 @@ TEST(ChromeOSFileSystemBackendTest, GetRootDirectories) {
TEST(ChromeOSFileSystemBackendTest, AccessPermissions) { TEST(ChromeOSFileSystemBackendTest, AccessPermissions) {
url::AddStandardScheme("chrome-extension"); url::AddStandardScheme("chrome-extension");
scoped_refptr<content::MockSpecialStoragePolicy> storage_policy =
new content::MockSpecialStoragePolicy();
scoped_refptr<storage::ExternalMountPoints> mount_points( scoped_refptr<storage::ExternalMountPoints> mount_points(
storage::ExternalMountPoints::CreateRefCounted()); storage::ExternalMountPoints::CreateRefCounted());
scoped_refptr<storage::ExternalMountPoints> system_mount_points( scoped_refptr<storage::ExternalMountPoints> system_mount_points(
...@@ -119,14 +110,11 @@ TEST(ChromeOSFileSystemBackendTest, AccessPermissions) { ...@@ -119,14 +110,11 @@ TEST(ChromeOSFileSystemBackendTest, AccessPermissions) {
chromeos::FileSystemBackend backend(NULL, // drive_delegate chromeos::FileSystemBackend backend(NULL, // drive_delegate
NULL, // file_system_provider_delegate NULL, // file_system_provider_delegate
NULL, // mtp_delegate NULL, // mtp_delegate
storage_policy,
mount_points.get(), mount_points.get(),
system_mount_points.get()); system_mount_points.get());
std::string extension("ddammdhioacbehjngdmkjcjbnfginlla"); std::string extension("ddammdhioacbehjngdmkjcjbnfginlla");
storage_policy->AddFileHandler(extension);
// Initialize mount points. // Initialize mount points.
ASSERT_TRUE(system_mount_points->RegisterFileSystem( ASSERT_TRUE(system_mount_points->RegisterFileSystem(
"system", "system",
...@@ -183,8 +171,6 @@ TEST(ChromeOSFileSystemBackendTest, AccessPermissions) { ...@@ -183,8 +171,6 @@ TEST(ChromeOSFileSystemBackendTest, AccessPermissions) {
} }
TEST(ChromeOSFileSystemBackendTest, GetVirtualPathConflictWithSystemPoints) { TEST(ChromeOSFileSystemBackendTest, GetVirtualPathConflictWithSystemPoints) {
scoped_refptr<content::MockSpecialStoragePolicy> storage_policy =
new content::MockSpecialStoragePolicy();
scoped_refptr<storage::ExternalMountPoints> mount_points( scoped_refptr<storage::ExternalMountPoints> mount_points(
storage::ExternalMountPoints::CreateRefCounted()); storage::ExternalMountPoints::CreateRefCounted());
scoped_refptr<storage::ExternalMountPoints> system_mount_points( scoped_refptr<storage::ExternalMountPoints> system_mount_points(
...@@ -192,7 +178,6 @@ TEST(ChromeOSFileSystemBackendTest, GetVirtualPathConflictWithSystemPoints) { ...@@ -192,7 +178,6 @@ TEST(ChromeOSFileSystemBackendTest, GetVirtualPathConflictWithSystemPoints) {
chromeos::FileSystemBackend backend(NULL, // drive_delegate chromeos::FileSystemBackend backend(NULL, // drive_delegate
NULL, // file_system_provider_delegate NULL, // file_system_provider_delegate
NULL, // mtp_delegate NULL, // mtp_delegate
storage_policy,
mount_points.get(), mount_points.get(),
system_mount_points.get()); system_mount_points.get());
......
...@@ -129,12 +129,6 @@ bool ExtensionSpecialStoragePolicy::HasSessionOnlyOrigins() { ...@@ -129,12 +129,6 @@ bool ExtensionSpecialStoragePolicy::HasSessionOnlyOrigins() {
return false; return false;
} }
bool ExtensionSpecialStoragePolicy::IsFileHandler(
const std::string& extension_id) {
base::AutoLock locker(lock_);
return file_handler_extensions_.ContainsExtension(extension_id);
}
bool ExtensionSpecialStoragePolicy::HasIsolatedStorage(const GURL& origin) { bool ExtensionSpecialStoragePolicy::HasIsolatedStorage(const GURL& origin) {
base::AutoLock locker(lock_); base::AutoLock locker(lock_);
return isolated_extensions_.Contains(origin); return isolated_extensions_.Contains(origin);
......
...@@ -36,7 +36,6 @@ class ExtensionSpecialStoragePolicy : public storage::SpecialStoragePolicy { ...@@ -36,7 +36,6 @@ class ExtensionSpecialStoragePolicy : public storage::SpecialStoragePolicy {
bool IsStorageUnlimited(const GURL& origin) override; bool IsStorageUnlimited(const GURL& origin) override;
bool IsStorageSessionOnly(const GURL& origin) override; bool IsStorageSessionOnly(const GURL& origin) override;
bool CanQueryDiskSize(const GURL& origin) override; bool CanQueryDiskSize(const GURL& origin) override;
bool IsFileHandler(const std::string& extension_id) override;
bool HasIsolatedStorage(const GURL& origin) override; bool HasIsolatedStorage(const GURL& origin) override;
bool HasSessionOnlyOrigins() override; bool HasSessionOnlyOrigins() override;
......
...@@ -24,11 +24,6 @@ bool MockExtensionSpecialStoragePolicy::CanQueryDiskSize(const GURL& origin) { ...@@ -24,11 +24,6 @@ bool MockExtensionSpecialStoragePolicy::CanQueryDiskSize(const GURL& origin) {
return false; return false;
} }
bool MockExtensionSpecialStoragePolicy::IsFileHandler(
const std::string& extension_id) {
return false;
}
bool MockExtensionSpecialStoragePolicy::HasSessionOnlyOrigins() { bool MockExtensionSpecialStoragePolicy::HasSessionOnlyOrigins() {
return false; return false;
} }
......
...@@ -23,7 +23,6 @@ class MockExtensionSpecialStoragePolicy : public ExtensionSpecialStoragePolicy { ...@@ -23,7 +23,6 @@ class MockExtensionSpecialStoragePolicy : public ExtensionSpecialStoragePolicy {
bool IsStorageUnlimited(const GURL& origin) override; bool IsStorageUnlimited(const GURL& origin) override;
bool IsStorageSessionOnly(const GURL& origin) override; bool IsStorageSessionOnly(const GURL& origin) override;
bool CanQueryDiskSize(const GURL& origin) override; bool CanQueryDiskSize(const GURL& origin) override;
bool IsFileHandler(const std::string& extension_id) override;
bool HasSessionOnlyOrigins() override; bool HasSessionOnlyOrigins() override;
void AddProtected(const GURL& origin) { void AddProtected(const GURL& origin) {
......
...@@ -50,19 +50,12 @@ class PlatformUtilTestContentBrowserClient ...@@ -50,19 +50,12 @@ class PlatformUtilTestContentBrowserClient
ScopedVector<storage::FileSystemBackend>* additional_backends) override { ScopedVector<storage::FileSystemBackend>* additional_backends) override {
storage::ExternalMountPoints* external_mount_points = storage::ExternalMountPoints* external_mount_points =
content::BrowserContext::GetMountPoints(browser_context); content::BrowserContext::GetMountPoints(browser_context);
scoped_refptr<content::MockSpecialStoragePolicy> special_storage_policy =
new content::MockSpecialStoragePolicy();
// New FileSystemBackend that uses our MockSpecialStoragePolicy. // New FileSystemBackend that uses our MockSpecialStoragePolicy.
chromeos::FileSystemBackend* backend = new chromeos::FileSystemBackend( chromeos::FileSystemBackend* backend = new chromeos::FileSystemBackend(
nullptr, nullptr, nullptr, special_storage_policy, nullptr, nullptr, nullptr, external_mount_points,
external_mount_points,
storage::ExternalMountPoints::GetSystemInstance()); storage::ExternalMountPoints::GetSystemInstance());
additional_backends->push_back(backend); additional_backends->push_back(backend);
// The only change we need to make is to add kFileManagerAppId as a file
// handler.
special_storage_policy->AddFileHandler(file_manager::kFileManagerAppId);
} }
}; };
......
...@@ -13,6 +13,8 @@ ...@@ -13,6 +13,8 @@
#include "extensions/common/error_utils.h" #include "extensions/common/error_utils.h"
#include "extensions/common/manifest.h" #include "extensions/common/manifest.h"
#include "extensions/common/manifest_constants.h" #include "extensions/common/manifest_constants.h"
#include "extensions/common/manifest_handlers/permissions_parser.h"
#include "extensions/common/permissions/api_permission.h"
#include "extensions/common/url_pattern.h" #include "extensions/common/url_pattern.h"
#include "url/url_constants.h" #include "url/url_constants.h"
...@@ -115,11 +117,12 @@ bool FileBrowserHandler::HasCreateAccessPermission() const { ...@@ -115,11 +117,12 @@ bool FileBrowserHandler::HasCreateAccessPermission() const {
// static // static
FileBrowserHandler::List* FileBrowserHandler::List*
FileBrowserHandler::GetHandlers(const extensions::Extension* extension) { FileBrowserHandler::GetHandlers(const extensions::Extension* extension) {
FileBrowserHandlerInfo* info = static_cast<FileBrowserHandlerInfo*>( FileBrowserHandlerInfo* const info = static_cast<FileBrowserHandlerInfo*>(
extension->GetManifestData(keys::kFileBrowserHandlers)); extension->GetManifestData(keys::kFileBrowserHandlers));
if (info) if (!info)
return &info->file_browser_handlers; return nullptr;
return NULL;
return &info->file_browser_handlers;
} }
FileBrowserHandlerParser::FileBrowserHandlerParser() { FileBrowserHandlerParser::FileBrowserHandlerParser() {
...@@ -268,12 +271,19 @@ bool LoadFileBrowserHandlers( ...@@ -268,12 +271,19 @@ bool LoadFileBrowserHandlers(
bool FileBrowserHandlerParser::Parse(extensions::Extension* extension, bool FileBrowserHandlerParser::Parse(extensions::Extension* extension,
base::string16* error) { base::string16* error) {
// If the permission is missing, then skip parsing the list of handlers.
if (!extensions::PermissionsParser::HasAPIPermission(
extension, extensions::APIPermission::ID::kFileBrowserHandler)) {
return true;
}
const base::ListValue* file_browser_handlers_value = NULL; const base::ListValue* file_browser_handlers_value = NULL;
if (!extension->manifest()->GetList(keys::kFileBrowserHandlers, if (!extension->manifest()->GetList(keys::kFileBrowserHandlers,
&file_browser_handlers_value)) { &file_browser_handlers_value)) {
*error = base::ASCIIToUTF16(errors::kInvalidFileBrowserHandler); *error = base::ASCIIToUTF16(errors::kInvalidFileBrowserHandler);
return false; return false;
} }
scoped_ptr<FileBrowserHandlerInfo> info(new FileBrowserHandlerInfo); scoped_ptr<FileBrowserHandlerInfo> info(new FileBrowserHandlerInfo);
if (!LoadFileBrowserHandlers(extension->id(), if (!LoadFileBrowserHandlers(extension->id(),
file_browser_handlers_value, file_browser_handlers_value,
......
...@@ -24,6 +24,53 @@ namespace { ...@@ -24,6 +24,53 @@ namespace {
class FileBrowserHandlerManifestTest : public ChromeManifestTest { class FileBrowserHandlerManifestTest : public ChromeManifestTest {
}; };
#if !defined(OS_CHROMEOS)
TEST_F(FileBrowserHandlerManifestTest, PermissionNotAllowedOnNonChromeOS) {
RunTestcase(
Testcase("filebrowser_valid.json",
"'fileBrowserHandler' is not allowed for specified platform."),
EXPECT_TYPE_WARNING);
}
#else
TEST_F(FileBrowserHandlerManifestTest, PermissionAllowed) {
RunTestcase(Testcase("filebrowser_valid.json"), EXPECT_TYPE_SUCCESS);
}
TEST_F(FileBrowserHandlerManifestTest, GetHandlersRequiresPermission) {
extensions::DictionaryBuilder bad_manifest_builder;
bad_manifest_builder.Set("name", "Foo")
.Set("version", "1.0.0")
.Set("manifest_version", 2)
.Set("file_browser_handlers",
extensions::ListBuilder().Append(
extensions::DictionaryBuilder()
.Set("id", "open")
.Set("default_title", "open")
.Set("file_filters", extensions::ListBuilder()
.Append("filesystem:*.txt")
.Append("filesystem:*.html"))));
scoped_ptr<base::DictionaryValue> bad_manifest_value(
bad_manifest_builder.Build());
// Create a good manifest by extending the bad one with the missing
// permission.
extensions::DictionaryBuilder good_manifest_builder(
*make_scoped_ptr(bad_manifest_value->DeepCopy()).get());
good_manifest_builder.Set(
"permissions", extensions::ListBuilder().Append("fileBrowserHandler"));
extensions::ExtensionBuilder bad_app_builder;
bad_app_builder.SetManifest(bad_manifest_value.Pass());
scoped_refptr<extensions::Extension> bad_app(bad_app_builder.Build());
EXPECT_FALSE(FileBrowserHandler::GetHandlers(bad_app.get()));
extensions::ExtensionBuilder good_app_builder;
good_app_builder.SetManifest(good_manifest_builder);
scoped_refptr<extensions::Extension> good_app(good_app_builder.Build());
EXPECT_TRUE(FileBrowserHandler::GetHandlers(good_app.get()));
}
TEST_F(FileBrowserHandlerManifestTest, InvalidFileBrowserHandlers) { TEST_F(FileBrowserHandlerManifestTest, InvalidFileBrowserHandlers) {
Testcase testcases[] = { Testcase testcases[] = {
Testcase("filebrowser_invalid_access_permission.json", Testcase("filebrowser_invalid_access_permission.json",
...@@ -56,18 +103,22 @@ TEST_F(FileBrowserHandlerManifestTest, InvalidFileBrowserHandlers) { ...@@ -56,18 +103,22 @@ TEST_F(FileBrowserHandlerManifestTest, InvalidFileBrowserHandlers) {
TEST_F(FileBrowserHandlerManifestTest, ValidFileBrowserHandler) { TEST_F(FileBrowserHandlerManifestTest, ValidFileBrowserHandler) {
scoped_refptr<const Extension> extension = scoped_refptr<const Extension> extension =
ExtensionBuilder() ExtensionBuilder()
.SetManifest(DictionaryBuilder() .SetManifest(
DictionaryBuilder()
.Set("name", "file browser handler test") .Set("name", "file browser handler test")
.Set("version", "1.0.0") .Set("version", "1.0.0")
.Set("manifest_version", 2) .Set("manifest_version", 2)
.Set("file_browser_handlers", ListBuilder() .Set("permissions",
.Append(DictionaryBuilder() extensions::ListBuilder().Append("fileBrowserHandler"))
.Set("id", "ExtremelyCoolAction") .Set("file_browser_handlers",
.Set("default_title", "Be Amazed") ListBuilder().Append(
.Set("default_icon", "icon.png") DictionaryBuilder()
.Set("file_filters", ListBuilder() .Set("id", "ExtremelyCoolAction")
.Append("filesystem:*.txt"))))) .Set("default_title", "Be Amazed")
.Build(); .Set("default_icon", "icon.png")
.Set("file_filters", ListBuilder().Append(
"filesystem:*.txt")))))
.Build();
ASSERT_TRUE(extension.get()); ASSERT_TRUE(extension.get());
FileBrowserHandler::List* handlers = FileBrowserHandler::List* handlers =
...@@ -91,19 +142,23 @@ TEST_F(FileBrowserHandlerManifestTest, ValidFileBrowserHandler) { ...@@ -91,19 +142,23 @@ TEST_F(FileBrowserHandlerManifestTest, ValidFileBrowserHandler) {
TEST_F(FileBrowserHandlerManifestTest, ValidFileBrowserHandlerMIMETypes) { TEST_F(FileBrowserHandlerManifestTest, ValidFileBrowserHandlerMIMETypes) {
scoped_refptr<const Extension> extension = scoped_refptr<const Extension> extension =
ExtensionBuilder() ExtensionBuilder()
.SetID(extension_misc::kQuickOfficeExtensionId) .SetID(extension_misc::kQuickOfficeExtensionId)
.SetManifest(DictionaryBuilder() .SetManifest(
DictionaryBuilder()
.Set("name", "file browser handler test") .Set("name", "file browser handler test")
.Set("version", "1.0.0") .Set("version", "1.0.0")
.Set("manifest_version", 2) .Set("manifest_version", 2)
.Set("file_browser_handlers", ListBuilder() .Set("permissions",
.Append(DictionaryBuilder() extensions::ListBuilder().Append("fileBrowserHandler"))
.Set("id", "ID") .Set("file_browser_handlers",
.Set("default_title", "Default title") ListBuilder().Append(
.Set("default_icon", "icon.png") DictionaryBuilder()
.Set("file_filters", ListBuilder() .Set("id", "ID")
.Append("filesystem:*.txt"))))) .Set("default_title", "Default title")
.Build(); .Set("default_icon", "icon.png")
.Set("file_filters", ListBuilder().Append(
"filesystem:*.txt")))))
.Build();
ASSERT_TRUE(extension.get()); ASSERT_TRUE(extension.get());
FileBrowserHandler::List* handlers = FileBrowserHandler::List* handlers =
...@@ -121,20 +176,24 @@ TEST_F(FileBrowserHandlerManifestTest, ValidFileBrowserHandlerMIMETypes) { ...@@ -121,20 +176,24 @@ TEST_F(FileBrowserHandlerManifestTest, ValidFileBrowserHandlerMIMETypes) {
TEST_F(FileBrowserHandlerManifestTest, ValidFileBrowserHandlerWithCreate) { TEST_F(FileBrowserHandlerManifestTest, ValidFileBrowserHandlerWithCreate) {
scoped_refptr<const Extension> extension = scoped_refptr<const Extension> extension =
ExtensionBuilder() ExtensionBuilder()
.SetManifest(DictionaryBuilder() .SetManifest(
DictionaryBuilder()
.Set("name", "file browser handler test create") .Set("name", "file browser handler test create")
.Set("version", "1.0.0") .Set("version", "1.0.0")
.Set("manifest_version", 2) .Set("manifest_version", 2)
.Set("file_browser_handlers", ListBuilder() .Set("permissions",
.Append(DictionaryBuilder() extensions::ListBuilder().Append("fileBrowserHandler"))
.Set("id", "ID") .Set("file_browser_handlers",
.Set("default_title", "Default title") ListBuilder().Append(
.Set("default_icon", "icon.png") DictionaryBuilder()
.Set("file_filters", ListBuilder() .Set("id", "ID")
.Append("filesystem:*.txt")) .Set("default_title", "Default title")
.Set("file_access", ListBuilder() .Set("default_icon", "icon.png")
.Append("create"))))) .Set("file_filters",
.Build(); ListBuilder().Append("filesystem:*.txt"))
.Set("file_access",
ListBuilder().Append("create")))))
.Build();
ASSERT_TRUE(extension.get()); ASSERT_TRUE(extension.get());
FileBrowserHandler::List* handlers = FileBrowserHandler::List* handlers =
...@@ -149,5 +208,6 @@ TEST_F(FileBrowserHandlerManifestTest, ValidFileBrowserHandlerWithCreate) { ...@@ -149,5 +208,6 @@ TEST_F(FileBrowserHandlerManifestTest, ValidFileBrowserHandlerWithCreate) {
EXPECT_FALSE(action->CanRead()); EXPECT_FALSE(action->CanRead());
EXPECT_FALSE(action->CanWrite()); EXPECT_FALSE(action->CanWrite());
} }
#endif
} // namespace } // namespace
...@@ -17,7 +17,6 @@ ...@@ -17,7 +17,6 @@
}, },
"permissions": [ "permissions": [
"fileManagerPrivate", "fileManagerPrivate",
"fileBrowserHandler",
{ {
"fileSystem": ["requestFileSystem", "write"] "fileSystem": ["requestFileSystem", "write"]
}, },
......
...@@ -11,7 +11,6 @@ ...@@ -11,7 +11,6 @@
} }
}, },
"permissions": [ "permissions": [
"fileBrowserHandler",
"fileManagerPrivate", "fileManagerPrivate",
{ {
"fileSystem": ["requestFileSystem"] "fileSystem": ["requestFileSystem"]
......
...@@ -11,7 +11,6 @@ ...@@ -11,7 +11,6 @@
} }
}, },
"permissions": [ "permissions": [
"fileBrowserHandler",
"fileManagerPrivate", "fileManagerPrivate",
{"fileSystem": ["requestFileSystem"]} {"fileSystem": ["requestFileSystem"]}
] ]
......
...@@ -11,7 +11,6 @@ ...@@ -11,7 +11,6 @@
} }
}, },
"permissions": [ "permissions": [
"fileBrowserHandler",
"fileManagerPrivate", "fileManagerPrivate",
{ {
"fileSystem": ["requestFileSystem", "write"] "fileSystem": ["requestFileSystem", "write"]
......
...@@ -11,7 +11,6 @@ ...@@ -11,7 +11,6 @@
} }
}, },
"permissions": [ "permissions": [
"fileBrowserHandler",
"fileManagerPrivate", "fileManagerPrivate",
{ {
"fileSystem": ["requestFileSystem", "write"] "fileSystem": ["requestFileSystem", "write"]
......
...@@ -11,7 +11,6 @@ ...@@ -11,7 +11,6 @@
} }
}, },
"permissions": [ "permissions": [
"fileBrowserHandler",
"fileManagerPrivate", "fileManagerPrivate",
{ {
"fileSystem": ["requestFileSystem"] "fileSystem": ["requestFileSystem"]
......
...@@ -11,7 +11,6 @@ ...@@ -11,7 +11,6 @@
} }
}, },
"permissions": [ "permissions": [
"fileBrowserHandler",
"fileManagerPrivate", "fileManagerPrivate",
{ {
"fileSystem": ["requestFileSystem", "write"] "fileSystem": ["requestFileSystem", "write"]
......
...@@ -11,8 +11,7 @@ ...@@ -11,8 +11,7 @@
{ {
"fileSystem": ["requestFileSystem", "write"] "fileSystem": ["requestFileSystem", "write"]
}, },
"fileManagerPrivate", "fileManagerPrivate"
"fileBrowserHandler"
], ],
"app": { "app": {
"background": { "background": {
......
...@@ -11,8 +11,7 @@ ...@@ -11,8 +11,7 @@
{ {
"fileSystem": ["requestFileSystem", "write"] "fileSystem": ["requestFileSystem", "write"]
}, },
"fileManagerPrivate", "fileManagerPrivate"
"fileBrowserHandler"
], ],
"app": { "app": {
"background": { "background": {
......
...@@ -11,8 +11,7 @@ ...@@ -11,8 +11,7 @@
{ {
"fileSystem": ["requestFileSystem", "write"] "fileSystem": ["requestFileSystem", "write"]
}, },
"fileManagerPrivate", "fileManagerPrivate"
"fileBrowserHandler"
], ],
"app": { "app": {
"background": { "background": {
......
...@@ -11,8 +11,7 @@ ...@@ -11,8 +11,7 @@
{ {
"fileSystem": ["requestFileSystem", "write"] "fileSystem": ["requestFileSystem", "write"]
}, },
"fileManagerPrivate", "fileManagerPrivate"
"fileBrowserHandler"
], ],
"app": { "app": {
"background": { "background": {
......
...@@ -11,8 +11,7 @@ ...@@ -11,8 +11,7 @@
{ {
"fileSystem": ["requestFileSystem", "write"] "fileSystem": ["requestFileSystem", "write"]
}, },
"fileManagerPrivate", "fileManagerPrivate"
"fileBrowserHandler"
], ],
"app": { "app": {
"background": { "background": {
......
...@@ -11,8 +11,7 @@ ...@@ -11,8 +11,7 @@
{ {
"fileSystem": ["requestFileSystem", "write"] "fileSystem": ["requestFileSystem", "write"]
}, },
"fileManagerPrivate", "fileManagerPrivate"
"fileBrowserHandler"
], ],
"app": { "app": {
"background": { "background": {
......
...@@ -11,8 +11,7 @@ ...@@ -11,8 +11,7 @@
{ {
"fileSystem": ["requestFileSystem", "write"] "fileSystem": ["requestFileSystem", "write"]
}, },
"fileManagerPrivate", "fileManagerPrivate"
"fileBrowserHandler"
], ],
"app": { "app": {
"background": { "background": {
......
...@@ -10,8 +10,7 @@ ...@@ -10,8 +10,7 @@
{ {
"fileSystem": ["requestFileSystem", "write"] "fileSystem": ["requestFileSystem", "write"]
}, },
"fileManagerPrivate", "fileManagerPrivate"
"fileBrowserHandler"
], ],
"app": { "app": {
"background": { "background": {
......
...@@ -11,8 +11,7 @@ ...@@ -11,8 +11,7 @@
{ {
"fileSystem": ["requestFileSystem", "write"] "fileSystem": ["requestFileSystem", "write"]
}, },
"fileManagerPrivate", "fileManagerPrivate"
"fileBrowserHandler"
], ],
"app": { "app": {
"background": { "background": {
......
...@@ -11,8 +11,7 @@ ...@@ -11,8 +11,7 @@
{ {
"fileSystem": ["requestFileSystem", "write"] "fileSystem": ["requestFileSystem", "write"]
}, },
"fileManagerPrivate", "fileManagerPrivate"
"fileBrowserHandler"
], ],
"file_handlers": { "file_handlers": {
"magic_handler": { "magic_handler": {
......
...@@ -11,8 +11,7 @@ ...@@ -11,8 +11,7 @@
{ {
"fileSystem": ["requestFileSystem", "write"] "fileSystem": ["requestFileSystem", "write"]
}, },
"fileManagerPrivate", "fileManagerPrivate"
"fileBrowserHandler"
], ],
"app": { "app": {
"background": { "background": {
......
...@@ -11,8 +11,7 @@ ...@@ -11,8 +11,7 @@
{ {
"fileSystem": ["requestFileSystem", "write"] "fileSystem": ["requestFileSystem", "write"]
}, },
"fileManagerPrivate", "fileManagerPrivate"
"fileBrowserHandler"
], ],
"app": { "app": {
"background": { "background": {
......
...@@ -11,8 +11,7 @@ ...@@ -11,8 +11,7 @@
{ {
"fileSystem": ["requestFileSystem", "write"] "fileSystem": ["requestFileSystem", "write"]
}, },
"fileManagerPrivate", "fileManagerPrivate"
"fileBrowserHandler"
], ],
"app": { "app": {
"background": { "background": {
......
...@@ -11,8 +11,7 @@ ...@@ -11,8 +11,7 @@
{ {
"fileSystem": ["requestFileSystem", "write"] "fileSystem": ["requestFileSystem", "write"]
}, },
"fileManagerPrivate", "fileManagerPrivate"
"fileBrowserHandler"
], ],
"app": { "app": {
"background": { "background": {
......
...@@ -11,8 +11,7 @@ ...@@ -11,8 +11,7 @@
{ {
"fileSystem": ["requestFileSystem", "write"] "fileSystem": ["requestFileSystem", "write"]
}, },
"fileManagerPrivate", "fileManagerPrivate"
"fileBrowserHandler"
], ],
"app": { "app": {
"background": { "background": {
......
...@@ -11,8 +11,7 @@ ...@@ -11,8 +11,7 @@
{ {
"fileSystem": ["requestFileSystem", "write"] "fileSystem": ["requestFileSystem", "write"]
}, },
"fileManagerPrivate", "fileManagerPrivate"
"fileBrowserHandler"
], ],
"app": { "app": {
"background": { "background": {
......
...@@ -11,8 +11,7 @@ ...@@ -11,8 +11,7 @@
{ {
"fileSystem": ["requestFileSystem", "write"] "fileSystem": ["requestFileSystem", "write"]
}, },
"fileManagerPrivate", "fileManagerPrivate"
"fileBrowserHandler"
], ],
"app": { "app": {
"background": { "background": {
......
...@@ -11,8 +11,7 @@ ...@@ -11,8 +11,7 @@
{ {
"fileSystem": ["requestFileSystem", "write"] "fileSystem": ["requestFileSystem", "write"]
}, },
"fileManagerPrivate", "fileManagerPrivate"
"fileBrowserHandler"
], ],
"app": { "app": {
"background": { "background": {
......
...@@ -15,7 +15,6 @@ ...@@ -15,7 +15,6 @@
"clipboardWrite", "clipboardWrite",
"contextMenus", "contextMenus",
"desktopCapture", "desktopCapture",
"fileBrowserHandler",
"fileSystem", "fileSystem",
"gcm", "gcm",
"geolocation", "geolocation",
......
{ {
"name": "test", "name": "test",
"version": "1", "version": "1",
"permissions": [
"fileBrowserHandler"
],
"file_browser_handlers": [ "file_browser_handlers": [
{ {
"id" : "ID", "id" : "ID",
......
{ {
"name": "test", "name": "test",
"version": "1", "version": "1",
"permissions": [
"fileBrowserHandler"
],
"file_browser_handlers": [ "file_browser_handlers": [
{ {
"id" : "ID", "id" : "ID",
......
{ {
"name": "test", "name": "test",
"version": "1", "version": "1",
"permissions": [
"fileBrowserHandler"
],
"file_browser_handlers": [ "file_browser_handlers": [
{ {
"default_title" : "Test", "default_title" : "Test",
......
{ {
"name": "test", "name": "test",
"version": "1", "version": "1",
"permissions": [
"fileBrowserHandler"
],
"file_browser_handlers": [ "file_browser_handlers": [
{ {
"id" : "ID", "id" : "ID",
......
{ {
"name": "test", "name": "test",
"version": "1", "version": "1",
"permissions": [
"fileBrowserHandler"
],
"file_browser_handlers": { "file_browser_handlers": {
} }
} }
{ {
"name": "test", "name": "test",
"version": "1", "version": "1",
"permissions": [
"fileBrowserHandler"
],
"file_browser_handlers": [ "file_browser_handlers": [
"bad" "bad"
] ]
......
{ {
"name": "test", "name": "test",
"version": "1", "version": "1",
"permissions": [
"fileBrowserHandler"
],
"file_browser_handlers": [ "file_browser_handlers": [
{ {
"id" : "ID", "id" : "ID",
......
{ {
"name": "test", "name": "test",
"version": "1", "version": "1",
"permissions": [
"fileBrowserHandler"
],
"file_browser_handlers": [ "file_browser_handlers": [
{ {
"id" : "ID", "id" : "ID",
......
{ {
"name": "test", "name": "test",
"version": "1", "version": "1",
"permissions": [
"fileBrowserHandler"
],
"file_browser_handlers": [ "file_browser_handlers": [
{ {
"id" : "ID", "id" : "ID",
......
{ {
"name": "test", "name": "test",
"version": "1", "version": "1",
"permissions": [
"fileBrowserHandler"
],
"file_browser_handlers": [ "file_browser_handlers": [
{ {
"id" : "ID", "id" : "ID",
......
{
"name": "test",
"version": "1",
"permissions": [
"fileBrowserHandler"
],
"file_browser_handlers": [
{
"id" : "ID",
"default_title" : "Test",
"default_icon" : "icon.png",
"file_filters" : [
"filesystem:*.html"
]
}
]
}
...@@ -31,7 +31,6 @@ ...@@ -31,7 +31,6 @@
"declarativeWebRequest", "declarativeWebRequest",
"downloads", "downloads",
"experimental", "experimental",
"fileBrowserHandler",
"fileManagerPrivate", "fileManagerPrivate",
"fileSystem", "fileSystem",
"fileSystem.write", "fileSystem.write",
......
...@@ -30,10 +30,6 @@ bool MockSpecialStoragePolicy::CanQueryDiskSize(const GURL& origin) { ...@@ -30,10 +30,6 @@ bool MockSpecialStoragePolicy::CanQueryDiskSize(const GURL& origin) {
return ContainsKey(can_query_disk_size_, origin); return ContainsKey(can_query_disk_size_, origin);
} }
bool MockSpecialStoragePolicy::IsFileHandler(const std::string& extension_id) {
return ContainsKey(file_handlers_, extension_id);
}
bool MockSpecialStoragePolicy::HasIsolatedStorage(const GURL& origin) { bool MockSpecialStoragePolicy::HasIsolatedStorage(const GURL& origin) {
return ContainsKey(isolated_, origin); return ContainsKey(isolated_, origin);
} }
......
...@@ -23,7 +23,6 @@ class MockSpecialStoragePolicy : public storage::SpecialStoragePolicy { ...@@ -23,7 +23,6 @@ class MockSpecialStoragePolicy : public storage::SpecialStoragePolicy {
bool IsStorageUnlimited(const GURL& origin) override; bool IsStorageUnlimited(const GURL& origin) override;
bool IsStorageSessionOnly(const GURL& origin) override; bool IsStorageSessionOnly(const GURL& origin) override;
bool CanQueryDiskSize(const GURL& origin) override; bool CanQueryDiskSize(const GURL& origin) override;
bool IsFileHandler(const std::string& extension_id) override;
bool HasIsolatedStorage(const GURL& origin) override; bool HasIsolatedStorage(const GURL& origin) override;
bool HasSessionOnlyOrigins() override; bool HasSessionOnlyOrigins() override;
...@@ -47,10 +46,6 @@ class MockSpecialStoragePolicy : public storage::SpecialStoragePolicy { ...@@ -47,10 +46,6 @@ class MockSpecialStoragePolicy : public storage::SpecialStoragePolicy {
can_query_disk_size_.insert(origin); can_query_disk_size_.insert(origin);
} }
void AddFileHandler(const std::string& id) {
file_handlers_.insert(id);
}
void AddIsolated(const GURL& origin) { void AddIsolated(const GURL& origin) {
isolated_.insert(origin); isolated_.insert(origin);
} }
......
...@@ -32,10 +32,6 @@ bool ShellSpecialStoragePolicy::HasSessionOnlyOrigins() { ...@@ -32,10 +32,6 @@ bool ShellSpecialStoragePolicy::HasSessionOnlyOrigins() {
return false; return false;
} }
bool ShellSpecialStoragePolicy::IsFileHandler(const std::string& extension_id) {
return true;
}
bool ShellSpecialStoragePolicy::HasIsolatedStorage(const GURL& origin) { bool ShellSpecialStoragePolicy::HasIsolatedStorage(const GURL& origin) {
return false; return false;
} }
......
...@@ -20,7 +20,6 @@ class ShellSpecialStoragePolicy : public storage::SpecialStoragePolicy { ...@@ -20,7 +20,6 @@ class ShellSpecialStoragePolicy : public storage::SpecialStoragePolicy {
bool IsStorageUnlimited(const GURL& origin) override; bool IsStorageUnlimited(const GURL& origin) override;
bool IsStorageSessionOnly(const GURL& origin) override; bool IsStorageSessionOnly(const GURL& origin) override;
bool CanQueryDiskSize(const GURL& origin) override; bool CanQueryDiskSize(const GURL& origin) override;
bool IsFileHandler(const std::string& extension_id) override;
bool HasIsolatedStorage(const GURL& origin) override; bool HasIsolatedStorage(const GURL& origin) override;
bool HasSessionOnlyOrigins() override; bool HasSessionOnlyOrigins() override;
......
...@@ -52,10 +52,6 @@ class STORAGE_EXPORT SpecialStoragePolicy ...@@ -52,10 +52,6 @@ class STORAGE_EXPORT SpecialStoragePolicy
// disk capacity. // disk capacity.
virtual bool CanQueryDiskSize(const GURL& origin) = 0; virtual bool CanQueryDiskSize(const GURL& origin) = 0;
// Checks if extension identified with |extension_id| is registered as
// file handler.
virtual bool IsFileHandler(const std::string& extension_id) = 0;
// Checks if the origin contains per-site isolated storage. // Checks if the origin contains per-site isolated storage.
virtual bool HasIsolatedStorage(const GURL& origin) = 0; virtual bool HasIsolatedStorage(const GURL& origin) = 0;
......
...@@ -19,7 +19,6 @@ ...@@ -19,7 +19,6 @@
"permissions": [ "permissions": [
"commandLinePrivate", "commandLinePrivate",
"fileSystem", "fileSystem",
"fileBrowserHandler",
"fileManagerPrivate", "fileManagerPrivate",
{ {
"fileSystem": ["requestFileSystem", "write"] "fileSystem": ["requestFileSystem", "write"]
......
...@@ -21,7 +21,6 @@ ...@@ -21,7 +21,6 @@
"chrome://extension-icon/", "chrome://extension-icon/",
"chrome://resources/", "chrome://resources/",
"chrome://theme/", "chrome://theme/",
"fileBrowserHandler",
"fileManagerPrivate", "fileManagerPrivate",
{ {
"fileSystem": ["requestFileSystem", "write"] "fileSystem": ["requestFileSystem", "write"]
......
...@@ -7,7 +7,6 @@ ...@@ -7,7 +7,6 @@
"incognito" : "split", "incognito" : "split",
"manifest_version": 2, "manifest_version": 2,
"permissions": [ "permissions": [
"fileBrowserHandler",
{ {
"fileSystem": ["requestFileSystem"] "fileSystem": ["requestFileSystem"]
}, },
......
...@@ -19,7 +19,6 @@ ...@@ -19,7 +19,6 @@
"permissions": [ "permissions": [
"commandLinePrivate", "commandLinePrivate",
"fileSystem", "fileSystem",
"fileBrowserHandler",
"fileManagerPrivate", "fileManagerPrivate",
{ {
"fileSystem": ["requestFileSystem", "write"] "fileSystem": ["requestFileSystem", "write"]
......
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