OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROME_BROWSER_CHROMEOS_FILE_SYSTEM_PROVIDER_PROVIDED_FILE_SYSTEM_INFO_H
_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_FILE_SYSTEM_PROVIDER_PROVIDED_FILE_SYSTEM_INFO_H
_ |
6 #define CHROME_BROWSER_CHROMEOS_FILE_SYSTEM_PROVIDER_PROVIDED_FILE_SYSTEM_INFO_H
_ | 6 #define CHROME_BROWSER_CHROMEOS_FILE_SYSTEM_PROVIDER_PROVIDED_FILE_SYSTEM_INFO_H
_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
11 #include "chrome/common/extensions/api/file_system_provider_capabilities/file_sy
stem_provider_capabilities_handler.h" | 11 #include "chrome/common/extensions/api/file_system_provider_capabilities/file_sy
stem_provider_capabilities_handler.h" |
| 12 #include "chrome/browser/chromeos/file_system_provider/provided_file_system_defs
.h" |
12 | 13 |
13 namespace chromeos { | 14 namespace chromeos { |
14 namespace file_system_provider { | 15 namespace file_system_provider { |
15 | 16 |
16 // Options for creating the provided file system info. | 17 // Options for creating the provided file system info. |
17 struct MountOptions { | 18 struct MountOptions { |
18 MountOptions(); | 19 MountOptions(); |
19 | 20 |
20 // Only mandatory fields. | 21 // Only mandatory fields. |
21 MountOptions(const std::string& file_system_id, | 22 MountOptions(const std::string& file_system_id, |
22 const std::string& display_name); | 23 const std::string& display_name); |
23 | 24 |
24 std::string file_system_id; | 25 std::string file_system_id; |
25 std::string display_name; | 26 std::string display_name; |
26 bool writable; | 27 bool writable; |
27 bool supports_notify_tag; | 28 bool supports_notify_tag; |
28 int opened_files_limit; | 29 int opened_files_limit; |
29 }; | 30 }; |
30 | 31 |
31 // Contains information about the provided file system instance. | 32 // Contains information about the provided file system instance. |
32 class ProvidedFileSystemInfo { | 33 class ProvidedFileSystemInfo { |
33 public: | 34 public: |
34 ProvidedFileSystemInfo(); | 35 ProvidedFileSystemInfo(); |
35 | 36 |
36 ProvidedFileSystemInfo(const std::string& extension_id, | 37 ProvidedFileSystemInfo(const std::string& source_id, |
37 const MountOptions& mount_options, | 38 const MountOptions& mount_options, |
38 const base::FilePath& mount_path, | 39 const base::FilePath& mount_path, |
39 bool configurable, | 40 bool configurable, |
40 extensions::FileSystemProviderSource source); | 41 extensions::FileSystemProviderSource source, |
| 42 Source_Type type = Source_Type::extension); |
41 | 43 |
42 ~ProvidedFileSystemInfo(); | 44 ~ProvidedFileSystemInfo(); |
43 | 45 |
44 const std::string& extension_id() const { return extension_id_; } | 46 // return the source or an empty string if the source type |
| 47 // is not the same as the expected one |
| 48 const std::string extension_id() const { |
| 49 return get_source_id(Source_Type::extension); |
| 50 } |
| 51 const std::string plugin_id() const { |
| 52 return get_source_id(Source_Type::plugin); |
| 53 } |
| 54 const std::string source_id() const { return get_source_id(source_type_); } |
| 55 |
| 56 Source_Type source_type() const { return source_type_; } |
| 57 |
45 const std::string& file_system_id() const { return file_system_id_; } | 58 const std::string& file_system_id() const { return file_system_id_; } |
46 const std::string& display_name() const { return display_name_; } | 59 const std::string& display_name() const { return display_name_; } |
47 bool writable() const { return writable_; } | 60 bool writable() const { return writable_; } |
48 bool supports_notify_tag() const { return supports_notify_tag_; } | 61 bool supports_notify_tag() const { return supports_notify_tag_; } |
49 int opened_files_limit() const { return opened_files_limit_; } | 62 int opened_files_limit() const { return opened_files_limit_; } |
50 const base::FilePath& mount_path() const { return mount_path_; } | 63 const base::FilePath& mount_path() const { return mount_path_; } |
51 const bool configurable() const { return configurable_; } | 64 const bool configurable() const { return configurable_; } |
52 extensions::FileSystemProviderSource source() const { return source_; } | 65 extensions::FileSystemProviderSource source() const { return source_; } |
53 | 66 |
54 private: | 67 private: |
55 // ID of the extension providing this file system. | 68 // Return the source that is providing the file system |
56 std::string extension_id_; | 69 const std::string get_source_id(Source_Type type) const; |
| 70 // ID of the source providing this file system. |
| 71 std::string source_id_; |
57 | 72 |
58 // ID of the file system. | 73 // ID of the file system. |
59 std::string file_system_id_; | 74 std::string file_system_id_; |
60 | 75 |
61 // Name of the file system, can be rendered in the UI. | 76 // Name of the file system, can be rendered in the UI. |
62 std::string display_name_; | 77 std::string display_name_; |
63 | 78 |
64 // Whether the file system is writable or just read-only. | 79 // Whether the file system is writable or just read-only. |
65 bool writable_; | 80 bool writable_; |
66 | 81 |
67 // Supports tags for file/directory change notifications. | 82 // Supports tags for file/directory change notifications. |
68 bool supports_notify_tag_; | 83 bool supports_notify_tag_; |
69 | 84 |
70 // Limit of opened files in parallel. If unlimited, then 0. | 85 // Limit of opened files in parallel. If unlimited, then 0. |
71 int opened_files_limit_; | 86 int opened_files_limit_; |
72 | 87 |
73 // Mount path of the underlying file system. | 88 // Mount path of the underlying file system. |
74 base::FilePath mount_path_; | 89 base::FilePath mount_path_; |
75 | 90 |
76 // Whether the file system is configurable. | 91 // Whether the file system is configurable. |
77 bool configurable_; | 92 bool configurable_; |
78 | 93 |
79 // Source of the file system's data. | 94 // Source of the file system's data. |
80 extensions::FileSystemProviderSource source_; | 95 extensions::FileSystemProviderSource source_; |
| 96 // The source of the filesystem |
| 97 Source_Type source_type_; |
81 }; | 98 }; |
82 | 99 |
83 } // namespace file_system_provider | 100 } // namespace file_system_provider |
84 } // namespace chromeos | 101 } // namespace chromeos |
85 | 102 |
86 #endif // CHROME_BROWSER_CHROMEOS_FILE_SYSTEM_PROVIDER_PROVIDED_FILE_SYSTEM_INF
O_H_ | 103 #endif // CHROME_BROWSER_CHROMEOS_FILE_SYSTEM_PROVIDER_PROVIDED_FILE_SYSTEM_INF
O_H_ |
OLD | NEW |