Revert of Add button to add new FSP services to Files app. (patchset #8 id:140001...
[chromium-blink-merge.git] / chrome / browser / chromeos / file_system_provider / mount_path_util.h
blob77a1759a167868771c229d80adc6523ba718f882
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_CHROMEOS_FILE_SYSTEM_PROVIDER_MOUNT_PATH_UTIL_H_
6 #define CHROME_BROWSER_CHROMEOS_FILE_SYSTEM_PROVIDER_MOUNT_PATH_UTIL_H_
8 #include <string>
10 #include "base/files/file_path.h"
11 #include "storage/browser/fileapi/file_system_url.h"
13 class Profile;
15 namespace chromeos {
16 namespace file_system_provider {
18 class ProvidedFileSystemInterface;
20 namespace util {
22 // Constructs a safe mount point path for the provided file system.
23 base::FilePath GetMountPath(Profile* profile,
24 const std::string& extension_id,
25 const std::string& file_system_id);
27 // Checks whether a local path is handled by File System Provider API or not.
28 bool IsFileSystemProviderLocalPath(const base::FilePath& local_path);
30 // Finds a file system, which is responsible for handling the specified |url| by
31 // analysing the mount path. Also, extract the file path from the virtual path
32 // to be used by the file system operations.
33 class FileSystemURLParser {
34 public:
35 explicit FileSystemURLParser(const storage::FileSystemURL& url);
36 virtual ~FileSystemURLParser();
38 // Parses the |url| passed to the constructor. If parsing succeeds, then
39 // returns true. Otherwise, false. Must be called on UI thread.
40 bool Parse();
42 ProvidedFileSystemInterface* file_system() const { return file_system_; }
43 const base::FilePath& file_path() const { return file_path_; }
45 private:
46 storage::FileSystemURL url_;
47 ProvidedFileSystemInterface* file_system_;
48 base::FilePath file_path_;
50 DISALLOW_COPY_AND_ASSIGN(FileSystemURLParser);
53 // Finds a file system, which is responsible for handling the specified
54 // |local_path| by analysing the mount point name. Alsoo, extract the file path
55 // from the local path to be used by the file system operations.
56 class LocalPathParser {
57 public:
58 LocalPathParser(Profile* profile, const base::FilePath& local_path);
59 virtual ~LocalPathParser();
61 // Parses the |local_path| passed to the constructor. If parsing succeeds,
62 // then returns true. Otherwise, false. Must be called on UI thread.
63 bool Parse();
65 ProvidedFileSystemInterface* file_system() const { return file_system_; }
66 const base::FilePath& file_path() const { return file_path_; }
68 private:
69 Profile* profile_;
70 base::FilePath local_path_;
71 ProvidedFileSystemInterface* file_system_;
72 base::FilePath file_path_;
74 DISALLOW_COPY_AND_ASSIGN(LocalPathParser);
76 } // namespace util
77 } // namespace file_system_provider
78 } // namespace chromeos
80 #endif // CHROME_BROWSER_CHROMEOS_FILE_SYSTEM_PROVIDER_MOUNT_PATH_UTIL_H_