summaryrefslogtreecommitdiffstats
path: root/webkit/chromeos/fileapi/cros_mount_point_provider.h
blob: 23af15ff0fe1ca3d189811e759a7b2085c22a884 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
  // Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef WEBKIT_CHROMEOS_FILEAPI_CROS_MOUNT_POINT_PROVIDER_H_
#define WEBKIT_CHROMEOS_FILEAPI_CROS_MOUNT_POINT_PROVIDER_H_

#include <map>
#include <string>
#include <vector>

#include "base/file_path.h"
#include "webkit/fileapi/file_system_mount_point_provider.h"
#include "webkit/quota/special_storage_policy.h"

namespace chromeos {

class FileAccessPermissions;

// An interface to provide local filesystem paths.
class CrosMountPointProvider
    : public fileapi::ExternalFileSystemMountPointProvider {
 public:
  CrosMountPointProvider(
      scoped_refptr<quota::SpecialStoragePolicy> special_storage_policy);
  virtual ~CrosMountPointProvider();

  // fileapi::FileSystemMountPointProvider overrides.
  virtual bool IsAccessAllowed(const GURL& origin_url,
                               fileapi::FileSystemType type,
                               const FilePath& virtual_path) OVERRIDE;
  virtual void GetFileSystemRootPath(
      const GURL& origin_url,
      fileapi::FileSystemType type,
      bool create,
      fileapi::FileSystemPathManager::GetRootPathCallback* callback) OVERRIDE;
  virtual FilePath GetFileSystemRootPathOnFileThread(
      const GURL& origin_url,
      fileapi::FileSystemType type,
      const FilePath& virtual_path,
      bool create);
  virtual bool IsRestrictedFileName(const FilePath& filename) const OVERRIDE;
  virtual std::vector<FilePath> GetRootDirectories() const OVERRIDE;

  // fileapi::ExternalFileSystemMountPointProvider overrides.
  virtual void GrantFullAccessToExtension(
      const std::string& extension_id) OVERRIDE;
  virtual void GrantFileAccessToExtension(
      const std::string& extension_id, const FilePath& virtual_path) OVERRIDE;
  void RevokeAccessForExtension(const std::string& extension_id) OVERRIDE;

 private:
  class GetFileSystemRootPathTask;
  typedef std::map<std::string, FilePath> MountPointMap;

  MountPointMap mount_point_map_;
  scoped_refptr<quota::SpecialStoragePolicy> special_storage_policy_;
  scoped_ptr<FileAccessPermissions> file_access_permissions_;
  DISALLOW_COPY_AND_ASSIGN(CrosMountPointProvider);
};

}  // namespace chromeos

#endif  // WEBKIT_CHROMEOS_FILEAPI_CROS_MOUNT_POINT_PROVIDER_H_