blob: 77a1759a167868771c229d80adc6523ba718f882 (
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
|
// Copyright 2014 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 CHROME_BROWSER_CHROMEOS_FILE_SYSTEM_PROVIDER_MOUNT_PATH_UTIL_H_
#define CHROME_BROWSER_CHROMEOS_FILE_SYSTEM_PROVIDER_MOUNT_PATH_UTIL_H_
#include <string>
#include "base/files/file_path.h"
#include "storage/browser/fileapi/file_system_url.h"
class Profile;
namespace chromeos {
namespace file_system_provider {
class ProvidedFileSystemInterface;
namespace util {
// Constructs a safe mount point path for the provided file system.
base::FilePath GetMountPath(Profile* profile,
const std::string& extension_id,
const std::string& file_system_id);
// Checks whether a local path is handled by File System Provider API or not.
bool IsFileSystemProviderLocalPath(const base::FilePath& local_path);
// Finds a file system, which is responsible for handling the specified |url| by
// analysing the mount path. Also, extract the file path from the virtual path
// to be used by the file system operations.
class FileSystemURLParser {
public:
explicit FileSystemURLParser(const storage::FileSystemURL& url);
virtual ~FileSystemURLParser();
// Parses the |url| passed to the constructor. If parsing succeeds, then
// returns true. Otherwise, false. Must be called on UI thread.
bool Parse();
ProvidedFileSystemInterface* file_system() const { return file_system_; }
const base::FilePath& file_path() const { return file_path_; }
private:
storage::FileSystemURL url_;
ProvidedFileSystemInterface* file_system_;
base::FilePath file_path_;
DISALLOW_COPY_AND_ASSIGN(FileSystemURLParser);
};
// Finds a file system, which is responsible for handling the specified
// |local_path| by analysing the mount point name. Alsoo, extract the file path
// from the local path to be used by the file system operations.
class LocalPathParser {
public:
LocalPathParser(Profile* profile, const base::FilePath& local_path);
virtual ~LocalPathParser();
// Parses the |local_path| passed to the constructor. If parsing succeeds,
// then returns true. Otherwise, false. Must be called on UI thread.
bool Parse();
ProvidedFileSystemInterface* file_system() const { return file_system_; }
const base::FilePath& file_path() const { return file_path_; }
private:
Profile* profile_;
base::FilePath local_path_;
ProvidedFileSystemInterface* file_system_;
base::FilePath file_path_;
DISALLOW_COPY_AND_ASSIGN(LocalPathParser);
};
} // namespace util
} // namespace file_system_provider
} // namespace chromeos
#endif // CHROME_BROWSER_CHROMEOS_FILE_SYSTEM_PROVIDER_MOUNT_PATH_UTIL_H_
|