OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 // Utilities for ARC documents provider file system. | 5 // Utilities for ARC documents provider file system. |
6 | 6 |
7 #ifndef CHROME_BROWSER_CHROMEOS_ARC_FILEAPI_ARC_DOCUMENTS_PROVIDER_UTIL_H_ | 7 #ifndef CHROME_BROWSER_CHROMEOS_ARC_FILEAPI_ARC_DOCUMENTS_PROVIDER_UTIL_H_ |
8 #define CHROME_BROWSER_CHROMEOS_ARC_FILEAPI_ARC_DOCUMENTS_PROVIDER_UTIL_H_ | 8 #define CHROME_BROWSER_CHROMEOS_ARC_FILEAPI_ARC_DOCUMENTS_PROVIDER_UTIL_H_ |
9 | 9 |
10 #include <string> | 10 #include <string> |
(...skipping 11 matching lines...) Expand all Loading... |
22 // The name of ARC documents provider file system mount point. | 22 // The name of ARC documents provider file system mount point. |
23 extern const char kDocumentsProviderMountPointName[]; | 23 extern const char kDocumentsProviderMountPointName[]; |
24 | 24 |
25 // The path of ARC documents provider file system mount point. | 25 // The path of ARC documents provider file system mount point. |
26 extern const base::FilePath::CharType kDocumentsProviderMountPointPath[]; | 26 extern const base::FilePath::CharType kDocumentsProviderMountPointPath[]; |
27 | 27 |
28 // MIME type for directories in Android. | 28 // MIME type for directories in Android. |
29 // Defined as DocumentsContract.Document.MIME_TYPE_DIR in Android. | 29 // Defined as DocumentsContract.Document.MIME_TYPE_DIR in Android. |
30 extern const char kAndroidDirectoryMimeType[]; | 30 extern const char kAndroidDirectoryMimeType[]; |
31 | 31 |
| 32 // Escapes a string so it can be used as a file/directory name. |
| 33 // [%/.] are escaped with percent-encoding. |
| 34 // NOTE: This function is visible only for unit testing. Usually you should not |
| 35 // call this function directly. |
| 36 std::string EscapePathComponent(const std::string& name); |
| 37 |
| 38 // Unescapes a string escaped by EscapePathComponent(). |
| 39 // NOTE: This function is visible only for unit testing. Usually you should not |
| 40 // call this function directly. |
| 41 std::string UnescapePathComponent(const std::string& escaped); |
| 42 |
| 43 // Returns the path of a directory where the specified DocumentsProvider is |
| 44 // mounted. |
| 45 // Appropriate escaping is done to embed |authority| and |root_document_id| in |
| 46 // a file path. |
| 47 base::FilePath GetDocumentsProviderMountPath( |
| 48 const std::string& authority, |
| 49 const std::string& root_document_id); |
| 50 |
32 // Parses a FileSystemURL pointing to ARC documents provider file system. | 51 // Parses a FileSystemURL pointing to ARC documents provider file system. |
| 52 // Appropriate unescaping is done to extract |authority| and |root_document_id| |
| 53 // from |url|. |
33 // On success, true is returned. All arguments must not be nullptr. | 54 // On success, true is returned. All arguments must not be nullptr. |
34 bool ParseDocumentsProviderUrl(const storage::FileSystemURL& url, | 55 bool ParseDocumentsProviderUrl(const storage::FileSystemURL& url, |
35 std::string* authority, | 56 std::string* authority, |
36 std::string* root_document_id, | 57 std::string* root_document_id, |
37 base::FilePath* path); | 58 base::FilePath* path); |
38 | 59 |
39 // C++ implementation of DocumentsContract.buildDocumentUri() in Android. | 60 // C++ implementation of DocumentsContract.buildDocumentUri() in Android. |
40 GURL BuildDocumentUrl(const std::string& authority, | 61 GURL BuildDocumentUrl(const std::string& authority, |
41 const std::string& document_id); | 62 const std::string& document_id); |
42 | 63 |
43 } // namespace arc | 64 } // namespace arc |
44 | 65 |
45 #endif // CHROME_BROWSER_CHROMEOS_ARC_FILEAPI_ARC_DOCUMENTS_PROVIDER_UTIL_H_ | 66 #endif // CHROME_BROWSER_CHROMEOS_ARC_FILEAPI_ARC_DOCUMENTS_PROVIDER_UTIL_H_ |
OLD | NEW |